How do I use the client.get_events catalog list to access and return origin time and coordinates?

Hello all,
I want to get a list of published events for a given timeframe, so that I can calculate distance, azimuth, and theoretical first-arrival time of the events to our experimental stations. I can generate a catalog from IRIS using this code here, but after reading the documentation, I still cannot see how to use the catalog class to access the origin time magnitude or epicenter coordinates! It’s probably one of those “It’s so simple, we didn’t bother to include an example” sort of situations, but I can’t figure it out. Once I get a time and location, I am good to go. But how do I extract that info from the list I receive from IRIS?

sample code here:

from obspy.clients.fdsn.client import Client
client = Client("IRIS")
starttime = "2021-12-12T00:00:01"
endtime = "2021-12-12T23:59:59"
Starttime = UTCDateTime(starttime)
Endtime = UTCDateTime(endtime)
catalog = client.get_events(starttime = Starttime, endtime = Endtime,
                           minmagnitude = 2.5, maxmagnitude = 8.0,
                           minlatitude = -85.0, maxlatitude = 85.0,
                           minlongitude = -179.9, maxlongitude = 179.9)
print(f"The catalog contains {len(catalog)} events.\n")

Okay, after scanning other people’s code, I found this works, almost. However I still need to figure out how to extract magnitude:


for event in catalog:
    for origin in
        print (f"{origin['time']} LAT: {origin['latitude']} LON: {origin['longitude']} Depth: {float(origin['depth'])/1000}")

This results in returning a printout of the DateTime, latitude, and longitude and depth (in meters). I can now take these values and save them to a simple list for calculation of distance and azimuth. But, now, I need to figure out how to unwrap the magnitude from the event. …Anyone have the answer? - Thanks!

[Origin(resource_id=ResourceIdentifier(id=""), time=UTCDateTime(2021, 12, 12, 23, 50, 3, 335000), longitude=153.1855, latitude=53.3714, depth=539760.0, creation_info=CreationInfo(author='us'))]
2021-12-12T23:50:03.335000Z LAT: 53.3714 LON: 153.1855 Depth: 539.76
2021-12-12T23:19:37.992000Z LAT: 38.6546 LON: -97.5039 Depth: 5.0
2021-12-12T23:13:14.760000Z LAT: 19.183667 LON: -155.473167 Depth: 35.76
2021-12-12T22:55:35.112000Z LAT: -3.8527 LON: 129.0833 Depth: 111.64
2021-12-12T22:36:56.914000Z LAT: -4.1991 LON: 101.3049 Depth: 10.0
2021-12-12T22:30:44.847000Z LAT: 24.1781 LON: 126.6475 Depth: 10.0
2021-12-12T22:21:57.230000Z LAT: 19.8505 LON: -155.2315 Depth: 43.48
2021-12-12T22:11:35.900000Z LAT: -53.0212 LON: 22.1307 Depth: 10.0
2021-12-12T21:33:36.760000Z LAT: 17.9683 LON: -66.2675 Depth: 8.0
2021-12-12T20:50:01.440000Z LAT: 17.9456 LON: -66.977 Depth: 10.0
2021-12-12T20:32:39.070000Z LAT: 17.9448 LON: -66.9171 Depth: 13.0
2021-12-12T19:42:21.892000Z LAT: -10.6714 LON: 120.4521 Depth: 35.0
2021-12-12T19:34:25.570000Z LAT: -10.5158 LON: 120.3091 Depth: 10.0
2021-12-12T19:05:43.120000Z LAT: -21.7237 LON: -68.0631 Depth: 116.52

Okay, last edit, I promise. This worked:

    for magnitude in event.magnitudes:
        print(f"    Magnitude {magnitude['mag']} {magnitude['magnitude_type']}")

So, now I can extract what I need from the event, albeit with a lot of fortranish coding. I haven’t seen much documentation into how to utilize the event or what it’s various fields and dictionaries are. Is there a place I need to look in order to more efficiently utilize the catalog event class?

Okay, I think I have it. The following generates a list of event times, coordinates, and magnitudes. I’ll use it for discrimination studies for various seismic stations and for tuning some of autopickers. Default parameters define the entire globe as the region of study, minimum magnitude = 2.5, and current day as the time of interest, unless otherwise explicitly specified by the user.

from obspy.clients.fdsn.client import Client
client = Client("IRIS")
from datetime import datetime

