diff --git a/pylot/core/io/phases.py b/pylot/core/io/phases.py index ba4de647..e004f53d 100644 --- a/pylot/core/io/phases.py +++ b/pylot/core/io/phases.py @@ -290,7 +290,16 @@ def picksdict_from_picks(evt): phase['channel'] = channel phase['network'] = network phase['picker'] = picker - phase['fm'] = 'N' + try: + if pick.polarity == 'positive': + phase['fm'] = 'U' + elif pick.polarity == 'negative': + phase['fm'] = 'D' + else: + phase['fm'] = 'N' + except: + print("No FM info available!") + phase['fm'] = 'N' phase['filter_id'] = filter_id if filter_id is not None else '' onsets[pick.phase_hint] = phase.copy() @@ -350,19 +359,25 @@ def picks_from_picksdict(picks, creation_info=None): warnings.warn(str(e), RuntimeWarning) filter_id = '' pick.filter_id = filter_id + try: - polarity = phase['fm'] + polarity = picks[station][label]['fm'] if polarity == 'U' or '+': pick.polarity = 'positive' elif polarity == 'D' or '-': pick.polarity = 'negative' else: pick.polarity = 'undecidable' - except KeyError as e: - if 'fm' in str(e): # no polarity information found for this phase - pass - else: - raise e + except: + pick.polarity = 'undecidable' + print("No polarity information available!") + #except KeyError as e: + # if 'fm' in str(e): # no polarity information found for this phase + #if 'polarity' in str(e): # no polarity information found for this phase + # print("No polarity information available!") + # pass + # else: + # raise e picks_list.append(pick) return picks_list diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index c534a998..bbde6969 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -2566,22 +2566,31 @@ class PickDlg(QDialog): mpp = stime + pick - # get first motion and quality classes - if self.getPhaseID(phase) == 'P': - # get first motion quality of P onset is sufficeint - minFMweight = parameter.get('minfmweight') - minFMSNR = parameter.get('minFMSNR') - quality = get_quality_class(spe, parameter.get('timeerrorsP')) - if quality <= minFMweight: - FM = fmpicker(self.getWFData().select(channel=channel), wfdata, parameter.get('fmpickwin'), mpp) - if epp: epp = stime + epp + stime_diff if lpp: lpp = stime + lpp + stime_diff + noise_win, gap_win, signal_win = self.getNoiseWin(phase) + snr, snrDB, noiselevel = getSNR(wfdata, (noise_win, gap_win, signal_win), pick - stime_diff) + print('SNR of final pick: {}'.format(snr)) + if snr < 1.5: + QMessageBox.warning(self, 'SNR too low', 'WARNING! SNR of final pick below 1.5! SNR = {}'.format(snr)) + + # get first motion and quality classes + FM = '' + if self.getPhaseID(phase) == 'P': + # get first motion quality of P onset is sufficeint + minFMweight = parameter.get('minfmweight') + minFMSNR = parameter.get('minFMSNR') + quality = get_quality_class(spe, parameter.get('timeerrorsP')) + if quality <= minFMweight and snr >= minFMSNR: + FM = fmpicker(self.getWFData().select(channel=channel), wfdata, parameter.get('fmpickwin'), + pick -stime_diff) + + # save pick times for actual phase - phasepicks = dict(epp=epp, lpp=lpp, mpp=mpp, spe=spe, + phasepicks = dict(epp=epp, lpp=lpp, mpp=mpp, spe=spe, fm=FM, picker='manual', channel=channel, network=wfdata[0].stats.network, filteroptions=transformFilteroptions2String(filteroptions)) @@ -2595,11 +2604,7 @@ class PickDlg(QDialog): self.zoomAction.setEnabled(True) # self.pick_block = self.togglPickBlocker() # self.resetZoom() - noise_win, gap_win, signal_win = self.getNoiseWin(phase) - snr, snrDB, noiselevel = getSNR(wfdata, (noise_win, gap_win, signal_win), pick - stime_diff) - print('SNR of final pick: {}'.format(snr)) - if snr < 1.5: - QMessageBox.warning(self, 'SNR too low', 'WARNING! SNR of final pick below 1.5! SNR = {}'.format(snr)) + self.leave_picking_mode() def savePick(self, phase, phasepicks):