[add] phase defaults for phasesTab
This commit is contained in:
parent
7748a39a72
commit
c644095b5a
@ -2583,7 +2583,8 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
def PyLoTprefs(self):
|
def PyLoTprefs(self):
|
||||||
if not self._props:
|
if not self._props:
|
||||||
self._props = PropertiesDlg(self, infile=self.infile)
|
self._props = PropertiesDlg(self, infile=self.infile,
|
||||||
|
inputs=self._inputs)
|
||||||
|
|
||||||
if self._props.exec_():
|
if self._props.exec_():
|
||||||
self.init_wfWidget()
|
self.init_wfWidget()
|
||||||
|
@ -38,6 +38,7 @@ from PySide.QtWebKit import QWebView
|
|||||||
from obspy import Stream, UTCDateTime
|
from obspy import Stream, UTCDateTime
|
||||||
from obspy.core.util import AttribDict
|
from obspy.core.util import AttribDict
|
||||||
from obspy.taup import TauPyModel
|
from obspy.taup import TauPyModel
|
||||||
|
from obspy.taup.utils import get_phase_names
|
||||||
from pylot.core.io.data import Data
|
from pylot.core.io.data import Data
|
||||||
from pylot.core.io.inputs import FilterOptions, PylotParameter
|
from pylot.core.io.inputs import FilterOptions, PylotParameter
|
||||||
from pylot.core.pick.utils import getSNR, earllatepicker, getnoisewin, \
|
from pylot.core.pick.utils import getSNR, earllatepicker, getnoisewin, \
|
||||||
@ -48,6 +49,7 @@ from pylot.core.util.utils import prepTimeAxis, full_range, scaleWFData, \
|
|||||||
demeanTrace, isSorted, findComboBoxIndex, clims
|
demeanTrace, isSorted, findComboBoxIndex, clims
|
||||||
from autoPyLoT import autoPyLoT
|
from autoPyLoT import autoPyLoT
|
||||||
from pylot.core.util.thread import Thread
|
from pylot.core.util.thread import Thread
|
||||||
|
|
||||||
if sys.version_info.major == 3:
|
if sys.version_info.major == 3:
|
||||||
import icons_rc_3 as icons_rc
|
import icons_rc_3 as icons_rc
|
||||||
elif sys.version_info.major == 2:
|
elif sys.version_info.major == 2:
|
||||||
@ -59,7 +61,8 @@ if pg:
|
|||||||
pg.setConfigOption('background', 'w')
|
pg.setConfigOption('background', 'w')
|
||||||
pg.setConfigOption('foreground', 'k')
|
pg.setConfigOption('foreground', 'k')
|
||||||
pg.setConfigOptions(antialias=True)
|
pg.setConfigOptions(antialias=True)
|
||||||
#pg.setConfigOption('leftButtonPan', False)
|
# pg.setConfigOption('leftButtonPan', False)
|
||||||
|
|
||||||
|
|
||||||
def getDataType(parent):
|
def getDataType(parent):
|
||||||
type = QInputDialog().getItem(parent, "Select phases type", "Type:",
|
type = QInputDialog().getItem(parent, "Select phases type", "Type:",
|
||||||
@ -72,13 +75,14 @@ def getDataType(parent):
|
|||||||
|
|
||||||
return type
|
return type
|
||||||
|
|
||||||
|
|
||||||
def plot_pdf(_axes, x, y, annotation, bbox_props, xlabel=None, ylabel=None,
|
def plot_pdf(_axes, x, y, annotation, bbox_props, xlabel=None, ylabel=None,
|
||||||
title=None):
|
title=None):
|
||||||
# try method or data
|
# try method or data
|
||||||
try:
|
try:
|
||||||
_axes.plot(x, y()) # y provided as method
|
_axes.plot(x, y()) # y provided as method
|
||||||
except:
|
except:
|
||||||
_axes.plot(x, y) # y provided as data
|
_axes.plot(x, y) # y provided as data
|
||||||
|
|
||||||
if title:
|
if title:
|
||||||
_axes.set_title(title)
|
_axes.set_title(title)
|
||||||
@ -91,6 +95,7 @@ def plot_pdf(_axes, x, y, annotation, bbox_props, xlabel=None, ylabel=None,
|
|||||||
|
|
||||||
return _axes
|
return _axes
|
||||||
|
|
||||||
|
|
||||||
def createAction(parent, text, slot=None, shortcut=None, icon=None,
|
def createAction(parent, text, slot=None, shortcut=None, icon=None,
|
||||||
tip=None, checkable=False):
|
tip=None, checkable=False):
|
||||||
"""
|
"""
|
||||||
@ -109,6 +114,7 @@ def createAction(parent, text, slot=None, shortcut=None, icon=None,
|
|||||||
action.setCheckable(True)
|
action.setCheckable(True)
|
||||||
return action
|
return action
|
||||||
|
|
||||||
|
|
||||||
class ComparisonDialog(QDialog):
|
class ComparisonDialog(QDialog):
|
||||||
def __init__(self, c, parent=None):
|
def __init__(self, c, parent=None):
|
||||||
self._data = c
|
self._data = c
|
||||||
@ -258,7 +264,7 @@ class ComparisonDialog(QDialog):
|
|||||||
_ax1 = self.canvas.figure.add_subplot(_gs[2, 0])
|
_ax1 = self.canvas.figure.add_subplot(_gs[2, 0])
|
||||||
_ax2 = self.canvas.figure.add_subplot(_gs[2, 1])
|
_ax2 = self.canvas.figure.add_subplot(_gs[2, 1])
|
||||||
|
|
||||||
#_axes.cla()
|
# _axes.cla()
|
||||||
station = self.plotprops['station']
|
station = self.plotprops['station']
|
||||||
phase = self.plotprops['phase']
|
phase = self.plotprops['phase']
|
||||||
pdf = self.data.comparison[station][phase]
|
pdf = self.data.comparison[station][phase]
|
||||||
@ -268,11 +274,11 @@ class ComparisonDialog(QDialog):
|
|||||||
annotation = "%s difference on %s\n" \
|
annotation = "%s difference on %s\n" \
|
||||||
"expectation: %7.4f s\n" \
|
"expectation: %7.4f s\n" \
|
||||||
"std: %7.4f s" % (phase, station,
|
"std: %7.4f s" % (phase, station,
|
||||||
exp, std)
|
exp, std)
|
||||||
bbox_props = dict(boxstyle='round', facecolor='lightgrey', alpha=.7)
|
bbox_props = dict(boxstyle='round', facecolor='lightgrey', alpha=.7)
|
||||||
|
|
||||||
plot_pdf(_axes, x, y, annotation, bbox_props, 'time difference [s]',
|
plot_pdf(_axes, x, y, annotation, bbox_props, 'time difference [s]',
|
||||||
'propability density [-]', phase)
|
'propability density [-]', phase)
|
||||||
|
|
||||||
pdf_a = copy.deepcopy(self.data.get('auto')[station][phase])
|
pdf_a = copy.deepcopy(self.data.get('auto')[station][phase])
|
||||||
pdf_m = copy.deepcopy(self.data.get('manu')[station][phase])
|
pdf_m = copy.deepcopy(self.data.get('manu')[station][phase])
|
||||||
@ -297,11 +303,11 @@ class ComparisonDialog(QDialog):
|
|||||||
# set annotation text
|
# set annotation text
|
||||||
mannotation = "probability density of manual pick\n" \
|
mannotation = "probability density of manual pick\n" \
|
||||||
"expectation: %7.4f s\n" \
|
"expectation: %7.4f s\n" \
|
||||||
"std: %7.4f s" % (expmanu-x0.timestamp, stdmanu)
|
"std: %7.4f s" % (expmanu - x0.timestamp, stdmanu)
|
||||||
|
|
||||||
aannotation = "probability density of automatic pick\n" \
|
aannotation = "probability density of automatic pick\n" \
|
||||||
"expectation: %7.4f s\n" \
|
"expectation: %7.4f s\n" \
|
||||||
"std: %7.4f s" % (expauto-x0.timestamp, stdauto)
|
"std: %7.4f s" % (expauto - x0.timestamp, stdauto)
|
||||||
|
|
||||||
_ax1 = plot_pdf(_ax1, xmanu, ymanu, mannotation,
|
_ax1 = plot_pdf(_ax1, xmanu, ymanu, mannotation,
|
||||||
bbox_props=bbox_props, xlabel='seconds since '
|
bbox_props=bbox_props, xlabel='seconds since '
|
||||||
@ -414,7 +420,7 @@ class PlotWidget(FigureCanvas):
|
|||||||
|
|
||||||
class WaveformWidgetPG(QtGui.QWidget):
|
class WaveformWidgetPG(QtGui.QWidget):
|
||||||
def __init__(self, parent=None, xlabel='x', ylabel='y', title='Title'):
|
def __init__(self, parent=None, xlabel='x', ylabel='y', title='Title'):
|
||||||
QtGui.QWidget.__init__(self, parent)#, 1)
|
QtGui.QWidget.__init__(self, parent) # , 1)
|
||||||
self.setParent(parent)
|
self.setParent(parent)
|
||||||
self._parent = parent
|
self._parent = parent
|
||||||
# attribute plotdict is a dictionary connecting position and a name
|
# attribute plotdict is a dictionary connecting position and a name
|
||||||
@ -443,7 +449,7 @@ class WaveformWidgetPG(QtGui.QWidget):
|
|||||||
if self.plotWidget.sceneBoundingRect().contains(pos):
|
if self.plotWidget.sceneBoundingRect().contains(pos):
|
||||||
mousePoint = self.plotWidget.getPlotItem().vb.mapSceneToView(pos)
|
mousePoint = self.plotWidget.getPlotItem().vb.mapSceneToView(pos)
|
||||||
x, y, = (mousePoint.x(), mousePoint.y())
|
x, y, = (mousePoint.x(), mousePoint.y())
|
||||||
#if x > 0:# and index < len(data1):
|
# if x > 0:# and index < len(data1):
|
||||||
wfID = self._parent.getWFID(y)
|
wfID = self._parent.getWFID(y)
|
||||||
station = self._parent.getStationName(wfID)
|
station = self._parent.getStationName(wfID)
|
||||||
if self._parent.get_current_event():
|
if self._parent.get_current_event():
|
||||||
@ -482,7 +488,7 @@ class WaveformWidgetPG(QtGui.QWidget):
|
|||||||
|
|
||||||
if not component == '*':
|
if not component == '*':
|
||||||
alter_comp = compclass.getCompPosition(component)
|
alter_comp = compclass.getCompPosition(component)
|
||||||
#alter_comp = str(alter_comp[0])
|
# alter_comp = str(alter_comp[0])
|
||||||
|
|
||||||
st_select = wfdata.select(component=component)
|
st_select = wfdata.select(component=component)
|
||||||
st_select += wfdata.select(component=alter_comp)
|
st_select += wfdata.select(component=alter_comp)
|
||||||
@ -499,9 +505,9 @@ class WaveformWidgetPG(QtGui.QWidget):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.plotWidget.getPlotItem().vb.setLimits(xMin=float(0),
|
self.plotWidget.getPlotItem().vb.setLimits(xMin=float(0),
|
||||||
xMax=float(wfend-wfstart),
|
xMax=float(wfend - wfstart),
|
||||||
yMin=-0.5,
|
yMin=-0.5,
|
||||||
yMax=len(nsc)+0.5)
|
yMax=len(nsc) + 0.5)
|
||||||
except:
|
except:
|
||||||
print('Warning: Could not set zoom limits')
|
print('Warning: Could not set zoom limits')
|
||||||
|
|
||||||
@ -511,7 +517,7 @@ class WaveformWidgetPG(QtGui.QWidget):
|
|||||||
if mapping:
|
if mapping:
|
||||||
comp = channel[-1]
|
comp = channel[-1]
|
||||||
n = compclass.getPlotPosition(str(comp))
|
n = compclass.getPlotPosition(str(comp))
|
||||||
#n = n[0]
|
# n = n[0]
|
||||||
if n > nmax:
|
if n > nmax:
|
||||||
nmax = n
|
nmax = n
|
||||||
if verbosity:
|
if verbosity:
|
||||||
@ -523,8 +529,8 @@ class WaveformWidgetPG(QtGui.QWidget):
|
|||||||
if not scaleddata:
|
if not scaleddata:
|
||||||
trace.detrend('constant')
|
trace.detrend('constant')
|
||||||
trace.normalize(np.max(np.abs(trace.data)) * 2)
|
trace.normalize(np.max(np.abs(trace.data)) * 2)
|
||||||
times = [time for index, time in enumerate(time_ax) if not index%nth_sample]
|
times = [time for index, time in enumerate(time_ax) if not index % nth_sample]
|
||||||
data = [datum + n for index, datum in enumerate(trace.data) if not index%nth_sample]
|
data = [datum + n for index, datum in enumerate(trace.data) if not index % nth_sample]
|
||||||
plots.append((times, data))
|
plots.append((times, data))
|
||||||
self.setPlotDict(n, (station, channel, network))
|
self.setPlotDict(n, (station, channel, network))
|
||||||
self.xlabel = 'seconds since {0}'.format(wfstart)
|
self.xlabel = 'seconds since {0}'.format(wfstart)
|
||||||
@ -572,7 +578,7 @@ class WaveformWidgetPG(QtGui.QWidget):
|
|||||||
self.plotWidget.getPlotItem().setTitle(text)
|
self.plotWidget.getPlotItem().setTitle(text)
|
||||||
self.draw()
|
self.draw()
|
||||||
|
|
||||||
def updateWidget(self):#, xlabel, ylabel, title):
|
def updateWidget(self): # , xlabel, ylabel, title):
|
||||||
self.updateXLabel(self.xlabel)
|
self.updateXLabel(self.xlabel)
|
||||||
self.updateYLabel(self.ylabel)
|
self.updateYLabel(self.ylabel)
|
||||||
self.updateTitle(self.title)
|
self.updateTitle(self.title)
|
||||||
@ -636,7 +642,7 @@ class WaveformWidget(FigureCanvas):
|
|||||||
|
|
||||||
if not component == '*':
|
if not component == '*':
|
||||||
alter_comp = compclass.getCompPosition(component)
|
alter_comp = compclass.getCompPosition(component)
|
||||||
#alter_comp = str(alter_comp[0])
|
# alter_comp = str(alter_comp[0])
|
||||||
|
|
||||||
st_select = wfdata.select(component=component)
|
st_select = wfdata.select(component=component)
|
||||||
st_select += wfdata.select(component=alter_comp)
|
st_select += wfdata.select(component=alter_comp)
|
||||||
@ -656,7 +662,7 @@ class WaveformWidget(FigureCanvas):
|
|||||||
if mapping:
|
if mapping:
|
||||||
comp = channel[-1]
|
comp = channel[-1]
|
||||||
n = compclass.getPlotPosition(str(comp))
|
n = compclass.getPlotPosition(str(comp))
|
||||||
#n = n[0]
|
# n = n[0]
|
||||||
if n > nmax:
|
if n > nmax:
|
||||||
nmax = n
|
nmax = n
|
||||||
if verbosity:
|
if verbosity:
|
||||||
@ -668,13 +674,13 @@ class WaveformWidget(FigureCanvas):
|
|||||||
if not scaleddata:
|
if not scaleddata:
|
||||||
trace.detrend('constant')
|
trace.detrend('constant')
|
||||||
trace.normalize(np.max(np.abs(trace.data)) * 2)
|
trace.normalize(np.max(np.abs(trace.data)) * 2)
|
||||||
times = [time for index, time in enumerate(time_ax) if not index%nth_sample]
|
times = [time for index, time in enumerate(time_ax) if not index % nth_sample]
|
||||||
data = [datum + n for index, datum in enumerate(trace.data) if not index%nth_sample]
|
data = [datum + n for index, datum in enumerate(trace.data) if not index % nth_sample]
|
||||||
self.getAxes().plot(times, data, 'k', linewidth=0.7)
|
self.getAxes().plot(times, data, 'k', linewidth=0.7)
|
||||||
if noiselevel is not None:
|
if noiselevel is not None:
|
||||||
for level in noiselevel:
|
for level in noiselevel:
|
||||||
self.getAxes().plot([time_ax[0], time_ax[-1]],
|
self.getAxes().plot([time_ax[0], time_ax[-1]],
|
||||||
[level, level], '--k')
|
[level, level], '--k')
|
||||||
if iniPick:
|
if iniPick:
|
||||||
ax = self.getAxes()
|
ax = self.getAxes()
|
||||||
ax.vlines(iniPick, ax.get_ylim()[0], ax.get_ylim()[1],
|
ax.vlines(iniPick, ax.get_ylim()[0], ax.get_ylim()[1],
|
||||||
@ -736,8 +742,69 @@ class WaveformWidget(FigureCanvas):
|
|||||||
axann.set_bbox(dict(facecolor='lightgrey', alpha=.6))
|
axann.set_bbox(dict(facecolor='lightgrey', alpha=.6))
|
||||||
|
|
||||||
|
|
||||||
|
class PhaseDefaults(QtGui.QDialog):
|
||||||
|
def __init__(self, parent=None, nrow=10,
|
||||||
|
phase_defaults=['P', 'S'],
|
||||||
|
current_phases=[]):
|
||||||
|
super(PhaseDefaults, self).__init__(parent)
|
||||||
|
self.nrow = nrow
|
||||||
|
self.main_layout = QtGui.QVBoxLayout()
|
||||||
|
self.sub_layout = QtGui.QGridLayout()
|
||||||
|
self.phase_names = phase_defaults
|
||||||
|
self.current_phases = current_phases
|
||||||
|
self.setButtons()
|
||||||
|
self.setupUi()
|
||||||
|
self.connectSignals()
|
||||||
|
self.setWindowTitle('Default Phases')
|
||||||
|
self.selected_phases = []
|
||||||
|
|
||||||
|
def setButtons(self):
|
||||||
|
self._buttonbox = QDialogButtonBox(QDialogButtonBox.Ok |
|
||||||
|
QDialogButtonBox.Cancel)
|
||||||
|
|
||||||
|
def setupUi(self):
|
||||||
|
self.setLayout(self.main_layout)
|
||||||
|
self.main_layout.addLayout(self.sub_layout)
|
||||||
|
self.init_phase_layout()
|
||||||
|
self.main_layout.addWidget(self._buttonbox)
|
||||||
|
|
||||||
|
def connectSignals(self):
|
||||||
|
self._buttonbox.accepted.connect(self.accept)
|
||||||
|
self._buttonbox.rejected.connect(self.reject)
|
||||||
|
|
||||||
|
def init_phase_layout(self):
|
||||||
|
self._checkboxes = {}
|
||||||
|
row = 0
|
||||||
|
column = 0
|
||||||
|
for index, phase in enumerate(self.phase_names):
|
||||||
|
if row > self.nrow:
|
||||||
|
column += 1
|
||||||
|
row = 0
|
||||||
|
checkbox = self.create_phase_box(phase)
|
||||||
|
self.sub_layout.addWidget(checkbox,
|
||||||
|
row, column)
|
||||||
|
self._checkboxes[phase] = checkbox
|
||||||
|
checkbox.setChecked(bool(phase in self.current_phases))
|
||||||
|
row += 1
|
||||||
|
|
||||||
|
def create_phase_box(self, phase_name):
|
||||||
|
checkbox = QtGui.QCheckBox(phase_name)
|
||||||
|
return checkbox
|
||||||
|
|
||||||
|
def update_selected_phases(self):
|
||||||
|
self.selected_phases = []
|
||||||
|
for phase in self.phase_names:
|
||||||
|
if self._checkboxes[phase].isChecked():
|
||||||
|
self.selected_phases.append(phase)
|
||||||
|
|
||||||
|
def accept(self):
|
||||||
|
self.update_selected_phases()
|
||||||
|
QtGui.QDialog.accept(self)
|
||||||
|
|
||||||
|
|
||||||
class PickDlg(QDialog):
|
class PickDlg(QDialog):
|
||||||
update_picks = QtCore.Signal(dict)
|
update_picks = QtCore.Signal(dict)
|
||||||
|
|
||||||
def __init__(self, parent=None, data=None, station=None, network=None, picks=None,
|
def __init__(self, parent=None, data=None, station=None, network=None, picks=None,
|
||||||
autopicks=None, rotate=False, parameter=None, embedded=False, model='iasp91'):
|
autopicks=None, rotate=False, parameter=None, embedded=False, model='iasp91'):
|
||||||
super(PickDlg, self).__init__(parent)
|
super(PickDlg, self).__init__(parent)
|
||||||
@ -1048,8 +1115,8 @@ class PickDlg(QDialog):
|
|||||||
phaseSelect = {'P': self.p_phase_select,
|
phaseSelect = {'P': self.p_phase_select,
|
||||||
'S': self.s_phase_select}
|
'S': self.s_phase_select}
|
||||||
|
|
||||||
nHotkey = 4 # max hotkeys per phase
|
nHotkey = 4 # max hotkeys per phase
|
||||||
hotkey = 1 # start hotkey
|
hotkey = 1 # start hotkey
|
||||||
|
|
||||||
# loop over P and S (use explicit list instead of iter over dict.keys to keep order)
|
# loop over P and S (use explicit list instead of iter over dict.keys to keep order)
|
||||||
for phaseIndex, phaseID in enumerate(['P', 'S']):
|
for phaseIndex, phaseID in enumerate(['P', 'S']):
|
||||||
@ -1070,7 +1137,7 @@ class PickDlg(QDialog):
|
|||||||
slot=slot,
|
slot=slot,
|
||||||
shortcut=shortcut)
|
shortcut=shortcut)
|
||||||
picksMenu.addAction(picksAction)
|
picksMenu.addAction(picksAction)
|
||||||
self.picksActions[str(phase)] = picksAction # save action in dictionary
|
self.picksActions[str(phase)] = picksAction # save action in dictionary
|
||||||
if phaseIndex == 0:
|
if phaseIndex == 0:
|
||||||
picksMenu.addSeparator()
|
picksMenu.addSeparator()
|
||||||
|
|
||||||
@ -1167,7 +1234,7 @@ class PickDlg(QDialog):
|
|||||||
self.activatePicking()
|
self.activatePicking()
|
||||||
self.currentPhase = str(self.s_button.text())
|
self.currentPhase = str(self.s_button.text())
|
||||||
|
|
||||||
def set_button_color(self, button, color = None):
|
def set_button_color(self, button, color=None):
|
||||||
if type(color) == QtGui.QColor:
|
if type(color) == QtGui.QColor:
|
||||||
palette = button.palette()
|
palette = button.palette()
|
||||||
role = button.backgroundRole()
|
role = button.backgroundRole()
|
||||||
@ -1235,7 +1302,7 @@ class PickDlg(QDialog):
|
|||||||
|
|
||||||
def getStation(self):
|
def getStation(self):
|
||||||
if self.network and self.station:
|
if self.network and self.station:
|
||||||
return self.network+'.'+self.station
|
return self.network + '.' + self.station
|
||||||
return self.station
|
return self.station
|
||||||
|
|
||||||
def getPlotWidget(self):
|
def getPlotWidget(self):
|
||||||
@ -1365,7 +1432,7 @@ class PickDlg(QDialog):
|
|||||||
itrace -= 1
|
itrace -= 1
|
||||||
|
|
||||||
stime = self.getStartTime()
|
stime = self.getStartTime()
|
||||||
stime_diff = wfdata[itrace].stats.starttime-stime
|
stime_diff = wfdata[itrace].stats.starttime - stime
|
||||||
|
|
||||||
# copy data for plotting
|
# copy data for plotting
|
||||||
data = self.getWFData().copy()
|
data = self.getWFData().copy()
|
||||||
@ -1382,7 +1449,7 @@ class PickDlg(QDialog):
|
|||||||
'Denied', 'setIniPickP: Could not filter waveform: {}'.format(e))
|
'Denied', 'setIniPickP: Could not filter waveform: {}'.format(e))
|
||||||
self.qmb.show()
|
self.qmb.show()
|
||||||
|
|
||||||
result = getSNR(wfdata, (noise_win, gap_win, signal_win), ini_pick-stime_diff, itrace)
|
result = getSNR(wfdata, (noise_win, gap_win, signal_win), ini_pick - stime_diff, itrace)
|
||||||
|
|
||||||
snr = result[0]
|
snr = result[0]
|
||||||
noiselevel = result[2]
|
noiselevel = result[2]
|
||||||
@ -1423,7 +1490,7 @@ class PickDlg(QDialog):
|
|||||||
signal_win = twins[2]
|
signal_win = twins[2]
|
||||||
|
|
||||||
stime = self.getStartTime()
|
stime = self.getStartTime()
|
||||||
stime_diff = wfdata[0].stats.starttime-stime
|
stime_diff = wfdata[0].stats.starttime - stime
|
||||||
|
|
||||||
# copy data for plotting
|
# copy data for plotting
|
||||||
data = self.getWFData().copy()
|
data = self.getWFData().copy()
|
||||||
@ -1441,7 +1508,7 @@ class PickDlg(QDialog):
|
|||||||
self.qmb.show()
|
self.qmb.show()
|
||||||
|
|
||||||
# determine SNR and noiselevel
|
# determine SNR and noiselevel
|
||||||
result = getSNR(wfdata, (noise_win, gap_win, signal_win), ini_pick-stime_diff)
|
result = getSNR(wfdata, (noise_win, gap_win, signal_win), ini_pick - stime_diff)
|
||||||
snr = result[0]
|
snr = result[0]
|
||||||
noiselevel = result[2]
|
noiselevel = result[2]
|
||||||
|
|
||||||
@ -1460,7 +1527,7 @@ class PickDlg(QDialog):
|
|||||||
horiz_comp = find_horizontals(data)
|
horiz_comp = find_horizontals(data)
|
||||||
data = scaleWFData(data, noiselevel * 2.5, horiz_comp)
|
data = scaleWFData(data, noiselevel * 2.5, horiz_comp)
|
||||||
|
|
||||||
x_res = getResolutionWindow(snr, parameter.get('extent'))
|
x_res = getResolutionWindow(snr, parameter.get('inp'))
|
||||||
|
|
||||||
self.setXLims(tuple([ini_pick - x_res, ini_pick + x_res]))
|
self.setXLims(tuple([ini_pick - x_res, ini_pick + x_res]))
|
||||||
traces = self.getTraceID(horiz_comp)
|
traces = self.getTraceID(horiz_comp)
|
||||||
@ -1506,8 +1573,6 @@ class PickDlg(QDialog):
|
|||||||
'Denied', 'setPick: Could not filter waveform: {}'.format(e))
|
'Denied', 'setPick: Could not filter waveform: {}'.format(e))
|
||||||
self.qmb.show()
|
self.qmb.show()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# get earliest and latest possible pick and symmetric pick error
|
# get earliest and latest possible pick and symmetric pick error
|
||||||
if wfdata[0].stats.channel[2] == 'Z' or wfdata[0].stats.channel[2] == '3':
|
if wfdata[0].stats.channel[2] == 'Z' or wfdata[0].stats.channel[2] == '3':
|
||||||
nfac = parameter.get('nfacP')
|
nfac = parameter.get('nfacP')
|
||||||
@ -1518,10 +1583,10 @@ class PickDlg(QDialog):
|
|||||||
|
|
||||||
# return absolute time values for phases
|
# return absolute time values for phases
|
||||||
stime = self.getStartTime()
|
stime = self.getStartTime()
|
||||||
stime_diff = wfdata[0].stats.starttime-stime
|
stime_diff = wfdata[0].stats.starttime - stime
|
||||||
|
|
||||||
[epp, lpp, spe] = earllatepicker(wfdata, nfac, (TSNR[0], TSNR[1], TSNR[2]),
|
[epp, lpp, spe] = earllatepicker(wfdata, nfac, (TSNR[0], TSNR[1], TSNR[2]),
|
||||||
pick-stime_diff, verbosity=1)
|
pick - stime_diff, verbosity=1)
|
||||||
|
|
||||||
mpp = stime + pick
|
mpp = stime + pick
|
||||||
if epp:
|
if epp:
|
||||||
@ -1645,7 +1710,7 @@ class PickDlg(QDialog):
|
|||||||
if not self.picks and not self.autopicks:
|
if not self.picks and not self.autopicks:
|
||||||
return
|
return
|
||||||
# init empty list and get station starttime
|
# init empty list and get station starttime
|
||||||
X=[]
|
X = []
|
||||||
starttime = self.getStartTime()
|
starttime = self.getStartTime()
|
||||||
# init dictionarys to iterate through and iterate over them
|
# init dictionarys to iterate through and iterate over them
|
||||||
allpicks = [self.picks, self.autopicks]
|
allpicks = [self.picks, self.autopicks]
|
||||||
@ -1655,7 +1720,7 @@ class PickDlg(QDialog):
|
|||||||
# add relative pick time, phaseID and picktype index
|
# add relative pick time, phaseID and picktype index
|
||||||
X.append((pick_rel, phase, index_ptype))
|
X.append((pick_rel, phase, index_ptype))
|
||||||
# find index and value closest to x
|
# find index and value closest to x
|
||||||
index, value = min(enumerate([val[0] for val in X]), key=lambda y: abs(y[1]-x))
|
index, value = min(enumerate([val[0] for val in X]), key=lambda y: abs(y[1] - x))
|
||||||
# unpack the found value
|
# unpack the found value
|
||||||
pick_rel, phase, index_ptype = X[index]
|
pick_rel, phase, index_ptype = X[index]
|
||||||
# delete the value from corresponding dictionary
|
# delete the value from corresponding dictionary
|
||||||
@ -1867,6 +1932,7 @@ class TuneAutopicker(QWidget):
|
|||||||
:param: parent
|
:param: parent
|
||||||
:type: QtPyLoT Mainwindow
|
:type: QtPyLoT Mainwindow
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
QtGui.QWidget.__init__(self, parent, 1)
|
QtGui.QWidget.__init__(self, parent, 1)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
@ -1890,8 +1956,8 @@ class TuneAutopicker(QWidget):
|
|||||||
self.metadata = self.parent.metadata
|
self.metadata = self.parent.metadata
|
||||||
else:
|
else:
|
||||||
self.metadata = None
|
self.metadata = None
|
||||||
#self.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal)
|
# self.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal)
|
||||||
#self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowStaysOnTopHint)
|
# self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowStaysOnTopHint)
|
||||||
|
|
||||||
def init_main_layouts(self):
|
def init_main_layouts(self):
|
||||||
self.main_layout = QtGui.QVBoxLayout()
|
self.main_layout = QtGui.QVBoxLayout()
|
||||||
@ -1935,7 +2001,7 @@ class TuneAutopicker(QWidget):
|
|||||||
stations.sort()
|
stations.sort()
|
||||||
model = self.stationBox.model()
|
model = self.stationBox.model()
|
||||||
for network, station in stations:
|
for network, station in stations:
|
||||||
item = QtGui.QStandardItem(network+'.'+station)
|
item = QtGui.QStandardItem(network + '.' + station)
|
||||||
if station in self.get_current_event().pylot_picks:
|
if station in self.get_current_event().pylot_picks:
|
||||||
item.setBackground(self.parent._colors['ref'])
|
item.setBackground(self.parent._colors['ref'])
|
||||||
model.appendRow(item)
|
model.appendRow(item)
|
||||||
@ -2047,7 +2113,7 @@ class TuneAutopicker(QWidget):
|
|||||||
st = self.data.getWFData()
|
st = self.data.getWFData()
|
||||||
tr = st.select(station=self.get_current_station())[0]
|
tr = st.select(station=self.get_current_station())[0]
|
||||||
starttime = tr.stats.starttime
|
starttime = tr.stats.starttime
|
||||||
p_axes=[
|
p_axes = [
|
||||||
('mainFig', 0),
|
('mainFig', 0),
|
||||||
('aicFig', 0),
|
('aicFig', 0),
|
||||||
('slength', 0),
|
('slength', 0),
|
||||||
@ -2055,7 +2121,7 @@ class TuneAutopicker(QWidget):
|
|||||||
('el_Ppick', 0),
|
('el_Ppick', 0),
|
||||||
('fm_picker', 0),
|
('fm_picker', 0),
|
||||||
('fm_picker', 1)]
|
('fm_picker', 1)]
|
||||||
s_axes=[
|
s_axes = [
|
||||||
('mainFig', 1),
|
('mainFig', 1),
|
||||||
('mainFig', 2),
|
('mainFig', 2),
|
||||||
('aicARHfig', 0),
|
('aicARHfig', 0),
|
||||||
@ -2076,24 +2142,24 @@ class TuneAutopicker(QWidget):
|
|||||||
self.plot_manual_Spick_to_ax(ax, (picks['S']['mpp'] - starttime))
|
self.plot_manual_Spick_to_ax(ax, (picks['S']['mpp'] - starttime))
|
||||||
|
|
||||||
def plot_manual_Ppick_to_ax(self, ax, pick):
|
def plot_manual_Ppick_to_ax(self, ax, pick):
|
||||||
y_top = 0.9*ax.get_ylim()[1]
|
y_top = 0.9 * ax.get_ylim()[1]
|
||||||
y_bot = 0.9*ax.get_ylim()[0]
|
y_bot = 0.9 * ax.get_ylim()[0]
|
||||||
ax.vlines(pick, y_bot, y_top,
|
ax.vlines(pick, y_bot, y_top,
|
||||||
color='teal', linewidth=2, label='manual P Onset')
|
color='teal', linewidth=2, label='manual P Onset')
|
||||||
ax.plot([pick-0.5, pick+0.5],
|
ax.plot([pick - 0.5, pick + 0.5],
|
||||||
[y_bot, y_bot], linewidth=2, color='teal')
|
[y_bot, y_bot], linewidth=2, color='teal')
|
||||||
ax.plot([pick-0.5, pick+0.5],
|
ax.plot([pick - 0.5, pick + 0.5],
|
||||||
[y_top, y_top], linewidth=2, color='teal')
|
[y_top, y_top], linewidth=2, color='teal')
|
||||||
ax.legend()
|
ax.legend()
|
||||||
|
|
||||||
def plot_manual_Spick_to_ax(self, ax, pick):
|
def plot_manual_Spick_to_ax(self, ax, pick):
|
||||||
y_top = 0.9*ax.get_ylim()[1]
|
y_top = 0.9 * ax.get_ylim()[1]
|
||||||
y_bot = 0.9*ax.get_ylim()[0]
|
y_bot = 0.9 * ax.get_ylim()[0]
|
||||||
ax.vlines(pick, y_bot, y_top,
|
ax.vlines(pick, y_bot, y_top,
|
||||||
color='magenta', linewidth=2, label='manual S Onset')
|
color='magenta', linewidth=2, label='manual S Onset')
|
||||||
ax.plot([pick-0.5, pick+0.5],
|
ax.plot([pick - 0.5, pick + 0.5],
|
||||||
[y_bot, y_bot], linewidth=2, color='magenta')
|
[y_bot, y_bot], linewidth=2, color='magenta')
|
||||||
ax.plot([pick-0.5, pick+0.5],
|
ax.plot([pick - 0.5, pick + 0.5],
|
||||||
[y_top, y_top], linewidth=2, color='magenta')
|
[y_top, y_top], linewidth=2, color='magenta')
|
||||||
ax.legend()
|
ax.legend()
|
||||||
|
|
||||||
@ -2162,7 +2228,7 @@ class TuneAutopicker(QWidget):
|
|||||||
if project.getEventFromPath(index):
|
if project.getEventFromPath(index):
|
||||||
if not project.getEventFromPath(index).isTestEvent():
|
if not project.getEventFromPath(index).isTestEvent():
|
||||||
break
|
break
|
||||||
#in case all events are marked as test events and last event is reached
|
# in case all events are marked as test events and last event is reached
|
||||||
if index == nevents - 1:
|
if index == nevents - 1:
|
||||||
index = -1
|
index = -1
|
||||||
self.eventBox.setCurrentIndex(index)
|
self.eventBox.setCurrentIndex(index)
|
||||||
@ -2200,7 +2266,7 @@ class TuneAutopicker(QWidget):
|
|||||||
self.ap_thread.finished.connect(self.finish_picker)
|
self.ap_thread.finished.connect(self.finish_picker)
|
||||||
self.figure_tabs.setCurrentIndex(4)
|
self.figure_tabs.setCurrentIndex(4)
|
||||||
self.ap_thread.start()
|
self.ap_thread.start()
|
||||||
#picks = autoPyLoT(self.parameter, fnames='None', iplot=2, fig_dict=self.fig_dict)
|
# picks = autoPyLoT(self.parameter, fnames='None', iplot=2, fig_dict=self.fig_dict)
|
||||||
|
|
||||||
def finish_picker(self):
|
def finish_picker(self):
|
||||||
self.enable(True)
|
self.enable(True)
|
||||||
@ -2212,8 +2278,8 @@ class TuneAutopicker(QWidget):
|
|||||||
if not self.pylot_picks:
|
if not self.pylot_picks:
|
||||||
self._warn('No picks found. See terminal output.')
|
self._warn('No picks found. See terminal output.')
|
||||||
return
|
return
|
||||||
#renew tabs
|
# renew tabs
|
||||||
#self.fill_figure_tabs()
|
# self.fill_figure_tabs()
|
||||||
self.set_stretch()
|
self.set_stretch()
|
||||||
self.update.emit('Update')
|
self.update.emit('Update')
|
||||||
self.figure_tabs.setCurrentIndex(1)
|
self.figure_tabs.setCurrentIndex(1)
|
||||||
@ -2241,7 +2307,7 @@ class TuneAutopicker(QWidget):
|
|||||||
if hasattr(self, 'pickDlg'):
|
if hasattr(self, 'pickDlg'):
|
||||||
if self.pickDlg:
|
if self.pickDlg:
|
||||||
self.pickDlg.setParent(None)
|
self.pickDlg.setParent(None)
|
||||||
del(self.pickDlg)
|
del (self.pickDlg)
|
||||||
if hasattr(self, 'overview'):
|
if hasattr(self, 'overview'):
|
||||||
self.overview.setParent(None)
|
self.overview.setParent(None)
|
||||||
if hasattr(self, 'p_tabs'):
|
if hasattr(self, 'p_tabs'):
|
||||||
@ -2268,6 +2334,7 @@ class TuneAutopicker(QWidget):
|
|||||||
class PylotParaBox(QtGui.QWidget):
|
class PylotParaBox(QtGui.QWidget):
|
||||||
accepted = QtCore.Signal(str)
|
accepted = QtCore.Signal(str)
|
||||||
rejected = QtCore.Signal(str)
|
rejected = QtCore.Signal(str)
|
||||||
|
|
||||||
def __init__(self, parameter, parent=None):
|
def __init__(self, parameter, parent=None):
|
||||||
'''
|
'''
|
||||||
Generate Widget containing parameters for PyLoT.
|
Generate Widget containing parameters for PyLoT.
|
||||||
@ -2321,7 +2388,7 @@ class PylotParaBox(QtGui.QWidget):
|
|||||||
|
|
||||||
def _init_dialog_buttons(self):
|
def _init_dialog_buttons(self):
|
||||||
self._dialog_buttons = QtGui.QHBoxLayout()
|
self._dialog_buttons = QtGui.QHBoxLayout()
|
||||||
self._okay = QtGui.QPushButton('Ok')
|
self._okay = QtGui.QPushButton('Ok')
|
||||||
self._close = QtGui.QPushButton('Close')
|
self._close = QtGui.QPushButton('Close')
|
||||||
self._apply = QtGui.QPushButton('Apply')
|
self._apply = QtGui.QPushButton('Apply')
|
||||||
self._dialog_buttons.addWidget(self._okay)
|
self._dialog_buttons.addWidget(self._okay)
|
||||||
@ -2593,7 +2660,7 @@ class PylotParaBox(QtGui.QWidget):
|
|||||||
continue
|
continue
|
||||||
box = self.boxes[param]
|
box = self.boxes[param]
|
||||||
value = self.parameter[param]
|
value = self.parameter[param]
|
||||||
#self.parameter.checkValue(param, value)
|
# self.parameter.checkValue(param, value)
|
||||||
self.setValue(box, value)
|
self.setValue(box, value)
|
||||||
|
|
||||||
def setValue(self, box, value):
|
def setValue(self, box, value):
|
||||||
@ -2681,18 +2748,19 @@ class PylotParaBox(QtGui.QWidget):
|
|||||||
|
|
||||||
|
|
||||||
class PropertiesDlg(QDialog):
|
class PropertiesDlg(QDialog):
|
||||||
def __init__(self, parent=None, infile=None):
|
def __init__(self, parent=None, infile=None, inputs=None):
|
||||||
super(PropertiesDlg, self).__init__(parent)
|
super(PropertiesDlg, self).__init__(parent)
|
||||||
|
|
||||||
self.infile = infile
|
self.infile = infile
|
||||||
|
self.inputs = inputs
|
||||||
|
|
||||||
self.setWindowTitle("PyLoT Properties")
|
self.setWindowTitle("PyLoT Properties")
|
||||||
self.tabWidget = QTabWidget()
|
self.tabWidget = QTabWidget()
|
||||||
self.tabWidget.addTab(InputsTab(self), "Inputs")
|
self.tabWidget.addTab(InputsTab(self), "Inputs")
|
||||||
#self.tabWidget.addTab(OutputsTab(self), "Outputs")
|
# self.tabWidget.addTab(OutputsTab(self), "Outputs")
|
||||||
self.tabWidget.addTab(PhasesTab(self), "Phases")
|
self.tabWidget.addTab(PhasesTab(self, inputs), "Phases")
|
||||||
self.tabWidget.addTab(GraphicsTab(self), "Graphics")
|
self.tabWidget.addTab(GraphicsTab(self), "Graphics")
|
||||||
#self.tabWidget.addTab(LocalisationTab(self), "Loc. Tools")
|
# self.tabWidget.addTab(LocalisationTab(self), "Loc. Tools")
|
||||||
self.tabWidget.addTab(LocalisationTab(self), "NonLinLoc")
|
self.tabWidget.addTab(LocalisationTab(self), "NonLinLoc")
|
||||||
self.tabWidget.addTab(ChannelOrderTab(self), "Channel Order")
|
self.tabWidget.addTab(ChannelOrderTab(self), "Channel Order")
|
||||||
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok |
|
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok |
|
||||||
@ -2712,7 +2780,7 @@ class PropertiesDlg(QDialog):
|
|||||||
self.buttonBox.button(QDialogButtonBox.RestoreDefaults).clicked.connect(self.restore)
|
self.buttonBox.button(QDialogButtonBox.RestoreDefaults).clicked.connect(self.restore)
|
||||||
|
|
||||||
def getinfile(self):
|
def getinfile(self):
|
||||||
return self.infile
|
return self.infile
|
||||||
|
|
||||||
def accept(self, *args, **kwargs):
|
def accept(self, *args, **kwargs):
|
||||||
self.apply()
|
self.apply()
|
||||||
@ -2752,7 +2820,6 @@ class PropertiesDlg(QDialog):
|
|||||||
for values in self._current_values():
|
for values in self._current_values():
|
||||||
self.setValues(values)
|
self.setValues(values)
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def setValues(tabValues):
|
def setValues(tabValues):
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
@ -2844,9 +2911,9 @@ class InputsTab(PropTab):
|
|||||||
para = PylotParameter(infile)
|
para = PylotParameter(infile)
|
||||||
datstruct = para.get('datastructure')
|
datstruct = para.get('datastructure')
|
||||||
if datstruct == 'SeisComp':
|
if datstruct == 'SeisComp':
|
||||||
index = 0
|
index = 0
|
||||||
else:
|
else:
|
||||||
index = 2
|
index = 2
|
||||||
datapath = para.get('datapath')
|
datapath = para.get('datapath')
|
||||||
rootpath = para.get('rootpath')
|
rootpath = para.get('rootpath')
|
||||||
database = para.get('database')
|
database = para.get('database')
|
||||||
@ -2858,6 +2925,7 @@ class InputsTab(PropTab):
|
|||||||
"data/Structure": self.structureSelect.setCurrentIndex(index)}
|
"data/Structure": self.structureSelect.setCurrentIndex(index)}
|
||||||
return values
|
return values
|
||||||
|
|
||||||
|
|
||||||
class OutputsTab(PropTab):
|
class OutputsTab(PropTab):
|
||||||
def __init__(self, parent=None, infile=None):
|
def __init__(self, parent=None, infile=None):
|
||||||
super(OutputsTab, self).__init__(parent)
|
super(OutputsTab, self).__init__(parent)
|
||||||
@ -2889,12 +2957,17 @@ class OutputsTab(PropTab):
|
|||||||
|
|
||||||
|
|
||||||
class PhasesTab(PropTab):
|
class PhasesTab(PropTab):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None, inputs=None):
|
||||||
super(PhasesTab, self).__init__(parent)
|
super(PhasesTab, self).__init__(parent)
|
||||||
|
self.inputs = inputs
|
||||||
|
|
||||||
|
self.Pphases = 'P, Pg, Pn, PmP, P1, P2, P3'
|
||||||
|
self.Sphases = 'S, Sg, Sn, SmS, S1, S2, S3'
|
||||||
|
|
||||||
self.PphasesEdit = QLineEdit()
|
self.PphasesEdit = QLineEdit()
|
||||||
self.SphasesEdit = QLineEdit()
|
self.SphasesEdit = QLineEdit()
|
||||||
|
|
||||||
|
self.pickDefaultsButton = QtGui.QPushButton('Choose default phases...')
|
||||||
PphasesLabel = QLabel("P Phases to pick")
|
PphasesLabel = QLabel("P Phases to pick")
|
||||||
SphasesLabel = QLabel("S Phases to pick")
|
SphasesLabel = QLabel("S Phases to pick")
|
||||||
|
|
||||||
@ -2905,24 +2978,96 @@ class PhasesTab(PropTab):
|
|||||||
self.PphasesEdit.setText("%s" % Pphases)
|
self.PphasesEdit.setText("%s" % Pphases)
|
||||||
self.SphasesEdit.setText("%s" % Sphases)
|
self.SphasesEdit.setText("%s" % Sphases)
|
||||||
|
|
||||||
|
self.main_layout = QtGui.QHBoxLayout()
|
||||||
layout = QGridLayout()
|
layout = QGridLayout()
|
||||||
layout.addWidget(PphasesLabel, 0, 0)
|
layout.addWidget(PphasesLabel, 0, 0)
|
||||||
layout.addWidget(SphasesLabel, 1, 0)
|
layout.addWidget(SphasesLabel, 1, 0)
|
||||||
|
|
||||||
layout.addWidget(self.PphasesEdit, 0, 1)
|
layout.addWidget(self.PphasesEdit, 0, 1)
|
||||||
layout.addWidget(self.SphasesEdit, 1, 1)
|
layout.addWidget(self.SphasesEdit, 1, 1)
|
||||||
self.setLayout(layout)
|
self.main_layout.addLayout(layout)
|
||||||
|
self.main_layout.addWidget(self.pickDefaultsButton)
|
||||||
|
self.setLayout(self.main_layout)
|
||||||
|
|
||||||
|
self.connectSignals()
|
||||||
|
|
||||||
|
def connectSignals(self):
|
||||||
|
self.pickDefaultsButton.clicked.connect(self.get_defaults)
|
||||||
|
|
||||||
|
def get_defaults(self):
|
||||||
|
phases = [p.strip() for p in self.Pphases.split(',')] + [s.strip() for s in self.Sphases.split(',')]
|
||||||
|
p_current = [p.strip() for p in self.PphasesEdit.text().split(',')]
|
||||||
|
s_current = [s.strip() for s in self.SphasesEdit.text().split(',')]
|
||||||
|
|
||||||
|
current_phases = p_current + s_current
|
||||||
|
if self.inputs:
|
||||||
|
parameter = self.inputs
|
||||||
|
if parameter.get('extent') == 'global':
|
||||||
|
# get all default phase names known to obspy.taup
|
||||||
|
# in a list
|
||||||
|
phases = get_phase_names('ttall')
|
||||||
|
phaseDefaults = PhaseDefaults(self, phase_defaults=phases,
|
||||||
|
current_phases=current_phases)
|
||||||
|
if phaseDefaults.exec_():
|
||||||
|
phase_dict = self.sortPhases(phaseDefaults.selected_phases)
|
||||||
|
p_phases=''
|
||||||
|
s_phases=''
|
||||||
|
for index, p in enumerate(phase_dict['P']):
|
||||||
|
p_phases += p
|
||||||
|
if not index == len(phase_dict['P']) - 1:
|
||||||
|
p_phases += ', '
|
||||||
|
for index, s in enumerate(phase_dict['S']):
|
||||||
|
s_phases += s
|
||||||
|
if not index == len(phase_dict['S']) - 1:
|
||||||
|
s_phases += ', '
|
||||||
|
self.PphasesEdit.setText(p_phases)
|
||||||
|
self.SphasesEdit.setText(s_phases)
|
||||||
|
|
||||||
|
def sortPhases(self, phases):
|
||||||
|
sorted_phases = {'P': [],
|
||||||
|
'S': []}
|
||||||
|
# suffix for phase name if not phase identified by last letter (P, p, etc.)
|
||||||
|
alt_PS = ['diff', 'n', 'g', '1', '2', '3'] # alternative suffix
|
||||||
|
for phase in phases:
|
||||||
|
self.loopIdentifyPhase(phase, alt_PS, sorted_phases)
|
||||||
|
return sorted_phases
|
||||||
|
|
||||||
|
def loopIdentifyPhase(self, phase, alt_PS, sorted_phases):
|
||||||
|
phase_copy = phase
|
||||||
|
while not self.identifyPhase(phase_copy):
|
||||||
|
identified = False
|
||||||
|
for alt_suf in alt_PS:
|
||||||
|
if phase_copy.endswith(alt_suf):
|
||||||
|
phase_copy = phase_copy.split(alt_suf)[0]
|
||||||
|
identified = True
|
||||||
|
if not identified:
|
||||||
|
phase_copy = phase_copy[:-1]
|
||||||
|
if len(phase_copy) < 1:
|
||||||
|
print('Warning: Could not identify phase {}!'.format(phase))
|
||||||
|
return
|
||||||
|
sorted_phases[self.identifyPhase(phase_copy)].append(phase)
|
||||||
|
|
||||||
|
def identifyPhase(self, phase):
|
||||||
|
# common phase suffix for P and S
|
||||||
|
common_P = ['P', 'p']
|
||||||
|
common_S = ['S', 's']
|
||||||
|
if phase[-1] in common_P:
|
||||||
|
return 'P'
|
||||||
|
if phase[-1] in common_S:
|
||||||
|
return 'S'
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
def getValues(self):
|
def getValues(self):
|
||||||
values = {'p_phases': self.PphasesEdit.text(),
|
p_phases = self.PphasesEdit.text()
|
||||||
's_phases': self.SphasesEdit.text()}
|
s_phases = self.SphasesEdit.text()
|
||||||
|
values = {'p_phases': p_phases,
|
||||||
|
's_phases': s_phases}
|
||||||
return values
|
return values
|
||||||
|
|
||||||
def resetValues(self, infile=None):
|
def resetValues(self, infile=None):
|
||||||
Pphases = 'P, Pg, Pn, PmP, P1, P2, P3'
|
values = {'p_phases': self.PphasesEdit.setText(self.Pphases),
|
||||||
Sphases = 'S, Sg, Sn, SmS, S1, S2, S3'
|
's_phases': self.SphasesEdit.setText(self.Sphases)}
|
||||||
values = {'p_phases': self.PphasesEdit.setText(Pphases),
|
|
||||||
's_phases': self.SphasesEdit.setText(Sphases)}
|
|
||||||
return values
|
return values
|
||||||
|
|
||||||
|
|
||||||
@ -3057,9 +3202,9 @@ class ChannelOrderTab(PropTab):
|
|||||||
"Channel E [east/west, default=2]": self.ChannelOrderEEdit.setText("%d" % Edefault)}
|
"Channel E [east/west, default=2]": self.ChannelOrderEEdit.setText("%d" % Edefault)}
|
||||||
return values
|
return values
|
||||||
|
|
||||||
# MP MP: No idea why this function exists!?
|
# MP MP: No idea why this function exists!?
|
||||||
# def getComponents(self):
|
# def getComponents(self):
|
||||||
# self.CompName = dict(Z='10', N='11', E='12')
|
# self.CompName = dict(Z='10', N='11', E='12')
|
||||||
|
|
||||||
|
|
||||||
class LocalisationTab(PropTab):
|
class LocalisationTab(PropTab):
|
||||||
@ -3069,14 +3214,14 @@ class LocalisationTab(PropTab):
|
|||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
curtool = settings.value("loc/tool", None)
|
curtool = settings.value("loc/tool", None)
|
||||||
|
|
||||||
#loctoollabel = QLabel("location tool")
|
# loctoollabel = QLabel("location tool")
|
||||||
self.locToolComboBox = QComboBox()
|
self.locToolComboBox = QComboBox()
|
||||||
#loctools = LOCTOOLS.keys()
|
# loctools = LOCTOOLS.keys()
|
||||||
#self.locToolComboBox.addItems(loctools)
|
# self.locToolComboBox.addItems(loctools)
|
||||||
|
|
||||||
#toolind = findComboBoxIndex(self.locToolComboBox, curtool)
|
# toolind = findComboBoxIndex(self.locToolComboBox, curtool)
|
||||||
|
|
||||||
#self.locToolComboBox.setCurrentIndex(toolind)
|
# self.locToolComboBox.setCurrentIndex(toolind)
|
||||||
|
|
||||||
curroot = settings.value("{0}/rootPath".format(curtool), None)
|
curroot = settings.value("{0}/rootPath".format(curtool), None)
|
||||||
curbin = settings.value("{0}/binPath".format(curtool), None)
|
curbin = settings.value("{0}/binPath".format(curtool), None)
|
||||||
@ -3098,13 +3243,13 @@ class LocalisationTab(PropTab):
|
|||||||
binBrowse = QPushButton('...', self)
|
binBrowse = QPushButton('...', self)
|
||||||
binBrowse.clicked.connect(lambda: self.selectDirectory(self.binedit))
|
binBrowse.clicked.connect(lambda: self.selectDirectory(self.binedit))
|
||||||
|
|
||||||
#self.locToolComboBox.currentIndexChanged.connect(self.updateUi)
|
# self.locToolComboBox.currentIndexChanged.connect(self.updateUi)
|
||||||
|
|
||||||
self.updateUi()
|
self.updateUi()
|
||||||
|
|
||||||
layout = QGridLayout()
|
layout = QGridLayout()
|
||||||
#layout.addWidget(loctoollabel, 0, 0)
|
# layout.addWidget(loctoollabel, 0, 0)
|
||||||
#layout.addWidget(self.locToolComboBox, 0, 1)
|
# layout.addWidget(self.locToolComboBox, 0, 1)
|
||||||
layout.addWidget(self.rootlabel, 1, 0)
|
layout.addWidget(self.rootlabel, 1, 0)
|
||||||
layout.addWidget(self.rootedit, 1, 1)
|
layout.addWidget(self.rootedit, 1, 1)
|
||||||
layout.addWidget(rootBrowse, 1, 2)
|
layout.addWidget(rootBrowse, 1, 2)
|
||||||
@ -3116,7 +3261,7 @@ class LocalisationTab(PropTab):
|
|||||||
|
|
||||||
def updateUi(self):
|
def updateUi(self):
|
||||||
curtool = self.locToolComboBox.currentText()
|
curtool = self.locToolComboBox.currentText()
|
||||||
#if curtool is not None:
|
# if curtool is not None:
|
||||||
self.rootlabel.setText("{0} root directory".format(curtool))
|
self.rootlabel.setText("{0} root directory".format(curtool))
|
||||||
self.binlabel.setText("{0} bin directory".format(curtool))
|
self.binlabel.setText("{0} bin directory".format(curtool))
|
||||||
|
|
||||||
@ -3130,7 +3275,7 @@ class LocalisationTab(PropTab):
|
|||||||
loctool = self.locToolComboBox.currentText()
|
loctool = self.locToolComboBox.currentText()
|
||||||
values = {"{0}/rootPath".format(loctool): self.rootedit.text(),
|
values = {"{0}/rootPath".format(loctool): self.rootedit.text(),
|
||||||
"{0}/binPath".format(loctool): self.binedit.text()}
|
"{0}/binPath".format(loctool): self.binedit.text()}
|
||||||
#"loc/tool": loctool}
|
# "loc/tool": loctool}
|
||||||
return values
|
return values
|
||||||
|
|
||||||
def resetValues(self, infile):
|
def resetValues(self, infile):
|
||||||
|
Loading…
Reference in New Issue
Block a user