本文整理汇总了Python中pyrocko.io.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testReadSeisan
def testReadSeisan(self):
fpath = common.test_data_file('test.seisan_waveform')
i = 0
for tr in io.load(fpath, format='seisan'):
i += 1
assert i == 39
示例2: testWriteRead
def testWriteRead(self):
now = time.time()
n = 10
deltat = 0.1
networks = [ rn(2) for i in range(5) ]
traces1 = [ trace.Trace(rc(networks), rn(4), rn(2), rn(3), tmin=now+i*deltat*n*2, deltat=deltat, ydata=num.arange(n, dtype=num.int32), mtime=now)
for i in range(3) ]
tempdir = tempfile.mkdtemp()
for format in ('mseed', 'sac', 'yaff'):
fns = io.save(traces1, pjoin(tempdir, '%(network)s_%(station)s_%(location)s_%(channel)s'), format=format)
for fn in fns:
assert io.detect_format(fn) == format
traces2 = []
for fn in fns:
traces2.extend(io.load(fn, format='detect'))
for tr in traces1:
assert tr in traces2, 'failed for format %s' % format
for fn in fns:
os.remove(fn)
shutil.rmtree(tempdir)
示例3: restitute_evalresp
def restitute_evalresp(tr_fn):
traces = io.load(tr_fn)
out_traces = []
for tr in traces:
try:
try:
evalresp = trace.Evalresp(respfile=evalresps['%s.%s'%(tr.station, tr.channel)],
nslc_id=tr.nslc_id,
target='dis')
except KeyError:
print 'skip ', '.'.join(tr.nslc_id[1:])
continue
if tr.station=='nkc' or tr.station=='zhc':
t_taper = 30
f_taper = (0.05, 0.08, 50., 75.), # frequency domain taper in [hz]
else:
t_taper = 5.
f_taper = (0.3, 0.6, 50., 75.), # frequency domain taper in [hz]
displacement = tr.transfer(
t_taper, # rise and fall of time domain taper in [s]
*f_taper, # frequency domain taper in [hz]
transfer_function=evalresp,
invert=True)
except trace.TraceTooShort:
continue
out_traces.append(displacement)
tr_fn = tr_fn.replace(inputdir, outputdir)
print tr_fn
io.save(out_traces, tr_fn)
del traces
示例4: load_data
def load_data(self, force=False):
file_changed = False
if not self.data_loaded or force:
logger.debug('loading data from file: %s' % self.abspath)
for itr, tr in enumerate(io.load(self.abspath, format=self.format, getdata=True, substitutions=self.substitutions)):
if itr < len(self.traces):
xtr = self.traces[itr]
if xtr.mtime != tr.mtime or xtr.tmin != tr.tmin or xtr.tmax != tr.tmax:
logger.debug('file may have changed since last access (trace number %i has changed): %s' % (itr, self.abspath))
self.remove(xtr)
self.traces.remove(xtr)
xtr.file = None
self.traces.append(tr)
self.add(tr)
tr.file = self
file_changed = True
else:
xtr.ydata = tr.ydata
else:
self.traces.add(tr)
self.add(tr)
logger.debug('file may have changed since last access (new trace found): %s' % self.abspath)
file_changed = True
self.data_loaded = True
return file_changed
示例5: testReadKan
def testReadKan(self):
fpath = common.test_data_file('01.kan')
i = 0
for tr in io.load(fpath, format='kan'):
i += 1
assert i == 1
示例6: call
def call(self):
"""Main work routine of the snuffling."""
self.cleanup()
view = self.get_viewer()
pile = self.get_pile()
tmin, tmax = view.get_time_range()
if self.useevent:
markers = view.selected_markers()
if len(markers) != 1:
self.fail("Exactly one marker must be selected.")
marker = markers[0]
if not isinstance(marker, EventMarker):
self.fail("An event marker must be selected.")
ev = marker.get_event()
lat, lon = ev.lat, ev.lon
else:
lat, lon = self.lat, self.lon
data = iris_ws.ws_station(
lat=lat, lon=lon, minradius=self.minradius, maxradius=self.maxradius, timewindow=(tmin, tmax), level="chan"
)
stations = iris_ws.grok_station_xml(data, tmin, tmax)
networks = set([s.network for s in stations])
t2s = util.time_to_str
dir = self.tempdir()
fns = []
for net in networks:
nstations = [s for s in stations if s.network == net]
selection = sorted(iris_ws.data_selection(nstations, tmin, tmax))
if selection:
for x in selection:
logger.info("Adding data selection: %s.%s.%s.%s %s - %s" % (tuple(x[:4]) + (t2s(x[4]), t2s(x[5]))))
try:
d = iris_ws.ws_bulkdataselect(selection)
fn = pjoin(dir, "data-%s.mseed" % net)
f = open(fn, "w")
f.write(d)
f.close()
fns.append(fn)
except urllib2.HTTPError:
pass
all_traces = []
for fn in fns:
try:
traces = list(io.load(fn))
all_traces.extend(traces)
except io.FileLoadError, e:
logger.warning("File load error, %s" % e)
示例7: testReadGSE1
def testReadGSE1(self):
fpath = common.test_data_file('test1.gse1')
i = 0
for tr in io.load(fpath, format='detect'):
i += 1
assert i == 19
示例8: call
def call(self):
'''Main work routine of the snuffling.'''
self.cleanup()
view = self.get_viewer()
pile = self.get_pile()
tmin, tmax = view.get_time_range()
if self.useevent:
markers = view.selected_markers()
if len(markers) != 1:
self.fail('Exactly one marker must be selected.')
marker = markers[0]
if not isinstance(marker, EventMarker):
self.fail('An event marker must be selected.')
ev = marker.get_event()
lat, lon = ev.lat, ev.lon
else:
lat, lon = self.lat, self.lon
print lat, lon, self.minradius, self.maxradius, util.time_to_str(tmin), util.time_to_str(tmax)
data = iris_ws.ws_station(lat=lat, lon=lon, minradius=self.minradius, maxradius=self.maxradius,
timewindow=(tmin,tmax), level='chan' )
stations = iris_ws.grok_station_xml(data, tmin, tmax)
networks = set( [ s.network for s in stations ] )
dir = self.tempdir()
fns = []
for net in networks:
nstations = [ s for s in stations if s.network == net ]
selection = sorted(iris_ws.data_selection( nstations, tmin, tmax ))
if selection:
for x in selection:
print x
try:
d = iris_ws.ws_bulkdataselect(selection)
fn = pjoin(dir,'data-%s.mseed' % net)
f = open(fn, 'w')
f.write(d)
f.close()
fns.append(fn)
except urllib2.HTTPError:
pass
newstations = []
for sta in stations:
if not view.has_station(sta):
print sta
newstations.append(sta)
view.add_stations(newstations)
for fn in fns:
traces = list(io.load(fn))
self.add_traces(traces)
示例9: testReadSEGY
def testReadSEGY(self):
fpath = common.test_data_file('test2.segy')
i = 0
for tr in io.load(fpath, format='segy'):
assert tr.meta['orfield_num'] == 1111
i += 1
assert i == 24
示例10: testReadCSS
def testReadCSS(self):
wfpath = common.test_data_file('test_css1.w') # noqa
fpath = common.test_data_file('test_css.wfdisc')
i = 0
for tr in io.load(fpath, format='css'):
i += 1
assert i == 1
示例11: testReadGcf
def testReadGcf(self):
fpath = common.test_data_file('test.gcf')
i = 0
for tr in io.load(fpath, format='gcf'):
i += 1
assert i == 1
示例12: test_ahfull_kiwi
def test_ahfull_kiwi(self):
setup = load(filename=common.test_data_file(
'test_ahfull_kiwi_setup.yaml'))
trs_ref = io.load(common.test_data_file(
'test_ahfull_kiwi_traces.mseed'))
for i, s in enumerate(setup.setups):
d3d = math.sqrt(s.x[0]**2 + s.x[1]**2 + s.x[2]**2)
tlen = d3d / s.vs * 2
n = int(num.round(tlen / s.deltat))
out_x = num.zeros(n)
out_y = num.zeros(n)
out_z = num.zeros(n)
ahfullgreen.add_seismogram(
s.vp, s.vs, s.density, 1000000.0, 1000000.0, s.x, s.f, s.m6,
'displacement',
s.deltat, 0.,
out_x, out_y, out_z,
ahfullgreen.Gauss(s.tau))
trs = []
for out, comp in zip([out_x, out_y, out_z], 'NED'):
tr = trace.Trace(
'', 'S%03i' % i, 'P', comp,
deltat=s.deltat, tmin=0.0, ydata=out)
trs.append(tr)
trs2 = []
for cha in 'NED':
t1 = g(trs, 'S%03i' % i, cha)
t2 = g(trs_ref, 'S%03i' % i, cha)
tmin = max(t1.tmin, t2.tmin)
tmax = min(t1.tmax, t2.tmax)
t1 = t1.chop(tmin, tmax, inplace=False)
t2 = t2.chop(tmin, tmax, inplace=False)
trs2.append(t2)
d = 2.0 * num.sum((t1.ydata - t2.ydata)**2) / \
(num.sum(t1.ydata**2) + num.sum(t2.ydata**2))
if d >= 0.02:
print(d)
# trace.snuffle([t1, t2])
assert d < 0.02
示例13: testReadSUDS
def testReadSUDS(self):
fpath = common.test_data_file('test.suds')
i = 0
for tr in io.load(fpath, format='detect'):
i += 1
assert i == 251
stations = suds.load_stations(fpath)
assert len(stations) == 91
示例14: test_to_obspy_trace
def test_to_obspy_trace(self):
traces = io.load(common.test_data_file('test1.mseed'))
for tr in traces:
obs_tr = tr.to_obspy_trace()
assert isinstance(obs_tr, obspy.Trace)
assert obs_tr.data.size == tr.data_len()
obs_stats = obs_tr.stats
for attr in ('network', 'station', 'location', 'channel'):
assert obs_stats.__getattr__(attr) == tr.__getattribute__(attr)
示例15: load_headers
def load_headers(self, mtime=None):
logger.debug('loading headers from file: %s' % self.abspath)
if mtime is None:
self.mtime = os.stat(self.abspath)[8]
self.remove(self.traces)
for tr in io.load(self.abspath, format=self.format, getdata=False, substitutions=self.substitutions):
self.traces.append(tr)
tr.file = self
self.add(self.traces)
self.data_loaded = False
self.data_use_count = 0