EA changed the pages
This commit is contained in:
parent
91634bf0c9
commit
6b68c4b418
15
new.gnuplot
15
new.gnuplot
@ -1,4 +1,4 @@
|
|||||||
set term png medium size 3200,1200 enhanced font "Helvitica" 14
|
set term png medium size 6400,1200 enhanced font "Helvitica" 14
|
||||||
set output "out/all.png"
|
set output "out/all.png"
|
||||||
|
|
||||||
set datafile missing "-"
|
set datafile missing "-"
|
||||||
@ -14,6 +14,7 @@ set ylabel "River level (m)"
|
|||||||
set grid y
|
set grid y
|
||||||
|
|
||||||
set key outside bottom center horizontal
|
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"
|
||||||
|
|
||||||
set title "River Levels in East Kent"
|
set title "River Levels in East Kent"
|
||||||
plot \
|
plot \
|
||||||
@ -92,7 +93,7 @@ plot \
|
|||||||
"data.tsv" using 1:33 with linespoints title "Medway at Allington Lock"
|
"data.tsv" using 1:33 with linespoints title "Medway at Allington Lock"
|
||||||
|
|
||||||
### Canterbury
|
### Canterbury
|
||||||
set term png medium size 1800,800 enhanced font "Helvitica" 14
|
set term png medium size 3600,800 enhanced font "Helvitica" 14
|
||||||
set output "out/canterbury.png"
|
set output "out/canterbury.png"
|
||||||
|
|
||||||
set title "River Levels around Canterbury"
|
set title "River Levels around Canterbury"
|
||||||
@ -103,3 +104,13 @@ plot \
|
|||||||
# "data.tsv" using 1:($5-$3) with linespoints title "Difference" axes x1y2
|
# "data.tsv" using 1:($5-$3) with linespoints title "Difference" axes x1y2
|
||||||
|
|
||||||
|
|
||||||
|
### Canterbury recent
|
||||||
|
set timefmt "%Y-%m-%dT%H:%M"
|
||||||
|
set term png medium size 3600,800 enhanced font "Helvitica" 14
|
||||||
|
set output "out/canterbury-recent.png"
|
||||||
|
|
||||||
|
set title "River Levels around Canterbury in last 3 months"
|
||||||
|
plot \
|
||||||
|
"< ./getlast3mo.sh 1145" using 1:2 with linespoints title "Great Stour at Wye", \
|
||||||
|
"< ./getlast3mo.sh 1135" using 1:2 with linespoints title "Great Stour at Horton weir", \
|
||||||
|
"< ./getlast3mo.sh 1143" using 1:2 with linespoints title "Great Stour at Vauxhall Bridge"
|
||||||
|
25
new.pl
25
new.pl
@ -3,6 +3,7 @@ $|=1 if $ENV{DEBUG};
|
|||||||
use strict;
|
use strict;
|
||||||
use diagnostics;
|
use diagnostics;
|
||||||
use DBI;
|
use DBI;
|
||||||
|
use JSON;
|
||||||
|
|
||||||
use LWP::UserAgent;
|
use LWP::UserAgent;
|
||||||
my $ua = LWP::UserAgent->new;
|
my $ua = LWP::UserAgent->new;
|
||||||
@ -19,7 +20,7 @@ my @stations = qw(
|
|||||||
3129 3130 3131 3132 3134 3135 3136 3138 3140 3145 3146 3149 3150 3151 3153
|
3129 3130 3131 3132 3134 3135 3136 3138 3140 3145 3146 3149 3150 3151 3153
|
||||||
);
|
);
|
||||||
|
|
||||||
my $base = "http://apps.environment-agency.gov.uk/river-and-sea-levels/136486.aspx?stationId=";
|
my $base = "https://flood-warning-information.service.gov.uk/station/";
|
||||||
|
|
||||||
my $db = DBI->connect("dbi:SQLite:dbname=rivers.db") or die $DBI::errstr;
|
my $db = DBI->connect("dbi:SQLite:dbname=rivers.db") or die $DBI::errstr;
|
||||||
|
|
||||||
@ -56,25 +57,23 @@ foreach my $station (@stations) {
|
|||||||
my $lastupdate;
|
my $lastupdate;
|
||||||
my $watercourse;
|
my $watercourse;
|
||||||
my $datum;
|
my $datum;
|
||||||
if ($res->is_success and $res->content =~ m~Current level:~) {
|
if ($res->is_success and $res->content =~ m~root.station~) {
|
||||||
$res->content =~ m~<h1>([^<]+)</h1>~;
|
$res->content =~ m~root.station = (.*);~;
|
||||||
$stationname = $1;
|
my $stationdata = from_json($1);
|
||||||
|
$res->content =~ m~root.chartData = (.*);~;
|
||||||
|
my $leveldata = from_json($1);
|
||||||
|
|
||||||
$res->content =~ m~Current level: (-?[\d\.]+)m~;
|
$stationname = $stationdata->{'external_name'};
|
||||||
$level = $1;
|
$level = $leveldata->{values}->[-1];
|
||||||
|
$lastupdate = $stationdata->{value_timestamps}->[-1];
|
||||||
$res->content =~ m~This measurement was recorded at (\d+:\d+) on (\d+)/(\d+)/(\d+)~;
|
|
||||||
$lastupdate = "$4-$3-$2T$1";
|
|
||||||
|
|
||||||
print STDERR "[$station] $stationname is $level at $lastupdate\n" if $ENV{R_DEBUG};
|
print STDERR "[$station] $stationname is $level at $lastupdate\n" if $ENV{R_DEBUG};
|
||||||
if($ENV{R_GPLOT}) {
|
if($ENV{R_GPLOT}) {
|
||||||
$res->content =~ m~Watercourse:( |\s)+([^<]+)~;
|
$watercourse = $stationdata->{'wiski_river_name'};
|
||||||
$watercourse = $2;
|
|
||||||
$watercourse =~ s~\s*$~~;
|
$watercourse =~ s~\s*$~~;
|
||||||
$watercourse =~ s~^\s*~~;
|
$watercourse =~ s~^\s*~~;
|
||||||
|
|
||||||
$res->content =~ m~Site datum:( |\s)+([^<]+) m AOD~;
|
$datum = $stationdata->{'wiski_river_name'};
|
||||||
$datum = $2;
|
|
||||||
$datum =~ s~\s*$~~;
|
$datum =~ s~\s*$~~;
|
||||||
$datum =~ s~^\s*~~;
|
$datum =~ s~^\s*~~;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user