Re-Added local changes that had been lost due to technical problems ( no access to old machine )
This commit is contained in:
parent
2d33a60421
commit
0c3fca9299
55
PyLoT.py
55
PyLoT.py
@ -60,7 +60,7 @@ except ImportError:
|
|||||||
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
|
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
|
||||||
from matplotlib.figure import Figure
|
from matplotlib.figure import Figure
|
||||||
|
|
||||||
from pylot.core.analysis.magnitude import LocalMagnitude, MomentMagnitude
|
from pylot.core.analysis.magnitude import LocalMagnitude, MomentMagnitude, calcsourcespec
|
||||||
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 autoPyLoT import autoPyLoT
|
from autoPyLoT import autoPyLoT
|
||||||
@ -83,7 +83,8 @@ from pylot.core.io.location import create_creation_info, create_event
|
|||||||
from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \
|
from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \
|
||||||
PylotCanvas, WaveformWidgetPG, PropertiesDlg, HelpForm, createAction, PickDlg, \
|
PylotCanvas, WaveformWidgetPG, PropertiesDlg, HelpForm, createAction, PickDlg, \
|
||||||
ComparisonWidget, TuneAutopicker, PylotParaBox, AutoPickDlg, CanvasWidget, AutoPickWidget, \
|
ComparisonWidget, TuneAutopicker, PylotParaBox, AutoPickDlg, CanvasWidget, AutoPickWidget, \
|
||||||
CompareEventsWidget, ProgressBarWidget, AddMetadataWidget, SingleTextLineDialog, LogWidget
|
CompareEventsWidget, ProgressBarWidget, AddMetadataWidget, SingleTextLineDialog, LogWidget, PickQualitiesFromXml, \
|
||||||
|
SourceSpecWindow, ChooseWaveFormWindow
|
||||||
from pylot.core.util.array_map import Array_map
|
from pylot.core.util.array_map import Array_map
|
||||||
from pylot.core.util.structure import DATASTRUCTURE
|
from pylot.core.util.structure import DATASTRUCTURE
|
||||||
from pylot.core.util.thread import Thread, Worker
|
from pylot.core.util.thread import Thread, Worker
|
||||||
@ -734,11 +735,22 @@ class MainWindow(QMainWindow):
|
|||||||
if use_logwidget:
|
if use_logwidget:
|
||||||
self.logwidget = LogWidget(parent=None)
|
self.logwidget = LogWidget(parent=None)
|
||||||
self.logwidget.show()
|
self.logwidget.show()
|
||||||
sys.stdout = self.logwidget.stdout
|
self.stdout = self.logwidget.stdout
|
||||||
sys.stderr = self.logwidget.stderr
|
self.stderr = self.logwidget.stderr
|
||||||
|
|
||||||
|
sys.stdout = self.stdout
|
||||||
|
sys.stderr = self.stderr
|
||||||
|
|
||||||
|
# Not sure why but the lines above kept messing with the Ouput even with use_logwidget disabled
|
||||||
|
sys.stdout = self.stdout
|
||||||
|
sys.stderr = self.stderr
|
||||||
|
|
||||||
self.setCentralWidget(_widget)
|
self.setCentralWidget(_widget)
|
||||||
|
|
||||||
|
# Need to store PickQualities Window somewhere so it doesnt disappear
|
||||||
|
self.pickQualitiesWindow = None
|
||||||
|
|
||||||
|
|
||||||
def init_wfWidget(self):
|
def init_wfWidget(self):
|
||||||
xlab = self.startTime.strftime('seconds since %Y/%m/%d %H:%M:%S (%Z)')
|
xlab = self.startTime.strftime('seconds since %Y/%m/%d %H:%M:%S (%Z)')
|
||||||
plottitle = None # "Overview: {0} components ".format(self.getComponent())
|
plottitle = None # "Overview: {0} components ".format(self.getComponent())
|
||||||
@ -1667,15 +1679,41 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
def pickQualities(self):
|
def pickQualities(self):
|
||||||
path = self.get_current_event_path()
|
path = self.get_current_event_path()
|
||||||
getQualitiesfromxml(path, self._inputs.get('timeerrorsP'), self._inputs.get('timeerrorsS'), plotflag=1)
|
(_, _, plot) = getQualitiesfromxml(path, self._inputs.get('timeerrorsP'), self._inputs.get('timeerrorsS'),plotflag=1)
|
||||||
|
self.pickQualitiesWindow = PickQualitiesFromXml(figure=plot, path=self.get_current_event_path(),inputVar=self._inputs)
|
||||||
|
self.pickQualitiesWindow.showUI()
|
||||||
return
|
return
|
||||||
|
|
||||||
def eventlistXml(self):
|
# WIP JG
|
||||||
|
def eventlistXml2(self):
|
||||||
path = self._inputs['rootpath'] + '/' + self._inputs['datapath'] + '/' + self._inputs['database']
|
path = self._inputs['rootpath'] + '/' + self._inputs['datapath'] + '/' + self._inputs['database']
|
||||||
outpath = self.project.location[:self.project.location.rfind('/')]
|
outpath = self.project.location[:self.project.location.rfind('/')]
|
||||||
geteventlistfromxml(path, outpath)
|
geteventlistfromxml(path, outpath)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# WIP JG
|
||||||
|
def eventlistXml(self):
|
||||||
|
global test
|
||||||
|
stations = []
|
||||||
|
names = []
|
||||||
|
traces = {}
|
||||||
|
for tr in self.get_data().wfdata.traces:
|
||||||
|
if not tr.stats.station in stations:
|
||||||
|
stations.append(tr.stats.station)
|
||||||
|
names.append(tr.stats.network + '.' + tr.stats.station)
|
||||||
|
for station in stations:
|
||||||
|
traces[station] = {}
|
||||||
|
for ch in ['Z', 'N', 'E']:
|
||||||
|
for tr in self.get_data().wfdata.select(component=ch).traces:
|
||||||
|
traces[tr.stats.station][ch] = tr
|
||||||
|
|
||||||
|
|
||||||
|
names.sort()
|
||||||
|
a = self.get_current_event()
|
||||||
|
test = ChooseWaveFormWindow(WaveForms=names, traces=traces, stream=self.get_data())
|
||||||
|
#self.get_data().wfdata.spectrogram()
|
||||||
|
test.show()
|
||||||
|
|
||||||
def compareMulti(self):
|
def compareMulti(self):
|
||||||
if not self.compareoptions:
|
if not self.compareoptions:
|
||||||
return
|
return
|
||||||
@ -3070,11 +3108,13 @@ class MainWindow(QMainWindow):
|
|||||||
lt = locateTool[loctool]
|
lt = locateTool[loctool]
|
||||||
# get working directory
|
# get working directory
|
||||||
locroot = parameter['nllocroot']
|
locroot = parameter['nllocroot']
|
||||||
|
#locroot = 'E:/NLL/src/Insheim'
|
||||||
if locroot is None:
|
if locroot is None:
|
||||||
self.PyLoTprefs()
|
self.PyLoTprefs()
|
||||||
self.locate_event()
|
self.locate_event()
|
||||||
|
|
||||||
ctrfile = os.path.join(locroot, 'run', parameter['ctrfile'])
|
ctrfile = os.path.join(locroot, 'run', parameter['ctrfile'])
|
||||||
|
#ctrfile = 'E:/NLL/src/Insheim/run/Insheim_min1d032016.in'
|
||||||
ttt = parameter['ttpatter']
|
ttt = parameter['ttpatter']
|
||||||
outfile = parameter['outpatter']
|
outfile = parameter['outpatter']
|
||||||
eventname = self.get_current_event_name()
|
eventname = self.get_current_event_name()
|
||||||
@ -3085,7 +3125,7 @@ class MainWindow(QMainWindow):
|
|||||||
phasefile = os.path.join(obsdir, filename + '.obs')
|
phasefile = os.path.join(obsdir, filename + '.obs')
|
||||||
lt.modify_inputs(ctrfile, locroot, filename, phasefile, ttt)
|
lt.modify_inputs(ctrfile, locroot, filename, phasefile, ttt)
|
||||||
try:
|
try:
|
||||||
lt.locate(ctrfile, self._inputs)
|
lt.locate(ctrfile, self.obspy_dmt)
|
||||||
except RuntimeError as e:
|
except RuntimeError as e:
|
||||||
print(e.message)
|
print(e.message)
|
||||||
# finally:
|
# finally:
|
||||||
@ -3487,6 +3527,7 @@ class MainWindow(QMainWindow):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
wf_copy = self.get_data().getWFData().copy()
|
wf_copy = self.get_data().getWFData().copy()
|
||||||
|
|
||||||
wf_select = Stream()
|
wf_select = Stream()
|
||||||
# restitute only picked traces
|
# restitute only picked traces
|
||||||
for station in np.unique(list(self.getPicks('manual').keys()) + list(self.getPicks('auto').keys())):
|
for station in np.unique(list(self.getPicks('manual').keys()) + list(self.getPicks('auto').keys())):
|
||||||
|
BIN
icons/eventlist_xml_button.png
Normal file
BIN
icons/eventlist_xml_button.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
icons/pick_qualities_button.png
Normal file
BIN
icons/pick_qualities_button.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
218853
icons_rc_3.py
218853
icons_rc_3.py
File diff suppressed because it is too large
Load Diff
@ -436,6 +436,40 @@ class MomentMagnitude(Magnitude):
|
|||||||
self.event.station_magnitudes.append(magnitude)
|
self.event.station_magnitudes.append(magnitude)
|
||||||
self.magnitudes = (station, magnitude)
|
self.magnitudes = (station, magnitude)
|
||||||
|
|
||||||
|
# WIP JG
|
||||||
|
def getSourceSpec(self):
|
||||||
|
for a in self.arrivals:
|
||||||
|
if a.phase not in 'pP':
|
||||||
|
continue
|
||||||
|
# make sure calculating Mo only from reliable onsets
|
||||||
|
# NLLoc: time_weight = 0 => do not use onset!
|
||||||
|
if a.time_weight == 0:
|
||||||
|
continue
|
||||||
|
pick = a.pick_id.get_referred_object()
|
||||||
|
station = pick.waveform_id.station_code
|
||||||
|
if len(self.stream) <= 2:
|
||||||
|
print("Station:" '{0}'.format(station))
|
||||||
|
print("WARNING: No instrument corrected data available,"
|
||||||
|
" no magnitude calculation possible! Go on.")
|
||||||
|
continue
|
||||||
|
wf = self.stream.select(station=station)
|
||||||
|
if not wf:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
scopy = wf.copy()
|
||||||
|
except AssertionError:
|
||||||
|
print("WARNING: Something's wrong with the data,"
|
||||||
|
"station {},"
|
||||||
|
"no calculation of moment magnitude possible! Go on.".format(station))
|
||||||
|
continue
|
||||||
|
onset = pick.time
|
||||||
|
distance = degrees2kilometers(a.distance)
|
||||||
|
azimuth = a.azimuth
|
||||||
|
incidence = a.takeoff_angle
|
||||||
|
w0, fc, plt = calcsourcespec(scopy, onset, self.p_velocity, distance,
|
||||||
|
azimuth, incidence, self.p_attenuation,
|
||||||
|
3, self.verbose)
|
||||||
|
return w0, fc, plt
|
||||||
|
|
||||||
def calcMoMw(wfstream, w0, rho, vp, delta, verbosity=False):
|
def calcMoMw(wfstream, w0, rho, vp, delta, verbosity=False):
|
||||||
'''
|
'''
|
||||||
@ -683,6 +717,8 @@ def calcsourcespec(wfstream, onset, vp, delta, azimuth, incidence,
|
|||||||
plt.xlabel('Frequency [Hz]')
|
plt.xlabel('Frequency [Hz]')
|
||||||
plt.ylabel('Amplitude [m/Hz]')
|
plt.ylabel('Amplitude [m/Hz]')
|
||||||
plt.grid()
|
plt.grid()
|
||||||
|
if iplot == 3:
|
||||||
|
return w0, Fc, plt
|
||||||
plt.show()
|
plt.show()
|
||||||
try:
|
try:
|
||||||
input()
|
input()
|
||||||
|
@ -16,10 +16,9 @@ autoregressive prediction: application ot local and regional distances, Geophys.
|
|||||||
|
|
||||||
:author: MAGS2 EP3 working group
|
:author: MAGS2 EP3 working group
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from obspy.core import Stream
|
|
||||||
from scipy import signal
|
from scipy import signal
|
||||||
|
from obspy.core import Stream
|
||||||
|
|
||||||
|
|
||||||
class CharacteristicFunction(object):
|
class CharacteristicFunction(object):
|
||||||
@ -259,7 +258,7 @@ class HOScf(CharacteristicFunction):
|
|||||||
"""
|
"""
|
||||||
Function to calculate skewness (statistics of order 3) or kurtosis
|
Function to calculate skewness (statistics of order 3) or kurtosis
|
||||||
(statistics of order 4), using one long moving window, as published
|
(statistics of order 4), using one long moving window, as published
|
||||||
in Kueperkoch et al. (2010).
|
in Kueperkoch et al. (2010), or order 2, i.e. STA/LTA.
|
||||||
:param data: data, time series (whether seismogram or CF)
|
:param data: data, time series (whether seismogram or CF)
|
||||||
:type data: tuple
|
:type data: tuple
|
||||||
:return: HOS cf
|
:return: HOS cf
|
||||||
@ -276,28 +275,47 @@ class HOScf(CharacteristicFunction):
|
|||||||
elif self.getOrder() == 4: # this is kurtosis
|
elif self.getOrder() == 4: # this is kurtosis
|
||||||
y = np.power(xnp, 4)
|
y = np.power(xnp, 4)
|
||||||
y1 = np.power(xnp, 2)
|
y1 = np.power(xnp, 2)
|
||||||
|
elif self.getOrder() == 2: # this is variance, used for STA/LTA processing
|
||||||
|
y = np.power(xnp, 2)
|
||||||
|
y1 = np.power(xnp, 2)
|
||||||
|
|
||||||
# Initialisation
|
# Initialisation
|
||||||
# t2: long term moving window
|
# t2: long term moving window
|
||||||
ilta = int(round(self.getTime2() / self.getIncrement()))
|
ilta = int(round(self.getTime2() / self.getIncrement()))
|
||||||
|
ista = int(round((self.getTime2() / 10) / self.getIncrement())) # TODO: still hard coded!!
|
||||||
lta = y[0]
|
lta = y[0]
|
||||||
lta1 = y1[0]
|
lta1 = y1[0]
|
||||||
|
sta = y[0]
|
||||||
# moving windows
|
# moving windows
|
||||||
LTA = np.zeros(len(xnp))
|
LTA = np.zeros(len(xnp))
|
||||||
|
STA = np.zeros(len(xnp))
|
||||||
for j in range(0, len(xnp)):
|
for j in range(0, len(xnp)):
|
||||||
if j < 4:
|
if j < 4:
|
||||||
LTA[j] = 0
|
LTA[j] = 0
|
||||||
|
STA[j] = 0
|
||||||
|
elif j <= ista:
|
||||||
|
lta = (y[j] + lta * (j - 1)) / j
|
||||||
|
if self.getOrder() == 2:
|
||||||
|
sta = (y[j] + sta * (j - 1)) / j
|
||||||
|
# elif j < 4:
|
||||||
elif j <= ilta:
|
elif j <= ilta:
|
||||||
lta = (y[j] + lta * (j - 1)) / j
|
lta = (y[j] + lta * (j - 1)) / j
|
||||||
lta1 = (y1[j] + lta1 * (j - 1)) / j
|
lta1 = (y1[j] + lta1 * (j - 1)) / j
|
||||||
|
if self.getOrder() == 2:
|
||||||
|
sta = (y[j] - y[j - ista]) / ista + sta
|
||||||
else:
|
else:
|
||||||
lta = (y[j] - y[j - ilta]) / ilta + lta
|
lta = (y[j] - y[j - ilta]) / ilta + lta
|
||||||
lta1 = (y1[j] - y1[j - ilta]) / ilta + lta1
|
lta1 = (y1[j] - y1[j - ilta]) / ilta + lta1
|
||||||
|
if self.getOrder() == 2:
|
||||||
|
sta = (y[j] - y[j - ista]) / ista + sta
|
||||||
# define LTA
|
# define LTA
|
||||||
if self.getOrder() == 3:
|
if self.getOrder() == 3:
|
||||||
LTA[j] = lta / np.power(lta1, 1.5)
|
LTA[j] = lta / np.power(lta1, 1.5)
|
||||||
elif self.getOrder() == 4:
|
elif self.getOrder() == 4:
|
||||||
LTA[j] = lta / np.power(lta1, 2)
|
LTA[j] = lta / np.power(lta1, 2)
|
||||||
|
else:
|
||||||
|
LTA[j] = lta
|
||||||
|
STA[j] = sta
|
||||||
|
|
||||||
# remove NaN's with first not-NaN-value,
|
# remove NaN's with first not-NaN-value,
|
||||||
# so autopicker doesnt pick discontinuity at start of the trace
|
# so autopicker doesnt pick discontinuity at start of the trace
|
||||||
@ -306,7 +324,10 @@ class HOScf(CharacteristicFunction):
|
|||||||
first = ind[0]
|
first = ind[0]
|
||||||
LTA[:first] = LTA[first]
|
LTA[:first] = LTA[first]
|
||||||
|
|
||||||
|
if self.getOrder() > 2:
|
||||||
self.cf = LTA
|
self.cf = LTA
|
||||||
|
else: # order 2 means STA/LTA!
|
||||||
|
self.cf = STA / LTA
|
||||||
self.xcf = x
|
self.xcf = x
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""
|
"""
|
||||||
Created on Wed Mar 19 11:27:35 2014
|
Created on Wed Mar 19 11:27:35 2014
|
||||||
|
|
||||||
@author: sebastianw
|
@author: sebastianw
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -3161,7 +3160,6 @@ class CanvasWidget(QWidget):
|
|||||||
class MultiEventWidget(QWidget):
|
class MultiEventWidget(QWidget):
|
||||||
start = Signal()
|
start = Signal()
|
||||||
'''
|
'''
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def __init__(self, options=None, parent=None, windowflag=Qt.Window):
|
def __init__(self, options=None, parent=None, windowflag=Qt.Window):
|
||||||
@ -3438,7 +3436,6 @@ class TuneAutopicker(QWidget):
|
|||||||
update = QtCore.Signal(str)
|
update = QtCore.Signal(str)
|
||||||
'''
|
'''
|
||||||
QWidget used to modifiy and test picking parameters for autopicking algorithm.
|
QWidget used to modifiy and test picking parameters for autopicking algorithm.
|
||||||
|
|
||||||
:param: parent
|
:param: parent
|
||||||
:type: PyLoT Mainwindow
|
:type: PyLoT Mainwindow
|
||||||
'''
|
'''
|
||||||
@ -3959,10 +3956,8 @@ class PylotParaBox(QtWidgets.QWidget):
|
|||||||
def __init__(self, parameter, parent=None, windowflag=Qt.Window):
|
def __init__(self, parameter, parent=None, windowflag=Qt.Window):
|
||||||
'''
|
'''
|
||||||
Generate Widget containing parameters for PyLoT.
|
Generate Widget containing parameters for PyLoT.
|
||||||
|
|
||||||
:param: parameter
|
:param: parameter
|
||||||
:type: PylotParameter (object)
|
:type: PylotParameter (object)
|
||||||
|
|
||||||
'''
|
'''
|
||||||
QtWidgets.QWidget.__init__(self, parent, windowflag)
|
QtWidgets.QWidget.__init__(self, parent, windowflag)
|
||||||
self.parameter = parameter
|
self.parameter = parameter
|
||||||
@ -5561,6 +5556,164 @@ class HelpForm(QDialog):
|
|||||||
self.pageLabel.setText(self.webBrowser.title())
|
self.pageLabel.setText(self.webBrowser.title())
|
||||||
|
|
||||||
|
|
||||||
|
class PickQualitiesFromXml(QWidget):
|
||||||
|
"""
|
||||||
|
PyLoT widget PickQualitiesFromXml is a QWidget object. It is an UI that enables the user
|
||||||
|
to create a plot showing the pick qualities in the event selected inside the QComboBox created
|
||||||
|
by this Widget. The user can also choose to select all Events.
|
||||||
|
The plot is being shown by a FigureCanvas from matlplotlib.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, parent=None, figure=Figure(), path="", inputVar=None):
|
||||||
|
super(PickQualitiesFromXml, self).__init__(parent)
|
||||||
|
|
||||||
|
self.fig = figure
|
||||||
|
self.chooseBox = QComboBox()
|
||||||
|
self.path = path
|
||||||
|
self.inputs = inputVar
|
||||||
|
self.setupUi()
|
||||||
|
|
||||||
|
def setupUi(self):
|
||||||
|
self.setWindowTitle("Get pick qualities from xml files")
|
||||||
|
self.main_layout = QtWidgets.QVBoxLayout()
|
||||||
|
self.figureC = FigureCanvas(self.fig)
|
||||||
|
self.chooseBox = self.createComboBox()
|
||||||
|
if self.chooseBox:
|
||||||
|
self.main_layout.addWidget(self.chooseBox)
|
||||||
|
self.main_layout.addWidget(self.figureC)
|
||||||
|
self.setLayout(self.main_layout)
|
||||||
|
|
||||||
|
def showUI(self):
|
||||||
|
self.show()
|
||||||
|
|
||||||
|
# Creates a QComboBox and adds all events in the current folder as options. Also gives the option to choose all events
|
||||||
|
def createComboBox(self):
|
||||||
|
self.chooseBox.addItems(glob.glob(os.path.join(os.path.dirname(self.path) + "/*/", '*.xml')))
|
||||||
|
self.chooseBox.addItem("All")
|
||||||
|
self.chooseBox.currentIndexChanged.connect(self.selectionChanged)
|
||||||
|
self.chooseBox.setCurrentIndex(self.chooseBox.count() - 1)
|
||||||
|
return self.chooseBox
|
||||||
|
|
||||||
|
# Function that gets called when the user changes the current selection in the QComboBox. Redraws the plot with the new data
|
||||||
|
def selectionChanged(self):
|
||||||
|
self.figureC.setParent(None)
|
||||||
|
if self.chooseBox.currentIndex() == self.chooseBox.count() - 1:
|
||||||
|
(_, _, plot) = getQualitiesfromxml(self.path, self.inputs.get('timeerrorsP'),
|
||||||
|
self.inputs.get('timeerrorsS'), plotflag=1)
|
||||||
|
self.figureC = FigureCanvas(plot)
|
||||||
|
else:
|
||||||
|
(_, _, plot) = getQualitiesfromxml(self.path, self.inputs.get('timeerrorsP'),
|
||||||
|
self.inputs.get('timeerrorsS'), plotflag=1,
|
||||||
|
xmlnames=[self.chooseBox.currentText()])
|
||||||
|
self.figureC = FigureCanvas(plot)
|
||||||
|
self.figureC.draw()
|
||||||
|
self.main_layout.addWidget(self.figureC)
|
||||||
|
self.setLayout(self.main_layout)
|
||||||
|
|
||||||
|
|
||||||
|
class SourceSpecWindow(QWidget):
|
||||||
|
def __init__(self, parent=None, figure=Figure()):
|
||||||
|
super(SourceSpecWindow, self).__init__(parent)
|
||||||
|
self.main_layout = QVBoxLayout()
|
||||||
|
self.setWindowTitle("Display source spectrum from selected trace")
|
||||||
|
self.fig = figure
|
||||||
|
|
||||||
|
def setupUi(self):
|
||||||
|
self.figureC = FigureCanvas(self.fig)
|
||||||
|
self.main_layout.addWidget(self.figureC)
|
||||||
|
self.setLayout(self.main_layout)
|
||||||
|
|
||||||
|
|
||||||
|
class ChooseWaveFormWindow(QWidget):
|
||||||
|
def __init__(self, parent=None, WaveForms=[], traces=[], stream=None, chooseB=False):
|
||||||
|
super(ChooseWaveFormWindow, self).__init__(parent)
|
||||||
|
self.main_layout = QVBoxLayout()
|
||||||
|
self.setWindowTitle("Choose trace to display source spectrum")
|
||||||
|
self.wFs = WaveForms
|
||||||
|
self.chooseBoxTraces = QComboBox()
|
||||||
|
self.chooseBoxComponent = QComboBox()
|
||||||
|
self.submitButton = QPushButton(text='test')
|
||||||
|
|
||||||
|
self.chooseB = chooseB
|
||||||
|
|
||||||
|
self.verticalButton = QPushButton(text='Z')
|
||||||
|
self.northButton = QPushButton(text='N')
|
||||||
|
self.eastButton = QPushButton(text='E')
|
||||||
|
self.component = ''
|
||||||
|
|
||||||
|
self.traces = traces
|
||||||
|
self.stream = stream
|
||||||
|
self.setupUI()
|
||||||
|
self.currentSpectro = Figure()
|
||||||
|
|
||||||
|
def setupUI(self):
|
||||||
|
self.submitButton.clicked.connect(self.submit)
|
||||||
|
self.createComboBoxTraces()
|
||||||
|
self.main_layout.addWidget(self.chooseBoxTraces)
|
||||||
|
|
||||||
|
if self.chooseB:
|
||||||
|
self.createComboBoxComponent()
|
||||||
|
self.main_layout.addWidget(self.submitButton)
|
||||||
|
self.main_layout.addWidget(self.chooseBoxComponent)
|
||||||
|
else:
|
||||||
|
self.createButtonsComponent()
|
||||||
|
|
||||||
|
self.setLayout(self.main_layout)
|
||||||
|
|
||||||
|
def submit(self):
|
||||||
|
matplotlib.pyplot.close(self.currentSpectro)
|
||||||
|
t = self.chooseBoxTraces.currentText() + " " + self.chooseBoxComponent.currentText()
|
||||||
|
self.currentSpectro = self.traces[
|
||||||
|
self.chooseBoxTraces.currentText()[3:]][self.chooseBoxComponent.currentText()].spectrogram(show=False, title=t)
|
||||||
|
self.currentSpectro.show()
|
||||||
|
|
||||||
|
def submitN(self):
|
||||||
|
matplotlib.pyplot.close(self.currentSpectro)
|
||||||
|
t = self.chooseBoxTraces.currentText() + " " + self.chooseBoxComponent.currentText()
|
||||||
|
self.currentSpectro = self.traces[
|
||||||
|
self.chooseBoxTraces.currentText()[3:]]['N'].spectrogram(show=False, title=t)
|
||||||
|
self.currentSpectro.show()
|
||||||
|
|
||||||
|
def submitE(self):
|
||||||
|
matplotlib.pyplot.close(self.currentSpectro)
|
||||||
|
t = self.chooseBoxTraces.currentText() + " " + self.chooseBoxComponent.currentText()
|
||||||
|
self.currentSpectro = self.traces[
|
||||||
|
self.chooseBoxTraces.currentText()[3:]]['E'].spectrogram(show=False, title=t)
|
||||||
|
self.currentSpectro.show()
|
||||||
|
|
||||||
|
def submitZ(self):
|
||||||
|
matplotlib.pyplot.close(self.currentSpectro)
|
||||||
|
t = self.chooseBoxTraces.currentText() + " " + self.chooseBoxComponent.currentText()
|
||||||
|
self.currentSpectro = self.traces[
|
||||||
|
self.chooseBoxTraces.currentText()[3:]]['Z'].spectrogram(show=False, title=t)
|
||||||
|
self.currentSpectro.show()
|
||||||
|
|
||||||
|
# Creates a QComboBox and adds all traces provided
|
||||||
|
def createComboBoxTraces(self):
|
||||||
|
if len(self.wFs) <= 0:
|
||||||
|
raise 'No traces provided'
|
||||||
|
self.chooseBoxTraces.addItems(self.wFs)
|
||||||
|
self.chooseBoxTraces.currentIndexChanged.connect(self.selectionChanged)
|
||||||
|
self.chooseBoxTraces.setCurrentIndex(0)
|
||||||
|
return self.chooseBoxTraces
|
||||||
|
|
||||||
|
def createButtonsComponent(self):
|
||||||
|
self.northButton.clicked.connect(self.submitN)
|
||||||
|
self.eastButton.clicked.connect(self.submitE)
|
||||||
|
self.verticalButton.clicked.connect(self.submitZ)
|
||||||
|
|
||||||
|
self.main_layout.addWidget(self.verticalButton)
|
||||||
|
self.main_layout.addWidget(self.northButton)
|
||||||
|
self.main_layout.addWidget(self.eastButton)
|
||||||
|
|
||||||
|
def createComboBoxComponent(self):
|
||||||
|
self.chooseBoxComponent.addItems(['Z', 'N', 'E'])
|
||||||
|
|
||||||
|
# Function that gets called when the user changes the current selection in the QComboBox.
|
||||||
|
def selectionChanged(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import doctest
|
import doctest
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user