krischer / instaseis

Instant high-frequency seismograms from an AxiSEM database
http://instaseis.net
Other
49 stars 23 forks source link

Problem reading USGS QuakeML files #4

Closed sstaehler closed 9 years ago

sstaehler commented 9 years ago

Hi guys,

probably not a standard compliant QuakeML file, but maybe you can point me towards the error. I try to read a moment tensor from USGS using a QuakeML file from http://earthquake.usgs.gov/earthquakes/eventpage/us20002926#scientific_tensor:us_us_20002926_mwc

The QuakeML file seems to be okay, at least it can be read using ObsPy:

cat = readEvents('http://earthquake.usgs.gov/realtime/product/moment-tensor/us_20002926_mwc/us/1429956564040/quakeml.xml')
print cat
1 Event(s) in Catalog:
2015-04-25T06:11:26.270000Z | +28.147,  +84.708 | 7.8 Mwc | manual

However, when trying to load it with Source.parse,

import instaseis
source = instaseis.Source.parse('http://earthquake.usgs.gov/realtime/product/moment-tensor/us_20002926_mwc/us/1429956564040/quakeml.xml')

the response is:

    ---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-34-6c8337453222> in <module>()
      2 print cat
      3 
----> 4 source = instaseis.Source.parse('http://earthquake.usgs.gov/realtime/product/moment-tensor/us_20002926_mwc/us/1429956564040/quakeml.xml')

/home/staehler/instaseis/instaseis/source.pyc in parse(filename_or_obj)
    201                 pass
    202             else:
--> 203                 return Source.parse(src)
    204             # CMT solution file.
    205             try:

/home/staehler/instaseis/instaseis/source.pyc in parse(filename_or_obj)
    215                     "Event catalog contains %i events. Only one is allowed. "
    216                     "Please parse seperately." % len(filename_or_obj))
--> 217             return Source.parse(filename_or_obj[0])
    218         elif isinstance(filename_or_obj, obspy.core.event.Event):
    219             ev = filename_or_obj

/home/staehler/instaseis/instaseis/source.pyc in parse(filename_or_obj)
    223                 raise SourceParseError("Event must contain a focal mechanism.")
    224             org = ev.preferred_origin() or ev.origins[0]
--> 225             fm = ev.preferred_focal_mechanism() or ev.focal_mechansisms[0]
    226             if not fm.moment_tensor:
    227                 raise SourceParseError("Event must contain a moment tensor.")

/home/staehler/anaconda/lib/python2.7/site-packages/obspy-0.10.1-py2.7-linux-x86_64.egg/obspy/core/util/attribdict.pyc in __getattr__(self, name, default)
    108             return self.__getitem__(name, default)
    109         except KeyError as e:
--> 110             raise AttributeError(e.args[0])
    111 
    112     __setattr__ = __setitem__

AttributeError: focal_mechansisms
krischer commented 9 years ago

I think this has been fixed about two weeks ago; it was just a typo... Can you checkout the latest version and try again? I'm not in front of a computer right now.

sstaehler commented 9 years ago

Yes, fixed in 0.0.1a 105 gbd44. Sorry for not updating before asking