ArtesiaWater / hydropandas

Module for loading observation data into custom DataFrames
https://hydropandas.readthedocs.io
MIT License
56 stars 11 forks source link

knmi precipitation data station attribute is sometimes a series with duplicate entries #241

Closed dbrakenhoff closed 1 month ago

dbrakenhoff commented 1 month ago

I'm sometimes getting duplicate station names in the station attribute (resulting in a series instead of an int) when downloading precipitation data:

o = hpd.read_knmi(stns=[733], starts="2024", meteo_vars=["RD"])
o.station

gives me:

name
RD_VLISSINGEN    YYYYMMDD
2023-12-31    733
2023-12-31    733
N...
Name: station, dtype: object

This is a bit annoying when you expect an integer. Any idea why this is happening? Maybe something on the KNMI side?

OnnoEbbens commented 1 month ago

This was sort of tricky because there are 2 things going on:

  1. The function hpd.read_knmi returns an ObsCollection and not an Obs object, even though you have only one observation. The station attribute of an ObsCollection is a Series of the ObsCollection DataFrame. To get an Obs object you can use: hpd.PrecipitationObs.from_knmi(meteo_var='RD', stn=733, start='2024').
  2. The fact that o.station returns a Series with two objects (and a date) even though you only have one observations is a bug fixed by #242.