Merge branch 'develop' of git.geophysik.ruhr-uni-bochum.de:marcel/pylot into develop

This commit is contained in:
Kaan Cökerim 2022-06-29 14:07:35 +02:00
commit 5ef427ec12
5 changed files with 62 additions and 38 deletions

View File

@ -254,7 +254,7 @@ class MainWindow(QMainWindow):
self._inputs.export2File(infile)
self.infile = infile
def setupUi(self, use_logwidget=True):
def setupUi(self, use_logwidget=False):
try:
self.startTime = min(
[tr.stats.starttime for tr in self.data.wfdata])
@ -734,11 +734,9 @@ class MainWindow(QMainWindow):
if use_logwidget:
self.logwidget = LogWidget(parent=None)
self.logwidget.show()
self.stdout = self.logwidget.stdout
self.stderr = self.logwidget.stderr
sys.stdout = self.stdout
sys.stderr = self.stderr
sys.stdout = self.logwidget.stdout
sys.stderr = self.logwidget.stderr
self.setCentralWidget(_widget)
@ -2550,6 +2548,7 @@ class MainWindow(QMainWindow):
picks=self.getPicksOnStation(station, 'manual'),
autopicks=self.getPicksOnStation(station, 'auto'),
metadata=self.metadata, event=event,
model=self.inputs.get('taup_model'),
filteroptions=self.filteroptions, wftype=wftype)
if self.filterActionP.isChecked():
pickDlg.currentPhase = "P"
@ -2663,7 +2662,7 @@ class MainWindow(QMainWindow):
self.init_fig_dict()
# if not self.tap:
# init TuneAutopicker object
self.tap = TuneAutopicker(self)
self.tap = TuneAutopicker(self, self.obspy_dmt)
# first call of update to init tabs with empty canvas
self.update_autopicker()
# connect update signal of TuneAutopicker with update function

View File

@ -24,10 +24,10 @@ It is highly recommended to use Anaconda for a simple creation of a Python insta
Afterwards run (from the PyLoT main directory where the files *requirements.txt* and *pylot.yml* are located)
conda create --name pylot_38 --file requirements.txt
conda env create -f pylot.yml
or
conda env create -f pylot.yml
conda create --name pylot_38 --file requirements.txt
to create a new Anaconda environment called "pylot_38".
@ -101,11 +101,11 @@ We hope to solve these with the next release.
Original author(s): L. Kueperkoch, S. Wehling-Benatelli, M. Bischoff (PILOT)
Developer(s): S. Wehling-Benatelli, L. Kueperkoch, K. Olbert, M. Bischoff, C. Wollin, M. Rische, M. Paffrath
Developer(s): S. Wehling-Benatelli, M. Paffrath, L. Kueperkoch, K. Olbert, M. Bischoff, C. Wollin, M. Rische, D. Arnold, K. Cökerim, S. Zimmermann
Others: A. Bruestle, T. Meier, W. Friederich
[ObsPy]: http://github.com/obspy/obspy/wiki
September 2017
April 2022

View File

