Compare commits
8 Commits
fe8c836182
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 7977aa96fb | |||
| 67d116f570 | |||
| 8078766a1a | |||
| db674670d1 | |||
| 50710ba6cb | |||
| 4554da48f9 | |||
| ca483a1986 | |||
| bb8a275163 |
44
out/stacked.html
Normal file
44
out/stacked.html
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Stacked river levels for the Great Stour around Canterbury, Kent</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Stacked river levels for the Great Stour around Canterbury, Kent</h1>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><a href="#wye">Wye</a></li>
|
||||||
|
<li><a href="#chartham">Chartham</a></li>
|
||||||
|
<li><a href="#westgategardens">Westgate Gardens</a></li>
|
||||||
|
<li><a href="#vauxhallbridge">Vauxhall Bridge</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h2>Background</h2>
|
||||||
|
<p>
|
||||||
|
The charts below show the annual levels of the Great Stour at various locations between Ashford and Canterbury in Kent.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Data collection began in 2014 for <a href="https://check-for-flooding.service.gov.uk/station/1145">Wye</a>, <a href="https://check-for-flooding.service.gov.uk/station/1135">Chartham</a>, and <a href="https://check-for-flooding.service.gov.uk/station/1143">Vauxhall bridge</a>. <a href="https://check-for-flooding.service.gov.uk/station/9274">Westgate Gardens</a> is a newer monitoring station and data is available back from 2020. There are a few periods of time where data is unavailable normally due to changes in the upstream data availability.
|
||||||
|
</p>
|
||||||
|
<p style="font-style: italic">
|
||||||
|
Data has been gathered from the <a href="https://check-for-flooding.service.gov.uk">Environment Agency in England</a> and is available under the the <a href="https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/">Open Government Licence v3.0</a>, except where otherwise stated.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
If you'd like a copy of the underlying data then please <a href="mailto:foo+rivers@mafoo.org.uk">drop me an email</a>.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<a id="wye"><h2>Wye</h2></a>
|
||||||
|
<img src="canterbury-1145-stacked.png" />
|
||||||
|
|
||||||
|
<a id="chartham"><h2>Chartham</h2></a>
|
||||||
|
<img src="canterbury-1135-stacked.png" />
|
||||||
|
|
||||||
|
<a id="westgategardens"><h2>Westgate Gardens, Canterbury</h2></a>
|
||||||
|
<img src="canterbury-9274-stacked.png" />
|
||||||
|
|
||||||
|
<a id="vauxhallbridge"><h2>Vauxhall Bridge, Canterbury</h2></a>
|
||||||
|
<img src="canterbury-1143-stacked.png" />
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
9
stack-build.sh
Executable file
9
stack-build.sh
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
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"
|
||||||
36
stack-years.pl
Normal file
36
stack-years.pl
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/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};
|
||||||
|
|
||||||
|
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";
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user