本文整理匯總了Python中obspy.iris.Client.saveResponse方法的典型用法代碼示例。如果您正苦於以下問題:Python Client.saveResponse方法的具體用法?Python Client.saveResponse怎麽用?Python Client.saveResponse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類obspy.iris.Client
的用法示例。
在下文中一共展示了Client.saveResponse方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_saveResponse
# 需要導入模塊: from obspy.iris import Client [as 別名]
# 或者: from obspy.iris.Client import saveResponse [as 別名]
def test_saveResponse(self):
"""
Fetches and stores response information as SEED RESP file.
"""
client = Client()
start = UTCDateTime("2005-001T00:00:00")
end = UTCDateTime("2008-001T00:00:00")
# RESP, single channel
origfile = os.path.join(self.path, "data", "RESP.ANMO.IU.00.BHZ")
tempfile = NamedTemporaryFile().name
client.saveResponse(tempfile, "IU", "ANMO", "00", "BHZ", start, end)
self.assertTrue(filecmp.cmp(origfile, tempfile))
os.remove(tempfile)
# RESP, multiple channels
origfile = os.path.join(self.path, "data", "RESP.ANMO.IU._.BH_")
tempfile = NamedTemporaryFile().name
client.saveResponse(tempfile, "IU", "ANMO", "*", "BH?", start, end)
self.assertTrue(filecmp.cmp(origfile, tempfile))
os.remove(tempfile)
# StationXML, single channel
tempfile = NamedTemporaryFile().name
client.saveResponse(tempfile, "IU", "ANMO", "00", "BHZ", start, end, format="StationXML")
data = open(tempfile).read()
self.assertTrue('<Station net_code="IU" sta_code="ANMO">' in data)
os.remove(tempfile)
# SACPZ, single channel
tempfile = NamedTemporaryFile().name
client.saveResponse(tempfile, "IU", "ANMO", "00", "BHZ", start, end, format="SACPZ")
data = open(tempfile).read()
self.assertTrue("NETWORK (KNETWK): IU" in data)
self.assertTrue("STATION (KSTNM): ANMO" in data)
os.remove(tempfile)
示例2: test_saveResponseToStringIO
# 需要導入模塊: from obspy.iris import Client [as 別名]
# 或者: from obspy.iris.Client import saveResponse [as 別名]
def test_saveResponseToStringIO(self):
"""
Same as test_saveResponse but saves to a StringIO.
"""
client = Client()
start = UTCDateTime("2005-001T00:00:00")
end = UTCDateTime("2008-001T00:00:00")
# RESP, single channel
origfile = os.path.join(self.path, 'data', 'RESP.ANMO.IU.00.BHZ')
with open(origfile, "rb") as fh:
org_data = fh.read()
memfile = StringIO.StringIO()
client.saveResponse(memfile, "IU", "ANMO", "00", "BHZ", start, end)
memfile.seek(0, 0)
new_data = memfile.read()
self.assertEqual(new_data, org_data)
# RESP, multiple channels
origfile = os.path.join(self.path, 'data', 'RESP.ANMO.IU._.BH_')
with open(origfile, "rb") as fh:
org_data = fh.read()
memfile = StringIO.StringIO()
client.saveResponse(memfile, "IU", "ANMO", "*", "BH?", start, end)
memfile.seek(0, 0)
new_data = memfile.read()
self.assertEqual(new_data, org_data)
# StationXML, single channel
memfile = StringIO.StringIO()
client.saveResponse(memfile, "IU", "ANMO", "00", "BHZ", start, end,
format="StationXML")
memfile.seek(0, 0)
data = memfile.read()
self.assertTrue('<Station net_code="IU" sta_code="ANMO">' in data)
# SACPZ, single channel
memfile = StringIO.StringIO()
client.saveResponse(memfile, "IU", "ANMO", "00", "BHZ", start, end,
format="SACPZ")
memfile.seek(0, 0)
data = memfile.read()
self.assertTrue('NETWORK (KNETWK): IU' in data)
self.assertTrue('STATION (KSTNM): ANMO' in data)
示例3: UTCDateTime
# 需要導入模塊: from obspy.iris import Client [as 別名]
# 或者: from obspy.iris.Client import saveResponse [as 別名]
from obspy.core.util import NamedTemporaryFile
import matplotlib.pyplot as plt
import numpy as np
# MW 7.1 Darfield earthquake, New Zealand
t1 = UTCDateTime("2010-09-3T16:30:00.000")
t2 = UTCDateTime("2010-09-3T17:00:00.000")
# Fetch waveform from IRIS web service into a ObsPy stream object
client = Client()
st = client.getWaveform('NZ', 'BFZ', '10', 'HHZ', t1, t2)
# Download and save instrument response file into a temporary file
with NamedTemporaryFile() as tf:
respf = tf.name
client.saveResponse(respf, 'NZ', 'BFZ', '10', 'HHZ', t1, t2, format="RESP")
# make a copy to keep our original data
st_orig = st.copy()
# define a filter band to prevent amplifying noise during the deconvolution
pre_filt = (0.005, 0.006, 30.0, 35.0)
# this can be the date of your raw data or any date for which the
# SEED RESP-file is valid
date = t1
seedresp = {'filename': respf, # RESP filename
# when using Trace/Stream.simulate() the "date" parameter can
# also be omitted, and the starttime of the trace is then used.
'date': date,
示例4: wavesdownloader
# 需要導入模塊: from obspy.iris import Client [as 別名]
# 或者: from obspy.iris.Client import saveResponse [as 別名]
#.........這裏部分代碼省略.........
# local same than eida - very easy
if args.server[2] == 1:
#if args.res != "0":
(respFiles, pazFiles) = extractResponse(args.fsfile,args.res,args.outdir)
if args.res == "2" or args.res == "3":
dataStreamLoca = addPazStats(dataStreamLoca,args.outdir,pazFiles)
dataStreamLoca = updateStats(dataStreamLoca,args.outdir,"rdseed.stations",ev_lat,ev_lon)
dataStreamLoca = purgeListStation(dataStreamLoca,args,'d')
shutil.move(args.outdir + os.sep + 'rdseed.stations',args.outdir + os.sep + 'local_rdseed.stations')
# iris - longer
if args.server[1] == 1:
pazFiles = []
temp_iris = open(args.outdir + os.sep + "tmp_iris.station","w")
# here store lat lon staz locId for later update of iris stream
for i in range(len(dataStreamIris)):
n = dataStreamIris[i].stats['network']
s = dataStreamIris[i].stats['station']
l = dataStreamIris[i].stats['location']
c = dataStreamIris[i].stats['channel']
nameresp = "RESP." + n + "." + s + "." + l + "." + c
namepaz = "SAC.PZs." + n + "." + s + "." + c
# get metadata station latitude and longitude
meta = irisClient.station(network=n, station=s, location=l, channel=c, starttime=t1, endtime=t2)
(lat,lon) = getXmlTagData(meta)
# update temp_iris
temp_iris.write(s + " " + n + " " + lat + " " + lon + "0.0\n")
# write resp files
if args.res == "1" or args.res == "3":
irisClient.saveResponse(filename=args.outdir + os.sep + nameresp ,network=n, station=s, location=args.loc, channel=c,\
starttime=t1, endtime=t2, format='RESP')
if args.res == "2" or args.res == "3":
sacpz = irisClient.sacpz(network=n, station=s, location=args.loc, channel=c, starttime=t1, endtime=t2)
sacpz = sac4sac(sacpz)
f = open(args.outdir + os.sep + namepaz, 'w')
f.write(sacpz)
f.close() # close close close!!!! porcoIddio che mi dimentico sempre!!!
pazFiles.append(namepaz)
# lose temp_iris
temp_iris.close()
# update stream
dataStreamIris = updateStats(dataStreamIris,args.outdir,"tmp_iris.station",ev_lat,ev_lon)
if args.res == '2' or args.res == '3':
dataStreamIris = addPazStats(dataStreamIris,args.outdir,pazFiles)
if args.server[3] == 1:
# Write webdc.stations file and extract PZ file
# and update lat lon and event loc into statz for consistency
dataStreamWbDc=writeWbDcStation(dataStreamWbDc,args)
if args.res == "2" or args.res == "3":
PzFileFromStat(dataStreamWbDc,args)
print "\nWarning, RESP files can not be downloaded from WebDC vie ArcLink\n"
if args.res == "1":
print "\nWarning, RESP files can not be downloaded from WebDC vie ArcLink\n"
#############################################################
## ---- G. Join all traces and write mseed files with original data