@ -429,7 +429,7 @@ class AutopickStation(object):
if station_coords is None:
exit_taupy()
raise AttributeError('Warning: Could not find station in metadata')
# TODO raise when metadata.get_coordinates returns None
# TODO: raise when metadata.get_coordinates returns None
source_origin = origin[0]
model = TauPyModel(taup_model)
taup_phases = self.pickparams['taup_phases']
@ -471,11 +471,13 @@ class AutopickStation(object):
"""If taupy failed to calculate theoretical starttimes, picking continues.
For this a clean exit is required, since the P starttime is no longer relative to the theoretic onset but
to the vertical trace starttime, eg. it can't be < 0."""
# TODO here the pickparams is modified, instead of a copy
if self.pickparams["pstart"] < 0:
# TODO here the pickparams is modified, instead of a copy
self.pickparams["pstart"] = 0
if self.pickparams["sstart"] < 0:
self.pickparams["sstart"] = 0
if self.pickparams["use_taup"] is False:
if get_Bool(self.pickparams["use_taup"]) is False:
# correct user mistake where a relative cuttime is selected (pstart < 0) but use of taupy is disabled/ has
# not the required parameters
exit_taupy()
@ -499,6 +501,20 @@ class AutopickStation(object):
self.pickparams["pstart"] = max(self.pickparams["pstart"], 0)
self.pickparams["pstop"] = min(self.pickparams["pstop"], len(self.ztrace) * self.ztrace.stats.delta)
if self.horizontal_traces_exist():
# for the two horizontal components take earliest and latest time to make sure that the s onset is not clipped
# if start and endtime of horizontal traces differ, the s windowsize will automatically increase
trace_s_start = min([self.etrace.stats.starttime, self.ntrace.stats.starttime])
# modifiy sstart and sstop relative to estimated first S arrival (relative to station time axis)
self.pickparams["sstart"] += (self.origin[0].time + estFirstS) - trace_s_start
self.pickparams["sstop"] += (self.origin[0].time + estFirstS) - trace_s_start
print('autopick: CF calculation times respectively:'
' sstart: {} s, sstop: {} s'.format(self.pickparams["sstart"], self.pickparams["sstop"]))
# make sure pstart and pstop are inside the starttime/endtime of horizontal traces
self.pickparams["sstart"] = max(self.pickparams["sstart"], 0)
self.pickparams["sstop"] = min(self.pickparams["sstop"], len(self.ntrace) * self.ntrace.stats.delta,
len(self.etrace) * self.etrace.stats.delta)
def autopickstation(self):
"""
Main function of autopickstation, which calculates P and S picks and returns them in a dictionary.
@ -508,6 +524,17 @@ class AutopickStation(object):
station's value is the station name on which the picks were calculated.
:rtype: dict
"""
if get_Bool(self.pickparams['use_taup']) is True and self.origin is not None:
try:
# modify pstart, pstop, sstart, sstop to be around theoretical onset if taupy should be used,
# else do nothing
self.modify_starttimes_taupy()
except AttributeError as ae:
print(ae)
except MissingTraceException as mte:
print(mte)
try:
self.pick_p_phase()
except MissingTraceException as mte:
@ -515,13 +542,15 @@ class AutopickStation(object):
except PickingFailedException as pfe:
print(pfe)
if self.horizontal_traces_exist() and self.p_results.weight is not None and self.p_results.weight < 4:
try:
self.pick_s_phase()
except MissingTraceException as mte:
print(mte)
except PickingFailedException as pfe:
print(pfe)
if self.horizontal_traces_exist():
if (self.p_results.weight is not None and self.p_results.weight < 4) or \
get_Bool(self.pickparams.get('use_taup')):
try:
self.pick_s_phase()
except MissingTraceException as mte:
print(mte)
except PickingFailedException as pfe:
print(pfe)
self.plot_pick_results()
self.finish_picking()
@ -661,13 +690,14 @@ class AutopickStation(object):
ax2.plot([self.s_results.lpp, self.s_results.lpp], [-1.1, 1.1], 'g--', label='lpp')
ax2.plot([self.s_results.epp, self.s_results.epp], [-1.1, 1.1], 'g--', label='epp')
title = '{channel}, S weight={sweight}, SNR={snr:7.2}, SNR[dB]={snrdb:7.2}'
ax2.set_title(title.format(channel=self.etrace.stats.channel,
sweight=self.s_results.weight,
snr=self.s_results.snr,
snrdb=self.s_results.snrdb))
ax2.set_title(title.format(channel=str(self.etrace.stats.channel),
sweight=str(self.s_results.weight),
snr=str(self.s_results.snr),
snrdb=str(self.s_results.snrdb)))
else:
title = '{channel}, S weight={sweight}, SNR=None, SNR[dB]=None'
ax2.set_title(title.format(channel=self.etrace.stats.channel, sweight=self.s_results.weight))
ax2.set_title(title.format(channel=str(self.etrace.stats.channel),
sweight=str(self.s_results.weight)))
ax2.legend(loc=1)
ax2.set_yticks([])
ax2.set_ylim([-1.5, 1.5])
@ -795,15 +825,6 @@ class AutopickStation(object):
# save filtered trace in instance for later plotting
self.tr_filt_z_bpz2 = tr_filt
if get_Bool(self.pickparams['use_taup']) is True and self.origin is not None:
try:
# modify pstart, pstop to be around theoretical onset if taupy should be used, else does nothing
self.modify_starttimes_taupy()
except AttributeError as ae:
print(ae)
except MissingTraceException as mte:
print(mte)
Lc = self.pickparams['pstop'] - self.pickparams['pstart']
Lwf = self.ztrace.stats.endtime - self.ztrace.stats.starttime
@ -1127,9 +1148,11 @@ class AutopickStation(object):
''.format(self.s_results.weight, self.s_results.snr, self.s_results.snrdb))
def pick_s_phase(self):
# determine time window for calculating CF after P onset
cuttimesh = self._calculate_cuttimes(type='S', iteration=1)
if get_Bool(self.pickparams.get('use_taup')) is True:
cuttimesh = (self.pickparams.get('sstart'), self.pickparams.get('sstop'))
else:
# determine time window for calculating CF after P onset
cuttimesh = self._calculate_cuttimes(type='S', iteration=1)
# calculate autoregressive CF
self.arhcf1 = self._calculate_autoregressive_cf_s_pick(cuttimesh)

View File

@ -478,6 +478,7 @@ class Array_map(QtWidgets.QWidget):
picks=self._parent.get_current_event().getPick(station),
autopicks=self._parent.get_current_event().getAutopick(station),
filteroptions=self._parent.filteroptions, metadata=self.metadata,
model=self.parameter.get('taup_model'),
event=pyl_mw.get_current_event())
except Exception as e:
message = 'Could not generate Plot for station {st}.\n {er}'.format(st=station, er=e)

View File

@ -123,7 +123,7 @@ class LogWidget(QtWidgets.QWidget):
self.layout.addWidget(self.tabs)
def active_error(self):
if self.current_active_error == False:
if not self.current_active_error:
self.current_active_error = True
self.show()
self.activateWindow()
@ -3679,6 +3679,7 @@ class TuneAutopicker(QWidget):
picks=self.get_current_event_picks(station),
autopicks=self.get_current_event_autopicks(station),
metadata=metadata, event=event, filteroptions=filteroptions,
model=self.parameter.get('taup_model'),
embedded=True, wftype=wftype)
self.pickDlg.update_picks.connect(self.picks_from_pickdlg)
self.pickDlg.update_picks.connect(self.fill_eventbox)