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

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

Open
megies opened this issue Aug 14, 2020 · 0 comments
Open
Labels

Comments

@megies
Copy link
Collaborator

megies commented Aug 14, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant