From 658399089ac7ae82e45ba67902a5b562fa7c109b Mon Sep 17 00:00:00 2001 From: Marcus Fey Date: Sun, 18 Oct 2020 19:20:04 +0200 Subject: [PATCH 1/2] add time based visualization for regions based on isMOOD --- analysis/visualizations/isMOOD_regions.pl | 74 +++++++++++++++++++++++ analysis/visualizations/isMOOD_regions.sh | 1 + 2 files changed, 75 insertions(+) create mode 100644 analysis/visualizations/isMOOD_regions.pl create mode 100644 analysis/visualizations/isMOOD_regions.sh diff --git a/analysis/visualizations/isMOOD_regions.pl b/analysis/visualizations/isMOOD_regions.pl new file mode 100644 index 000000000..2d69ffd9f --- /dev/null +++ b/analysis/visualizations/isMOOD_regions.pl @@ -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(/,/, ); +my @dates=@header[3 .. $#header]; + +my @datesRelevant=@dates[$DATE_RANGE .. $#dates]; + +my @deltasAll; +my @regions; + +open (OUT, ">",$datName); + +while() { + 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"; diff --git a/analysis/visualizations/isMOOD_regions.sh b/analysis/visualizations/isMOOD_regions.sh new file mode 100644 index 000000000..486570669 --- /dev/null +++ b/analysis/visualizations/isMOOD_regions.sh @@ -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 From 8f5cb1f20b848e50e253bdb1a96dd22e7311cd76 Mon Sep 17 00:00:00 2001 From: Marcus Fey Date: Mon, 19 Oct 2020 20:00:27 +0200 Subject: [PATCH 2/2] chmod 755 --- analysis/visualizations/isMOOD_regions.pl | 0 analysis/visualizations/isMOOD_regions.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 analysis/visualizations/isMOOD_regions.pl mode change 100644 => 100755 analysis/visualizations/isMOOD_regions.sh diff --git a/analysis/visualizations/isMOOD_regions.pl b/analysis/visualizations/isMOOD_regions.pl old mode 100644 new mode 100755 diff --git a/analysis/visualizations/isMOOD_regions.sh b/analysis/visualizations/isMOOD_regions.sh old mode 100644 new mode 100755