get bro groundwater measurement from a GLD id or a GMW id with a
filter number.
Parameters:
bro_id (str) – starts with ‘GLD’ or ‘GMW’ e.g. ‘GLD000000012893’.
tube_nr (int or None, optional) – tube number, required if bro_id starts with ‘GMW’. The default is
None.
only_metadata (bool, optional) – if True download only metadata, significantly faster. The default
is False.
crs (str, int, pyproj.CRS or None) – The desired coordinate reference system of the observations, if it differs from
the crs in BRO the coordinates are transformed, by default EPSG: 28992.
engine (str, optional) – Select how data from the bro-database is obtained, options are ‘hydropandas’ or
‘brodata’ The default is ‘hydropandas’.
extent (list, tuple, numpy-array or None, optional) – get groundwater monitoring wells within this extent
[xmin, xmax, ymin, ymax]
ObsClass (type) – class of the observations, e.g. GroundwaterObs or WaterlvlObs
tmin (str or None, optional) – start time of observations. The default is None.
tmax (str or None, optional) – end time of observations. The default is None.
only_metadata (bool, optional) – if True download only metadata, significantly faster. The default
is False.
crs (str, int, pyproj.CRS or None, optional) – The coordinate reference system of the extent and the observations, if it
differs from the crs in BRO the coordinates are transformed, by default
EPSG: 28992.
ignore_max_obs (bool, optional) – by default you get a prompt if you want to download over a 1000
observations at once. if ignore_max_obs is True you won’t get the
prompt. The default is False
engine (str, optional) – Select how data from the bro-database is obtained, options are ‘hydropandas’,
‘brodata’ or ‘brodata_gm’. When engine=’brodata_gm’ use the dataset
Grondwatermonitoring (GM) in samenhang - karakteristieken, hosted by PDOK. This
up-to-date dataset combines well- and tube-properties. So users do not have to
download each individual Groundwater Monitoring Well (GMW), which speeds up the
request. The gm-dataset does not contain the attributes tube_top and
ground_level, so you need to use engine=’brodata’ or ‘hydropandas’ if you
need those. The Groundwater Level Dossiers (GLD) are still downloaded
individually. The default is ‘hydropandas’.
get a list of observation from a groundwater monitoring network.
Parameters:
bro_id (str) – starts with ‘GMN’ e.g. ‘GMN000000000163’.
ObsClass (type) – class of the observations, so far only GroundwaterObs is supported
only_metadata (bool, optional) – if True download only metadata, significantly faster. The default
is False.
keep_all_obs (boolean, optional) – add all observation points to the collection, even without
measurements
crs (str, int, pyproj.CRS or None, optional) – The desired coordinate reference system of the observations, if it differs from
the crs in BRO the coordinates are transformed, by default EPSG: 28992.
engine (str, optional) – Select how data from the bro-database is obtained, options are ‘hydropandas’ or
‘brodata’ The default is ‘hydropandas’.
Raises:
ValueError – DESCRIPTION.
Returns:
obs_list (list) – list with observation objects.
meta (dict) – metadata of the groundwater monitoring net.
get a list of observation from a groundwater monitoring network using the
hydropandas engine.
Parameters:
bro_id (str) – starts with ‘GMN’ e.g. ‘GMN000000000163’.
ObsClass (type) – class of the observations, so far only GroundwaterObs is supported
only_metadata (bool, optional) – if True download only metadata, significantly faster. The default
is False.
keep_all_obs (boolean, optional) – add all observation points to the collection, even without
measurements
crs (str, int, pyproj.CRS or None, optional) – The desired coordinate reference system of the observations, if it differs from
the crs in BRO the coordinates are transformed, by default EPSG: 28992.
Raises:
ValueError – DESCRIPTION.
Returns:
obs_list (list) – list with observation objects.
meta (dict) – metadata of the groundwater monitoring net.
get measurements and metadata from a grondwaterstandonderzoek (gld)
bro_id
Parameters:
bro_id (str) – e.g. ‘GLD000000012893’.
tmin (str or None, optional) – start date in format YYYY-MM-DD
tmax (str or None, optional) – end date in format YYYY-MM-DD
to_wintertime (bool, optional) – if True the time index is converted to Dutch winter time. The default
is True.
crs (str, int, pyproj.CRS or None, optional) – The desired coordinate reference system of the observations, if it differs from
the crs in BRO the coordinates are transformed, by default EPSG: 28992.
drop_duplicate_times (bool, optional) – if True rows with a duplicate time stamp are removed keeping only the
first row. The default is True.
add_registration_history (bool, optional) – if True the registration history is added to the metadata. The defualt
is True.
TODO:
- Evt. nog verbeteren door meteen Dataframe te vullen op het moment dat een
observatie wordt ingelezen. Nu wordt eerst alles ingelezen in een lijst en
daar een dataframe van gemaakt.
Parameters:
dirname (str or pathlib.Path) – directory name, can be a .zip file or the parent directory of subdir
ObsClass (type) – class of the observations, e.g. GroundwaterObs or WaterlvlObs
subdir (str) – subdirectory of dirname with data files
suffix (str) – suffix of files in subdir that will be read
unpackdir (str or pathlib.Path) – destination directory of the unzipped file
force_unpack (boolean, optional) – force unpack if dst already exists
preserve_datetime (boolean, optional) – use date of the zipfile for the destination file
keep_all_obs (boolean, optional) – add all observation points to the collection, even without data or
metadata
**kwargs (dict, optional) – Extra arguments are passed to ObsClass.from_artdino_file()
Returns:
obs_df – collection of multiple point observations
TODO:
- Evt. nog verbeteren door meteen Dataframe te vullen op het moment dat een
observatie wordt ingelezen. Nu wordt eerst alles ingelezen in een lijst en
daar een dataframe van gemaakt.
- aparte unzip functie maken en toch de juiste tijdelijke directory krijgen.
Parameters:
path (str | Path) – directory name, can be a .zip file or the parent directory of subdir
ObsClass (type) – class of the observations, e.g. GroundwaterObs or WaterlvlObs
subdir (str) – subdirectory of dirname with data files. For old school dino zip files this
should be “Grondwaterstanden_Put”. For new style the default value
‘DINO_Grondwaterstanden’ is sufficient. The default is ‘DINO_Grondwaterstanden’.
suffix (str or None, optional) – suffix of files in subdir that will be read. For old school dino zip files
this should be ‘1.csv’. For new style the default value None is sufficient.
The default is None.
keep_all_obs (boolean, optional) – add all observation points to the collection, even without data or
metadata
**kwargs (dict, optional) – Extra arguments are passed to ObsClass.from_dino_file()
Returns:
obs_df – collection of multiple point observations
Read a FEWS XML-file with measurements, memory efficient.
Parameters:
fname (str or pathlib.Path) – full path to file
ObsClass (Union[Obs, Dict[str, Obs]],) – class of the observations, e.g. GroundwaterObs or WaterlvlObs
translate_dic (dic or None, optional) – translate names from fews. If None this default dictionary is used:
{‘locationId’: ‘location’}.
locationIds (tuple or list of str, optional) – list of locationId’s to read from XML file, others are skipped.
If None (default) all locations are read.
filterdict (dict, optional) – dictionary with tag name to apply filter to as keys, and list of
accepted names as dictionary values to keep in final result,
i.e. {“locationId”: [“B001”, “B002”]}
return_events (bool, optional) – return all event-information in a DataFrame per location, instead of
just a Series (defaults to False). Overrules keep_flags kwarg.
keep_flags (list of ints, optional) – keep the values with these flags (defaults to 0 and 1). Only used
when return_events is False.
tags (list of strings, optional) – Select the tags to be parsed. Defaults to series, header and event
crs (str, int, pyproj.CRS or None, optional) – The coordinate reference system of the observations. There is no check
if the coordinates in the xml are actually this crs. This crs is only
used to set the crs attribute of the observations, by default None
return_df (bool, optional) – return a DataFame with the data, instead of two lists (default is
False)
Returns:
df (pandas.DataFrame) – a DataFrame containing the metadata and the series if ‘return_df’
is True
obs_list (list of pandas Series) – list of timeseries if ‘return_df’ is False
Read a list of xml files into a list of observation objects.
Parameters:
fnames (TYPE) – DESCRIPTION.
ObsClass (Union[Obs, Dict[str, Obs]]) – class of the observations, e.g. GroundwaterObs or WaterlvlObs
directory (TYPE, optional) – DESCRIPTION. The default is None.
locations (tuple or list of str, optional) – list of locationId’s to read from XML file, others are skipped.
If None (default) all locations are read.
translate_dic (dic or None, optional) – translate names from fews. If None this default dictionary is used:
{‘locationId’: ‘location’}.
filterdict (dict, optional) – dictionary with tag name to apply filter to as keys, and list of
accepted names as dictionary values to keep in final result,
i.e. {“locationId”: [“B001”, “B002”]}
remove_nan (boolean, optional) – remove nan values from measurements, flag information about the
nan values is also lost, only used if low_memory=False
low_memory (bool, optional) – whether to use xml-parsing method with lower memory footprint,
default is True
crs (str, int, pyproj.CRS or None, optional) – The coordinate reference system of the observations. There is no check
if the coordinates in the xml are actually this crs. This crs is only
used to set the crs attribute of the observations, by default None
Read an xml filename into a list of observations objects.
Parameters:
fname (str or pathlib.Path) – full path to file
ObsClass (Union[Obs, Dict[str, Obs]]) – class of the observations, e.g. GroundwaterObs or WaterlvlObs
translate_dic (dic or None, optional) – translate names from fews. If None this default dictionary is used:
{‘locationId’: ‘location’}.
low_memory (bool, optional) – whether to use xml-parsing method with lower memory footprint,
default is True
locationIds (tuple or list of str, optional) – list of locationId’s to read from XML file, others are skipped.
If None (default) all locations are read.
filterdict (dict, optional) – dictionary with tag name to apply filter to as keys, and list of
accepted names as dictionary values to keep in final result,
i.e. {“locationId”: [“B001”, “B002”]}
return_events (bool, optional) – return all event-information in a DataFrame per location, instead of
just a Series (defaults to False). Overrules keep_flags kwarg.
keep_flags (list of ints, optional) – keep the values with these flags (defaults to 0 and 1). Only used
when return_events is False.
tags (list of strings, optional) – Select the tags to be parsed. Defaults to series, header and event
return_df (bool, optional) – return a DataFame with the data, instead of two lists (default is
False)
remove_nan (boolean, optional) – remove nan values from measurements, flag information about the
nan values is also lost, only used if low_memory=False
crs (str, int, pyproj.CRS or None, optional) – The coordinate reference system of the observations. There is no check
if the coordinates in the xml are actually this crs. This crs is only
used to set the crs attribute of the observations, by default None
Read a FEWS XML-file with measurements, return list of ObsClass objects.
Parameters:
root (xml.etree.ElementTree.Element) – root element of a fews xml
ObsClass (Union[Obs, Dict[str, Obs]],) – class of the observations, e.g. GroundwaterObs or WaterlvlObs
translate_dic (dic or None, optional) – translate names from fews. If None this default dictionary is used:
{‘locationId’: ‘location’}.
locationIds (tuple or list of str, optional) – list of locationId’s to read from XML file, others are skipped.
If None (default) all locations are read.
remove_nan (boolean, optional) – remove nan values from measurements, flag information about the
nan values is also lost
crs (str, int, pyproj.CRS or None, optional) – The coordinate reference system of the observations. There is no check
if the coordinates in the xml are actually this crs. This crs is only
used to set the crs attribute of the observations, by default None
Read xmlstring into an list of Obs objects. Xmlstrings are usually
obtained using a fews api.
Parameters:
xmlstring (str) – xml string to be parsed. Typically from a fews api.
ObsClass (Union[Obs, Dict[str, Obs]]) – class of the observations, e.g. GroundwaterObs or WaterlvlObs
translate_dic (dic or None, optional) – translate names from fews. If None this default dictionary is used:
{‘locationId’: ‘location’}.
locationIds (tuple or list of str, optional) – list of locationId’s to read from XML file, others are skipped.
If None (default) all locations are read.
low_memory (bool, optional) – whether to use xml-parsing method with lower memory footprint,
default is True
remove_nan (boolean, optional) – remove nan values from measurements, flag information about the
nan values is also lost, only used if low_memory=False
crs (str, int, pyproj.CRS or None, optional) – The coordinate reference system of the observations. There is no check
if the coordinates in the xml are actually this crs. This crs is only
used to set the crs attribute of the observations, by default None
get knmi observation from stn, fname or nearest xy coordinates.
Parameters:
stn (int, str or None, optional) – measurement station e.g. 829. The default is None.
fname (str, pathlib.Path, file-like object or None, optional) – filename of a knmi file. The default is None.
xy (list, tuple or None, optional) – RD coördinates of a location in the Netherlands. The station nearest
to this location used. The Default is None.
meteo_var (str or None, optional) – meteo variable e.g. “RH” or “EV24”. See list with all options in the
hydropandas documentation.
start (str, datetime or None, optional) – start date of observations. The default is None.
end (str, datetime or None, optional) – end date of observations. The default is None.
**kwargs –
fill_missing_obsbool, optional
if True nan values in time series are filled with nearby time series.
The default is False. Note: if the given stn has no data between start and
end the data from nearby stations is used. In this case the metadata of the
Observation is the metadata from the nearest station that has any
measurement in the given period.
fill_missing_obs_with_factorbool, optional
if True, donor-station values are scaled with an overlap-based factor
before filling missing values. This automatically enables
fill_missing_obs.
The default is False.
intervalstr, optional
desired time interval for observations. Options are ‘daily’ and
‘hourly’. The default is ‘daily’.
use_apibool, optional
if True the api is used to obtain the data, API documentation is here:
Get a list of observations of knmi stations. Either specify a list of
knmi stations (stns) or a dataframe with x, y coordinates (locations).
Parameters:
locations (pandas DataFrame or None) – dataframe with x and y coordinates. The default is None
stns (list of int or None) – list of knmi stations. The default is None
xy (list or numpy array, optional) – xy coordinates of the locations. e.g. [[10,25], [5,25]]
meteo_vars (list or tuple of str) – meteo variables e.g. [“RH”, “EV24”]. The default is (“RH”)
starts (None, str, datetime or list, optional) – start date of observations per meteo variable. The start date is
included in the time series.
If start is None the start date will be January 1st of the
previous year.
if start is str it will be converted to datetime
if start is a list it should be the same length as meteo_vars and
the start time for each variable. The default is None
ends (list of str, datetime or None) – end date of observations per meteo variable. The end date is
included in the time series.
If end is None the start date will be January 1st of the
previous year.
if end is a str it will be converted to datetime
if end is a list it should be the same length as meteo_vars and
the end time for each meteo variable. The default is None
ObsClasses (list of type or None) – class of the observations, can be PrecipitationObs or
EvaporationObs. The default is None.
progress_callback (callable or None, optional) – callback function that is called with (i, total) for each station
processed, where i is the zero-based index and total is the total
number of stations. The default is None.
**kwargs –
fill_missing_obsbool, optional
if True nan values in time series are filled with nearby time series.
The default is False. Note: if the given stn has no data between start and
end the data from nearby stations is used. In this case the metadata of the
Observation is the metadata from the nearest station that has any
measurement in the given period.
fill_missing_obs_with_factorbool, optional
if True, donor-station values are scaled with an overlap-based factor
before filling missing values. This automatically enables
fill_missing_obs.
The default is False.
intervalstr, optional
desired time interval for observations. Options are ‘daily’ and
‘hourly’. The default is ‘daily’.
use_apibool, optional
if True the api is used to obtain the data, API documentation is here:
Fetch and process KNMI climate scenario data for a station.
The station argument is accepted as an integer or string for convenience.
Internally it is converted to a string when interacting with the KNMI API.
Retrieves climate scenario data from KNMI and returns a dictionary of
processed DataFrames with temperature, precipitation, and evaporation data.
Parameters:
stn (int or str) – Station number (e.g., 550 or “550”).
years (tuple, optional) – Years of climate scenario. The default is (‘2033’,’2050’,’2100’,’2150’).
scenarios (tuple, optional) – Names of climate scenario. The default is (‘Ld’,’Ln’,’Md’,’Mn’,’Hd’,’Hn’).
This includes all scenarios including the original measurements.
evap (str, optional) – Method for calculating evaporation. Options are ‘EV24’, ‘makkink’, ‘penman’,
or ‘hargreaves’. The default is ‘EV24’.
Returns:
Dictionary mapping scenario names to pandas DataFrames with processed
climate data. Each DataFrame has a datetime index and columns:
TG (temperature), RH (precipitation), Q (radiation), TX, TN, UG, FG,
and EV24 (evaporation).
Return type:
dict
Raises:
RuntimeError – If the API request fails or data cannot be retrieved.
Convert climate scenario dataframes into observation objects.
Parameters:
stn (int or str) – Station number (e.g., 550 or “550”).
years (tuple, optional) – Years of climate scenario. The default is (‘2033’,’2050’,’2100’,’2150’).
scenarios (tuple, optional) – Names of climate scenario. The default is (‘Ld’,’Ln’,’Md’,’Mn’,’Hd’,’Hn’).
This includes all scenarios including the original measurements.
evap (Literal["EV24", "makkink", "penman", "hargreaves"], optional) – Method for calculating evaporation. Options are ‘EV24’, ‘makkink’, ‘penman’,
or ‘hargreaves’. The default is ‘EV24’.
meteo_vars (iterable of str or None, optional) – Meteorological variables to include in the ObsCollection. Possible
variables include ‘TG’, ‘RD’, ‘Q’, ‘TX’, ‘TN’, ‘UG’, ‘FG’, and ‘EV24’.
If None (default), all available variables are included.
ObsClass (dict[str, PrecipitationObs | EvaporationObs | MeteoObs]) – Dictionary mapping variable names to observation classes. The function will
use these classes to instantiate the observations.
Returns:
List of instantiated observation objects. Each object has station
and meteo_var attributes set in addition to the usual metadata.
interpret data from knmi by selecting meteo_var data and meta
and transforming the variables
Parameters:
df (DataFrame) – dataframe with meteo_var as column
meta (dictionary) – dictionary with meteo_var as key
meteo_var (str) – e.g. ‘EV24’.
start (pd.Timestamp or None) – start time of observations.
end (pd.Timestamp or None) – end time of observations.
add_day (boolean, optional) – add 1 day so that the timestamp is at the end of the period the data describes,
default is False, and has to be set per type of file.
add_hour (boolean, optional) – add 1 hour to convert from UT to UT+1 (standard-time in the Netherlands),
default is True as this is usually the case.
Returns:
pandas DataFrame – measurements.
variables (dictionary) – additional information about the variables
Translates an extent (xmin, xmax, ymin, ymax) to a polygon with coordinate system
WGS84.
Parameters:
extent (list or tuple) – extent in epsg 28992 within which the observations are collected.
crs (str, int or pyproj.CRS) – The coordinate reference system of the extent if it is not wgs84
the coordinates are transformed, by default EPSG: 28992.
Return type:
polygon of the extent with coordinate system WGS84
Extracts the metadata and timeseries of an observation well from a LIZARD-API
based on the code of a monitoring well.
Parameters:
code (str) – code of the measuring well, e.g. ‘27B-0444’
tube_nr (int, optional) – select specific tube top
Default selects tube_nr = 1
tmin (str YYYY-m-d, optional) – start of the observations, by default the entire serie is returned
tmax (str YYYY-m-d, optional) – end of the observations, by default the entire serie is returned
type_timeseries (str, optional (deprecated)) – Old keyword, use which_timeseries instead.
which_timeseries (tuple of str, optional) – Which timeseries to retrieve. Options: “hand”, “diver”, “diver_validated”.
Defaults to (“hand”, “diver”) (which should be correct for Vitens).
datafilters (list of strings, optional) – Methods to filter the timeseries data.
If None (default), all measurements will be shown.
Currently implemented datafilter methods:
“remove_unvalidated_diver_values_when_validated_available”: Removes diver values before last date with validated diver.
“remove_hand_during_diver_period”: Removes hand measurements during periods where diver or diver_validated measurements are available.
combine_method (str, optional) – “merge” (vertical stack with ‘origin’ column) or “columns” (side-by-side columns).
If None, defaults to “merge”.
only_metadata (bool, optional) – if True only metadata is returned and no time series data. The
default is False.
organisation (str, optional) – organisation as used by Lizard, currently only “vitens” is officially supported.
auth (tuple, optional) – authentication credentials for the API request, e.g.: (“__key__”, your_api_key)
crs (str, int or pyproj.CRS, optional) – The coordinate reference system of the extent and the observations, if it
differs from the crs in Lizard the coordinates are transformed, by default
EPSG: 28992.
Returns:
measurements (pd.DataFrame) – returns a DataFrame with metadata and timeseries
Extract the metadata for a specific tube from the monitoring well metadata.
Parameters:
metadata_mw (dict) – dictionary with all available metadata of the monitoring well and all its
filters
tube_nr (int or None) – select metadata from a specific tube number
auth (tuple, optional) – authentication credentials for the API request, e.g.: (“__key__”, your_api_key)
crs (str, int or pyproj.CRS, optional) – The coordinate reference system of the observation, if it
differs from the crs in Lizard the coordinates are transformed, by default
EPSG: 28992.
Raises:
ValueError – if code of the monitoring well is invalid.
Returns:
dictionary with metadata of a specific tube
.. warning:: – This function assumes that there is only one ‘hand’ timeseries and one ‘diver’
timeseries for each tube. This seems to comply with the Vitens use of Lizard.
Get all observations from a list of codes of the monitoring wells and a list of
tube numbers.
Parameters:
codes (list of str or str) – codes of the monitoring wells
ObsClass (type) – class of the observations, e.g. GroundwaterObs
tube_nr (lst of str) – list of tube numbers of the monitoring wells that should be selected.
By default ‘all’ available tubes are selected.
tmin (str YYYY-m-d, optional) – start of the observations, by default the entire serie is returned
tmax (str YYYY-m-d, optional) – end of the observations, by default the entire serie is returned
type_timeseries (str, optional (deprecated)) – Old keyword, use which_timeseries instead.
which_timeseries (tuple of str, optional) – Which timeseries to retrieve. Options: “hand”, “diver”, “diver_validated”.
Defaults to (“hand”, “diver”) (which should be correct for Vitens).
datafilters (list of strings, optional) – Methods to filter the timeseries data.
If None (default), all measurements will be shown.
Currently implemented datafilter methods:
“remove_unvalidated_diver_values_when_validated_available”: Removes diver values before last date with validated diver.
“remove_hand_during_diver_period”: Removes hand measurements during periods where diver or diver_validated measurements are available.
combine_method (str, optional) – “merge” (vertical stack with ‘origin’ column) or “columns” (side-by-side columns).
If None, defaults to “merge”.
only_metadata (bool, optional) – if True only metadata is returned and no time series data. The
default is False.
organisation (str, optional) – organisation as used by Lizard, currently only “vitens” is officially supported.
auth (tuple, optional) – authentication credentials for the API request, e.g.: (“__key__”, your_api_key)
crs (str, int or pyproj.CRS, optional) – The coordinate reference system of the extent and the observations, if it
differs from the crs in Lizard the coordinates are transformed, by default
EPSG: 28992.
extent (list or shapefile) – get groundwater monitoring wells within this extent [xmin, xmax, ymin, ymax]
or within a predefined Polygon from a shapefile
ObsClass (type) – class of the observations, e.g. GroundwaterObs
tube_nr (lst of str) – list of tube numbers of the monitoring wells that should be selected.
By default ‘all’ available tubes are selected.
tmin (str, optional) – start of the observations (format YYYY-m-d), by default the entire series
is returned
tmax (str, optional) – end of the observations (format YYYY-m-d), by default the entire series
is returned
type_timeseries (str, optional (deprecated)) – Old keyword, use which_timeseries instead.
which_timeseries (tuple of str, optional) – Which timeseries to retrieve. Options: “hand”, “diver”, “diver_validated”.
Defaults to (“hand”, “diver”) (which should be correct for Vitens).
datafilters (list of strings, optional) – Methods to filter the timeseries data.
If None (default), all measurements will be shown.
Currently implemented datafilter methods:
“remove_unvalidated_diver_values_when_validated_available”: Removes diver values before last date with validated diver.
“remove_hand_during_diver_period”: Removes hand measurements during periods where diver or diver_validated measurements are available.
combine_method (str, optional) – “merge” (vertical stack with ‘origin’ column) or “columns” (side-by-side columns).
If None, defaults to “merge”.
only_metadata (bool, optional) – if True only metadata is returned and no time series data. The
default is False.
organisation (str) – organisation as used by Lizard, currently only “vitens” is officially supported.
auth (tuple, optional) – authentication credentials for the API request, e.g.: (“__key__”, your_api_key)
page_size (int, optional) – number of records to retrieve per page, default is 100
nr_threads (int, optional) – number of threads to use for the API requests, default is 10
crs (str, int, pyproj.CRS or None, optional) – The coordinate reference system of the extent (input) and the observations
(output), by default EPSG: 28992.
Returns:
obs_col – ObsCollection DataFrame with the ‘obs’ column
Extracts specified timeseries for a tube and combines them as requested.
Parameters:
tube_metadata (dict) – metadata of a tube
tmin (str YYYY-m-d, optional) – start of the observations
tmax (str YYYY-m-d, optional) – end of the observations
type_timeseries (str, optional (deprecated)) – deprecated, use ‘which_timeseries’ and ‘combine_method’ instead.
which_timeseries (tuple of str, optional) – Which timeseries to retrieve. Options: “hand”, “diver”, “diver_validated”.
Defaults to (“hand”, “diver”) (which should be correct for Vitens).
datafilters (list of strings, optional) – Methods to filter the timeseries data.
If None (default), all measurements will be shown.
Currently implemented datafilter methods:
“remove_unvalidated_diver_values_when_validated_available”: Removes diver values before last date with validated diver.
“remove_hand_during_diver_period”: Removes hand measurements during periods where diver or diver_validated measurements are available.
combine_method (str, optional) – “merge” (vertical stack with ‘origin’ column) or “columns” (side-by-side columns).
If None, defaults to “merge”.
organisation (str, optional) – organisation as used by Lizard.
auth (tuple, optional) – authentication credentials for the API request, e.g.: (“__key__”, your_api_key)
Returns:
measurements (pandas DataFrame) – timeseries of the monitoring well
metadata_df (dict) – metadata of the monitoring well
Transform a MATLAB serial date number to a Python datetime object, rounded
to seconds.
Parameters:
tindex (float) – The MATLAB serial date number to convert.
Returns:
datetime – The equivalent datetime object in Python.
Return type:
datetime.datetime
Notes
MATLAB serial date numbers represent the number of days elapsed since
January 1, 0000 (the proleptic Gregorian calendar), with January 1, 0000 as
day 1. Fractions of a day can be represented as a decimal.
The returned datetime object is rounded to the nearest second.
mat (dict) – A dictionary object containing the Menyanthes file data.
Returns:
A dictionary containing oseries data, with oseries names as keys and
their corresponding metadata and values as values.
Return type:
dict
Notes
This function reads the oseries data from a Menyanthes file in .mat format
and returns it in a dictionary format. The oseries data contains the
following metadata:
name: The name of the oseries.
x: The x-coordinate of the oseries location.
y: The y-coordinate of the oseries location.
source: The data source.
unit: The unit of measurement.
In addition to the metadata, the oseries data also contains a pandas Series
object named ‘values’, which contains the time series data for the oseries.
ObsClass (Obs, optional) – type of Obs to read data as, by default GroundwaterObs
metadata_mapping (dict, optional) – dictionary containing map between metadata field names in pastastore and
metadata field names expected by hydropandas, by default None.
Get measurements from ddlpy for a specific location and grootheid_code
Parameters:
location_gdf (geopandas.GeoDataFrame, optional) – geodataframe with one or more locations, default is None
locatie (str or list of str, optional) – name(s) of the location
grootheid_code (str or list of str, optional) – code(s) of the grootheid
groepering_code (str or list of str, optional) – code(s) of the groepering
parameter_code (str or list of str, optional) – code(s) of the parameter
proces_type (str or list of str, optional) – code(s) of the proces type, e.g. ‘meting’
tmin (pd.Timestamp, optional) – start date of the measurements, default is 2025-01-01
tmax (pd.Timestamp, optional) – end date of the measurements, default is now
crs (str, int or pyproj.CRS, optional) – desired coordinate reference system of the observation,
if it differs from 25831 the coordinates are transformed, default is 28992
Returns:
df (pandas.DataFrame) – DataFrame with measurements
Get observations within a specific extent and optionally for a specific location
and grootheid_code.
Parameters:
extent (list, tuple, numpy-array or None, optional) – get waterinfo measurements within this extent
[xmin, xmax, ymin, ymax]
ObsClass (type) – class of the observations, e.g. WaterlvlObs
locatie (str or list of str, optional) – select only measurement with this location(s), e.g. ‘schoonhoven’, default is None
grootheid_code (str or list of str, optional) – select only measurement with this grootheid_code, e.g. ‘WATHTE’, default is None
groepering_code (str or list of str, optional) – select only measurement with this groepering_code, e.g. ‘GETETBRKD2’, default is None
parameter_code (str or list of str, optional) – select only measurement with this parameter_code, e.g. ‘Cl’, default is None
proces_type (str or list of str, optional) – select only measurement with this proces type, e.g. ‘meting’, default is None
tmin (str or None, optional) – start time of observations. The default is None.
tmax (str or None, optional) – end time of observations. The default is None.
only_metadata (bool, optional) – if True download only metadata, significantly faster. The default
is False.
keep_all_obs (bool, optional) – if False, only observations with measurements are kept. The default
is True.
crs (str, int or pyproj.CRS, optional) – coordinate reference system of the extent. The default is 28992 (RD).
location_gdf (GeoDataFrame, optional) – geodataframe with the locations of the measurements you want to include. If
location_gdf is provided the provided extent and epgs will be ignored.
path (str or pathlib.Path, optional) – path to waterinfo file (.zip or .csv), default is None
location_gdf (geopandas.GeoDataFrame, optional) – geodataframe with locations, default is None
locatie (str or list of str, optional) – name of the location, e.g. ‘schoonhoven’, default is None
grootheid_code (str or list of str, optional) – code(s) of the grootheid, e.g. ‘WATHTE’, default is None
groepering_code (str or list of str, optional) – code(s) of the groepering, e.g. ‘GETETBRKD2’, default is None
parameter_code (str or list of str, optional) – code(s) of the parameter, e.g. ‘Cl’, default is None
proces_type (str or list of str, optional) – code(s) of the proces type, e.g. ‘meting’, default is None
tmin (pd.Timestamp, optional) – start date of the measurements, default is None
tmax (pd.Timestamp, optional) – end date of the measurements, default is None
crs (str, int or pyproj.CRS, optional) – desired coordinate reference system of the observation,
if it differs from 25831 the coordinates are transformed, default is 28992 (RD)
Returns:
df (pandas.DataFrame) – DataFrame with measurements
path (str or pathlib.Path) – path to waterinfo file (.zip or .csv)
index_cols (list of str, optional) – columns to use as index, default is [“WAARNEMINGDATUM”, “WAARNEMINGTIJD (MET/CET)”]
return_metadata (bool, optional) – if True return metadata, default is True
value_col (str, optional) – name of the column containing the measurement values, default is “NUMERIEKEWAARDE”
location_col (str, optional) – name of the column containing the location identifiers, default is “MEETPUNT_IDENTIFICATIE”
xcol (str, optional) – name of the column containing the x coordinates, default is “X”
ycol (str, optional) – name of the column containing the y coordinates, default is “Y”
crs (str, int or pyproj.CRS, optional) – desired coordinate reference system of the observation,
if it differs from 25831 the coordinates are transformed, default is 28992 (RD).
Get weather observations and metadata from a WOW-KNMI station based on the
station name or lat, lon location
Parameters:
meteo_var (str) – The meteorological variable to query, one of ‘rain_rate’,
‘temperature’, ‘wind’, ‘humidity’, ‘pressure_msl’.
stn (str) – The station ID of the WOW-KNMI station.
xy (List[float], optional) – The coordinates of the location to query in the format [lon, lat], by
default None. If specified, the nearest station within 1 degree will be
used.
start (pd.Timestamp, optional) – The start date and time of the observations, by default None. If None,
the januari first of the year before will be used.
end (pd.Timestamp, optional) – The end date and time of the observations, by default None. If None,
the yesterday will be used.
Returns:
A tuple of a dataframe with the observations and a dictionary with the
station metadata.
Return type:
Tuple[pd.DataFrame, dict]
Raises:
ValueError – If both stn and xy are None or if meteo_var is not valid.
stn (str) – The station ID of the WOW-KNMI station.
meteo_var (str) – The meteorological variable to query, one of ‘rain_rate’,
‘temperature’, ‘wind’, ‘humidity’, ‘pressure_msl’.
start (pd.Timestamp, optional) – The start date and time of the observations, by default None. If None,
the januari first of the year before will be used.
end (pd.Timestamp, optional) – The end date and time of the observations, by default None. If None,
the yesterday will be used.
Returns:
A dataframe with the measurements.
Return type:
pd.DataFrame
Raises:
ValueError – If meteo_var is not valid.
requests.HTTPError – If the request to the WOW-KNMI API fails.
Get a DataFrame with the observation stations from WOW-KNMI.
Parameters:
meteo_var (str, optional) – The meteorological variable to query, one of ‘rain_rate’,
‘temperature’, ‘wind’, ‘humidity’, ‘pressure_msl’ by default
‘rain_rate’.
date (Optional[pd.Timestamp], optional) – The date and time of the observations, by default the latest available
(10 minutes ago).
bbox (Optional[List[float]], optional) – The bounding box of the spatial query in the format [min_lon, min_lat,
max_lon, max_lat], by default the extent of the Netherlands.
obs_filter (Optional[str], optional) – The filter to apply to the observations, one of ‘wow_observations’,
‘official_observations’, by default None which selects all stations.
Returns:
A dataframe with the station information and observations.
Return type:
pd.DataFrame
Raises:
ValueError – If meteo_var or obs_filter are not valid choices.
requests.HTTPError – If the request to the WOW-KNMI API fails.