fmiopendata
fmiopendata copied to clipboard
Add support to the FMI timeseries endpoint, which provides CSV, JSON and XML formats
The FMI SmartMet server also has a /timeseries endpoint, which provides much streamlined access to a lot of the kind of data that doesn't really fit in the GIS world that well, except for the sensors of course having locations in the physical world.
https://github.com/fmidev/smartmet-plugin-timeseries/blob/master/docs/Using-the-Timeseries-API.md
https://github.com/fmidev/smartmet-plugin-timeseries/blob/master/docs/Examples.md
https://opendata.fmi.fi/timeseries?producer=airquality_urban&area=Helsinki¶m=name,time,fmisid,stationname,PM10_PT1H_avg,PM25_PT1H_avg,O3_PT1H_avg,CO_PT1H_avg,SO2_PT1H_avg,NO2_PT1H_avg,TRSC_PT1H_avg
https://opendata.fmi.fi/timeseries?format=ascii&groupareas=0&separator=,&attributes=time,fmisid&producer=airquality_urban&area=Helsinki¶m=time,fmisid,PM10_PT1H_avg,PM25_PT1H_avg,O3_PT1H_avg,CO_PT1H_avg,SO2_PT1H_avg,NO2_PT1H_avg,TRSC_PT1H_avg
https://opendata.fmi.fi/timeseries?format=ascii&groupareas=0&separator=,&attributes=time,fmisid&producer=airquality_urban&area=Uusimaa¶m=time,fmisid,PM10_PT1H_avg,PM25_PT1H_avg,O3_PT1H_avg,CO_PT1H_avg,SO2_PT1H_avg,NO2_PT1H_avg,TRSC_PT1H_avg&starttime=2022-07-27T14:39:51&endtime=2022-08-03T14:36:55&tz=UTC
20220727T150000,100662,8,5,55,nan,-0,9,nan
20220727T160000,100662,6,4,48,nan,-0,11,nan
20220727T170000,100662,7,4,54,nan,-0,4,nan
20220727T180000,100662,7,4,50,nan,-0,8,nan
20220727T190000,100662,8,5,52,nan,-0,5,nan
...
import requests
import pandas as pd
import numpy as np
aq_fields = {
'fmisid': np.int32,
'time': np.datetime64,
'AQINDEX_PT1H_avg': np.float64,
'PM10_PT1H_avg': np.float64,
'PM25_PT1H_avg': np.float64,
'O3_PT1H_avg': np.float64,
'CO_PT1H_avg': np.float64,
'SO2_PT1H_avg': np.float64,
'NO2_PT1H_avg': np.float64,
'TRSC_PT1H_avg': np.float64,
}
url = 'https://opendata.fmi.fi/timeseries'
params = {
'format': 'json',
'precision': 'double',
'groupareas': '0',
'producer': 'airquality_urban',
'area': 'Uusimaa',
'param': ','.join(aq_fields.keys()),
'starttime': '-7d',
'endtime': '-1m',
'tz': 'UTC',
}
data = requests.get(url, params=params).json()
df = pd.DataFrame(data).astype(aq_fields)
#df = df.set_index(['fmisid', 'time'])
Never mind, they cut down access to the data through this endpoint, to seven previous days.