writing USGS/NEIC QuakeML files

Dear all,

as you know already USGS/NEIC stepped to https starting March 1st. Since then I have been experiencing problems with the event FDSN web service script that writes the QuakeML file.

I just updated to 1.03 but I am still experiencing the same problem as with the previous version of obspy 1.02.

In practice, just try to run the following commands that are nothing else than a global search

In [1]: from obspy.clients.fdsn import Client
In [2]: from obspy.clients.fdsn.header import URL_MAPPINGS
In [3]: from obspy import UTCDateTime, Catalog
In [4]: starttime = UTCDateTime(“2010-01-01”)
In [5]: endtime = UTCDateTime(“2011-01-01”)
In [6]: client = Client("USGS”)
In [7]: minmag = 7.0
In [8]: maxmag = 9.9
In [9]: cat = client.get_events(starttime=starttime, endtime=endtime,minmagnitude=minmag, maxmagnitude=maxmag)
In [10]: len(cat)
Out[10]: 24

In [11]: cat.write(“output_USGS.qml”,format=“QUAKEML”)

Hi Alberto,

the resource ids in the file are not valid.

Upon writing ObsPy checks if the URI validates according to the URI regex defined in the QuakeML standard. If not it tries to make it validate but that is of course only possible for some limited cases. In other cases it raises the error you see.

The original QuakeML from the USGS also fails to validate against the schema.

The allowed resource URIs are defined in section 3.1 of the QuakeML spec.

You could “fix” this by looping through the file and setting all resource_ids to valid identifiers. A proper fix would have to be done by the USGS on the server side.

Cheers!

Lion

I also opened an issue so that ObsPy hopefully produces better error messages in these cases in the future:

According to a member of our web team at the NEIC, this has been fixed
as of this morning. Please post here if you see any more issues, and
I'll try to pass those on.

--Mike Hearne

Hi Mike,

here is another issue with the query parameters being passed straight to
the resource ids which does not make up valid URIs. You'll need a local
QuakeML schema to run this.

$ curl -s
"https://earthquake.usgs.gov/fdsnws/event/1/query?starttime=2010-01-01T00%3A00%3A00.000000&endtime=2011-01-01T00%3A00%3A00.000000&minmagnitude=7.0"

xmllint --noout --schema

~/workspace/code/obspy/obspy/io/quakeml/data/QuakeML-1.2.xsd -

-:3: element eventParameters: Schemas validity error : Element
'{http://quakeml.org/xmlns/bed/1.2}eventParameters', attribute
'publicID': [facet 'pattern'] The value
'quakeml:earthquake.usgs.gov/fdsnws/event/1/query?starttime=2010-01-01T00%3A00%3A00.000000&endtime=2011-01-01T00%3A00%3A00.000000&minmagnitude=7.0'
is not accepted by the pattern
'(smi|quakeml):[\w\d][\w\d\-\.\*\(\)_~']{2,}/[\w\d\-\.\*\(\)_~'][\w\d\-\.\*\(\)\+\?_~'=,;#/&]*'.
-:3: element eventParameters: Schemas validity error : Element
'{http://quakeml.org/xmlns/bed/1.2}eventParameters', attribute
'publicID':
'quakeml:earthquake.usgs.gov/fdsnws/event/1/query?starttime=2010-01-01T00%3A00%3A00.000000&endtime=2011-01-01T00%3A00%3A00.000000&minmagnitude=7.0'
is not a valid value of the atomic type
'{http://quakeml.org/xmlns/bed/1.2}ResourceReference'.
- fails to validate

Cheers!

Lion