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

Retrieve salinity measurements on multiple heights #31

Closed
veenstrajelmer opened this issue Apr 4, 2024 · 2 comments
Closed

Retrieve salinity measurements on multiple heights #31

veenstrajelmer opened this issue Apr 4, 2024 · 2 comments

Comments

@veenstrajelmer
Copy link

veenstrajelmer commented Apr 4, 2024

When retrieving salinity measurements for e.g. HOEKVHLD, it is difficult to get data on all the available heights. There are dedicated HVH90/HVH45/HVH25 stations but these seem to contain only realtime information (and only nans). When downloading data for all stations for an arbitrary period, there are only two stations with data:

import ddlpy
import matplotlib.pyplot as plt
plt.close("all")

locations = ddlpy.locations()
# bool_stations = locations.index.isin(['HOEKVHLD'])
bool_stations = locations['Naam'].str.contains("olland")
# bool_stations = locations.index.isin(['HVH90','HVH45','HVH25'])
bool_grootheid = locations['Grootheid.Code'].isin(['SALNTT'])
selected = locations.loc[bool_grootheid & bool_stations]

start_data = "1988-01-01"
end_date = "1990-01-01"

print(f"downloading data for {len(selected)} stations")
fig, ax = plt.subplots()
for irow, row in selected.iterrows():
    last = ddlpy.measurements_latest(selected.iloc[0])
    station_code = row.name
    print(f"{station_code}: last measurement is {last.index[0]}")
    measurements = ddlpy.measurements(row, start_data, end_date)
    if measurements.empty:
        print("[NODATA]")
        continue
    measurements.plot(ax=ax, label=station_code, y='Meetwaarde.Waarde_Numeriek')
ax.legend()

Gives:
image

And prints:

downloading data for 8 stations
HVH90: last measurement is 2024-04-04 09:50:00+01:00
100%|██████████| 24/24 [00:14<00:00,  1.71it/s]
[NODATA]
HOEKVHLDMDN: last measurement is 1976-04-13 10:10:00+01:00
100%|██████████| 24/24 [00:14<00:00,  1.67it/s]
[NODATA]
HOEKVHLDNOVR: last measurement is 1976-04-13 10:20:00+01:00
100%|██████████| 24/24 [00:13<00:00,  1.72it/s]
[NODATA]
HOEKVHLZOVR: last measurement is 1976-04-13 10:00:00+01:00
100%|██████████| 24/24 [00:14<00:00,  1.66it/s]
[NODATA]
HVH45: last measurement is 2024-04-04 09:50:00+01:00
100%|██████████| 24/24 [00:13<00:00,  1.74it/s]
[NODATA]
HOEKVHLD: last measurement is 1990-12-03 08:00:00+01:00
100%|██████████| 24/24 [00:14<00:00,  1.70it/s]
HVH25: last measurement is 2024-04-04 09:50:00+01:00
100%|██████████| 24/24 [00:13<00:00,  1.74it/s]
[NODATA]
HOEKVHLBSD: last measurement is 1997-04-14 09:20:00+01:00
100%|██████████| 24/24 [00:14<00:00,  1.61it/s]

The stations with different height notations have the last month/day as last measurements so these seem to be realtime stations. How to get to the rest of the salinity measurements (historic timeseries)?

@veenstrajelmer
Copy link
Author

veenstrajelmer commented Apr 26, 2024

There are Hoek van Holland Chlorinity measurements available, and the different heights are available via the "WaarnemingMetadata.BemonsteringshoogteLijst" property:

import ddlpy
import matplotlib.pyplot as plt
plt.close("all")

locations = ddlpy.locations()
# bool_stations = locations.index.isin(['HOEKVHLD'])
# bool_stations = locations['Naam'].str.contains("olland")

# historic
bool_stations = locations.index.isin(['HOEKVHLRTOVR']) #contains 3 depths (BemonsteringshoogteLijst)
bool_grootheid = locations['Grootheid.Code'].isin(['CONCTTE'])
bool_hoedanigheid = locations['Hoedanigheid.Code'].isin(['Cl'])
selected = locations.loc[bool_stations & bool_grootheid & bool_hoedanigheid]

# LMW/realtime
# bool_stations = locations.index.isin(['HVH90','HVH45','HVH25'])
# bool_grootheid = locations['Grootheid.Code'].isin(['SALNTT'])
# selected = locations.loc[bool_stations & bool_grootheid]

start_data = "2022-07-01"
end_date = "2022-09-01"

print(f"downloading data for {len(selected)} stations")

for irow, row in selected.iterrows():
    last = ddlpy.measurements_latest(selected.iloc[0])
    station_code = row.name
    print(f"{station_code}: last measurement is {last.index[0]}")
    # measurements_latest = ddlpy.measurements_latest(row)
    measurements = ddlpy.measurements(row, start_data, end_date, freq=None)
    if measurements.empty:
        print("[NODATA]")
        continue

fig, ax = plt.subplots()
for hoogte in measurements["WaarnemingMetadata.BemonsteringshoogteLijst"].drop_duplicates().values:
    sel_bool = measurements["WaarnemingMetadata.BemonsteringshoogteLijst"] == hoogte
    measurements_sel = measurements.loc[sel_bool]
    measurements_sel.plot(ax=ax, label=hoogte, y='Meetwaarde.Waarde_Numeriek')
ax.legend()

Gives:
image

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

No branches or pull requests

2 participants