Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add waterinfo api #93

Open
OnnoEbbens opened this issue Feb 10, 2023 · 9 comments
Open

add waterinfo api #93

OnnoEbbens opened this issue Feb 10, 2023 · 9 comments
Labels
enhancement New feature or request

Comments

@OnnoEbbens
Copy link
Collaborator

There is already code to read a waterinfo csv file but no code yet to use an API to get waterinfo data. This package (https://github.com/openearth/ddlpy) uses the API so maybe we can use this package.

@martinvonk
Copy link
Collaborator

martinvonk commented Mar 19, 2024

Some extra info from RWS:
https://rijkswaterstaatdata.nl/waterdata/#hf1666c4e-b766-49e0-af37-c1b95f8f56e1

https://rijkswaterstaat.github.io/wm-ws-dl/#introduction

@martinvonk
Copy link
Collaborator

martinvonk commented Mar 20, 2024

@rubencalje also wrote some code in art_tools which can be used. I think it is faster than ddlpy because Ruben chunks the data in bigger parts.

@martinvonk martinvonk added the enhancement New feature or request label Mar 20, 2024
@martinvonk
Copy link
Collaborator

Maybe the Matroos api could work as well. I can download some files but they are empty ... From this example: https://github.com/openearth/sealevel/blob/62c8d6254ad42b491dd7777c3f53f60f190e4796/data/rws/matroos/download_matroos.ipynb

import yarl
import pathlib

stations = [
    "schoonhoven",
]

url = yarl.URL('http://noos.matroos.rws.nl/direct/get_series.php')


station = stations[0]

defaults = {
    "tstart": 201701010000,
    "tstop": 201901010100,
    "format": "text"
}
params_list = [
    {
        "source": "observed",
        "unit": "waterlevel",
        "name": "waterlevel_observed"
    },
]
for station in stations:
    for params in params_list:
        download_url = url.update_query(defaults).update_query(params).update_query({"loc": station})
        filepath = "{}_{}.txt".format(station, params["name"])
        !wget -c -O "$filepath" "$download_url"

print(pathlib.Path("schoonhoven_waterlevel_observed.txt").read_text())

@martinvonk
Copy link
Collaborator

Another repository that obtains data from waterinfo:
https://gitlab.com/rwsdatalab/public/codebase/tools/rws-waterinfo

@OnnoEbbens
Copy link
Collaborator Author

@OnnoEbbens
Copy link
Collaborator Author

And another repo that does this: https://github.com/Deltares/ddlpy/blob/main/docs/notebooks/measurements.ipynb

Sorry this one is not very useful it only supports reading data not downloading.

@martinvonk
Copy link
Collaborator

There is a new api under development for rijkswaterstaat:
https://rijkswaterstaatdata.nl/projecten/beta-waterwebservices/
Also, a webinar:
https://www.youtube.com/watch?v=T5jkHv7PFaA

@martinvonk
Copy link
Collaborator

And another repo that does this: https://github.com/Deltares/ddlpy/blob/main/docs/notebooks/measurements.ipynb

Sorry this one is not very useful it only supports reading data not downloading.

This was also the repo with which the issue was originally created.

@HMEUW
Copy link
Collaborator

HMEUW commented Nov 25, 2024

And another repo that does this: https://github.com/Deltares/ddlpy/blob/main/docs/notebooks/measurements.ipynb

Sorry this one is not very useful it only supports reading data not downloading.

I don't understand the statement that ddply only supports reading, not downloading. I can succesfully download data via ddply.

import ddlpy
import matplotlib.pyplot as plt
import datetime as dt

# prepare location
locations = ddlpy.locations()

# Filter the locations dataframe 
# with the desired stations.
bool_stations = locations.Naam.str.contains('Bergse')
# and parameters
# 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(2024, 1, 1)
end_date = dt.datetime(2024, 11, 25)

# 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
)

plt.plot(measurements.index, measurements["Meetwaarde.Waarde_Numeriek"]/100)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants