Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add "daily new cases per 100.000 inh." visualization for regions based on isMOOD #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions analysis/visualizations/isMOOD_regions.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/perl -w

use strict;
my $DATE_RANGE=14;

my ($csvName, $datName, $gpName, $pngName) = @ARGV;

open (IN, "<", $csvName);

my @header=split(/,/, <IN>);
my @dates=@header[3 .. $#header];

my @datesRelevant=@dates[$DATE_RANGE .. $#dates];

my @deltasAll;
my @regions;

open (OUT, ">",$datName);

while(<IN>) {
my ($nameGr,$nameEn,$inh,@cumm)=split(/,/);
my @delta;
if($inh) {
for(my $i=$DATE_RANGE;$i<=$#cumm;$i++) {
push @delta, ($cumm[$i] - $cumm[$i-$DATE_RANGE]) / $inh * 100000;
}
push @deltasAll, \@delta;
push @regions, $nameEn;
}
}

for (my $i=0;$i<=$#datesRelevant;$i++) {
print OUT $datesRelevant[$i]."\t";
for(my $j=0;$j<=$#deltasAll;$j++) {
print OUT ${$deltasAll[$j]}[$i]."\t";
}
print OUT "\n";
}
close (OUT);

open (OUT, ">" , $gpName);
print OUT "set title \"Cases per 100.000 inh., date range $DATE_RANGE days\"\n";
print OUT "set key left top\n";
print OUT 'set timefmt "%d/%m/%y"'."\n";
print OUT "set xdata time\n";
print OUT "set xtics 10/01, 604800\n";
print OUT "set ytics 0, 10\n";
#print OUT "set xlabel \"foo\" rotate by 90\n";
print OUT 'set output "'.$pngName."\"\n";
#print OUT "set term png medium size 1200,900\n";
print OUT "set term svg size 1200,900 enhanced background rgb 'white'\n";
print OUT "set grid xtics, ytics\n";
print OUT "set nologscale y\n";
print OUT "set samples 400\n";
print OUT "plot ";

my $smooth=
"";
#"smooth csplines";
for(my $j=0;$j<$#regions;$j++) {
print OUT ($j>0 ? "," : "") ." \"$datName\" using 1:" . ($j+2) . " with linespoints $smooth title \"" . $regions[$j]. '"';
}
print OUT "\n";

for(my $j=0;$j<$#regions;$j++) {
print OUT 'set output "'.substr($pngName, 0, -4).$j.substr($pngName, -4)."\"\n";
print OUT "plot \"$datName\" using 1:" . ($j+2) . " with linespoints $smooth title \"" . $regions[$j]. "\"\n";
}


close OUT;

system "gnuplot $gpName";
system "thunar $pngName";
1 change: 1 addition & 0 deletions analysis/visualizations/isMOOD_regions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./isMOOD_regions.pl ../../data/greece/isMOOD/cases_by_region_timeline.csv `tempfile` isMOOD_cases_by_region_timeline.plt isMOOD_cases_by_region_timeline.svg