reformatted data.py to meet coding conventions
This commit is contained in:
parent
038caf4d54
commit
497ca39c91
@ -14,20 +14,17 @@ from pylot.core.util.errors import FormatError, OverwriteError
|
|||||||
|
|
||||||
|
|
||||||
class Data(object):
|
class Data(object):
|
||||||
'''
|
"""
|
||||||
Data container with attributes wfdata holding ~obspy.core.stream.
|
Data container with attributes wfdata holding ~obspy.core.stream.
|
||||||
|
|
||||||
:type parent: PySide.QtGui.QWidget object, optional
|
:type parent: PySide.QtGui.QWidget object, optional
|
||||||
:param parent: A PySide.QtGui.QWidget object utilized when
|
:param parent: A PySide.QtGui.QWidget object utilized when
|
||||||
called by a GUI to display a PySide.QtGui.QMessageBox instead of printing
|
called by a GUI to display a PySide.QtGui.QMessageBox instead of printing
|
||||||
to standard out.
|
to standard out.
|
||||||
:type wfdata: ~obspy.core.stream.Stream object, optional
|
|
||||||
:param wfdata: ~obspy.core.stream.Stream object containing all available
|
|
||||||
waveform data for the actual event
|
|
||||||
:type evtdata: ~obspy.core.event.Event object, optional
|
:type evtdata: ~obspy.core.event.Event object, optional
|
||||||
:param evtdata ~obspy.core.event.Event object containing all derived or
|
:param evtdata ~obspy.core.event.Event object containing all derived or
|
||||||
loaded event. Container object holding, e.g. phase arrivals, etc.
|
loaded event. Container object holding, e.g. phase arrivals, etc.
|
||||||
'''
|
"""
|
||||||
|
|
||||||
def __init__(self, parent=None, evtdata=None):
|
def __init__(self, parent=None, evtdata=None):
|
||||||
self._parent = parent
|
self._parent = parent
|
||||||
@ -168,8 +165,8 @@ class Data(object):
|
|||||||
"""
|
"""
|
||||||
assert isinstance(fnames, list), "input parameter 'fnames' is " \
|
assert isinstance(fnames, list), "input parameter 'fnames' is " \
|
||||||
"supposed to be of type 'list' " \
|
"supposed to be of type 'list' " \
|
||||||
"but is actually {0}".format(type(
|
"but is actually" \
|
||||||
fnames))
|
" {0}".format(type(fnames))
|
||||||
if self.dirty:
|
if self.dirty:
|
||||||
self.resetWFData()
|
self.resetWFData()
|
||||||
|
|
||||||
@ -254,8 +251,9 @@ class Data(object):
|
|||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
print(
|
print(
|
||||||
"Correcting %s, %s for instrument response ..." \
|
"Correcting %s, %s for instrument response "
|
||||||
% (st[i].stats.station, st[i].stats.channel))
|
"..." % (st[i].stats.station,
|
||||||
|
st[i].stats.channel))
|
||||||
# get corner frequencies for pre-filtering
|
# get corner frequencies for pre-filtering
|
||||||
fny = st[i].stats.sampling_rate / 2
|
fny = st[i].stats.sampling_rate / 2
|
||||||
fc21 = fny - (fny * 0.05)
|
fc21 = fny - (fny * 0.05)
|
||||||
@ -263,7 +261,7 @@ class Data(object):
|
|||||||
prefilt = [0.5, 0.9, fc21, fc22]
|
prefilt = [0.5, 0.9, fc21, fc22]
|
||||||
# instrument correction
|
# instrument correction
|
||||||
st[i].simulate(pre_filt=prefilt,
|
st[i].simulate(pre_filt=prefilt,
|
||||||
seedresp={'filename': parser, \
|
seedresp={'filename': parser,
|
||||||
'date': st[
|
'date': st[
|
||||||
i].stats.starttime,
|
i].stats.starttime,
|
||||||
'units': "VEL"})
|
'units': "VEL"})
|
||||||
@ -285,9 +283,9 @@ class Data(object):
|
|||||||
st[i].stats.processing
|
st[i].stats.processing
|
||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
print(
|
print("Correcting %s, %s for instrument response "
|
||||||
"Correcting %s, %s for instrument response ..." \
|
"..." % (st[i].stats.station,
|
||||||
% (st[i].stats.station, st[i].stats.channel))
|
st[i].stats.channel))
|
||||||
# get corner frequencies for pre-filtering
|
# get corner frequencies for pre-filtering
|
||||||
fny = st[i].stats.sampling_rate / 2
|
fny = st[i].stats.sampling_rate / 2
|
||||||
fc21 = fny - (fny * 0.05)
|
fc21 = fny - (fny * 0.05)
|
||||||
@ -295,7 +293,8 @@ class Data(object):
|
|||||||
prefilt = [0.5, 0.9, fc21, fc22]
|
prefilt = [0.5, 0.9, fc21, fc22]
|
||||||
# instrument correction
|
# instrument correction
|
||||||
st[i].attach_response(inv)
|
st[i].attach_response(inv)
|
||||||
st[i].remove_response(output='VEL', pre_filt=prefilt)
|
st[i].remove_response(output='VEL',
|
||||||
|
pre_filt=prefilt)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
vmsg = '{0}'.format(e)
|
vmsg = '{0}'.format(e)
|
||||||
print(vmsg)
|
print(vmsg)
|
||||||
@ -313,18 +312,20 @@ class Data(object):
|
|||||||
st[i].stats.processing
|
st[i].stats.processing
|
||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
print(
|
print("Correcting %s, %s for instrument response "
|
||||||
"Correcting %s, %s for instrument response ..." \
|
"..." % (st[i].stats.station,
|
||||||
% (st[i].stats.station, st[i].stats.channel))
|
st[i].stats.channel))
|
||||||
# get corner frequencies for pre-filtering
|
# get corner frequencies for pre-filtering
|
||||||
fny = st[i].stats.sampling_rate / 2
|
fny = st[i].stats.sampling_rate / 2
|
||||||
fc21 = fny - (fny * 0.05)
|
fc21 = fny - (fny * 0.05)
|
||||||
fc22 = fny - (fny * 0.02)
|
fc22 = fny - (fny * 0.02)
|
||||||
prefilt = [0.5, 0.9, fc21, fc22]
|
prefilt = [0.5, 0.9, fc21, fc22]
|
||||||
# instrument correction
|
# instrument correction
|
||||||
seedresp={'filename': respfile[0], 'date': st[0].stats.starttime, \
|
seedresp = {'filename': respfile[0],
|
||||||
|
'date': st[0].stats.starttime,
|
||||||
'units': "VEL"}
|
'units': "VEL"}
|
||||||
st[i].simulate(paz_remove=None, pre_filt=prefilt, seedresp=seedresp)
|
st[i].simulate(paz_remove=None, pre_filt=prefilt,
|
||||||
|
seedresp=seedresp)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
vmsg = '{0}'.format(e)
|
vmsg = '{0}'.format(e)
|
||||||
print(vmsg)
|
print(vmsg)
|
||||||
@ -332,10 +333,10 @@ class Data(object):
|
|||||||
print("Trace has already been corrected!")
|
print("Trace has already been corrected!")
|
||||||
|
|
||||||
if len(respfile) < 1 and len(invfile) < 1 and len(dlfile) < 1:
|
if len(respfile) < 1 and len(invfile) < 1 and len(dlfile) < 1:
|
||||||
print(
|
print("No dataless-SEED file,inventory-xml file nor RESP-file "
|
||||||
"No dataless-SEED file,inventory-xml file nor RESP-file found!")
|
"found!")
|
||||||
print(
|
print("Go on processing data without source parameter "
|
||||||
"Go on processing data without source parameter determination!")
|
"determination!")
|
||||||
|
|
||||||
return st
|
return st
|
||||||
|
|
||||||
@ -416,10 +417,10 @@ class Data(object):
|
|||||||
|
|
||||||
|
|
||||||
class GenericDataStructure(object):
|
class GenericDataStructure(object):
|
||||||
'''
|
"""
|
||||||
GenericDataBase type holds all information about the current data-
|
GenericDataBase type holds all information about the current data-
|
||||||
base working on.
|
base working on.
|
||||||
'''
|
"""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
|
||||||
@ -582,10 +583,10 @@ class GenericDataStructure(object):
|
|||||||
|
|
||||||
|
|
||||||
class PilotDataStructure(GenericDataStructure):
|
class PilotDataStructure(GenericDataStructure):
|
||||||
'''
|
"""
|
||||||
Object containing the data access information for the old PILOT data
|
Object containing the data access information for the old PILOT data
|
||||||
structure.
|
structure.
|
||||||
'''
|
"""
|
||||||
|
|
||||||
def __init__(self, **fields):
|
def __init__(self, **fields):
|
||||||
if not fields:
|
if not fields:
|
||||||
@ -598,14 +599,14 @@ class PilotDataStructure(GenericDataStructure):
|
|||||||
|
|
||||||
|
|
||||||
class SeiscompDataStructure(GenericDataStructure):
|
class SeiscompDataStructure(GenericDataStructure):
|
||||||
'''
|
"""
|
||||||
Dictionary containing the data access information for an SDS data archive:
|
Dictionary containing the data access information for an SDS data archive:
|
||||||
|
|
||||||
:param str dataType: Desired data type. Default: ``'waveform'``
|
:param str dataType: Desired data type. Default: ``'waveform'``
|
||||||
:param sdate, edate: Either date string or an instance of
|
:param sdate, edate: Either date string or an instance of
|
||||||
:class:`obspy.core.utcdatetime.UTCDateTime. Default: ``None``
|
:class:`obspy.core.utcdatetime.UTCDateTime. Default: ``None``
|
||||||
:type sdate, edate: str or UTCDateTime or None
|
:type sdate, edate: str or UTCDateTime or None
|
||||||
'''
|
"""
|
||||||
|
|
||||||
def __init__(self, rootpath='/data/SDS', dataformat='MSEED',
|
def __init__(self, rootpath='/data/SDS', dataformat='MSEED',
|
||||||
filesuffix=None, **kwargs):
|
filesuffix=None, **kwargs):
|
||||||
@ -649,7 +650,7 @@ class SeiscompDataStructure(GenericDataStructure):
|
|||||||
else:
|
else:
|
||||||
value = str(value)
|
value = str(value)
|
||||||
try:
|
try:
|
||||||
self.setField(key, value)
|
self.setFieldValue(key, value)
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
errmsg = ''
|
errmsg = ''
|
||||||
errmsg += 'WARNING:\n'
|
errmsg += 'WARNING:\n'
|
||||||
@ -669,22 +670,6 @@ class SeiscompDataStructure(GenericDataStructure):
|
|||||||
print('Warning: trying to set value of non-existent field '
|
print('Warning: trying to set value of non-existent field '
|
||||||
'{field}'.format(field=key))
|
'{field}'.format(field=key))
|
||||||
|
|
||||||
def getFields(self):
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
return self.__sdsFields
|
|
||||||
|
|
||||||
def getName(self):
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
return self.__name
|
|
||||||
|
|
||||||
def expandDataPath(self):
|
def expandDataPath(self):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user