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# enabling debug logging so we can see what happens in the background
 9import logging
10logging.basicConfig()
11logging.getLogger("ddlpy").setLevel(logging.DEBUG)
12
13# get the dataframe with locations and their available parameters
14locations = ddlpy.locations()
15
16# Filter the locations dataframe with the desired parameters and stations.
17bool_stations = locations.index.isin(["ijmuiden.buitenhaven", "dantziggat.zuid", "hoekvanholland", "ameland.nes"])
18# meting/astronomisch/verwachting
19bool_procestype = locations["ProcesType"].isin(["meting"])
20# waterlevel/waterhoogte (WATHTE)
21bool_grootheid = locations["Grootheid.Code"].isin(["WATHTE"])
22# timeseries ("") versus extremes (GETETM2/GETETMSL2/GETETBRKD2/GETETBRKDMSL2)
23bool_groepering = locations["Groepering.Code"].isin([""])
24# vertical reference (NAP/MSL)
25bool_hoedanigheid = locations["Hoedanigheid.Code"].isin(["NAP"])
26selected = locations.loc[
27    bool_procestype
28    & bool_stations
29    & bool_grootheid
30    & bool_groepering
31    & bool_hoedanigheid
32    ]
33
34start_date = dt.datetime(2023, 1, 1)
35end_date = dt.datetime(2023, 1, 15)
36
37# provide a single row of the locations dataframe to ddlpy.measurements
38measurements = ddlpy.measurements(selected.iloc[0], start_date=start_date, end_date=end_date)
39
40if not measurements.empty:
41    print("Data was found in RWS Waterwebservices/DDL")
42    measurements.plot(y="Meetwaarde.Waarde_Numeriek", linewidth=0.8)
43else:
44    print("No Data!")