iris-edu / irisFetch-matlab

11 stars 8 forks source link

crash on empty Azimuth in StationXML #12

Open rtweekly-iris opened 2 years ago

rtweekly-iris commented 2 years ago

There are many channels that do not have an Azimuth field defined in the StationXML metadata. This field is not required by the stationxml-validator and is commonly missing for non-seismic (e.g. BDF) channel codes. This causes problems for irisFetch because the library treats it as a required field. There is likely a similar issue with Dip.

Example: IM.I52H1,I51H4.--.BDF Channel-level metadata for station I52H1 DOES NOT include an Azimuth or Dip field, but station I51H4 DOES. https://service.iris.edu/fdsnws/station/1/query?net=IM&sta=I52H1,I51H4&cha=BDF&level=channel&starttime=2022-01-15T00:00:00

<Station code="I51H4" startDate="2008-11-10T00:00:00.0000" restrictedStatus="open" iris:alternateNetworkCodes="_INT-NON_FDSN,_REALTIME,.UNRESTRICTED">
    <Latitude>32.349571</Latitude>
    <Longitude>-64.711037</Longitude>
    <Elevation>12.6</Elevation>
    <Site>
        <Name>Bermuda Infrasound Array, Site H4, United Kingdom</Name>
    </Site>
    <TotalNumberChannels>1</TotalNumberChannels>
    <SelectedNumberChannels>1</SelectedNumberChannels>
    <Channel code="BDF" locationCode="" startDate="2008-11-10T00:00:00.0000" restrictedStatus="open">
        <Latitude>32.349571</Latitude>
        <Longitude>-64.711037</Longitude>
        <Elevation>12.6</Elevation>
        <Depth>0</Depth>
        <Azimuth>0</Azimuth>
        <Dip>0</Dip>
        <Type>CONTINUOUS</Type>
        <Type>GEOPHYSICAL</Type>
        <SampleRate>2E01</SampleRate>
        <ClockDrift>0E00</ClockDrift>
        ...

<Station code="I52H1" startDate="2002-12-18T00:00:00.0000" restrictedStatus="open" iris:alternateNetworkCodes="_INT-NON_FDSN,_REALTIME,.UNRESTRICTED">
    <Latitude>-7.37779</Latitude>
    <Longitude>72.484169</Longitude>
    <Elevation>2.3</Elevation>
    <Site>
        <Name>Diego Garcia infrasound array site H1, United Kingdom</Name>
    </Site>
    <CreationDate>2002-12-18T00:00:00.0000</CreationDate>
    <TotalNumberChannels>6</TotalNumberChannels>
    <SelectedNumberChannels>1</SelectedNumberChannels>
    <Channel code="BDF" locationCode="" startDate="2021-02-27T00:00:00.0000" restrictedStatus="open">
        <Latitude>-7.37779</Latitude>
        <Longitude>72.484169</Longitude>
        <Elevation>2.3</Elevation>
        <Depth>0</Depth>
        <Type>CONTINUOUS</Type>
        <Type>GEOPHYSICAL</Type>
        <SampleRate>2E01</SampleRate>
        ...

In Matlab, this creates a NullPointerException:

traces = tracedata.fetchTraces("IM", "I52H1", "*", "BDF", "2021-01-15 00:00:00.000", "2021-01-15 00:00:00.000", 'M', 0) 2022/01/31 14:50:49 INFO: edu.iris.dmc.extensions.fetch.TraceData fetchTraces: StationService url set to: http://service.iris.edu/fdsnws/station/1/ An [MATLAB:Java:GenericException] exception occurred in irisFetch.getTheTraces() but was caught full text follows: message: Java exception occurred: java.lang.NullPointerException at edu.iris.dmc.extensions.entities.Metadata.parseMetadata(Metadata.java:239) at edu.iris.dmc.extensions.fetch.TraceData.fetchTraces(TraceData.java:325) at edu.iris.dmc.extensions.fetch.TraceData.fetchTraces(TraceData.java:192) at edu.iris.dmc.extensions.fetch.TraceData.fetchTraces(TraceData.java:137) at edu.iris.dmc.extensions.fetch.TraceData.fetchTraces(TraceData.java:102)

There may still be issues with the underlying Matlab code in dealing with an empty/null Azimuth (and Dip), but those problems are difficult to address without a successful request made through the library.

rtweekly-iris commented 2 years ago

NullPointerException comes from: edu.iris.edu.dmc.extensions.entities.Metadata.parseMetadata(Metadata.java:239)