add station selection

This commit is contained in:
Sebastian Wehling-Benatelli 2014-12-11 09:43:59 +01:00
parent d665e47d02
commit 3c9865c767
3 changed files with 38 additions and 32 deletions

View File

@ -1,5 +1,6 @@
from pylot.core.read.data import (Data, from pylot.core.read.inputs import AutoPickParameter
GenericDataStructure, from pylot.core.read.inputs import FilterOptions
SeiscompDataStructure) from pylot.core.read.data import Data
from pylot.core.read.inputs import (AutoPickParameter, from pylot.core.read.data import GenericDataStructure
FilterOptions) from pylot.core.read.data import SeiscompDataStructure

View File

@ -126,10 +126,19 @@ class SeiscompDataStructure(object):
:type sdate, edate: str or UTCDateTime or None :type sdate, edate: str or UTCDateTime or None
''' '''
# Data type options
__typeOptions = {'waveform': 'D', # Waveform data
'detect': 'E', # Detection data
'log': 'L', # Log data
'timing': 'T', # Timing data
'calib': 'C', # Calibration data
'resp': 'R', # Response data
'opaque': 'O' # Opaque data
}
def __init__(self, dataType='waveform', sdate=None, edate=None, **kwargs): def __init__(self, dataType='waveform', sdate=None, edate=None, **kwargs):
# imports # imports
from obspy.core import UTCDateTime from obspy.core import UTCDateTime
import numpy as np
def checkDate(date): def checkDate(date):
if not isinstance(date, UTCDateTime): if not isinstance(date, UTCDateTime):
@ -143,7 +152,9 @@ class SeiscompDataStructure(object):
edate = UTCDateTime(edate) edate = UTCDateTime(edate)
except TypeError: except TypeError:
edate = UTCDateTime() edate = UTCDateTime()
sdate = edate - np.pi*1e7/2 halfyear = UTCDateTime('1970-07-01')
sdate = UTCDateTime(edate - halfyear)
del halfyear
year = '' year = ''
if not edate.year == sdate.year: if not edate.year == sdate.year:
@ -152,17 +163,7 @@ class SeiscompDataStructure(object):
year += '{0:04d},'.format(sdate.year+yr) year += '{0:04d},'.format(sdate.year+yr)
year = '{'+year[:-1]+'}' year = '{'+year[:-1]+'}'
else: else:
year = '{0:04d},'.format(sdate.year) year = '{0:04d}'.format(sdate.year)
# Data type options
self.__typeOptions = {'waveform': 'D', # Waveform data
'detect': 'E', # Detection data
'log': 'L', # Log data
'timing': 'T', # Timing data
'calib': 'C', # Calibration data
'resp': 'R', # Response data
'opaque': 'O' # Opaque data
}
if dataType in self.__typeOptions.keys(): if dataType in self.__typeOptions.keys():
self.dataType = dataType self.dataType = dataType
@ -180,7 +181,7 @@ class SeiscompDataStructure(object):
'NET': '??', # up to 8 characters 'NET': '??', # up to 8 characters
'STA': '????', # up to 8 characters 'STA': '????', # up to 8 characters
'CHAN': 'HH?', # up to 8 characters 'CHAN': 'HH?', # up to 8 characters
'TYPE': self._getType(), # 1 character 'TYPE': self.getType(), # 1 character
'LOC': '', # up to 8 characters 'LOC': '', # up to 8 characters
'DAY': '{0:03d}'.format(sdate.julday) # 3 digits 'DAY': '{0:03d}'.format(sdate.julday) # 3 digits
} }
@ -190,10 +191,14 @@ class SeiscompDataStructure(object):
if kwargs and isinstance(kwargs, dict): if kwargs and isinstance(kwargs, dict):
for key, value in kwargs.iteritems(): for key, value in kwargs.iteritems():
key = str(key) key = str(key)
if type(value) not in (str, int, float):
for n, val in enumerate(value):
value[n] = str(val)
else:
value = str(value) value = str(value)
try: try:
if key in self.__sdsFields.keys(): if key in self.getSDSFields().keys():
self.__sdsFields[key] = str(value) self.getSDSFields()[key] = value
else: else:
raise KeyError('unknown SDS wildcard: %s.' % key) raise KeyError('unknown SDS wildcard: %s.' % key)
except KeyError, e: except KeyError, e:
@ -203,16 +208,19 @@ class SeiscompDataStructure(object):
errmsg += '%s; desired value was: %s\n' % (e, value) errmsg += '%s; desired value was: %s\n' % (e, value)
print errmsg print errmsg
def _getType(self): def getType(self):
return self.__typeOptions[self.dataType] return self.__typeOptions[self.dataType]
def getSDSFields(self):
return self.__sdsFields
def expandDataPath(self): def expandDataPath(self):
fullChan = '{0}.{1}'.format(self.__sdsFields['CHAN'], self._getType()) fullChan = '{0}.{1}'.format(self.getSDSFields()['CHAN'], self.getType())
dataPath = os.path.join(self.__sdsFields['SDSdir'], dataPath = os.path.join(self.getSDSFields()['SDSdir'],
self.__sdsFields['YEAR'], self.getSDSFields()['YEAR'],
self.__sdsFields['NET'], self.getSDSFields()['NET'],
self.__sdsFields['STA'], self.getSDSFields()['STA'],
fullChan, fullChan,
'*{0}'.format(self.__sdsFields['DAY']) '*{0}'.format(self.getSDSFields()['DAY'])
) )
return dataPath return dataPath

View File

@ -179,21 +179,18 @@ class FilterOptions(object):
order=self.getOrder) order=self.getOrder)
return hrs return hrs
@property
def getFreq(self): def getFreq(self):
return self.__getattribute__('_freq') return self.__getattribute__('_freq')
def setFreq(self, freq): def setFreq(self, freq):
self.__setattr__('_freq', freq) self.__setattr__('_freq', freq)
@property
def getOrder(self): def getOrder(self):
return self.__getattribute__('_order') return self.__getattribute__('_order')
def setOrder(self, order): def setOrder(self, order):
self.__setattr__('_order', order) self.__setattr__('_order', order)
@property
def getFilterType(self): def getFilterType(self):
return self.__getattribute__('_filtertype') return self.__getattribute__('_filtertype')