You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importpandasaspdfromobspyimportCatalog, UTCDateTime, read_eventsfromobspy.core.eventimportEvent, Magnitude, Origin, Pick, Arrival, WaveformStreamID# Create an empty Catalog objectcat=Catalog()
# Read events from a CSV file## The CSV file should contain the following columns:# - time# - longitude# - latitude# - depth (in km)# - magnitudedf=pd.read_csv("catalog.csv")
for_, rowindf.iterrows(): # loop over events# Create the Origin objectorigin=Origin(
time=UTCDateTime(row["time"]),
longitude=row["longitude"],
latitude=row["latitude"],
depth=row["depth"] *1000.0, # depth is in meter in ObsPy
)
# Create the Magnitude objectmagnitude=Magnitude(mag=row["magnitude"])
# picks are stored in separate TXT filespickfile=origin.time.strftime("%Y%m%d%H%M%S") +".txt"dfpick=pd.read_csv(pickfile)
picks, arrivals= [], []
for_, rowpindfpick.iterrows(): # loop over pickspick=Pick(
time=rowp["time"],
waveform_id=WaveformStreamID(seed_string=rowp["seed_id"])
)
arrival=Arrival(phase=rowp["phase"], pick_id=pick.resource_id)
picks.append(pick)
arrivals.append(arrival)
# Associate arrivals to the Origin objectorigin.arrivals=arrivals# Create the Event objectevent=Event(origins=[origin], magnitudes=[magnitude], picks=picks)
# Append the Event object to the Catalog objectcat.append(event)
# Save as QUAKEML formatcat.write("catalog.quakeml", format="QUAKEML")
data files:
20190101050556.txt
20190101061544.txt
catalog.csv
The text was updated successfully, but these errors were encountered: