本文整理汇总了Python中obspy.UTCDateTime.formatIRISWebService方法的典型用法代码示例。如果您正苦于以下问题:Python UTCDateTime.formatIRISWebService方法的具体用法?Python UTCDateTime.formatIRISWebService怎么用?Python UTCDateTime.formatIRISWebService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obspy.UTCDateTime
的用法示例。
在下文中一共展示了UTCDateTime.formatIRISWebService方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GetIIData
# 需要导入模块: from obspy import UTCDateTime [as 别名]
# 或者: from obspy.UTCDateTime import formatIRISWebService [as 别名]
class GetIIData(object):
# initialize input vars
def __init__(self, year, startday, network, **kwargs):
# initialize year/start/net
# if statement to check for main args set QUERY=True
# else sys.exit(1)
if (year != "") and (startday != "") and (network != ""):
self.year = year
self.startday = startday
self.network = network
QUERY = True
else:
QUERY = False
# loop through **kwargs and initialize optargs
self.endday = "" # init endday string
self.station = "" # init station string
self.location = "" # init location string
self.channel = "" # init channel string
self.debug = False # init debug
self.archive = False # init archive
endday = self.endday
for key,val in kwargs.iteritems():
if key == "endday": self.endday = val
elif key == "station": self.station = val
elif key == "location": self.location = val
elif key == "channel": self.channel = val
elif key == "debug": self.debug = self.toBool(val)
elif key == "archive": self.archive = self.toBool(val)
# print arguments if 'debug' mode
if self.debug:
print "Year: " + self.year
print "Start Day: " + self.startday
print "End Day: " + self.endday
print "Network: " + self.network
print "Station: " + self.station
print "Location: " + self.location
print "Channel: " + self.channel
# handle wildcards
if self.location == "?":
self.location = "*"
if self.channel == "?":
self.channel = "*"
if self.station == "?":
self.station = "*"
# set start/end to UTCDateTime object
#--------------------------------------------------------------------
self.startTime = UTCDateTime(year + startday +"T00:00:00.000")
# If no end day in parser default to 1 day
if self.endday == "?":
self.endday = str(int(self.startday) + 1).zfill(3)
self.endTime = self.startTime + 24*60*60
else:
self.endTime = UTCDateTime(year + self.endday +"T00:00:00.000")
print "Here is our start time: " + self.startTime.formatIRISWebService()
print "Here is our end time: " + self.endTime.formatIRISWebService()
self.days = int(self.endday)- int(self.startday)
# there are 24, 1 hour increments in a day
self.hours = (int(self.endday)- int(self.startday)) * 24
# Will only run if main args are given
# check QUERY flag if True continue
if QUERY:
self.queryData()
else:
print '\nNo main args given.'
print 'Exiting\n'
sys.exit(1)
def queryData(self):
# code from IRIS client
# Here we pull the data
client = Client("IRIS")
DupStations = []
DupLocations = []
DupChannels = []
self.st = Stream()
self.STAWILD = False
self.LOCWILD = False
self.CHANWILD = False
try:
timeout = 300
socket.setdefaulttimeout(timeout)
# this needs to have a get_waveform that queries data 1 hour at a time
# data cant query right now if the data is too bulky
# also needs to include a timeout exception
for hourIndex in range(0,self.hours): #this cant be days... has to be hours
self.startTime1 = self.startTime + (hourIndex)*1*60*60
self.endTime1 = self.startTime + (hourIndex+1)*1*60*60
requestArray = [(self.network,self.station,self.location, \
self.channel,self.startTime1,self.endTime1)]
self.st1 = client.get_waveforms_bulk(requestArray)
self.st += self.st1
print self.st
print
#self.st = client.get_waveforms_bulk(timeout=10,requestArray)
#.........这里部分代码省略.........
示例2: GetIIData
# 需要导入模块: from obspy import UTCDateTime [as 别名]
# 或者: from obspy.UTCDateTime import formatIRISWebService [as 别名]
class GetIIData(object):
# initialize input vars
def __init__(self, year, startday, network, **kwargs):
# initialize year/start/net
# if statement to check for main args set QUERY=True
# else sys.exit(1)
if (year != "") and (startday != "") and (network != ""):
self.year = year
self.startday = startday
self.network = network
QUERY = True
else:
QUERY = False
# loop through **kwargs and initialize optargs
self.endday = "" # init endday string
self.station = "" # init station string
self.location = "" # init location string
self.channel = "" # init channel string
self.debug = False # init debug
self.archive = False # init archive
endday = self.endday
for key,val in kwargs.iteritems():
if key == "endday": self.endday = val
elif key == "station": self.station = val
elif key == "location": self.location = val
elif key == "channel": self.channel = val
elif key == "debug": self.debug = self.toBool(val)
elif key == "archive": self.archive = self.toBool(val)
# print arguments if 'debug' mode
if self.debug:
print "Year: " + self.year
print "Start Day: " + self.startday
print "End Day: " + self.endday
print "Network: " + self.network
print "Station: " + self.station
print "Location: " + self.location
print "Channel: " + self.channel
# handle wildcards
if self.location == "?":
self.location = "*"
if self.channel == "?":
self.channel = "*"
if self.station == "?":
self.station = "*"
# set start/end to UTCDateTime object
#--------------------------------------------------------------------
self.startTime = UTCDateTime(year + startday +"T00:00:00.000")
#If no end day in parser default to 1 day
if self.endday == "?":
self.endTime = self.startTime + 24*60*60
else:
self.endTime = UTCDateTime(year + self.endday +"T00:00:00.000")
print "Here is our start time " + self.startTime.formatIRISWebService()
print "Here is our end time " + self.endTime.formatIRISWebService()
# Will only run if main args are given
# check QUERY flag if True continue
if QUERY:
self.queryData()
else:
print '\nNo main args given.'
print 'Exiting\n'
sys.exit(1)
def queryData(self):
# code from IRIS client
#Here we pull the data
client = Client("IRIS")
DupStations = []
DupLocations = []
DupChannels = []
self.STAWILD = False
self.LOCWILD = False
self.CHANWILD = False
try:
requestArray = [(self.network,self.station,self.location, \
self.channel,self.startTime,self.endTime)]
print
if self.debug:
print(requestArray)
print
self.st = client.get_waveforms_bulk(requestArray)
for self.tr in self.st:
#Here we remove the M data quality and go with D
self.tr.stats.mseed['dataquality'] = 'D'
if self.debug:
#print "Here is a trace we have"
#print(tr.stats)
if self.station == '*':
self.STAWILD = True
DupStations.append(self.tr.stats.station)
elif self.station != '*':
self.STAWILD = False
if self.location == '*':
self.LOCWILD = True
DupLocations.append(self.tr.stats.location)
#.........这里部分代码省略.........