当前位置: 首页>>代码示例>>Python>>正文


Python Stream.write方法代码示例

本文整理汇总了Python中obspy.core.stream.Stream.write方法的典型用法代码示例。如果您正苦于以下问题:Python Stream.write方法的具体用法?Python Stream.write怎么用?Python Stream.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在obspy.core.stream.Stream的用法示例。


在下文中一共展示了Stream.write方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: saveData

# 需要导入模块: from obspy.core.stream import Stream [as 别名]
# 或者: from obspy.core.stream.Stream import write [as 别名]
 def saveData(self, filename = None):
     stream = Stream()
     for i in range(0,self.ntraces):
         curr_trace = self.data[:,i]
         curr_trace = np.require(curr_trace, dtype='float32')
         temp = Trace(data=curr_trace)
         # Attributes in trace.stats will overwrite everything in
         # trace.stats.segy.trace_header
         temp.stats.delta = 0.01
             # Add trace to stream
         stream.append(temp)
     print "Stream object before writing..."
     print stream
     stream.write(filename, format="SEGY", data_encoding=1,
                 byteorder=sys.byteorder)
开发者ID:amine85,项目名称:seismic-data-processing,代码行数:17,代码来源:model.py

示例2: range

# 需要导入模块: from obspy.core.stream import Stream [as 别名]
# 或者: from obspy.core.stream.Stream import write [as 别名]
	month=path[-2:]
	lifile=glob.glob('*')
	for days in [x+1 for x in range(31)]:
		day=('%02d' % days)
		for hours in [x for x in range(24)]:
			hour=('%02d' % hours)
			wav_files=[wav for wav in lifile if year in wav[0:4] \
			and month in wav[5:7] \
			and day in wav[8:10] \
			and hour in wav[11:13]]
			if not wav_files:
				continue
			else:
				output_name='%s-%s-%s-%s00_%s.%s' % (year,month,day,hour,suffix,wav_format)
				stream_wav=Stream()
				for i in range(len(wav_files)):
					stream_wav+=read(wav_files[i])
				stream_wav.write(output_name,format=("%s" % wav_format))
				stream_wav.clear()
			shutil.move(output_name,("%s%s/%s/" % (final_base,year,month)))
			print "Processing...%s...Please wait" % output_name
				
sys.exit()			
#				cat_wav=(' '.join(wav_files))
#				cat_command('cat %s > %s-%s-%s-%s
#				os.system(cat_command)
#				print wav_files
#				IPython.embed()
#				2008-07-21-1500_VANARC.MSEED

开发者ID:ChrisBail,项目名称:NEW,代码行数:31,代码来源:rename_continuous.py

示例3: GetIIData

# 需要导入模块: from obspy.core.stream import Stream [as 别名]
# 或者: from obspy.core.stream.Stream import write [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))
开发者ID:aringler-usgs,项目名称:getIIdata,代码行数:104,代码来源:getIIdata.py

示例4: read

# 需要导入模块: from obspy.core.stream import Stream [as 别名]
# 或者: from obspy.core.stream.Stream import write [as 别名]
#=============================================================

# Imports
import glob
from obspy.core import read
from obspy.core.stream import Stream
from obspy.core.trace import Trace

# Read multiple mSEED files
# st = read("/Users/Proxima/Documents/classes/Fall2015/hacking-measurement/save-seistool/examples/CHILE_M8.3/BDM.BK.LHN.00.D.2015.259.225431.gz")
st = Stream()
i = 0

# glob.glob returns a list of files in the directory
for file in glob.glob("../examples/CHILE_M8.3/*.gz"):
	i += 1
	if (i>5):
		break
	else:
 		st += read(file)

st.write("5_trace.mseed",format="mSEED")
# for stream in st:
# 	# stream.write("5_trace.mseed",format="mSEED")
# 	multiplestream += stream

# multiplestream = Stream(traces=[Trace(s) for s in st])
# multiplestream.write("5_trace_test.mseed",format="MSEED")

print("5 streams written into file 5_trace.mseed")
	
开发者ID:BIDS-collaborative,项目名称:save-seistool,代码行数:32,代码来源:write_multiple_trace.py

示例5: Collecting

# 需要导入模块: from obspy.core.stream import Stream [as 别名]
# 或者: from obspy.core.stream.Stream import write [as 别名]

