annual stacking
This commit is contained in:
parent
fe8c836182
commit
bb8a275163
6
stack-build.sh
Executable file
6
stack-build.sh
Executable file
@ -0,0 +1,6 @@
|
||||
set -ex
|
||||
for n in 1143 1145 1135 9274
|
||||
do
|
||||
perl stack-years.pl $n >$n-pivot.txt
|
||||
done
|
||||
time gnuplot stack-by-year.gnuplot
|
73
stack-by-year.gnuplot
Normal file
73
stack-by-year.gnuplot
Normal file
@ -0,0 +1,73 @@
|
||||
set term png medium size 6400,1200 enhanced font "Helvitica" 14
|
||||
|
||||
set datafile missing "-"
|
||||
set xlabel "Date"
|
||||
set timefmt "%s"
|
||||
set format x "%Y-%m-%d"
|
||||
# set format x "%Y-%m-%d %H:%M:%S"
|
||||
set xdata time
|
||||
# set xtics rotate by 45 offset -0.8,-1.8
|
||||
set xtics autofreq
|
||||
|
||||
set ylabel "River level (m)"
|
||||
set grid y
|
||||
|
||||
set key outside bottom center horizontal
|
||||
set label 11 left at graph 0,char 1 "Data from Environment Agency processed via mafoo.org.uk" font ",12"
|
||||
|
||||
### Canterbury
|
||||
set term png medium size 3600,800 enhanced font "Helvitica" 14
|
||||
set timefmt "%Y-%m-%dT%H:%M"
|
||||
set xrange ['2000-01-01 00:00:00':'2000-12-31 23:59:59']
|
||||
|
||||
set output "out/canterbury-1143-stacked.png"
|
||||
set title "River Levels around at Vauxhall Bridge, Great Stour"
|
||||
plot \
|
||||
"1143-pivot.txt" using 1:2 with linespoints title "2014", \
|
||||
"1143-pivot.txt" using 1:3 with linespoints title "2015", \
|
||||
"1143-pivot.txt" using 1:4 with linespoints title "2016", \
|
||||
"1143-pivot.txt" using 1:5 with linespoints title "2017", \
|
||||
"1143-pivot.txt" using 1:6 with linespoints title "2018", \
|
||||
"1143-pivot.txt" using 1:7 with linespoints title "2019", \
|
||||
"1143-pivot.txt" using 1:8 with linespoints title "2020", \
|
||||
"1143-pivot.txt" using 1:9 with linespoints title "2021", \
|
||||
"1143-pivot.txt" using 1:10 with linespoints title "2022", \
|
||||
"1143-pivot.txt" using 1:11 with linespoints title "2023"
|
||||
|
||||
set output "out/canterbury-1145-stacked.png"
|
||||
set title "River Levels around at Wye, Great Stour"
|
||||
plot \
|
||||
"1145-pivot.txt" using 1:2 with linespoints title "2014", \
|
||||
"1145-pivot.txt" using 1:3 with linespoints title "2015", \
|
||||
"1145-pivot.txt" using 1:4 with linespoints title "2016", \
|
||||
"1145-pivot.txt" using 1:5 with linespoints title "2017", \
|
||||
"1145-pivot.txt" using 1:6 with linespoints title "2018", \
|
||||
"1145-pivot.txt" using 1:7 with linespoints title "2019", \
|
||||
"1145-pivot.txt" using 1:8 with linespoints title "2020", \
|
||||
"1145-pivot.txt" using 1:9 with linespoints title "2021", \
|
||||
"1145-pivot.txt" using 1:10 with linespoints title "2022", \
|
||||
"1145-pivot.txt" using 1:11 with linespoints title "2023"
|
||||
|
||||
set output "out/canterbury-1135-stacked.png"
|
||||
|
||||
set title "River Levels around at Chartham, Great Stour"
|
||||
plot \
|
||||
"1135-pivot.txt" using 1:2 with linespoints title "2014", \
|
||||
"1135-pivot.txt" using 1:3 with linespoints title "2015", \
|
||||
"1135-pivot.txt" using 1:4 with linespoints title "2016", \
|
||||
"1135-pivot.txt" using 1:5 with linespoints title "2017", \
|
||||
"1135-pivot.txt" using 1:6 with linespoints title "2018", \
|
||||
"1135-pivot.txt" using 1:7 with linespoints title "2019", \
|
||||
"1135-pivot.txt" using 1:8 with linespoints title "2020", \
|
||||
"1135-pivot.txt" using 1:9 with linespoints title "2021", \
|
||||
"1135-pivot.txt" using 1:10 with linespoints title "2022", \
|
||||
"1135-pivot.txt" using 1:11 with linespoints title "2023"
|
||||
|
||||
set output "out/canterbury-9274-stacked.png"
|
||||
|
||||
set title "River Levels around at Westgate Gardens, Great Stour"
|
||||
plot \
|
||||
"9274-pivot.txt" using 1:2 with linespoints title "2020", \
|
||||
"9274-pivot.txt" using 1:3 with linespoints title "2021", \
|
||||
"9274-pivot.txt" using 1:4 with linespoints title "2022", \
|
||||
"9274-pivot.txt" using 1:5 with linespoints title "2023"
|
37
stack-years.pl
Normal file
37
stack-years.pl
Normal file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use diagnostics;
|
||||
use DBI;
|
||||
use POSIX;
|
||||
use Data::Dumper;
|
||||
|
||||
my $station = shift @ARGV or die;
|
||||
|
||||
my $db = DBI->connect("dbi:SQLite:dbname=rivers.db") or die $DBI::errstr;
|
||||
|
||||
my $years_st = $db->prepare("select distinct substr(timestamp, 1, 4) from levels where stationid=?");
|
||||
my $getdata_st = $db->prepare("select strftime('2000-%m-%dT%H:%M:%S.000Z', timestamp) as t, level from levels where stationid = ? and timestamp like ? || '-%'");
|
||||
|
||||
$years_st->execute($station);
|
||||
my @years = @{$years_st->fetchall_arrayref};
|
||||
print STDERR Dumper(@years);
|
||||
|
||||
my %data;
|
||||
foreach my $y_ref (@years) {
|
||||
my $y = $y_ref->[0];
|
||||
$getdata_st->execute($station, $y);
|
||||
while(my $row = $getdata_st->fetchrow_arrayref) {
|
||||
$data{$row->[0]}{$y} = $row->[1];
|
||||
}
|
||||
}
|
||||
# print Dumper(\%data);
|
||||
|
||||
foreach my $ts (sort keys %data) {
|
||||
print "$ts\t";
|
||||
foreach my $y_ref (@years) {
|
||||
my $y = $y_ref->[0];
|
||||
print $data{$ts}{$y} || '-', "\t";
|
||||
}
|
||||
print "\n";
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user