本文整理汇总了Python中obspy.core.Trace.stats['location']方法的典型用法代码示例。如果您正苦于以下问题:Python Trace.stats['location']方法的具体用法?Python Trace.stats['location']怎么用?Python Trace.stats['location']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.core.Trace
的用法示例。
在下文中一共展示了Trace.stats['location']方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: export_mseed
# 需要导入模块: from obspy.core import Trace [as 别名]
# 或者: from obspy.core.Trace import stats['location'] [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
示例2: usarray_read
# 需要导入模块: from obspy.core import Trace [as 别名]
# 或者: from obspy.core.Trace import stats['location'] [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
示例3: kutec_read
# 需要导入模块: from obspy.core import Trace [as 别名]
# 或者: from obspy.core.Trace import stats['location'] [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