ArtesiaWater / hydropandas

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

Add option to read thresholds from FEWS xml #114

Open martinvonk opened 1 year ago

martinvonk commented 1 year ago

Sometimes not all metadata (highLevelThreshold) is included when reading xml from FEWS:

test.xml:

<?xml version="1.0" encoding="UTF-8"?>

1.0
instantaneous pr.gw.merge GW000001 GW.G filter1 NaN statname 52.0 5.40 150000.0 454000.0 3.3 mNAP

This:

xmlTree = ET.parse("test.xml").getroot()
for elem in xmlTree.iter():
    print(elem.tag)

gives:

{http://www.wldelft.nl/fews/PI}TimeSeries
{http://www.wldelft.nl/fews/PI}timeZone
{http://www.wldelft.nl/fews/PI}series
{http://www.wldelft.nl/fews/PI}header
{http://www.wldelft.nl/fews/PI}type
{http://www.wldelft.nl/fews/PI}moduleInstanceId
{http://www.wldelft.nl/fews/PI}locationId
{http://www.wldelft.nl/fews/PI}parameterId
{http://www.wldelft.nl/fews/PI}qualifierId
{http://www.wldelft.nl/fews/PI}timeStep
{http://www.wldelft.nl/fews/PI}startDate
{http://www.wldelft.nl/fews/PI}endDate
{http://www.wldelft.nl/fews/PI}missVal
{http://www.wldelft.nl/fews/PI}stationName
{http://www.wldelft.nl/fews/PI}lat
{http://www.wldelft.nl/fews/PI}lon
{http://www.wldelft.nl/fews/PI}x
{http://www.wldelft.nl/fews/PI}y
{http://www.wldelft.nl/fews/PI}z
{http://www.wldelft.nl/fews/PI}units
{http://www.wldelft.nl/fews/PI}thresholds
{http://www.wldelft.nl/fews/PI}highLevelThreshold
{http://www.wldelft.nl/fews/PI}highLevelThreshold
{http://www.wldelft.nl/fews/PI}event
{http://www.wldelft.nl/fews/PI}event
{http://www.wldelft.nl/fews/PI}event
{http://www.wldelft.nl/fews/PI}event

And this :

for f in xmlTree.iter("{http://www.wldelft.nl/fews/PI}highLevelThreshold"):
    print(f.tag)
    print(f.text)
    print(f.attrib)

gives :

{http://www.wldelft.nl/fews/PI}highLevelThreshold
None
{'id': 'MV_LTID', 'name': 'Maaiveld', 'label': 'Maaiveld Peilbuis', 'value': '3.3', 'groupId': 'GW_LT', 'groupName': 'GW Level Thresholds'}
{http://www.wldelft.nl/fews/PI}highLevelThreshold
None
{'id': 'BKB_LTID_1', 'name': 'Bovenkant Buis', 'label': 'Bovenkant peilbuis filter 1', 'value': '3.779', 'groupId': 'GW_LT', 'groupName': 'GW Level Thresholds'}

So the metadata is there somewhere but we have to fix how we extract it.