Event information from catalog object

Hi All,

I would like to get event information separately.

details:

#!/usr/bin/env python
from obspy.iris import Client
from obspy import UTCDateTime
client = Client()
starttime = UTCDateTime("2011-04-11")
endtime = UTCDateTime("2011-04-12")
EVTs = client.getEvents(starttime=starttime, endtime=endtime, minmag=6.7)
print(EVTs)

output:
In [7]: print(EVTs)
1 Event(s) in Catalog:
2011-04-11T08:16:12.730000Z | +37.001, +140.401 | 6.7 MW

I try to get time / lat/ lon/ depth/ ma as its attribute.
I cannot find it.

In [8]: EVTs.
EVTs.append EVTs.copy EVTs.description EVTs.filter EVTs.write
EVTs.clear EVTs.count EVTs.events EVTs.plot
EVTs.comments EVTs.creation_info EVTs.extend EVTs.resource_id

any one knows how to call those parameters separately?

Thank you so much.

Cheers,
Patty

Hi Patty,
I have not worked with Event objects very much, but it looks like you can access the attributes you want in this way:
Your EVTs object is a list of events (in this case, there is only one in the list).
To create an object with just this event in it, and see its attributes, I did this:

In [8]: myevent=EVTs[0]

(try myevent. to see all of the attributes now…)

In [9]: myevent.origins
Out[9]:
[Origin
resource_id: ResourceIdentifier(resource_id=“smi:www.iris.edu/ws/event/query?originId=9535656”)
time: UTCDateTime(2011, 4, 11, 8, 16, 12, 730000)
latitude: 37.001
longitude: 140.401
depth: 11.0
creation_info: CreationInfo(author=‘NEIC’)]

In [11]: myevent.origins[0][‘latitude’]
Out[11]: 37.001

So it looks like each Event can have a list of different origins associated with it (though again, there is only one for this event). You could do a similar thing to get the longitude, time, and depth. The “magnitudes” attribute also seems to be structured in a similar way:

In [18]: myevent.magnitudes
Out[18]:
[Magnitude
resource_id: ResourceIdentifier(resource_id=“smi:www.iris.edu/ws/event/query?magnitudeId=14183133”)
mag: 6.7
magnitude_type: ‘MW’
origin_id: ResourceIdentifier(resource_id=“smi:www.iris.edu/ws/event/query?originId=7916388”)
creation_info: CreationInfo(author=‘GCMT’)]

In [19]: myevent.magnitudes[0][‘mag’]
Out[19]: 6.7

Hope that helps! If there is a better way of explaining or accessing Event attributes, please let me know…

Emily

Hi Emily,

thank you so much… This is what I am looking for.

It’s not so straightforward.
did try EVTs[0].… but didn’t see the related attributes

thanks!!!

Cheers,
Patty

Hi Patty,

If you are puzzled by the setup of all the event related objects, I can
recommend a look at the QuakeML standard. It is quite complex,
admittedly, but it makes sense and the ObsPy Event structure is modeled
pretty closely around it (as QuakeML is the standard Event/Catalog
exchange format right now).

https://quake.ethz.ch/quakeml/docs/REC?action=AttachFile&do=view&target=QuakeML-BED-20130214a.pdf

best,
Tobias