[FMISID = 101421]

Ulkoinen verkkosivu
Grafiikka päivittyy 10 min välein | Ladataan palvelimelle 20 min välein.
Edellinen päivitys: 10.08.2022 17:25
-!-

Graphing weather statistics with RRDTool
Get Varkaus Kosulanniemi FMISID=101421 weather data

wget -t 2 -O /data/local/fmidata/varkaus-all.xml ${URL}
URL="https://opendata.fmi.fi/wfs?
service=WFS(-)version=2.0.0(-)request=getFeature(-)
storedquery_id=fmi::observations::weather::timevaluepair(-)
fmisid=101421(-)timestep=10(-)"

! Ampersand character is replaced with (-) !

Parse XML data to time:value pairs

0 15-07-2017 13:50 Temperature 17.1 °C
1 15-07-2017 13:50 Wind 3.4 m/s
2 15-07-2017 13:50 Direction 311.0°
3 15-07-2017 13:50 Humidity 57.0 %
4 15-07-2017 13:50 Dew Point 8.6 °C
5 15-07-2017 13:50 Pressure 1013.7 hPa
6 15-07-2017 13:50 Felt like 16.9 °C

Save values to CSV file for RRDs tool input.
Save values to MySQL database, just in case.

Collect data from CSV file

TEMP=`cat ~/fmidata.csv | cut -d ',' -f1`
WIND=`cat ~/fmidata.csv | cut -d ',' -f2`
... and so on ..

Update RRD database:
rrdtool update ${RRDDIR}/temp.rrd N:${TEMP}
rrdtool update ${RRDDIR}/wind.rrd N:${WIND}

Create RRD Ghraps (Daily)

rrdtool graph $OUTPATH/wind-day.png
--start -24h --end N --step 300
...
DEF:w=$RRDPATH/$WINDFILE:wind:AVERAGE
LINE2:w$WINDCOLOR:"$WINDWORD"
COMMENT:"5 $MINUTEWORD $avgWORD\\n"
GPRINT:w:MIN:"$MINWORD\: %5.1lf"
GPRINT:w:MAX:"$MAXWORD\: %5.1lf"
GPRINT:w:AVERAGE:"$AVGWORD\: %5.1lf"
GPRINT:w:LAST:"$LASTWORD\: %5.1lf\\n"

Save FMI data to Windrose database

There are eight "buckets" (0-7) with ranges
displayed on the legend (m/s):
0-1, 1-2, 2-3, 3-5, 5-6, 6-10, 10-13.5, 13-99

The first element (0) specify the percentage of 0-1 reading the sum of these reading,
this will be placed in the center of the windrose plot.
The second element (1) specifies the percentage of 1-2 readings,
the third element (2) the percentage of 2-3 readings and so on.

First create a new windrose graph:
$graph = new WindroseGraph(600,600);
Get data from database and create the windrose plot: $wp = new WindrosePlot($data);

Copy FMI and Windrose graphs to server:

Recurse through a local FMI directory and upload the entire contents to a remote FTP server.
Copy the entire "FI101421-all/" directory located at ~/fmidata/ to a
remote server's /public_html/fmidata/FI101421-all/ via FTP.

The Data Collection System (31.3.2022)

  Operating system: Ubuntu 20.04.2 LTS Server
  Kernel: 5.4.0-104-generic
  Machine: HP Compaq dc7700
  HTTP Server version: Apache/2.4.41
  Data collection: Perl v5.30.0 and GNU bash 5.0.17
  Graphics: RRDtool 1.7.2
  Weather information: ©Finnish Meteorological Institute (FMI)

The page was loaded 0.0580 seconds (CI3 Time)
Powered By   Web Hosting by InMotion    CodeIgniter PHP Framework   BaseURL: https://datatuki.net/web/  Page rendered in 0.0580 seconds