diff --git a/QtPyLoT.py b/QtPyLoT.py index f9bbb8c4..c52e3ae5 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -56,7 +56,7 @@ from pylot.core.pick.compare import Comparison from pylot.core.pick.utils import symmetrize_error from pylot.core.io.phases import picksdict_from_picks import pylot.core.loc.nll as nll -from pylot.core.util.defaults import FILTERDEFAULTS, COMPNAME_MAP +from pylot.core.util.defaults import FILTERDEFAULTS, SetChannelComponents from pylot.core.util.errors import FormatError, DatastructureError, \ OverwriteError, ProcessingError from pylot.core.util.connection import checkurl @@ -1200,10 +1200,12 @@ class MainWindow(QMainWindow): ''' Plot waveform data to current plotWidget. ''' + compclass = SetChannelComponents() zne_text = {'Z': 'vertical', 'N': 'north-south', 'E': 'east-west'} comp = self.getComponent() title = 'section: {0} components'.format(zne_text[comp]) - alter_comp = COMPNAME_MAP[comp] + alter_comp = compclass.getCompPosition(comp) + alter_comp = str(alter_comp[0]) wfst = self.get_data().getWFData().select(component=comp) wfst += self.get_data().getWFData().select(component=alter_comp) height_need = len(self.data.getWFData())*12 diff --git a/pylot/RELEASE-VERSION b/pylot/RELEASE-VERSION index 90d2768c..d1898d5f 100644 --- a/pylot/RELEASE-VERSION +++ b/pylot/RELEASE-VERSION @@ -1 +1 @@ -69b2-dirty +b3a44-dirty diff --git a/pylot/core/util/defaults.py b/pylot/core/util/defaults.py index e716d9cb..e98ac5cc 100644 --- a/pylot/core/util/defaults.py +++ b/pylot/core/util/defaults.py @@ -55,9 +55,28 @@ OUTPUTFORMATS = {'.xml': 'QUAKEML', LOCTOOLS = dict(nll=nll, hyposat=hyposat, velest=velest, hypo71=hypo71, hypodd=hypodd) -COMPPOSITION_MAP = dict(Z=2, N=1, E=0) -COMPPOSITION_MAP['1'] = 1 -COMPPOSITION_MAP['2'] = 0 -COMPPOSITION_MAP['3'] = 2 -COMPNAME_MAP = dict(Z='3', N='1', E='2') +class SetChannelComponents: + def getdefaultCompPosition(): + # default component order + CompPosition_Map = dict(Z=2, N=1, E=0) + CompPosition_Map['1'] = 1 + CompPosition_Map['2'] = 0 + CompPosition_Map['3'] = 2 + CompName_Map = dict(Z='3', N='1', E='2') + CompName_Map['1'] = str(1) + CompName_Map['2'] = str(2) + CompName_Map['3'] = str(3) + return CompPosition_Map, CompName_Map + + CompPosition_Map, CompName_Map = getdefaultCompPosition() + + def setCompPosition(self, component, position): + self.CompPosition_Map[component] = position + self.CompName_Map[component] = str(position) + + def getCompPosition(self, component): + self.comppos = self.CompPosition_Map[component] + self.compname = self.CompName_Map[component] + return self.comppos, self.compname + diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index 64366a75..62b742a7 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -36,7 +36,7 @@ from pylot.core.pick.utils import getSNR, earllatepicker, getnoisewin, \ getResolutionWindow from pylot.core.pick.compare import Comparison from pylot.core.util.defaults import OUTPUTFORMATS, FILTERDEFAULTS, LOCTOOLS, \ - COMPPOSITION_MAP, COMPNAME_MAP + SetChannelComponents from pylot.core.util.utils import prepTimeAxis, full_range, scaleWFData, \ demeanTrace, isSorted, findComboBoxIndex, clims from autoPyLoT import autoPyLoT @@ -437,13 +437,15 @@ class WaveformWidget(FigureCanvas): self.clearPlotDict() wfstart, wfend = full_range(wfdata) nmax = 0 + compclass = SetChannelComponents() for n, trace in enumerate(wfdata): channel = trace.stats.channel network = trace.stats.network station = trace.stats.station if mapping: comp = channel[-1] - n = COMPPOSITION_MAP[comp] + n = compclass.getCompPosition(str(comp)) + n = n[0] if n > nmax: nmax = n msg = 'plotting %s channel of station %s' % (channel, station) @@ -2004,18 +2006,19 @@ class PropertiesDlg(QDialog): @staticmethod def setValues(tabValues): settings = QSettings() + compclass = SetChannelComponents() for setting, value in tabValues.items(): settings.setValue(setting, value) if value is not None: if setting.startswith('Channel Z'): - COMPPOSITION_MAP['Z'] = value - COMPNAME_MAP['Z'] = value + component = 'Z' + compclass.setCompPosition(component, value) elif setting.startswith('Channel E'): - COMPPOSITION_MAP['E'] = value - COMPNAME_MAP['E'] = value + component = 'E' + compclass.setCompPosition(component, value) elif setting.startswith('Channel N'): - COMPPOSITION_MAP['N'] = value - COMPNAME_MAP['N'] = value + component = 'N' + compclass.setCompPosition(component, value) settings.sync() @@ -2145,6 +2148,8 @@ class ChannelOrderTab(PropTab): def __init__(self, parent=None, infile=None): super(ChannelOrderTab, self).__init__(parent) + compclass = SetChannelComponents() + ChannelOrderLabelZ = QLabel("Channel Z [up/down, default=3]") ChannelOrderLabelN = QLabel("Channel N [north/south, default=1]") ChannelOrderLabelE = QLabel("Channel E [east/west, default=2]") @@ -2157,9 +2162,13 @@ class ChannelOrderTab(PropTab): self.ChannelOrderEEdit = QLineEdit() self.ChannelOrderEEdit.setMaxLength(1) self.ChannelOrderEEdit.setFixedSize(20, 20) - self.ChannelOrderZEdit.setText("3") - self.ChannelOrderNEdit.setText("1") - self.ChannelOrderEEdit.setText("2") + # get channel order settings + zpos, zcomp = compclass.getCompPosition('Z') + epos, ecomp = compclass.getCompPosition('E') + npos, ncomp = compclass.getCompPosition('N') + self.ChannelOrderZEdit.setText("%s" % zcomp) + self.ChannelOrderNEdit.setText("%s" % ecomp) + self.ChannelOrderEEdit.setText("%s" % ncomp) layout = QGridLayout() layout.addWidget(ChannelOrderLabelZ, 0, 0) @@ -2186,6 +2195,10 @@ class ChannelOrderTab(PropTab): "Channel E [east/west, default=2]": self.ChannelOrderEEdit.setText("%d" % Edefault)} return values + def getComponents(self): + + self.CompName = dict(Z='10', N='11', E='12') + class LocalisationTab(PropTab): def __init__(self, parent=None, infile=None): super(LocalisationTab, self).__init__(parent)