add_knmi_data

Python wrapper to fetch + parse KNMI observations, as csv or Pandas DataFrame
command line example: get_day_data_dataframe(stations =[240], start = ‘2017-01-01’, end=‘2018-25-02’, variables = [‘DDVEC’, ‘TG’, ‘DR’, ‘SQ’])

usage: add_knmi_data [-h] stations start end variables

Positional Arguments

stations specify the weather stations you want to return. for simplicity reason we only include SCHIPHOL and AMSTERDAM COENHAVEN.
start Specify the start date
end Specify the end date
variables weather variables you want to see returned. Default is fetch all. Following categories are available: WIND = DDVEC:FG:FHX:FHX:FX wind, TEMP = TG:TN:TX:T10N temperatuur, SUNR = SQ:SP:Q Zonneschijnduur en globale straling, PRCP = DR:RH:EV24 neerslag en potentiële verdamping, PRES = PG:PGX:PGN druk op zeeniveau, VICL = VVN:VVX:NG zicht en bewolking, MSTR = UG:UX:UN luchtvochtigheid

functions

transform.enrichment.add_knmi_data.chunk_splitter(raw)

Generator to read a raw file and yield chunks that are separated by ‘empty lines’: “# ” Args:

raw : str
transform.enrichment.add_knmi_data.get_day_data_dataframe(stations, start=None, end=None, inseason=False, variables=None)

Get daily weather data from KNMI as a Pandas DataFrame args:

stations : [int]
list of KNMI station numbers
start : datetime.datetime | str
date (optional, default is begin of current month) can be a datetime object, or a string in format “%Y%m%d”
end : datetime.datetime | str
date (optional, default is today) can be a datetime object, or a string in format “%Y%m%d”
inseason : bool (optional, default False)
see http://www.knmi.nl/kennis-en-datacentrum/achtergrond/data-ophalen-vanuit-een-script for the full explanation

variables : list of variables to fetch (optional, default is ALL)

Returns
daily weather data in a Pandas DataFrame. Parts included: disclaimer, stations, legend, data
transform.enrichment.add_knmi_data.get_day_data_raw(stations, start=None, end=None, inseason=False, variables=None)

Get daily weather data from KNMI args:

stations : [int]
list of KNMI station numbers
start : datetime.datetime | str
date (optional, default is begin of current month) can be a datetime object, or a string in format “%Y%m%d”
end : datetime.datetime | str
date (optional, default is today) can be a datetime object, or a string in format “%Y%m%d”
inseason : bool (optional, default False)
see http://www.knmi.nl/kennis-en-datacentrum/achtergrond/data-ophalen-vanuit-een-script for the full explanation
variables : list of variables to fetch (optional, default is ALL)
WIND = DDVEC:FG:FHX:FHX:FX wind TEMP = TG:TN:TX:T10N temperatuur SUNR = SQ:SP:Q Zonneschijnduur en globale straling PRCP = DR:RH:EV24 neerslag en potentiële verdamping PRES = PG:PGX:PGN druk op zeeniveau VICL = VVN:VVX:NG zicht en bewolking MSTR = UG:UX:UN luchtvochtigheid
Returns:
raw daily weather data generated by the specified weather stations. Parts included: disclaimer, stations, legend, data
transform.enrichment.add_knmi_data.parse_day_data(raw)

Parse the raw csv response of KNMI into relevant pieces. Args:

raw : str

Returns

transform.enrichment.add_knmi_data.parser()

Parser function to run arguments from the command line and to add description to sphinx.