Asia Region Data Download Issue
iiiooooo opened this issue · comments
Sir, I want to download real data for the moment tensor of this earthquake, but there's no data coming. Additionally, I only want three components (mseed files) from one station, as I posted the name of files for your reference. Please check out the code below to see what mistakes I made.
I need my mseed files like this for a one station. Only three components.
BK.BUCR.00.BHE__20190716T201001Z__20190716T201601Z.mseed
BK.BUCR.00.BHN__20190716T201001Z__20190716T201601Z.mseed
BK.BUCR.00.BHZ__20190716T201001Z__20190716T201601Z.mseed
https://earthquake.usgs.gov/earthquakes/eventpage/us7000jwcr/origin/detail
# Import third-party libraries
from pathlib import Path
from obspy.clients.fdsn import Client
from obspy import read_events, UTCDateTime
from obspy.clients.fdsn.mass_downloader import CircularDomain, Restrictions, MassDownloader
event_bool = True
if event_bool:
dataCenter="IRIS"
client = Client(dataCenter)
starttime = UTCDateTime("2023-04-27T00:00:00")
endtime = UTCDateTime("2023-04-27T23:59:59")
catalog = client.get_events(starttime=starttime, endtime=endtime,
minmagnitude=3, maxmagnitude=5,
minlatitude=28, maxlatitude=30,
minlongitude=80, maxlongitude=82)
catalog.write("quakes.xml", format="QUAKEML")
dataCenter="IRIS"
# Time before and after event origin for waveform segments
time_before = 60
time_after = 300
download_bool = True
catalog = read_events("quakes.xml")
for event in catalog:
evid = str(catalog[0].origins[0].resource_id).split("=")[-1] # User origin resource id as the event id
outdir = evid
Path(outdir).mkdir(parents=True,exist_ok=True)
# Event origin
origin_time = event.preferred_origin().time
starttime = origin_time - time_before
endtime = origin_time + time_after
# Event location
evlo = event.preferred_origin().longitude
evla = event.preferred_origin().latitude
depth = event.preferred_origin().depth # in meters
# Set the search area
domain = CircularDomain(latitude=evla, longitude=evlo, minradius=30, maxradius=50)
# Set the search period and additional criteria
restrictions = Restrictions(starttime=starttime, endtime=endtime,
reject_channels_with_gaps=True,
minimum_length=0.95,
network="BK",
channel_priorities=["BH[ZNE12]", "HH[ZNE12]"],
sanitize=True)
# Save catalog info to file
event_out = (
"{evid:s},{origin:s},{jdate:s},"
"{lon:.4f},{lat:.4f},{depth:.4f},"
"{mag:.2f},{auth:s}\n"
)
if event.preferred_magnitude() is None:
mag = -999.
magtype = "ml"
else:
mag = event.preferred_magnitude().mag
magtype = event.preferred_magnitude().magnitude_type.lower()
if event.preferred_origin().extra.catalog.value is None:
auth = "unknown"
else:
auth = event.preferred_origin().extra.catalog.value.replace(" ","")
event_out = event_out.format(
evid=evid,
origin=str(origin_time),
jdate="%s%s"%(origin_time.year,origin_time.julday),
lon=evlo,
lat=evla,
depth=depth/1E3,
mag=mag,
auth=auth
)
outfile = "datetime.csv"
with open(outfile,"w") as f:
f.write("evid,origin,jdate,lon,lat,depth,%s,auth\n"%magtype)
f.write(event_out)
# Dowanload waveforms and metadata
if download_bool:
mseed_storage = "%s/waveforms"%outdir
stationxml_storage = "%s/stations"%outdir
mdl = MassDownloader(providers=[dataCenter])
mdl_helper = mdl.download(domain, restrictions,
mseed_storage=mseed_storage,stationxml_storage=stationxml_storage)
print("%s download completed"%outdir)
print("%s is DONE."%outdir)