#.........这里部分代码省略.........
            
            
            timeNow = datetime.time(datetime.now())
            time = timeNow.minute + (timeNow.second + timeNow.microsecond/1000000.0)/60.0
            hour = timeNow.hour 
            plotClear = False
              
            if (hour != lastHour):
                ## Everytime the hour changes the following code saves hour long SAC Files
                
                lastHour = hour
                currentTime = str(datetime.utcnow()) 
                now2 = currentTime.split(' ',1 )
                now3 = now2[1].split(':',1)
                now3 = int(now3[0])-1
                if (now3 == -1):
                    now3 = 23

                stats['endtime'] = UTCDateTime()
                stats['ntps'] = len(hourSeismicData)
                
                st = Stream([Trace(data=hourSeismicData, header=stats)])
                
                sacdateAndTime = str(stats['starttime']).split('T')
                
                sacdate =  sacdateAndTime[0].split('-')
                sactime =  sacdateAndTime[1].split(':')
                sacyear  = sacdate[0][2:]
                sacmonth = sacdate[1]
                sacday = sacdate[2]
                sachour = sactime[0]
                sacminute = sactime[1]
                fileNaame = str(sacyear+sacmonth+sacday+sachour+sacminute+stats['station']+".sac")
                st.write(sacyear+sacmonth+sacday+sachour+sacminute+stats['station']+".sac", format='SAC')
                stats = initializeHeader(stationId, stationName,stationAddress, longitude, latitude , elevation)
                hourSeismicData = np.array([]) 
                
                ##Uploads SAC file right after creating it
                
                contentType = "application/octet-stream" #image/png
                c = pycurl.Curl()
                c.setopt(c.URL, 'https://nzseis.phy.auckland.ac.nz/pyjamaseis/upload/')
                c.setopt(c.HTTPHEADER, ['Authorization:'+'Basic %s' % base64.b64encode("kofi:pyjamaseis")])
                c.setopt(c.HTTPPOST, [("payload",(c.FORM_FILE, fileNaame, c.FORM_CONTENTTYPE, contentType)), ("mode","sac")])
                
                try:
                    c.perform()
                    c.close()
                except pycurl.error, error:
                    errno, errstr = error
                    print 'An error occurred: ', errstr
                
                
                totalHoursConst = totalHoursConst-1
                if(totalHoursConst == -1):
                    plotClear = True
                    totalHoursConst = 23
                
                hasHourChanged = True
                
            if ((count % skipConst == 0) or hasHourChanged):
                if ((tempSeismicData.size >= 18) or hasHourChanged):
                    
                    ##After every 18 values are read from the TC1 seismometer, the array containing these values along with the tempMillisecond array which contains the exact time the value was read put on the queue for the plotting process to read
                    queue.put([tempSeismicData, tempMillisecond, hasHourChanged, plotClear, mode])
                    mode = "None"
开发者ID:PALab,项目名称:pyjamaseis,代码行数:70,代码来源:pyjamaseisv1.0.py

示例6: GetIIData

# 需要导入模块: from obspy.core.stream import Stream [as 别名]
# 或者: from obspy.core.stream.Stream import write [as 别名]

#.........这里部分代码省略.........
					print "Start of day: " + str(trimStart)
					print "End of day:   " + str(trimEnd)
					#Converting date into julian day
					timesplit = re.split('T', str(trimStart))
					s = timesplit[0]
					fmt = '%Y-%m-%d'
					dt = datetime.datetime.strptime(s, fmt)
					tt = dt.timetuple()
					if tt.tm_yday < 10:
						NewStartDay = '00' + str(tt.tm_yday)
					elif tt.tm_yday < 100:
						NewStartDay = '0' + str(tt.tm_yday)
					else:
						NewStartDay = str(tt.tm_yday)
					self.stFinal = trace.copy()
					self.stFinal.trim(starttime = trimStart, endtime = trimEnd)	
					self.stFinal = self.stFinal.split()
					if not self.stFinal:
						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
						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

		elif self.LOCWILD:
			for self.location in self.locations:
				print
				print "For station: " + self.station
				trace = self.st.select(location = self.location)
				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
					timesplit = re.split('T', str(trimStart))
					s = timesplit[0]
					fmt = '%Y-%m-%d'
					dt = datetime.datetime.strptime(s, fmt)
					tt = dt.timetuple()
					if tt.tm_yday < 10:
						NewStartDay = '00' + str(tt.tm_yday)
					elif tt.tm_yday < 100:
						NewStartDay = '0' + str(tt.tm_yday)
					else:
						NewStartDay = str(tt.tm_yday)
					self.stFinal = trace.copy()
开发者ID:mkline-usgs,项目名称:getIIdata,代码行数:70,代码来源:getIIdata.py


注:本文中的obspy.core.stream.Stream.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。