Skip to content

FDSNWS: station query errors out if startDate missing in StationXML files #107

@megies

Description

@megies

If some matching channels in a FDSN WS station query are missing startDate attribute in their StationXML, an exception occurs on the server:

query url: http://george/fdsnws/station/1/query?network=XF&station=XB100&location=--&channel=HJZ&level=response

File "/local_home/george/jane/src/jane/fdsnws/views/station_1.py" in query
  259.         status = query_stations(fh, url=url, user=user, **params)

File "/local_home/george/jane/src/jane/fdsnws/station_query.py" in query_stations
  231.                                                  stats=stats)

File "/local_home/george/jane/src/jane/fdsnws/station_query.py" in assemble_network_elements
  444.     files = parse_stationxml_files(results)

File "/local_home/george/jane/src/jane/fdsnws/station_query.py" in parse_stationxml_files
  588.                 starttime = str(UTCDateTime(elem.get('startDate')))

File "/usr/lib/python3/dist-packages/obspy/core/utcdatetime.py" in __init__
  330.         dt = datetime.datetime(*args, **kwargs)

Exception Type: TypeError at /fdsnws/station/1/query
Exception Value: an integer is required (got type NoneType)

It looks like some workarounds for missing end times are already in place, so something similar could be done for missing start time (although it's not immediately clear if channels without a start date should be included or excluded if start/endtime restrictions are used in the query.

See

starttime = str(UTCDateTime(elem.get('startDate')))
endtime = elem.get('endDate')
if endtime:
endtime = str(UTCDateTime(endtime))

Also.. looking at the indexed data, it seems the indexer handles missing start and end dates differently:

json contents of one index:

{'latitude': 48.16282985, 'start_date': 'None', 'network': 'XF', ..., 'end_date': None}

CC @fbernauer

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions