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