Minimal example#

 1"""
 2This is a minimal example on how to retrieve data from the DDL with ddlpy.
 3"""
 4
 5import ddlpy
 6import datetime as dt
 7
 8# get the dataframe with locations and their available parameters
 9locations = ddlpy.locations()
10
11#select a set of parameters 
12# Filter the locations dataframe with the desired parameters and stations.
13bool_stations = locations.index.isin(['IJMDBTHVN', 'DANTZGZD','HOEKVHLD'])
14# measured (WATHTE) versus computed/astro
15bool_grootheid = locations['Grootheid.Code'].isin(['WATHTE'])
16# timeseries (NVT) versus extremes
17bool_groepering = locations['Groepering.Code'].isin(['NVT'])
18# vertical reference (NAP/MSL)
19bool_hoedanigheid = locations['Hoedanigheid.Code'].isin(['NAP'])
20selected = locations.loc[bool_stations & bool_grootheid & 
21                         bool_groepering & bool_hoedanigheid]
22
23start_date = dt.datetime(2023, 1, 1)
24end_date = dt.datetime(2023, 1, 15)
25
26# provide a single row of the locations dataframe to ddlpy.measurements
27measurements = ddlpy.measurements(selected.iloc[0], start_date=start_date, end_date=end_date)
28
29if not measurements.empty:
30    print('Data was found in Waterbase')
31    measurements.plot(y="Meetwaarde.Waarde_Numeriek", linewidth=0.8)
32else:
33    print('No Data!')