#  Get_eventlist will return a list from IRIS of all origin times, coordinates, and magnitudes in their event catalog
#  for the selected timeframe and selected geographical region.
# Default parameters must be spelled out
def get_eventlist(parameters = {}):
    # Declare the defaults if they are not already specified
    if (type(parameters) is not dict):
        parameters = {}
        print('parameters was not a dictionary and has been retyped and defaults are being assigned.')
    if 'minmag' not in parameters:
        parameters['minmag'] = 2.5 # min magnitude = 2.5
    if 'maxmag' not in parameters:
        parameters['maxmag'] = 8.0
    if 'minlat' not in parameters:
        parameters['minlat'] = -90.0
    if 'maxlat' not in parameters:
        parameters['maxlat'] = 90.0
    if 'minlon' not in parameters:
        parameters['minlon'] = -180.0
    if 'maxlon' not in parameters:
        parameters['maxlon'] = 180.0
    if 'starttime' not in parameters:  # Use the current day starting at 00:00:00 GMT
        now =
        parameters['starttime'] = now.strftime("%Y-%m-%dT00:00:00")
    if 'endtime' not in parameters:   # Use now as the endtime. 
        now =
        parameters['endtime'] = now.strftime("%Y-%m-%dT%H:%M:%S") 
    starttime = parameters['starttime'] #"2021-12-12T00:00:01"
    endtime = parameters['endtime'] # "2021-12-12T23:59:59"
    Starttime = UTCDateTime(starttime)
    Endtime = UTCDateTime(endtime)
    catalog = client.get_events(starttime = Starttime, endtime = Endtime,
                               minmagnitude = parameters['minmag'], maxmagnitude = parameters['maxmag'],
                               minlatitude = parameters['minlat'], maxlatitude = parameters['maxlat'],
                               minlongitude = parameters['minlon'], maxlongitude = parameters['maxlon'])
    Eventlist = []
    for event in catalog:
        Eventlist.append([[0]['time'],float([0]['latitude']), \
                          float([0]['longitude']),float([0]['depth'])/1000, \

I can now specify any region, as well as min and max magnitudes. It’s flexible enough that you can specify zero parameters or all of the parameters. I use it thus:

parameters = {'minmag':5.0}
parameters['starttime'] = "2021-12-12T00:00:00"
parameters['endtime'] = "2021-12-12T23:59:59"

Eventlist = get_eventlist(parameters)
print(f"Length of event list = {len(Eventlist)} events.")

resulting in:

Length of event list = 7 events.
[[2021-12-12T22:11:35.900000Z, -53.0212, 22.1307, 10.0, 5.3, 'mww'],
 [2021-12-12T19:04:41.386000Z, 48.8583, 154.3976, 80.76, 5.0, 'Mww'],
 [2021-12-12T09:45:02.503000Z, -60.7916, 153.8235, 10.0, 5.3, 'Mww'],
 [2021-12-12T08:58:07.323000Z, -60.7956, 154.1393, 10.0, 6.6, 'mww'],
 [2021-12-12T08:46:42.682000Z, -59.4247, -25.9313, 35.0, 5.0, 'mb'],
 [2021-12-12T06:47:44.518000Z, 24.1708, 126.677, 10.0, 5.0, 'mb'],
 [2021-12-12T06:43:11.712000Z, 24.1926, 126.7194, 10.0, 5.2, 'mb']]

I can now use the list to do things like calculate distance and azimuth to the station of interest, and calculate, on a daily basis , predicted origin time, and look to see if there’s a visible arrival.

Kia ora @Tychoaussie - you might have been looking for this kind of thing for examples of how to use the ObsPy Event class hierarchy.

It looks like you are looking for ways to query catalogs based on magnitude and location. This is implemented in obsplus if you are interested.

In general if you only care about the preferred origin or magnitude you can use the .preferred_magnitude() and .preferred_origin() methods, provided that the event has the preferred origin and magnitude set. A helpful way to do get the preferred origin or magnitude is to use code like:

    magnitude = event.preferred_magnitude() or event.magnitude[-1]
except IndexError: # Cope with no magnitudes provided
    magnitude = None

    origin = event.preferred_origin() or[-1]
except IndexError: # Cope with no origins provided
    origin = None

HI Calum, yes! I am interested. Thanks for the heads-up on Obsplus!

@Tychoaussie not sure if its still relevant… there is a graphical overview of Catalog/Event object here and it links to QuakeML documents, which we model pretty closely after.

Catalog has a filter method, not sure if thats what you were looking for?