ArtesiaWater / hydropandas

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

Popped metadata in the Obs class (in the 'from_bro' function) gives KeyError when making interactive map #108

Closed Florisklooster closed 1 year ago

Florisklooster commented 1 year ago

When trying to make an interactive map with map_labels (with the locations: 'monitoring_well' as label), this gives a KeyError. This is because allmost all the metadata is popped (e.g. monitoring_well=meta.pop("monitoring_well")) when the metadata is returned in the 'from_bro' function in the observation.py, why is that done?

OnnoEbbens commented 1 year ago

We use the meta.pop("monitoring_well") when we create an observation object from the meta dictionary. The observation object will have the value set as an attribute. In this case the monitoring_well attribute. So the data is still there but not in the meta dictionary anymore.

The problem is that the map_label in the interactive plot function will only look in the meta dictionary of the observation. I modified the code so it will look in the attributes of the observation first and if the attribute is not found it will look in the meta dictionary. The new code is available in the 'dev' branch.

I hope this will solve your issue.

Florisklooster commented 1 year ago

It does, thanks a lot!