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 option to read thresholds from FEWS xml #114

Open
martinvonk opened this issue Mar 20, 2023 · 0 comments
Open

Add option to read thresholds from FEWS xml #114

martinvonk opened this issue Mar 20, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@martinvonk
Copy link
Collaborator

martinvonk commented Mar 20, 2023

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

test.xml:

        <TimeSeries xmlns="http://www.wldelft.nl/fews/PI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.wldelft.nl/fews/PI http://fews.wldelft.nl/schemas/version1.0/pi-schemas/pi_timeseries.xsd" version="1.26" xmlns:fs="http://www.wldelft.nl/fews/fs">
            <timeZone>1.0</timeZone>
            <series>
                <header>
                    <type>instantaneous</type>
                    <moduleInstanceId>pr.gw.merge</moduleInstanceId>
                    <locationId>GW000001</locationId>
                    <parameterId>GW.G</parameterId>
                    <qualifierId>filter1</qualifierId>
                    <timeStep unit="nonequidistant"/>
                    <startDate date="2020-04-16" time="14:00:00"/>
                    <endDate date="2020-04-17" time="08:00:00"/>
                    <missVal>NaN</missVal>
                    <stationName>statname</stationName>
                    <lat>52.0</lat>
                    <lon>5.40</lon>
                    <x>150000.0</x>
                    <y>454000.0</y>
                    <z>3.3</z>
                    <units>mNAP</units>
                    <thresholds>
                        <highLevelThreshold id="MV_LTID" name="Maaiveld" label="Maaiveld Peilbuis" value="3.3" groupId="GW_LT" groupName="GW Level Thresholds"></highLevelThreshold>
                        <highLevelThreshold id="BKB_LTID_1" name="Bovenkant Buis" label="Bovenkant peilbuis filter 1" value="3.779" groupId="GW_LT" groupName="GW Level Thresholds"></highLevelThreshold>
                    </thresholds>
                </header>
                <event date="2020-04-16" time="14:00:00" value="2.119" flag="0"/>
                <event date="2020-04-16" time="20:00:00" value="2.122" flag="0"/>
                <event date="2020-04-17" time="02:00:00" value="2.123" flag="0"/>
                <event date="2020-04-17" time="08:00:00" value="2.121" flag="0"/>
            </series>
        </TimeSeries>

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.

@martinvonk martinvonk self-assigned this Mar 20, 2023
@martinvonk martinvonk changed the title Fix reading FEWS xml Add option to read thresholds from FEWS xml> Mar 31, 2023
@martinvonk martinvonk changed the title Add option to read thresholds from FEWS xml> Add option to read thresholds from FEWS xml Mar 31, 2023
@martinvonk martinvonk added the enhancement New feature or request label Mar 31, 2023
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

1 participant