本文整理汇总了Python中obspy.core.Trace.stats['station']方法的典型用法代码示例。如果您正苦于以下问题:Python Trace.stats['station']方法的具体用法?Python Trace.stats['station']怎么用?Python Trace.stats['station']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.core.Trace
的用法示例。
在下文中一共展示了Trace.stats['station']方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: export_sac
# 需要导入模块: from obspy.core import Trace [as 别名]
# 或者: from obspy.core.Trace import stats['station'] [as 别名]
def export_sac(db, filename, pair, components, filterid, corr, ncorr=0,
sac_format=None, maxlag=None, cc_sampling_rate=None):
if sac_format is None:
sac_format = get_config(db, "sac_format")
if maxlag is None:
maxlag = float(get_config(db, "maxlag"))
if cc_sampling_rate is None:
cc_sampling_rate = float(get_config(db, "cc_sampling_rate"))
try:
os.makedirs(os.path.split(filename)[0])
except:
pass
filename += ".SAC"
mytrace = Trace(data=corr)
mytrace.stats['station'] = pair
mytrace.stats['sampling_rate'] = cc_sampling_rate
if maxlag:
mytrace.stats.starttime = -maxlag
mytrace.stats.sac = AttribDict()
mytrace.stats.sac.depmin = np.min(corr)
mytrace.stats.sac.depmax = np.max(corr)
mytrace.stats.sac.depmen = np.mean(corr)
mytrace.stats.sac.scale = 1
mytrace.stats.sac.npts = len(corr)
st = Stream(traces=[mytrace, ])
st.write(filename, format='SAC')
del st
return
示例2: export_sac
# 需要导入模块: from obspy.core import Trace [as 别名]
# 或者: from obspy.core.Trace import stats['station'] [as 别名]
def export_sac(db, filename, pair, components, filterid, corr, ncorr=0, sac_format=None, maxlag=None, cc_sampling_rate=None):
if sac_format is None:
sac_format = get_config(db, "sac_format")
if maxlag is None:
maxlag = float(get_config(db, "maxlag"))
if cc_sampling_rate is None:
cc_sampling_rate = float(get_config(db, "cc_sampling_rate"))
try:
os.makedirs(os.path.split(filename)[0])
except:
pass
filename += ".SAC"
mytrace = Trace(data=corr)
mytrace.stats['station'] = pair
mytrace.stats['sampling_rate'] = cc_sampling_rate
st = Stream(traces=[mytrace, ])
st.write(filename, format='SAC')
tr = SacIO(filename)
if sac_format == "doublets":
tr.SetHvalue('A', 120)
else:
tr.SetHvalue('B', -maxlag)
tr.SetHvalue('DEPMIN', np.min(corr))
tr.SetHvalue('DEPMAX', np.max(corr))
tr.SetHvalue('DEPMEN', np.mean(corr))
tr.SetHvalue('SCALE', 1)
tr.SetHvalue('NPTS', len(corr))
tr.WriteSacBinary(filename)
del st, tr
return
示例3: export_mseed
# 需要导入模块: from obspy.core import Trace [as 别名]
# 或者: from obspy.core.Trace import stats['station'] [as 别名]
def export_mseed(db, filename, pair, components, filterid,corr,ncorr=0):
try:
os.makedirs(os.path.split(filename)[0])
except:
pass
filename += ".MSEED"
maxlag = float(get_config(db,"maxlag"))
cc_sampling_rate = float(get_config(db,"cc_sampling_rate"))
mytrace = Trace(data=corr)
mytrace.stats['station'] = pair[:11]
mytrace.stats['sampling_rate'] = cc_sampling_rate
mytrace.stats['start_time'] = -maxlag
mytrace.stats['location'] = "%02i" % ncorr
st = Stream(traces = [mytrace,])
st.write(filename,format='MSEED')
del st
return
示例4: aquireGreens
# 需要导入模块: from obspy.core import Trace [as 别名]
# 或者: from obspy.core.Trace import stats['station'] [as 别名]
#.........这里部分代码省略.........
freq = i*df
if(freq < df):
freq = 0.01*df
om = twpi * freq
for i in range(n2+0,nyq):
data[i] = complex(0.0,0.0)
# conjug
for i in range(1,n2+0):
data[n+0-i] = data[i].conjugate()
data[0] = complex(0.0,0.0)
data[nyq-1] = complex(0.0,0.0)
# From spectraToTime
data = four1(data,n,1,dt,df)
# Apply damping factor
fac = exp(alpha*t0x)
dfac = exp(alpha*dt)
for i in range(len(data)):
data[i]=(data[i])*fac
fac = fac * dfac
# velocity to displavement if required
if(ivel=='1'):
data=velTodisData(data,dt)
# put data into trace
prel = 0
prel = int(eval(args.pre) / eval(args.delta))
length=numpy.arange(len(data)+prel)*0.0
t=Trace(length)
for i in range(len(data)):
t.data[i+prel]=data[i]
t.stats['delta'] = dt
t.stats['dist'] = Range[j]
name = 'GREEN_' + str(t.stats['dist'])
t.stats['station'] = name
# update stats and apply -1 for tss,xds,zss,zdd
if k==7:
t.stats['channel'] = 'tss'
for i in range(len(data)):
t.data[i] = t.data[i]*(-1)
if k==4:
t.stats['channel'] = 'tds'
for i in range(len(data)):
t.data[i] = t.data[i]*(+1)
if k==6:
t.stats['channel'] = 'xss'
for i in range(len(data)):
t.data[i] = t.data[i]*(+1)
if k==3:
t.stats['channel'] = 'xds'
for i in range(len(data)):
t.data[i] = t.data[i]*(-1)
if k==1:
t.stats['channel'] = 'xdd'
for i in range(len(data)):
t.data[i] = t.data[i]*(+1)
if k==5:
t.stats['channel'] = 'zss'
for i in range(len(data)):
t.data[i] = t.data[i]*(-1)
if k==2:
t.stats['channel'] = 'zds'
for i in range(len(data)):
t.data[i] = t.data[i]*(+1)
if k==0:
t.stats['channel'] = 'zdd'
for i in range(len(data)):
t.data[i] = t.data[i]*(-1)
if k==8:
t.stats['channel'] = 'ex1'
# t.data[i] = t.data[i]
# if(args.iso=='1'):
# for i in range(len(data)):
# t.data[i] = 0.0
# else:
# for i in range(len(data)):
# t.data[i] = 0.0
if k==9:
t.stats['channel'] = 'ex2'
# t.data[i] = t.data[i]
# if(args.iso=='1'):
# for i in range(len(data)):
# t.data[i] = 0.0
# else:
# for i in range(len(data)):
# t.data[i] = 0.0
green.append(t)
return green
示例5: usarray_read
# 需要导入模块: from obspy.core import Trace [as 别名]
# 或者: from obspy.core.Trace import stats['station'] [as 别名]
def usarray_read(fname):
""" Read the BAM US-Array lbv data format used on Mike-2 test specimen.
Read the BAM US-Array lbv data format used on Mike-2 test specimen into a
stream object.
As there is no obvious station (or any other) information in the data file.
As the parameters are not supposed to change, they are hardcoded here.
:parameters:
------------
:type fname: string
:param fname: Path to the file containing the data to be read
(WITHOUT EXTENSION) extensions .dat and .hdr will be added
automatically
:rtype: :class:`~obspy.core.Stream` object
:return: **st**: obspy.core.Stream object
Obspy stream object containing the data
"""
# filenames
lbvfilename = fname + '.lbv'
hdrfilename = fname + '.hdr'
# initialise
st = Stream()
tr = Trace()
# tr = SacIO()
# static parameters
t = os.path.getmtime(hdrfilename)
tt = datetime.datetime.fromtimestamp(t)
tr.stats['starttime'] = UTCDateTime(tt.year, tt.month, tt.day, tt.hour,
tt.minute, tt.second, tt.microsecond)
tr.stats['network'] = 'BAM-USArray'
tr.stats['channel'] = 'z'
# reading header from file
fh = open(hdrfilename, 'r')
while True:
line = fh.readline()
if line.__len__() < 1:
break
line = line.rstrip()
if line.find('PK') > -1:
parts = re.split(':', line)
tr.stats['location'] = parts[1].lstrip()
if line.find('transceivers') > -1:
parts = re.split(':', line)
ntra = int(parts[1].lstrip())
traco = np.zeros((ntra, 3), float)
for i in range(ntra):
coordstr = fh.readline().split()
for j in range(3):
traco[i, j] = float(coordstr[j])
if line.find('measurements') > -1:
parts = re.split(':', line)
nmeas = int(parts[1].lstrip())
measco = np.zeros((nmeas, 2), int)
for i in range(nmeas):
configstr = fh.readline().split()
for j in range(2):
measco[i, j] = float(configstr[j])
if line.find('samples') > -1:
parts = re.split(':', line)
tr.stats['npts'] = int(parts[1].lstrip())
if line.find('samplefreq') > -1:
parts = re.split(':', line)
tr.stats['sampling_rate'] = int(parts[1].lstrip())
fh.close()
# reading data from file
fd = open(lbvfilename, 'rb')
datatype = '>i2'
read_data = np.fromfile(file=fd, dtype=datatype)
fd.close()
# sort and store traces
for i in range(nmeas):
# receiver number stored as station name
tr.stats['station'] = str(measco[i, 1])
# receiver coords (storing not yet implemented)
stla = traco[measco[i, 1] - 1, 1] # x
stlo = traco[measco[i, 1] - 1, 1] # y
stel = traco[measco[i, 1] - 1, 1] # z
# transmitter number stored as event name (storing not yet implemented)
kevnm = str(measco[i, 0])
# transmitter coords (storing not yet implemented)
evla = traco[measco[i, 1] - 1, 0] # x
evlo = traco[measco[i, 1] - 1, 0] # y
evdp = traco[measco[i, 1] - 1, 0] # z
tr.data = read_data[i * tr.stats.npts:(i + 1) * tr.stats.npts]
st.extend([tr])
# plot 1 trace for test purposes
# if i==20:
# tr.plot()
# print ('plot done')
return st
示例6: kutec_read
# 需要导入模块: from obspy.core import Trace [as 别名]
# 或者: from obspy.core.Trace import stats['station'] [as 别名]
#.........这里部分代码省略.........
keys[keyval[0]]['Stunden'] = int(keyval[6])
keys[keyval[0]]['Minuten'] = int(keyval[7])
keys[keyval[0]]['Sekunden'] = float(keyval[8])
tr.stats['starttime'] = UTCDateTime(keys[keyval[0]]['Jahr'], \
keys[keyval[0]]['Monat'], \
keys[keyval[0]]['Tag'], \
keys[keyval[0]]['Stunden'], \
keys[keyval[0]]['Minuten'], \
keys[keyval[0]]['Sekunden'])
elif keyval[0] == 'CD':
keys[keyval[0]] = {}
keys[keyval[0]]['Version'] = int(keyval[1])
keys[keyval[0]]['Lang'] = int(keyval[2])
keys[keyval[0]]['dx'] = float(keyval[3])
tr.stats['delta'] = keys[keyval[0]]['dx']
keys[keyval[0]]['kalibiert'] = int(keyval[4])
if keys[keyval[0]]['kalibiert'] != 1:
print "%s %s = %d not implemented." % \
(keyval[0], 'kalibiert',
keys[keyval[0]]['kalibiert'])
break
keys[keyval[0]]['EinheitLang'] = int(keyval[5])
keys[keyval[0]]['Einheit'] = keyval[6]
if keys[keyval[0]]['Version'] == 2:
keys[keyval[0]]['Reduktion'] = int(keyval[7])
keys[keyval[0]]['InMultiEvents'] = int(keyval[8])
keys[keyval[0]]['SortiereBuffer'] = int(keyval[9])
keys[keyval[0]]['x0'] = float(keyval[10])
keys[keyval[0]]['PretriggerVerwendung'] = int(keyval[11])
if keys[keyval[0]]['Version'] == 1:
keys[keyval[0]]['Reduktion'] = ''
keys[keyval[0]]['InMultiEvents'] = ''
keys[keyval[0]]['SortiereBuffer'] = ''
keys[keyval[0]]['x0'] = ''
keys[keyval[0]]['PretriggerVerwendung'] = 0
elif keyval[0] == 'CR':
keys[keyval[0]] = {}
keys[keyval[0]]['Version'] = int(keyval[1])
keys[keyval[0]]['Lang'] = int(keyval[2])
keys[keyval[0]]['Transformieren'] = int(keyval[3])
keys[keyval[0]]['Faktor'] = float(keyval[4])
keys[keyval[0]]['Offset'] = float(keyval[5])
keys[keyval[0]]['Kalibriert'] = int(keyval[6])
keys[keyval[0]]['EinheitLang'] = int(keyval[7])
keys[keyval[0]]['Einheit'] = keyval[8]
elif keyval[0] == 'CN': # station names
keys[keyval[0]] = {}
keys[keyval[0]]['Version'] = int(keyval[1])
keys[keyval[0]]['Lang'] = int(keyval[2])
keys[keyval[0]]['IndexGruppe'] = int(keyval[3])
keys[keyval[0]]['IndexBit'] = int(keyval[5])
keys[keyval[0]]['NameLang'] = int(keyval[6])
keys[keyval[0]]['Name'] = keyval[7]
keys[keyval[0]]['KommLang'] = int(keyval[8])
keys[keyval[0]]['Kommentar'] = keyval[9]
else:
keys[keyval[0]] = {}
keys[keyval[0]]['KeyString'] = keyval[1:]
# NT key is beginning of measurement (starting of measurement unit)
# keys['Cb']['Addzeit'] needs to be added to obtain the absolute trigger
# time
tr.stats['starttime'] += keys['Cb']['Addzeit']
# Adjust starttime according to pretrigger (There is some uncertainty
# about the CD key) to get relative trigger time
# for CD:Version == 1 always use Cb:x0
# for CD:Version == 2 only use Cb:x0 if CD:PretriggerVerwendung == 1
if keys['CD']['Version'] == 1 or \
(keys['CD']['Version'] == 2 and
keys['CD']['PretriggerVerwendung'] == 1):
tr.stats['starttime'] += keys['Cb']['x0']
if 'CR' in keys:
if keys['CR']['Transformieren']:
tr.data = tr.data * keys['CR']['Faktor'] + keys['CR']['Offset']
f.close()
# ### Channel naming
tr.stats['network'] = 'KU'
tr.stats['location'] = ''
# ### Pre 20120619 namin convention to extract the station name from the
# filename
# tr.stats['station'] = fname[-12:-7]
# ### Now take the station name from the ICN key
tr.stats['station'] = keys['CN']['Name'].replace('_', '')
# ### or construct a name that is consistent with the old filename
# generated one from the key
# ### This is is very likely to cause a problem sooner or later.
# tr.stats['station'] = 'MK%03d' % int(keys['CN']['Name'].split('_')[-1])
# tr.stats['station'] = keys['CN']['Name'].replace('_','')
st = Stream()
st.extend([tr])
return st