data plotting; waveform filtering and convenience imports in order to get a overview window displaying data; new data structure available -> PyLoT should be able to read PILOT data
This commit is contained in:
parent
dbd53024b2
commit
d22a224804
27
QtPyLoT.py
27
QtPyLoT.py
@ -166,7 +166,20 @@ class MainWindow(QMainWindow):
|
|||||||
self.data = Data(evtdata=self.fname)
|
self.data = Data(evtdata=self.fname)
|
||||||
|
|
||||||
def getWFFnames(self):
|
def getWFFnames(self):
|
||||||
pass
|
try:
|
||||||
|
evt = self.getData().getEvtData()
|
||||||
|
if evt.picks:
|
||||||
|
for pick in evt.picks:
|
||||||
|
if pick.waveform_id is not None:
|
||||||
|
fname = pick.waveform_id.getSEEDstring()
|
||||||
|
if fname not in self.fnames:
|
||||||
|
self.fnames.append(fname)
|
||||||
|
else:
|
||||||
|
if self.dataStructure:
|
||||||
|
searchPath = self.dataStructure.expandDataPath()
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def saveData(self):
|
def saveData(self):
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
@ -177,7 +190,7 @@ class MainWindow(QMainWindow):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def getComponent(self):
|
def getDispComponent(self):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def getData(self):
|
def getData(self):
|
||||||
@ -294,20 +307,20 @@ class MainWindow(QMainWindow):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def plotData(self):
|
def plotData(self):
|
||||||
pass #self.data.plotData(self.DataPlot)
|
self.getData().plotData(self.getDataWidget())
|
||||||
|
|
||||||
def filterData(self):
|
def filterData(self):
|
||||||
if self.getData():
|
if self.getData():
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
freq = self.filteroptions.getFreq()
|
freq = self.getFilterOptions().getFreq()
|
||||||
if len(freq) > 1:
|
if len(freq) > 1:
|
||||||
kwargs['freqmin'] = freq[0]
|
kwargs['freqmin'] = freq[0]
|
||||||
kwargs['freqmax'] = freq[1]
|
kwargs['freqmax'] = freq[1]
|
||||||
else:
|
else:
|
||||||
kwargs['freq'] = freq
|
kwargs['freq'] = freq
|
||||||
kwargs['type'] = self.filteroptions.getFilterType()
|
kwargs['type'] = self.getFilterOptions().getFilterType()
|
||||||
#kwargs['order'] = self.filteroptions.getOrder()
|
kwargs['corners'] = self.filteroptions.getOrder()
|
||||||
self.data.filter(**kwargs)
|
self.getData().filter(kwargs)
|
||||||
|
|
||||||
def adjustFilterOptions(self):
|
def adjustFilterOptions(self):
|
||||||
filteroptions = None
|
filteroptions = None
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
from pylot.core.read.inputs import AutoPickParameter
|
from pylot.core.read.inputs import AutoPickParameter
|
||||||
from pylot.core.read.inputs import FilterOptions
|
from pylot.core.read.inputs import FilterOptions
|
||||||
from pylot.core.read.data import Data
|
|
||||||
from pylot.core.read.data import GenericDataStructure
|
from pylot.core.read.data import GenericDataStructure
|
||||||
from pylot.core.read.data import SeiscompDataStructure
|
from pylot.core.read.data import SeiscompDataStructure
|
||||||
|
from pylot.core.read.data import PilotDataStructure
|
||||||
|
from pylot.core.read.data import Data
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,8 +94,10 @@ class Data(object):
|
|||||||
not implemented: {1}'''.format(evtformat, e))
|
not implemented: {1}'''.format(evtformat, e))
|
||||||
|
|
||||||
def plotData(self, widget):
|
def plotData(self, widget):
|
||||||
time_ax = np.arange(0, len(self.wfdata[0].data)/self.wfdata[0].stats.sampling_rate, self.wfdata[0].stats.delta)
|
wfst = self.getWFData()
|
||||||
widget.axes.plot(time_ax, self.wfdata[0].data)
|
time_ax = np.arange(0, len(wfst[0].data) / wfst[0].stats.sampling_rate,
|
||||||
|
wfst[0].stats.delta)
|
||||||
|
widget.axes.plot(time_ax, wfst[0].data)
|
||||||
|
|
||||||
def getID(self):
|
def getID(self):
|
||||||
try:
|
try:
|
||||||
@ -103,12 +105,22 @@ class Data(object):
|
|||||||
except:
|
except:
|
||||||
return 'smi:bug/pylot/1234'
|
return 'smi:bug/pylot/1234'
|
||||||
|
|
||||||
|
def filter(self, kwargs):
|
||||||
|
self.getWFData().filter(**kwargs)
|
||||||
|
|
||||||
|
def getWFData(self):
|
||||||
|
return self.wfdata
|
||||||
|
|
||||||
|
def getEvtData(self):
|
||||||
|
return self.evtdata
|
||||||
|
|
||||||
|
|
||||||
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, stexp=None, folderdepth=4, **kwargs):
|
def __init__(self, stexp=None, folderdepth=4, **kwargs):
|
||||||
structExpression = []
|
structExpression = []
|
||||||
depth = 0
|
depth = 0
|
||||||
@ -130,6 +142,53 @@ class GenericDataStructure(object):
|
|||||||
self.dataBaseDict = {}
|
self.dataBaseDict = {}
|
||||||
|
|
||||||
|
|
||||||
|
class PilotDataStructure(object):
|
||||||
|
'''
|
||||||
|
Object containing the data access information for the old PILOT data
|
||||||
|
structure.
|
||||||
|
'''
|
||||||
|
|
||||||
|
def __init__(self, dataformat='GSE2', fsuffix='gse',
|
||||||
|
root='/data/Egelados/EVENT_DATA/LOCAL/', database='2006.01',
|
||||||
|
**kwargs):
|
||||||
|
self.dataType = dataformat
|
||||||
|
self.__pdsFields = {'ROOT': root,
|
||||||
|
'DATABASE': database,
|
||||||
|
'SUFFIX': fsuffix
|
||||||
|
}
|
||||||
|
|
||||||
|
self.modifiyFields(**kwargs)
|
||||||
|
|
||||||
|
def modifiyFields(self, **kwargs):
|
||||||
|
if kwargs and isinstance(kwargs, dict):
|
||||||
|
for key, value in kwargs.iteritems():
|
||||||
|
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)
|
||||||
|
try:
|
||||||
|
if key in self.getFields().keys():
|
||||||
|
self.getFields()[key] = value
|
||||||
|
else:
|
||||||
|
raise KeyError('unknown PDS wildcard: %s.' % key)
|
||||||
|
except KeyError, e:
|
||||||
|
errmsg = ''
|
||||||
|
errmsg += 'WARNING:\n'
|
||||||
|
errmsg += 'unable to set values for PDS fields\n'
|
||||||
|
errmsg += '%s; desired value was: %s\n' % (e, value)
|
||||||
|
print errmsg
|
||||||
|
|
||||||
|
def getType(self):
|
||||||
|
return self.dataType
|
||||||
|
|
||||||
|
def getFields(self):
|
||||||
|
return self.__pdsFields
|
||||||
|
|
||||||
|
def expandDataPath(self):
|
||||||
|
return
|
||||||
|
|
||||||
class SeiscompDataStructure(object):
|
class SeiscompDataStructure(object):
|
||||||
'''
|
'''
|
||||||
Dictionary containing the data access information for an SDS data archive:
|
Dictionary containing the data access information for an SDS data archive:
|
||||||
@ -142,13 +201,13 @@ class SeiscompDataStructure(object):
|
|||||||
|
|
||||||
# Data type options
|
# Data type options
|
||||||
__typeOptions = {'waveform': 'D', # Waveform data
|
__typeOptions = {'waveform': 'D', # Waveform data
|
||||||
'detect': 'E', # Detection data
|
'detect': 'E', # Detection data
|
||||||
'log': 'L', # Log data
|
'log': 'L', # Log data
|
||||||
'timing': 'T', # Timing data
|
'timing': 'T', # Timing data
|
||||||
'calib': 'C', # Calibration data
|
'calib': 'C', # Calibration data
|
||||||
'resp': 'R', # Response data
|
'resp': 'R', # Response data
|
||||||
'opaque': 'O' # Opaque 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
|
||||||
@ -174,8 +233,8 @@ class SeiscompDataStructure(object):
|
|||||||
if not edate.year == sdate.year:
|
if not edate.year == sdate.year:
|
||||||
nyears = edate.year - sdate.year
|
nyears = edate.year - sdate.year
|
||||||
for yr in range(nyears):
|
for yr in range(nyears):
|
||||||
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)
|
||||||
|
|
||||||
@ -198,7 +257,7 @@ class SeiscompDataStructure(object):
|
|||||||
'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
|
||||||
}
|
}
|
||||||
self.modifiyFields(**kwargs)
|
self.modifiyFields(**kwargs)
|
||||||
|
|
||||||
def modifiyFields(self, **kwargs):
|
def modifiyFields(self, **kwargs):
|
||||||
@ -211,8 +270,8 @@ class SeiscompDataStructure(object):
|
|||||||
else:
|
else:
|
||||||
value = str(value)
|
value = str(value)
|
||||||
try:
|
try:
|
||||||
if key in self.getSDSFields().keys():
|
if key in self.getFields().keys():
|
||||||
self.getSDSFields()[key] = value
|
self.getFields()[key] = value
|
||||||
else:
|
else:
|
||||||
raise KeyError('unknown SDS wildcard: %s.' % key)
|
raise KeyError('unknown SDS wildcard: %s.' % key)
|
||||||
except KeyError, e:
|
except KeyError, e:
|
||||||
@ -225,7 +284,7 @@ class SeiscompDataStructure(object):
|
|||||||
def getType(self):
|
def getType(self):
|
||||||
return self.__typeOptions[self.dataType]
|
return self.__typeOptions[self.dataType]
|
||||||
|
|
||||||
def getSDSFields(self):
|
def getFields(self):
|
||||||
return self.__sdsFields
|
return self.__sdsFields
|
||||||
|
|
||||||
def expandDataPath(self):
|
def expandDataPath(self):
|
||||||
@ -236,5 +295,5 @@ class SeiscompDataStructure(object):
|
|||||||
self.getSDSFields()['STA'],
|
self.getSDSFields()['STA'],
|
||||||
fullChan,
|
fullChan,
|
||||||
'*{0}'.format(self.getSDSFields()['DAY'])
|
'*{0}'.format(self.getSDSFields()['DAY'])
|
||||||
)
|
)
|
||||||
return dataPath
|
return dataPath
|
||||||
|
@ -134,16 +134,26 @@ class InputsTab(PropTab):
|
|||||||
fulluser = settings.value("user/FullName")
|
fulluser = settings.value("user/FullName")
|
||||||
login = settings.value("user/Login")
|
login = settings.value("user/Login")
|
||||||
|
|
||||||
fullNameLabel = QLabel("Full name for user '{0}'".format(login))
|
fullNameLabel = QLabel("Full name for user '{0}': ".format(login))
|
||||||
|
|
||||||
|
# get the full name of the actual user
|
||||||
self.fullNameEdit = QLineEdit()
|
self.fullNameEdit = QLineEdit()
|
||||||
self.fullNameEdit.setText(fulluser)
|
self.fullNameEdit.setText(fulluser)
|
||||||
|
|
||||||
|
# information about data structure
|
||||||
dataroot = settings.value("data/dataRoot")
|
dataroot = settings.value("data/dataRoot")
|
||||||
dataDirLabel = QLabel("data directory:")
|
dataDirLabel = QLabel("data root directory: ")
|
||||||
self.dataDirEdit = QLineEdit()
|
self.dataDirEdit = QLineEdit()
|
||||||
self.dataDirEdit.setText(dataroot)
|
self.dataDirEdit.setText(dataroot)
|
||||||
self.dataDirEdit.selectAll()
|
self.dataDirEdit.selectAll()
|
||||||
|
structureLabel = QLabel("data structure: ")
|
||||||
|
self.structureSelect = QComboBox()
|
||||||
|
|
||||||
|
from pylot.core.util.structure import DATASTRUCTURE
|
||||||
|
|
||||||
|
datastruct = DATASTRUCTURE.keys()
|
||||||
|
self.structureSelect.addItems(datastruct)
|
||||||
|
self.updateWidget(DATASTRUCTURE)
|
||||||
|
|
||||||
layout = QGridLayout()
|
layout = QGridLayout()
|
||||||
layout.addWidget(dataDirLabel, 0, 0)
|
layout.addWidget(dataDirLabel, 0, 0)
|
||||||
@ -159,6 +169,13 @@ class InputsTab(PropTab):
|
|||||||
values["user/FullName"] = self.fullNameEdit.text()
|
values["user/FullName"] = self.fullNameEdit.text()
|
||||||
return values
|
return values
|
||||||
|
|
||||||
|
def updateWidget(self, structure):
|
||||||
|
key = self.structureSelect.currentText()
|
||||||
|
structure = structure[key]
|
||||||
|
structure().getFields().keys()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class OutputsTab(PropTab):
|
class OutputsTab(PropTab):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user