# gcmt eventid

**URL:** https://discourse.obspy.org/t/gcmt-eventid/767
**Category:** Users Mailing List Archive
**Tags:** archive
**Created:** [March 29, 2018, 2:34am UTC](https://discourse.obspy.org/t/gcmt-eventid/767 "2018-03-29T02:34:16Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![mth](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/m/dc4da7/32.png) [@mth](https://discourse.obspy.org/u/mth)
#### Post date: [March 29, 2018, 2:34am UTC](https://discourse.obspy.org/t/gcmt-eventid/767/1 "2018-03-29T02:34:16Z")

</div>

I have a script that pulls synthetics from the IRIS/syngine instaseis webservice using, e.g.,  
obspy…read() + “eventid=GCMT:C201802061550A”.

I’m trying to build on this by either looking up the GCMT eventid for a given event,  
or using the GCMT eventid to find the event parameters.

i.e., I’d like to either:

1. specify the GCMT eventid for a particular event and  
use it to query one of the fdsn clients (e.g., IRIS) to get the corresponding event origin time,  
lat, lon, etc)

ie, I can go to [http://ds.iris.edu/spud/momenttensor](http://ds.iris.edu/spud/momenttensor) or [http://www.globalcmt.org/CMTsearch.htm](http://www.globalcmt.org/CMTsearch.htm)l  
and find the GCMT eventid for a specified event.

But is there a way to use in this in obspy (e.g., catalog, get\_event ?) to find the event specs ?

-or-

1. use the specified origin (time, lat, lon) to search the GCMT programatically for the corresponding gcmt eventid.

Is there any way to query one of the catalog providers for GCMT eventid in obspy ?

I’ve looked through the obspy docs but I can’t tell which catalogs are supported and/or if ‘gcmt’ is  
used for anything beyond syngine/instaseis, where it is passed to the IRIS web service and used to  
look up the event parameters (lat, lon, origin, moment tensor) needed to sum the green’s functions  
to form the synthetic (?)

Cheers!

-Mike

---

<div class="post-metadata">

### Author: ![LionKrischer](https://discourse.obspy.org/user_avatar/discourse.obspy.org/lionkrischer/32/219_2.png) [@LionKrischer](https://discourse.obspy.org/u/LionKrischer)
#### Post date: [March 29, 2018, 7:45am UTC](https://discourse.obspy.org/t/gcmt-eventid/767/2 "2018-03-29T07:45:18Z")

</div>

Hi Mike,

a couple of things:

(1) I did not get if you are using ObsPy’s syngine client. To be sure you are aware of it:

(2) We currently have no “clients” for the spud mts or the GCMT website. These would most likely require some HTML parsing which tend to be tedious to maintain.

(3) In these cases I usually just download all GCMT events and manually query these files:

(4) The ISC webservice can give you GCMT MTs. But their service (at least used to) implements very strict rate limits so it is tedious to use it.

(5) Instead of passing the event id you can also pass the event parameters including MT components directly to syngine.

(6) Instaseis () can use syngine as a backend and has some functionality to convert ObsPy event objects (and thus any event file ObsPy can read) to proper syngine queries.

Cheers!

Lion

---

<div class="post-metadata">

### Author: ![mth](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/m/dc4da7/32.png) [@mth](https://discourse.obspy.org/u/mth)
#### Post date: [March 29, 2018, 11:58am UTC](https://discourse.obspy.org/t/gcmt-eventid/767/3 "2018-03-29T11:58:04Z")

</div>

Hi Lion,

I have a call like this in my python/obspy script:

st\_synth = read(“[http://service.iris.edu/irisws/syngine/1/query?%s](http://service.iris.edu/irisws/syngine/1/query?%25s)”  
“eventid=GCMT:%s&dt=0.05&”  
“units=displacement&”  
“model=%s&label=Tutorial&format=miniseed” % (receiver,eventid,model))

Right now I’m picking up the event info (origin, lat, lon) from a config.yml file.

I wanted to replace this with just the gcmt eventid to save time, if there were a  
way to look up the event info from gcmt eventid.

It looks to me like obspy can query other catalogs (e.g., ISC, NEIC ?) and get info for events  
within a range (location box, time box, etc). I guess each of those catalogs has its own  
eventid numbering; I thought maybe one of them might also contain the gcmt eventid as  
an event parameter (as opposed to primary key).

Cheers!  
-Mike

---

<div class="post-metadata">

### Author: ![Chad\_Trabant](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/c/bcef8e/32.png) [@Chad\_Trabant](https://discourse.obspy.org/u/Chad_Trabant)
#### Post date: [March 29, 2018, 4:19pm UTC](https://discourse.obspy.org/t/gcmt-eventid/767/4 "2018-03-29T16:19:53Z")

</div>

Hi Lion,

> (2) We currently have no “clients” for the spud mts or the GCMT website. These would most likely require some HTML parsing which tend to be tedious to maintain.

Should anyone need to programmatically access data products in SPUD there is no need to parse HTML, there is a whole web service interface for SPUD. From the SPUD landing page, click Help =\> Spudservices user guide and you get to:

[http://ds.iris.edu/spud/spudsvcsguide](http://ds.iris.edu/spud/spudsvcsguide)

The usage can get complicated because the products themselves are complicated, but simple things like pulling a GCMT out based on our internal ID or the GCMT ID are easy, that’s how Syngine does it internally.

For example, getting the NDK for a GCMT based on the GCMT ID is this:

[http://ds.iris.edu/spudservice/momenttensor/gcmtid//ndk](http://ds.iris.edu/spudservice/momenttensor/gcmtid/%3CGCMTID%3E/ndk)

Chad

---

<div class="post-metadata">

### Author: ![mth](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/m/dc4da7/32.png) [@mth](https://discourse.obspy.org/u/mth)
#### Post date: [March 29, 2018, 4:34pm UTC](https://discourse.obspy.org/t/gcmt-eventid/767/5 "2018-03-29T16:34:10Z")

</div>

Thanks Chad! - the delineation between obspy/syngine/iris web services is a bit murky for me.

It seems I can just do:

import requests  
response = requests.get(‘[http://ds.iris.edu/spudservice/momenttensor/gcmtid/C201802061550A/ndk](http://ds.iris.edu/spudservice/momenttensor/gcmtid/C201802061550A/ndk)’)

and then parse response.content to get the event info.

Cheers,  
-Mike

---

<div class="post-metadata">

### Author: ![LionKrischer](https://discourse.obspy.org/user_avatar/discourse.obspy.org/lionkrischer/32/219_2.png) [@LionKrischer](https://discourse.obspy.org/u/LionKrischer)
#### Post date: [March 29, 2018, 7:00pm UTC](https://discourse.obspy.org/t/gcmt-eventid/767/6 "2018-03-29T19:00:11Z")

</div>

@Chad - Also thanks from me! I was not aware of the SPUD API. I’ll probably add a client to ObsPy as I have a personal need for this.

@Mike - you can also directly read the ndk file with

> > > cat = obspy.read\_events(“[http://ds.iris.edu/spudservice/momenttensor/gcmtid/C201802061550A/ndk](http://ds.iris.edu/spudservice/momenttensor/gcmtid/C201802061550A/ndk)”)

which will parse it to ObsPy’s event class.

Lion

---

<div class="post-metadata">

### Author: ![mth](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/m/dc4da7/32.png) [@mth](https://discourse.obspy.org/u/mth)
#### Post date: [March 29, 2018, 7:14pm UTC](https://discourse.obspy.org/t/gcmt-eventid/767/7 "2018-03-29T19:14:21Z")

</div>

Hi Lion,  
I did stumble on your ndk parser, but I don’t see that it has methods to return lat,lon,origin, moment tensor.  
It’s not clear to me if I need to convert ndk to quakeml to see everything (?)  
e.g:

cat = read\_events(‘[http://ds.iris.edu/spudservice/momenttensor/gcmtid/C201802061550A/ndk](http://ds.iris.edu/spudservice/momenttensor/gcmtid/C201802061550A/ndk)’)  
events = cat.events  
for event in events:  
print(event)  
origin = event.preferred\_origin // This looks like an id to use with some other catalog ??

print(origin)

\<bound method Event.preferred\_origin of Event(resource\_id=ResourceIdentifier(id=“smi:local/ndk/C201802061550A/event”), event\_type=‘earthquake’, event\_type\_certainty=‘known’, preferred\_origin\_id=ResourceIdentifier(id=“smi:local/ndk/C201802061550A/origin#cmtorigin”), preferred\_magnitude\_id=ResourceIdentifier(id=“smi:local/ndk/C201802061550A/magnitude#moment\_mag”), preferred\_focal\_mechanism\_id=ResourceIdentifier(id=“smi:local/ndk/C201802061550A/focal\_mechanism”))\>

---

<div class="post-metadata">

### Author: ![LionKrischer](https://discourse.obspy.org/user_avatar/discourse.obspy.org/lionkrischer/32/219_2.png) [@LionKrischer](https://discourse.obspy.org/u/LionKrischer)
#### Post date: [March 29, 2018, 7:48pm UTC](https://discourse.obspy.org/t/gcmt-eventid/767/8 "2018-03-29T19:48:02Z")

</div>

Hi Mike,

within ObsPy it does not really matter that much if your data originated as QuakeML or an NDK (or any of the other supported formats). They all are parsed to the same objects. The event object is more or less a verbatim copy of QuakeML’s data model as it is the most comprehensive of all formats.

Regarding your issue: its a method you have to call. I prefer to do (as preferred children might not be set):

> > > origin = event.preferred\_origin() or event.origins[0]

> > > origin.latitude, origin.longitude, origin.time, …

> > > fm = event.preferred\_focal\_mechanism() or event.focal\_mechanisms[0]

> > > mt = fm.moment\_tensor.tensor

Cheers!

Lion
