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")
print(catalog[0],"\n")
print(catalog[0].keys(),"\n")
print(catalog[0]['resource_id'])
EDIT:
Okay, after scanning other people’s code, I found this works, almost. However I still need to figure out how to extract magnitude:
print(catalog[0].origins)
for event in catalog:
for origin in event.origins:
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="smi:service.iris.edu/fdsnws/event/1/query?originid=46223586"), 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?