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)
|
||||
|
||||
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):
|
||||
settings = QSettings()
|
||||
@ -177,7 +190,7 @@ class MainWindow(QMainWindow):
|
||||
return False
|
||||
return True
|
||||
|
||||
def getComponent(self):
|
||||
def getDispComponent(self):
|
||||
return self
|
||||
|
||||
def getData(self):
|
||||
@ -294,20 +307,20 @@ class MainWindow(QMainWindow):
|
||||
return True
|
||||
|
||||
def plotData(self):
|
||||
pass #self.data.plotData(self.DataPlot)
|
||||
self.getData().plotData(self.getDataWidget())
|
||||
|
||||
def filterData(self):
|
||||
if self.getData():
|
||||
kwargs = {}
|
||||
freq = self.filteroptions.getFreq()
|
||||
freq = self.getFilterOptions().getFreq()
|
||||
if len(freq) > 1:
|
||||
kwargs['freqmin'] = freq[0]
|
||||
kwargs['freqmax'] = freq[1]
|
||||
else:
|
||||
kwargs['freq'] = freq
|
||||
kwargs['type'] = self.filteroptions.getFilterType()
|
||||
#kwargs['order'] = self.filteroptions.getOrder()
|
||||
self.data.filter(**kwargs)
|
||||
kwargs['type'] = self.getFilterOptions().getFilterType()
|
||||
kwargs['corners'] = self.filteroptions.getOrder()
|
||||
self.getData().filter(kwargs)
|
||||
|
||||
def adjustFilterOptions(self):
|
||||
filteroptions = None
|
||||
|
@ -1,6 +1,8 @@
|
||||
from pylot.core.read.inputs import AutoPickParameter
|
||||
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 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))
|
||||
|
||||
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)
|
||||
widget.axes.plot(time_ax, self.wfdata[0].data)
|
||||
wfst = self.getWFData()
|
||||
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):
|
||||
try:
|
||||
@ -103,12 +105,22 @@ class Data(object):
|
||||
except:
|
||||
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):
|
||||
'''
|
||||
GenericDataBase type holds all information about the current data-
|
||||
base working on.
|
||||
'''
|
||||
|
||||
def __init__(self, stexp=None, folderdepth=4, **kwargs):
|
||||
structExpression = []
|
||||
depth = 0
|
||||
@ -130,6 +142,53 @@ class GenericDataStructure(object):
|
||||
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):
|
||||
'''
|
||||
Dictionary containing the data access information for an SDS data archive:
|
||||
@ -174,8 +233,8 @@ class SeiscompDataStructure(object):
|
||||
if not edate.year == sdate.year:
|
||||
nyears = edate.year - sdate.year
|
||||
for yr in range(nyears):
|
||||
year += '{0:04d},'.format(sdate.year+yr)
|
||||
year = '{'+year[:-1]+'}'
|
||||
year += '{0:04d},'.format(sdate.year + yr)
|
||||
year = '{' + year[:-1] + '}'
|
||||
else:
|
||||
year = '{0:04d}'.format(sdate.year)
|
||||
|
||||
@ -211,8 +270,8 @@ class SeiscompDataStructure(object):
|
||||
else:
|
||||
value = str(value)
|
||||
try:
|
||||
if key in self.getSDSFields().keys():
|
||||
self.getSDSFields()[key] = value
|
||||
if key in self.getFields().keys():
|
||||
self.getFields()[key] = value
|
||||
else:
|
||||
raise KeyError('unknown SDS wildcard: %s.' % key)
|
||||
except KeyError, e:
|
||||
@ -225,7 +284,7 @@ class SeiscompDataStructure(object):
|
||||
def getType(self):
|
||||
return self.__typeOptions[self.dataType]
|
||||
|
||||
def getSDSFields(self):
|
||||
def getFields(self):
|
||||
return self.__sdsFields
|
||||
|
||||
def expandDataPath(self):
|
||||
|
@ -134,16 +134,26 @@ class InputsTab(PropTab):
|
||||
fulluser = settings.value("user/FullName")
|
||||
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.setText(fulluser)
|
||||
|
||||
# information about data structure
|
||||
dataroot = settings.value("data/dataRoot")
|
||||
dataDirLabel = QLabel("data directory:")
|
||||
dataDirLabel = QLabel("data root directory: ")
|
||||
self.dataDirEdit = QLineEdit()
|
||||
self.dataDirEdit.setText(dataroot)
|
||||
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.addWidget(dataDirLabel, 0, 0)
|
||||
@ -159,6 +169,13 @@ class InputsTab(PropTab):
|
||||
values["user/FullName"] = self.fullNameEdit.text()
|
||||
return values
|
||||
|
||||
def updateWidget(self, structure):
|
||||
key = self.structureSelect.currentText()
|
||||
structure = structure[key]
|
||||
structure().getFields().keys()
|
||||
|
||||
|
||||
|
||||
|
||||
class OutputsTab(PropTab):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user