[cleanup] add @staticmethod, some other stuff
This commit is contained in:
parent
d151cdbc6d
commit
415af11f63
18
PyLoT.py
18
PyLoT.py
@ -860,7 +860,8 @@ class MainWindow(QMainWindow):
|
|||||||
def inputs(self):
|
def inputs(self):
|
||||||
return self._inputs
|
return self._inputs
|
||||||
|
|
||||||
def getRoot(self):
|
@staticmethod
|
||||||
|
def getRoot():
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
return settings.value("data/dataRoot")
|
return settings.value("data/dataRoot")
|
||||||
|
|
||||||
@ -1022,7 +1023,8 @@ class MainWindow(QMainWindow):
|
|||||||
raise DatastructureError('not specified')
|
raise DatastructureError('not specified')
|
||||||
return fnames
|
return fnames
|
||||||
|
|
||||||
def getPhaseID(self, phase):
|
@staticmethod
|
||||||
|
def getPhaseID(phase):
|
||||||
return identifyPhaseID(phase)
|
return identifyPhaseID(phase)
|
||||||
|
|
||||||
def get_current_event(self, eventbox=None):
|
def get_current_event(self, eventbox=None):
|
||||||
@ -1150,7 +1152,8 @@ class MainWindow(QMainWindow):
|
|||||||
self.project.remove_event(event)
|
self.project.remove_event(event)
|
||||||
self.init_events(True)
|
self.init_events(True)
|
||||||
|
|
||||||
def createEventBox(self):
|
@staticmethod
|
||||||
|
def createEventBox():
|
||||||
'''
|
'''
|
||||||
Eventbox generator.
|
Eventbox generator.
|
||||||
'''
|
'''
|
||||||
@ -1926,7 +1929,8 @@ class MainWindow(QMainWindow):
|
|||||||
self.compare_action.setEnabled(True)
|
self.compare_action.setEnabled(True)
|
||||||
self.draw()
|
self.draw()
|
||||||
|
|
||||||
def checkEvent4comparison(self, event):
|
@staticmethod
|
||||||
|
def checkEvent4comparison(event):
|
||||||
if event.pylot_picks and event.pylot_autopicks:
|
if event.pylot_picks and event.pylot_autopicks:
|
||||||
for station in event.pylot_picks:
|
for station in event.pylot_picks:
|
||||||
if station in event.pylot_autopicks:
|
if station in event.pylot_autopicks:
|
||||||
@ -2560,13 +2564,15 @@ class MainWindow(QMainWindow):
|
|||||||
if event.pylot_id == eventID:
|
if event.pylot_id == eventID:
|
||||||
return event
|
return event
|
||||||
|
|
||||||
def get_event_paths(self, eventlist):
|
@staticmethod
|
||||||
|
def get_event_paths(eventlist):
|
||||||
eventPaths = []
|
eventPaths = []
|
||||||
for event in eventlist:
|
for event in eventlist:
|
||||||
eventPaths.append(event.path)
|
eventPaths.append(event.path)
|
||||||
return eventPaths
|
return eventPaths
|
||||||
|
|
||||||
def get_event_ids(self, eventlist):
|
@staticmethod
|
||||||
|
def get_event_ids(eventlist):
|
||||||
eventIDs = []
|
eventIDs = []
|
||||||
for event in eventlist:
|
for event in eventlist:
|
||||||
eventIDs.append(event.pylot_id)
|
eventIDs.append(event.pylot_id)
|
||||||
|
@ -38,6 +38,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
|
|||||||
"""
|
"""
|
||||||
Determine phase onsets automatically utilizing the automatic picking
|
Determine phase onsets automatically utilizing the automatic picking
|
||||||
algorithms by Kueperkoch et al. 2010/2012.
|
algorithms by Kueperkoch et al. 2010/2012.
|
||||||
|
:param obspyDMT_wfpath: if obspyDMT is used, name of data directory ("raw" or "processed")
|
||||||
:param input_dict:
|
:param input_dict:
|
||||||
:type input_dict:
|
:type input_dict:
|
||||||
:param parameter: PylotParameter object containing parameters used for automatic picking
|
:param parameter: PylotParameter object containing parameters used for automatic picking
|
||||||
@ -200,8 +201,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even
|
|||||||
events.append(os.path.join(datapath, eventID))
|
events.append(os.path.join(datapath, eventID))
|
||||||
else:
|
else:
|
||||||
# autoPyLoT was initialized from GUI
|
# autoPyLoT was initialized from GUI
|
||||||
events = []
|
events = [eventid]
|
||||||
events.append(eventid)
|
|
||||||
evID = os.path.split(eventid)[-1]
|
evID = os.path.split(eventid)[-1]
|
||||||
locflag = 2
|
locflag = 2
|
||||||
else:
|
else:
|
||||||
|
@ -76,6 +76,7 @@ def modify_inputs(ctrfn, root, nllocoutn, phasefn, tttn):
|
|||||||
def locate(fnin, parameter=None):
|
def locate(fnin, parameter=None):
|
||||||
"""
|
"""
|
||||||
takes an external program name and tries to run it
|
takes an external program name and tries to run it
|
||||||
|
:param parameter: PyLoT Parameter object
|
||||||
:param fnin: external program name
|
:param fnin: external program name
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
@ -506,7 +506,8 @@ class PDFstatistics(object):
|
|||||||
|
|
||||||
return rlist
|
return rlist
|
||||||
|
|
||||||
def writeThetaToFile(self, array, out_dir):
|
@staticmethod
|
||||||
|
def writeThetaToFile(array, out_dir):
|
||||||
"""
|
"""
|
||||||
Method to write array like data to file. Useful since acquiring can take
|
Method to write array like data to file. Useful since acquiring can take
|
||||||
serious amount of time when dealing with large databases.
|
serious amount of time when dealing with large databases.
|
||||||
|
@ -226,8 +226,7 @@ def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=0, fig=None, linecolor='k'):
|
|||||||
# get zero crossings after most likely pick
|
# get zero crossings after most likely pick
|
||||||
# initial onset is assumed to be the first zero crossing
|
# initial onset is assumed to be the first zero crossing
|
||||||
# first from unfiltered trace
|
# first from unfiltered trace
|
||||||
zc1 = []
|
zc1 = [Pick]
|
||||||
zc1.append(Pick)
|
|
||||||
index1 = []
|
index1 = []
|
||||||
i = 0
|
i = 0
|
||||||
for j in range(ipick[0][1], ipick[0][len(t[ipick]) - 1]):
|
for j in range(ipick[0][1], ipick[0][len(t[ipick]) - 1]):
|
||||||
@ -272,8 +271,7 @@ def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=0, fig=None, linecolor='k'):
|
|||||||
|
|
||||||
# now using filterd trace
|
# now using filterd trace
|
||||||
# next zero crossings after most likely pick
|
# next zero crossings after most likely pick
|
||||||
zc2 = []
|
zc2 = [Pick]
|
||||||
zc2.append(Pick)
|
|
||||||
index2 = []
|
index2 = []
|
||||||
i = 0
|
i = 0
|
||||||
for j in range(ipick[0][1], ipick[0][len(t[ipick]) - 1]):
|
for j in range(ipick[0][1], ipick[0][len(t[ipick]) - 1]):
|
||||||
|
@ -263,7 +263,8 @@ class Metadata(object):
|
|||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
|
|
||||||
def _read_dless(self, path_to_inventory):
|
@staticmethod
|
||||||
|
def _read_dless(path_to_inventory):
|
||||||
exc = None
|
exc = None
|
||||||
try:
|
try:
|
||||||
parser = Parser(path_to_inventory)
|
parser = Parser(path_to_inventory)
|
||||||
@ -272,7 +273,8 @@ class Metadata(object):
|
|||||||
return parser, exc
|
return parser, exc
|
||||||
|
|
||||||
|
|
||||||
def _read_inventory_file(self, path_to_inventory):
|
@staticmethod
|
||||||
|
def _read_inventory_file(path_to_inventory):
|
||||||
exc = None
|
exc = None
|
||||||
try:
|
try:
|
||||||
inv = read_inventory(path_to_inventory)
|
inv = read_inventory(path_to_inventory)
|
||||||
@ -582,9 +584,6 @@ def restitute_data(data, metadata, unit='VEL', force=False, ncores=0):
|
|||||||
takes a data stream and a path_to_inventory and returns the corrected
|
takes a data stream and a path_to_inventory and returns the corrected
|
||||||
waveform data stream
|
waveform data stream
|
||||||
:param data: seismic data stream
|
:param data: seismic data stream
|
||||||
:param invtype: type of found metadata
|
|
||||||
:param inobj: either list of metadata files or `obspy.io.xseed.Parser`
|
|
||||||
object
|
|
||||||
:param unit: unit to correct for (default: 'VEL')
|
:param unit: unit to correct for (default: 'VEL')
|
||||||
:param force: force restitution for already corrected traces (default:
|
:param force: force restitution for already corrected traces (default:
|
||||||
False)
|
False)
|
||||||
|
@ -162,7 +162,6 @@ class Event(ObsPyEvent):
|
|||||||
"""
|
"""
|
||||||
Add automatic picks to event
|
Add automatic picks to event
|
||||||
:param autopicks: automatic picks to add to event
|
:param autopicks: automatic picks to add to event
|
||||||
:type autopicks dict:
|
|
||||||
:return:
|
:return:
|
||||||
:rtype: None
|
:rtype: None
|
||||||
"""
|
"""
|
||||||
|
@ -541,7 +541,7 @@ def isSorted(iterable):
|
|||||||
False
|
False
|
||||||
"""
|
"""
|
||||||
assert isIterable(iterable), 'object is not iterable; object: {' \
|
assert isIterable(iterable), 'object is not iterable; object: {' \
|
||||||
'0}'.format(iterable)
|
'}'.format(iterable)
|
||||||
if type(iterable) is str:
|
if type(iterable) is str:
|
||||||
iterable = [s for s in iterable]
|
iterable = [s for s in iterable]
|
||||||
return sorted(iterable) == iterable
|
return sorted(iterable) == iterable
|
||||||
|
@ -242,7 +242,8 @@ class ComparisonWidget(QWidget):
|
|||||||
def clf(self):
|
def clf(self):
|
||||||
self.canvas.figure.clf()
|
self.canvas.figure.clf()
|
||||||
|
|
||||||
def hasvalue(self, sender):
|
@staticmethod
|
||||||
|
def hasvalue(sender):
|
||||||
text = sender.currentText()
|
text = sender.currentText()
|
||||||
index = sender.findText(text.upper())
|
index = sender.findText(text.upper())
|
||||||
return index
|
return index
|
||||||
@ -895,7 +896,8 @@ class PylotCanvas(FigureCanvas):
|
|||||||
fname += '.png'
|
fname += '.png'
|
||||||
self.figure.savefig(fname)
|
self.figure.savefig(fname)
|
||||||
|
|
||||||
def calcPanZoom(self, origin, lower_b, upper_b, factor, positive):
|
@staticmethod
|
||||||
|
def calcPanZoom(origin, lower_b, upper_b, factor, positive):
|
||||||
d_lower = abs(origin - lower_b)
|
d_lower = abs(origin - lower_b)
|
||||||
d_upper = abs(origin - upper_b)
|
d_upper = abs(origin - upper_b)
|
||||||
|
|
||||||
@ -1029,7 +1031,8 @@ class PylotCanvas(FigureCanvas):
|
|||||||
def clearPlotDict(self):
|
def clearPlotDict(self):
|
||||||
self.plotdict = dict()
|
self.plotdict = dict()
|
||||||
|
|
||||||
def calcPlotPositions(self, wfdata, compclass):
|
@staticmethod
|
||||||
|
def calcPlotPositions(wfdata, compclass):
|
||||||
possible_plot_pos = list(range(len(wfdata)))
|
possible_plot_pos = list(range(len(wfdata)))
|
||||||
plot_positions = {}
|
plot_positions = {}
|
||||||
for trace in wfdata:
|
for trace in wfdata:
|
||||||
@ -1173,16 +1176,20 @@ class PylotCanvas(FigureCanvas):
|
|||||||
self.setYLims(ax, zoomy)
|
self.setYLims(ax, zoomy)
|
||||||
self.draw()
|
self.draw()
|
||||||
|
|
||||||
def getXLims(self, ax):
|
@staticmethod
|
||||||
|
def getXLims(ax):
|
||||||
return ax.get_xlim()
|
return ax.get_xlim()
|
||||||
|
|
||||||
def getYLims(self, ax):
|
@staticmethod
|
||||||
|
def getYLims(ax):
|
||||||
return ax.get_ylim()
|
return ax.get_ylim()
|
||||||
|
|
||||||
def setXLims(self, ax, lims):
|
@staticmethod
|
||||||
|
def setXLims(ax, lims):
|
||||||
ax.set_xlim(lims)
|
ax.set_xlim(lims)
|
||||||
|
|
||||||
def setYLims(self, ax, lims):
|
@staticmethod
|
||||||
|
def setYLims(ax, lims):
|
||||||
ax.set_ylim(lims)
|
ax.set_ylim(lims)
|
||||||
|
|
||||||
def setYTickLabels(self, pos, labels):
|
def setYTickLabels(self, pos, labels):
|
||||||
@ -1298,7 +1305,8 @@ class PhaseDefaults(QtGui.QDialog):
|
|||||||
checkbox.setChecked(bool(phase in self.current_phases))
|
checkbox.setChecked(bool(phase in self.current_phases))
|
||||||
row += 1
|
row += 1
|
||||||
|
|
||||||
def create_phase_box(self, phase_name):
|
@staticmethod
|
||||||
|
def create_phase_box(phase_name):
|
||||||
checkbox = QtGui.QCheckBox(phase_name)
|
checkbox = QtGui.QCheckBox(phase_name)
|
||||||
return checkbox
|
return checkbox
|
||||||
|
|
||||||
@ -1699,7 +1707,8 @@ class PickDlg(QDialog):
|
|||||||
phases)
|
phases)
|
||||||
self.arrivals = arrivals
|
self.arrivals = arrivals
|
||||||
|
|
||||||
def prepare_phases(self):
|
@staticmethod
|
||||||
|
def prepare_phases():
|
||||||
settings = QtCore.QSettings()
|
settings = QtCore.QSettings()
|
||||||
p_phases = settings.value('p_phases')
|
p_phases = settings.value('p_phases')
|
||||||
s_phases = settings.value('s_phases')
|
s_phases = settings.value('s_phases')
|
||||||
@ -1875,7 +1884,8 @@ class PickDlg(QDialog):
|
|||||||
self.currentPhase = str(self.s_button.text())
|
self.currentPhase = str(self.s_button.text())
|
||||||
self.activatePicking()
|
self.activatePicking()
|
||||||
|
|
||||||
def getPhaseID(self, phase):
|
@staticmethod
|
||||||
|
def getPhaseID(phase):
|
||||||
return identifyPhaseID(phase)
|
return identifyPhaseID(phase)
|
||||||
|
|
||||||
def set_button_border_color(self, button, color=None):
|
def set_button_border_color(self, button, color=None):
|
||||||
@ -2087,7 +2097,8 @@ class PickDlg(QDialog):
|
|||||||
st += data.select(channel=action.text())
|
st += data.select(channel=action.text())
|
||||||
return st
|
return st
|
||||||
|
|
||||||
def calcNoiseScaleFactor(self, noiselevel, zoomfactor=5., norm=1):
|
@staticmethod
|
||||||
|
def calcNoiseScaleFactor(noiselevel, zoomfactor=5., norm=1):
|
||||||
# calculate factor to upscale a trace normed to 'norm' in a way that all values
|
# calculate factor to upscale a trace normed to 'norm' in a way that all values
|
||||||
# zoomfactor*noiselevel are found within -0.5*norm and 0.5*norm
|
# zoomfactor*noiselevel are found within -0.5*norm and 0.5*norm
|
||||||
scaleFactor = (norm/2.) / (zoomfactor * noiselevel)
|
scaleFactor = (norm/2.) / (zoomfactor * noiselevel)
|
||||||
@ -2626,15 +2637,18 @@ class PickDlg(QDialog):
|
|||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
settings.setValue('autoFilter', self.autoFilterAction.isChecked())
|
settings.setValue('autoFilter', self.autoFilterAction.isChecked())
|
||||||
|
|
||||||
def updateChannelSettingsP(self, action):
|
@staticmethod
|
||||||
|
def updateChannelSettingsP(action):
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
settings.setValue('p_channel_{}'.format(action.text()), action.isChecked())
|
settings.setValue('p_channel_{}'.format(action.text()), action.isChecked())
|
||||||
|
|
||||||
def updateChannelSettingsS(self, action):
|
@staticmethod
|
||||||
|
def updateChannelSettingsS(action):
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
settings.setValue('s_channel_{}'.format(action.text()), action.isChecked())
|
settings.setValue('s_channel_{}'.format(action.text()), action.isChecked())
|
||||||
|
|
||||||
def getChannelSettingsP(self, channel):
|
@staticmethod
|
||||||
|
def getChannelSettingsP(channel):
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
rval = real_Bool(settings.value('p_channel_{}'.format(channel)))
|
rval = real_Bool(settings.value('p_channel_{}'.format(channel)))
|
||||||
compclass = settings.value('compclass')
|
compclass = settings.value('compclass')
|
||||||
@ -2648,7 +2662,8 @@ class PickDlg(QDialog):
|
|||||||
rval = False
|
rval = False
|
||||||
return rval
|
return rval
|
||||||
|
|
||||||
def getChannelSettingsS(self, channel):
|
@staticmethod
|
||||||
|
def getChannelSettingsS(channel):
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
rval = real_Bool(settings.value('s_channel_{}'.format(channel)))
|
rval = real_Bool(settings.value('s_channel_{}'.format(channel)))
|
||||||
compclass = settings.value('compclass')
|
compclass = settings.value('compclass')
|
||||||
@ -3220,7 +3235,8 @@ class TuneAutopicker(QWidget):
|
|||||||
def get_current_station_id(self):
|
def get_current_station_id(self):
|
||||||
return str(self.stationBox.currentText())
|
return str(self.stationBox.currentText())
|
||||||
|
|
||||||
def gen_tab_widget(self, name, canvas):
|
@staticmethod
|
||||||
|
def gen_tab_widget(name, canvas):
|
||||||
widget = QtGui.QWidget()
|
widget = QtGui.QWidget()
|
||||||
v_layout = QtGui.QVBoxLayout()
|
v_layout = QtGui.QVBoxLayout()
|
||||||
v_layout.addWidget(canvas)
|
v_layout.addWidget(canvas)
|
||||||
@ -3650,7 +3666,8 @@ class PylotParaBox(QtGui.QWidget):
|
|||||||
grid.addWidget(box, index1, 2)
|
grid.addWidget(box, index1, 2)
|
||||||
return grid
|
return grid
|
||||||
|
|
||||||
def create_box(self, typ, tooltip):
|
@staticmethod
|
||||||
|
def create_box(typ, tooltip):
|
||||||
if typ == str:
|
if typ == str:
|
||||||
box = QtGui.QLineEdit()
|
box = QtGui.QLineEdit()
|
||||||
elif typ == float:
|
elif typ == float:
|
||||||
@ -3665,7 +3682,8 @@ class PylotParaBox(QtGui.QWidget):
|
|||||||
raise TypeError('Unrecognized type {}'.format(typ))
|
raise TypeError('Unrecognized type {}'.format(typ))
|
||||||
return box
|
return box
|
||||||
|
|
||||||
def create_multi_box(self, boxes, headline=None):
|
@staticmethod
|
||||||
|
def create_multi_box(boxes, headline=None):
|
||||||
box = QtGui.QWidget()
|
box = QtGui.QWidget()
|
||||||
gl = QtGui.QGridLayout()
|
gl = QtGui.QGridLayout()
|
||||||
column = 0
|
column = 0
|
||||||
@ -4366,7 +4384,8 @@ class PhasesTab(PropTab):
|
|||||||
self.PphasesEdit.setText(p_phases)
|
self.PphasesEdit.setText(p_phases)
|
||||||
self.SphasesEdit.setText(s_phases)
|
self.SphasesEdit.setText(s_phases)
|
||||||
|
|
||||||
def sortPhases(self, phases):
|
@staticmethod
|
||||||
|
def sortPhases(phases):
|
||||||
sorted_phases = {'P': [],
|
sorted_phases = {'P': [],
|
||||||
'S': []}
|
'S': []}
|
||||||
for phase in phases:
|
for phase in phases:
|
||||||
@ -4607,7 +4626,8 @@ class LocalisationTab(PropTab):
|
|||||||
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))
|
||||||
|
|
||||||
def selectDirectory(self, edit):
|
@staticmethod
|
||||||
|
def selectDirectory(edit):
|
||||||
selected_directory = QFileDialog.getExistingDirectory()
|
selected_directory = QFileDialog.getExistingDirectory()
|
||||||
# check if string is empty
|
# check if string is empty
|
||||||
if selected_directory:
|
if selected_directory:
|
||||||
|
Loading…
Reference in New Issue
Block a user