Deltares / ddlpy

API to Dutch Rijkswaterstaat archive (DDL, waterinfo.rws.nl) of monitoring water data
https://deltares.github.io/ddlpy/
GNU General Public License v3.0
20 stars 6 forks source link

catch switched start/end dates #44

Closed veenstrajelmer closed 6 months ago

veenstrajelmer commented 6 months ago

Description

When accidentally requesting data with start/end date switched, DDL gives "NoDataException: Check meetwaarden aanwezig mislukt". ddlpy.measurements() gives no error at all because the month loop is empty, although ddl does give a decent error. Consider catching this with ddlpy or let ddl provide better feedback.

What I Did

import ddlpy

locations = ddlpy.locations()
bool_hoedanigheid = locations['Hoedanigheid.Code'].isin(['NAP'])
bool_stations = locations.index.isin(['HOEKVHLD'])
bool_grootheid = locations['Grootheid.Code'].isin(['WATHTE'])
# bool_groepering = locations['Groepering.Code'].isin(['NVT'])
selected = locations.loc[bool_grootheid & bool_hoedanigheid & bool_stations]

start_date = "2019-02-01"
end_date = "2019-01-01"

# if we pass one row to the measurements function you can get all the measurements
avail = ddlpy.measurements_available(selected.iloc[0], start_date, end_date)
measurements = ddlpy.measurements(selected.iloc[0], start_date, end_date)