本文整理汇总了Python中obspy.core.stream.Stream.select方法的典型用法代码示例。如果您正苦于以下问题:Python Stream.select方法的具体用法?Python Stream.select怎么用?Python Stream.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.core.stream.Stream
的用法示例。
在下文中一共展示了Stream.select方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_xyzalgorithm_uneccesary_channel_empty
# 需要导入模块: from obspy.core.stream import Stream [as 别名]
# 或者: from obspy.core.stream.Stream import select [as 别名]
def test_xyzalgorithm_uneccesary_channel_empty():
"""XYZAlgorithm_test.test_xyzalgorithm_uneccesary_channel_gaps()
confirms the process will run when an uneccesary channel is input
but contains gaps or is completely empty. ie. gaps in 'Z' channel
or and empty 'F' channel. This also makes sure the 'Z' and 'F' channels
are passed without any modification.
"""
algorithm = XYZAlgorithm('obs', 'mag')
timeseries = Stream()
timeseries += __create_trace('H', [1, 1])
timeseries += __create_trace('E', [1, 1])
timeseries += __create_trace('Z', [1, np.NaN])
timeseries += __create_trace('F', [np.NaN, np.NaN])
outstream = algorithm.process(timeseries)
assert_equals(outstream.select(channel='Z')[0].data.all(),
timeseries.select(channel='Z')[0].data.all())
assert_equals(outstream.select(channel='F')[0].data.all(),
timeseries.select(channel='F')[0].data.all())
ds = outstream.select(channel='D')
# there is 1 trace
assert_equals(len(ds), 1)
d = ds[0]
# d has 2 values (same as input)
assert_equals(len(d.data), 2)
# d has no NaN values
assert_equals(np.isnan(d).any(), False)
示例2: GetIIData
# 需要导入模块: from obspy.core.stream import Stream [as 别名]
# 或者: from obspy.core.stream.Stream import select [as 别名]
#.........这里部分代码省略.........
self.CHANWILD = True
DupChannels.append(self.tr.stats.channel)
elif self.channel != '*':
self.CHANWILD = False
#except TimeoutError:
#print 'Get waveform timeout, exiting...'
#sys.exit(0)
except:
print 'Trouble getting data'
sys.exit(0)
# Takes duplicate stations out of list and
# makes station, location, and channel into an array
# for looping( probably easier way but it works)
self.stations = list(set(DupStations))
if self.station != '*':
self.stations.append(self.station)
self.locations = list(set(DupLocations))
if self.location != '*':
self.locations.append(self.location)
self.channels = list(set(DupChannels))
if self.channel != '*':
self.channels.append(self.channel)
print
print "Station(s) being pulled: " + str(self.stations)
print "Location(s) being pulled: " + str(self.locations)
print "Channel(s) being pulled: " + str(self.channels)
# Now call code to store streams in mseed files
self.storeMSEED()
def storeMSEED(self):
#Main program
#code for storing MSEED files
codepath = '/home/mkline/dev/getIIdataBackup/TEST_ARCHIVE/'
self.stFinal = Stream()
for self.channel in self.channels:
self.trace2 = self.st.select(channel = self.channel)
for self.location in self.locations:
self.trace1 = self.trace2.select(location = self.location)
for self.station in self.stations:
print
print "For station, location, and channel: " \
+ self.station +" "+ self.location +" "+ self.channel
trace = self.trace1.select(station = self.station)
trace.merge()
trace.sort()
trace.count()
for dayIndex in range(0,self.days):
print "Day properties: "
#startTime works better than trace[0].stats.starttime
trimStart = self.startTime + (dayIndex)*24*60*60
trimEnd = self.startTime + (dayIndex+1)*24*60*60
print "Start of day: " + str(trimStart)
print "End of day: " + str(trimEnd)
#Converting date into julian day to store in directory
timesplit = re.split('T', str(trimStart))
s = timesplit[0]
fmt = '%Y-%m-%d'
dt = datetime.datetime.strptime(s, fmt)
tt = dt.timetuple()
NewStartDay = str(tt.tm_yday).zfill(3)
self.stFinal = trace.copy()
self.stFinal.trim(starttime = trimStart, endtime = trimEnd)
# This if statement is used to make sure traces with no
# data dont get added to the directory structure
if not self.stFinal or str(self.stFinal[0].max()) == '--':
print "No trace for given day"
else:
#Added the directory structures in here since you won't want to
#add directory structures that you don't use
self.stFinal = self.stFinal.split()
if not os.path.exists(codepath + self.network + '_' + self.station + '/'):
os.mkdir(codepath + self.network + '_' + self.station + '/')
if not os.path.exists(codepath + self.network + '_' + self.station + '/' \
+ self.year + '/'):
os.mkdir(codepath + self.network + '_' + self.station + '/' \
+ self.year + '/')
stpath = codepath + self.network + '_' + self.station + '/' + self.year + \
'/' + self.year + '_' + NewStartDay + '/'
if not os.path.exists(stpath):
os.mkdir(stpath)
# Here we write the data using STEIM 2 and 512 record lengths
self.stFinal.write(stpath + self.stFinal[0].stats.location + '_' + \
self.stFinal[0].stats.channel + '.512.seed', format='MSEED', \
reclen = 512, encoding='STEIM2')
print self.stFinal
# convert optional boolean strings to boolean vars
def toBool(self, value):
"""
Converts 'string' to boolean. Raises exception for invalid formats
True values: 1, True, true, "1", "True", "true", "yes", "y", "t"
False values: 0, False, false, "0", "False", "false", "no", "n", "f"
"""
if str(value).lower() in ("true", "yes", "t", "y", "1"): return True
if str(value).lower() in ("false", "no", "f", "n", "0"): return False
raise Exception('Invalid value for boolean conversion: ' + str(value))