From 217fa330c1f0a0a149d3cfade15e234af2d209f6 Mon Sep 17 00:00:00 2001 From: Jeldrik Gaal Date: Mon, 29 Mar 2021 16:05:50 +0200 Subject: [PATCH 1/9] Fixed eventlist not working after locating twice Changed exception when less then 2 horizontals are found to warning --- PyLoT.py | 20 ++++++++------------ pylot/core/analysis/magnitude.py | 15 ++++++++++----- pylot/core/io/data.py | 7 ++++--- pylot/core/io/phases.py | 2 +- pylot/core/loc/nll.py | 1 - pylot/core/util/gui.py | 7 ++++--- 6 files changed, 27 insertions(+), 25 deletions(-) diff --git a/PyLoT.py b/PyLoT.py index 2db7a1ff..125309d2 100755 --- a/PyLoT.py +++ b/PyLoT.py @@ -1492,12 +1492,11 @@ class MainWindow(QMainWindow): :param outformats: str/list of output formats :return: ''' - if not event: + if not event: event = self.get_current_event() if not type(outformats) == list: outformats = [outformats] - - def getSavePath(event, directory, outformats): + def getSavePath(event, directory, outformats): if not directory: title = 'Save event data as {} to directory ...'.format(outformats) directory = QFileDialog.getExistingDirectory(self, @@ -1515,13 +1514,13 @@ class MainWindow(QMainWindow): uppererrorP = self._inputs['timeerrorsP'] uppererrorS = self._inputs['timeerrorsS'] - + # Inserted to prevent Bug in Eventlist + self.get_data().setEvtData(event) try: self.get_data().applyEVTData(event, typ='event') # getPicks()) except OverwriteError: self.get_data().resetPicks() return self.saveData(event, directory, outformats) - fcheck = ['auto', 'manual', 'origins', 'magnitude'] saved_as = str() @@ -1537,7 +1536,6 @@ class MainWindow(QMainWindow): msg = 'Event {} saved as {} in format(s) {}'.format(event.pylot_id, fbasename, saved_as.strip()) self.update_status(msg) print(msg) - event.dirty = False self.fill_eventbox() return True @@ -3012,12 +3010,11 @@ class MainWindow(QMainWindow): self.locate_event() ctrfile = os.path.join(locroot, 'run', parameter['ctrfile']) - ttt = parameter['ttpatter'] outfile = parameter['outpatter'] eventname = self.get_current_event_name() obsdir = os.path.join(self._inputs['rootpath'], self._inputs['datapath'], self._inputs['database'], eventname) - self.saveData(event=self.get_current_event(), directory=obsdir, outformats='.obs') + self.saveData(event=self.get_current_event(), directory=obsdir, outformats='.obs') filename = 'PyLoT_' + eventname locpath = os.path.join(locroot, 'loc', filename) phasefile = os.path.join(obsdir, filename + '.obs') @@ -3028,7 +3025,6 @@ class MainWindow(QMainWindow): print(e.message) # finally: # os.remove(phasefile) - self.get_data().applyEVTData(lt.read_location(locpath), typ='event') for event in self.calc_magnitude(): self.get_data().applyEVTData(event, typ='event') @@ -3210,7 +3206,7 @@ class MainWindow(QMainWindow): # iterate through eventlist and generate items for table rows self.project._table = [] - for index, event in enumerate(eventlist): + for index, event in enumerate(eventlist): phaseErrors = {'P': self._inputs['timeerrorsP'], 'S': self._inputs['timeerrorsS']} @@ -3751,7 +3747,7 @@ class Project(object): self.search_eventfile_info() def remove_event(self, event): - self.eventlist.remove(event) + self.eventlist.remove(event) def remove_event_by_id(self, eventID): for event in self.eventlist: @@ -3760,7 +3756,7 @@ class Project(object): break def read_eventfile_info(self, filename, separator=','): - ''' + ''' Try to read event information from file (:param:filename) comparing specific event datetimes. File structure (each row): event, date, time, magnitude, latitude, longitude, depth separated by :param:separator each. diff --git a/pylot/core/analysis/magnitude.py b/pylot/core/analysis/magnitude.py index 4b1fd6fe..dc5204ed 100644 --- a/pylot/core/analysis/magnitude.py +++ b/pylot/core/analysis/magnitude.py @@ -221,11 +221,16 @@ class LocalMagnitude(Magnitude): power = [np.power(tr.data, 2) for tr in st if tr.stats.channel[-1] not in 'Z3'] - if len(power) != 2: - raise ValueError('Wood-Anderson amplitude defintion only valid for ' - 'two horizontals: {0} given'.format(len(power))) - power_sum = power[0] + power[1] - # + # checking horizontal count and calculating power_sum accordingly + if len(power) == 1: + print ('WARNING: Only one horizontal found for station {0}.'.format(st[0].stats.station)) + power_sum = power[0] + elif len(power) == 2: + power_sum = power[0] + power[1] + else: + raise ValueError('Wood-Anderson aomplitude defintion only valid for' + ' up to two horizontals: {0} given'.format(len(power))) + sqH = np.sqrt(power_sum) # get time array diff --git a/pylot/core/io/data.py b/pylot/core/io/data.py index c737eb21..d7faced9 100644 --- a/pylot/core/io/data.py +++ b/pylot/core/io/data.py @@ -21,7 +21,6 @@ from pylot.core.util.obspyDMT_interface import qml_from_obspyDMT from pylot.core.util.utils import fnConstructor, full_range, check4rotated, \ check4gapsAndMerge, trim_station_components - class Data(object): """ Data container with attributes wfdata holding ~obspy.core.stream. @@ -258,7 +257,7 @@ class Data(object): can be a str or a list of strings of ['manual', 'auto', 'origin', 'magnitude'] """ from pylot.core.util.defaults import OUTPUTFORMATS - + if not type(fcheck) == list: fcheck = [fcheck] @@ -276,7 +275,7 @@ class Data(object): # check for already existing xml-file if fnext == '.xml': if os.path.isfile(fnout + fnext): - print("xml-file already exists! Check content ...") + print("xml-file already exists! Check content ...") cat = read_events(fnout + fnext) if len(cat) > 1: raise IOError('Ambigious event information in file {}'.format(fnout + fnext)) @@ -288,7 +287,9 @@ class Data(object): return self.checkEvent(event, fcheck) self.setEvtData(event) + self.get_evt_data().write(fnout + fnext, format=evtformat) + # try exporting event else: evtdata_org = self.get_evt_data() diff --git a/pylot/core/io/phases.py b/pylot/core/io/phases.py index bc05800c..30d26ffc 100644 --- a/pylot/core/io/phases.py +++ b/pylot/core/io/phases.py @@ -805,7 +805,7 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None): return stime = eventsource['time'] event = parameter.get('eventID') - hddID = event.split('.')[0][1:5] + hddID = event.split('.')[0][1:5] # write header fid.write('# %d %d %d %d %d %5.2f %7.4f +%6.4f %7.4f %4.2f 0.1 0.5 %4.2f %s\n' % ( stime.year, stime.month, stime.day, stime.hour, stime.minute, stime.second, diff --git a/pylot/core/loc/nll.py b/pylot/core/loc/nll.py index 4a9f8b27..5ed9d101 100644 --- a/pylot/core/loc/nll.py +++ b/pylot/core/loc/nll.py @@ -81,7 +81,6 @@ def locate(fnin, parameter=None): :param fnin: external program name :return: None """ - exe_path = which('NLLoc', parameter) if exe_path is None: raise NLLocError('NonLinLoc executable not found; check your ' diff --git a/pylot/core/util/gui.py b/pylot/core/util/gui.py index 6119af96..bc54cdf0 100644 --- a/pylot/core/util/gui.py +++ b/pylot/core/util/gui.py @@ -53,7 +53,7 @@ def which(program, parameter): settings = QSettings() for key in settings.allKeys(): if 'binPath' in key: - os.environ['PATH'] += ':{0}'.format(settings.value(key)) + os.environ['PATH'] += ':{0}'.format(settings.value(key)) nllocpath = ":" + parameter.get('nllocbin') os.environ['PATH'] += nllocpath except Exception as e: @@ -73,7 +73,7 @@ def which(program, parameter): return program else: for path in os.environ["PATH"].split(os.pathsep): - exe_file = os.path.join(path, program) + exe_file = os.path.join(path, program) for candidate in ext_candidates(exe_file): if is_exe(candidate): return candidate @@ -100,4 +100,5 @@ def make_pen(picktype, phase, key, quality): rgba = pick_color(picktype, phase, quality) linestyle, width = pick_linestyle_pg(picktype, key) pen = pg.mkPen(rgba, width=width, style=linestyle) - return pen \ No newline at end of file + return pen + From 07e7ef3efa3fa8a309c84e185d584696a4b9bf57 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 30 Mar 2021 16:39:44 +0200 Subject: [PATCH 2/9] [revision] cleaned up unclean code: tabs -> spaces --- PyLoT.py | 14 +++++++------- pylot/core/analysis/magnitude.py | 18 +++++++++--------- pylot/core/io/data.py | 4 ++-- pylot/core/io/phases.py | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/PyLoT.py b/PyLoT.py index f02fd377..fcdd455e 100755 --- a/PyLoT.py +++ b/PyLoT.py @@ -1501,11 +1501,11 @@ class MainWindow(QMainWindow): :param outformats: str/list of output formats :return: ''' - if not event: + if not event: event = self.get_current_event() if not type(outformats) == list: outformats = [outformats] - def getSavePath(event, directory, outformats): + def getSavePath(event, directory, outformats): if not directory: title = 'Save event data as {} to directory ...'.format(outformats) directory = QFileDialog.getExistingDirectory(self, @@ -1523,8 +1523,8 @@ class MainWindow(QMainWindow): uppererrorP = self._inputs['timeerrorsP'] uppererrorS = self._inputs['timeerrorsS'] - # Inserted to prevent Bug in Eventlist - self.get_data().setEvtData(event) + # Inserted to prevent Bug in Eventlist + self.get_data().setEvtData(event) try: self.get_data().applyEVTData(event, typ='event') # getPicks()) except OverwriteError: @@ -3023,7 +3023,7 @@ class MainWindow(QMainWindow): outfile = parameter['outpatter'] eventname = self.get_current_event_name() obsdir = os.path.join(self._inputs['rootpath'], self._inputs['datapath'], self._inputs['database'], eventname) - self.saveData(event=self.get_current_event(), directory=obsdir, outformats='.obs') + self.saveData(event=self.get_current_event(), directory=obsdir, outformats='.obs') filename = 'PyLoT_' + eventname locpath = os.path.join(locroot, 'loc', filename) phasefile = os.path.join(obsdir, filename + '.obs') @@ -3756,7 +3756,7 @@ class Project(object): self.search_eventfile_info() def remove_event(self, event): - self.eventlist.remove(event) + self.eventlist.remove(event) def remove_event_by_id(self, eventID): for event in self.eventlist: @@ -3765,7 +3765,7 @@ class Project(object): break def read_eventfile_info(self, filename, separator=','): - ''' + ''' Try to read event information from file (:param:filename) comparing specific event datetimes. File structure (each row): event, date, time, magnitude, latitude, longitude, depth separated by :param:separator each. diff --git a/pylot/core/analysis/magnitude.py b/pylot/core/analysis/magnitude.py index dc5204ed..40e98a48 100644 --- a/pylot/core/analysis/magnitude.py +++ b/pylot/core/analysis/magnitude.py @@ -221,15 +221,15 @@ class LocalMagnitude(Magnitude): power = [np.power(tr.data, 2) for tr in st if tr.stats.channel[-1] not in 'Z3'] - # checking horizontal count and calculating power_sum accordingly - if len(power) == 1: - print ('WARNING: Only one horizontal found for station {0}.'.format(st[0].stats.station)) - power_sum = power[0] - elif len(power) == 2: - power_sum = power[0] + power[1] - else: - raise ValueError('Wood-Anderson aomplitude defintion only valid for' - ' up to two horizontals: {0} given'.format(len(power))) + # checking horizontal count and calculating power_sum accordingly + if len(power) == 1: + print ('WARNING: Only one horizontal found for station {0}.'.format(st[0].stats.station)) + power_sum = power[0] + elif len(power) == 2: + power_sum = power[0] + power[1] + else: + raise ValueError('Wood-Anderson aomplitude defintion only valid for' + ' up to two horizontals: {0} given'.format(len(power))) sqH = np.sqrt(power_sum) diff --git a/pylot/core/io/data.py b/pylot/core/io/data.py index d7faced9..4f1a1101 100644 --- a/pylot/core/io/data.py +++ b/pylot/core/io/data.py @@ -275,7 +275,7 @@ class Data(object): # check for already existing xml-file if fnext == '.xml': if os.path.isfile(fnout + fnext): - print("xml-file already exists! Check content ...") + print("xml-file already exists! Check content ...") cat = read_events(fnout + fnext) if len(cat) > 1: raise IOError('Ambigious event information in file {}'.format(fnout + fnext)) @@ -287,7 +287,7 @@ class Data(object): return self.checkEvent(event, fcheck) self.setEvtData(event) - + self.get_evt_data().write(fnout + fnext, format=evtformat) # try exporting event diff --git a/pylot/core/io/phases.py b/pylot/core/io/phases.py index 30d26ffc..8442ed7f 100644 --- a/pylot/core/io/phases.py +++ b/pylot/core/io/phases.py @@ -805,7 +805,7 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None): return stime = eventsource['time'] event = parameter.get('eventID') - hddID = event.split('.')[0][1:5] + hddID = event.split('.')[0][1:5] # write header fid.write('# %d %d %d %d %d %5.2f %7.4f +%6.4f %7.4f %4.2f 0.1 0.5 %4.2f %s\n' % ( stime.year, stime.month, stime.day, stime.hour, stime.minute, stime.second, From c9bd0a147c7b3665bde0ced815f020170279c3ca Mon Sep 17 00:00:00 2001 From: Ludger Kueperkoch Date: Thu, 1 Apr 2021 11:01:06 +0200 Subject: [PATCH 3/9] Preparation of implementing pick-quality button. --- PyLoT.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PyLoT.py b/PyLoT.py index fcdd455e..c9e67b9c 100755 --- a/PyLoT.py +++ b/PyLoT.py @@ -470,7 +470,8 @@ class MainWindow(QMainWindow): icon=qualities_icon, tip='Histogram of pick qualities') self.qualities_action.setEnabled(False) # MP MP not yet implemented, therefore hide: - self.qualities_action.setVisible(False) + # LK will be implemented soon, basic script has already (03/2021) been finished + self.qualities_action.setVisible(True) printAction = self.createAction(self, "&Print event ...", self.show_event_information, QKeySequence.Print, From 27c9bbb96af91df4b19355de7e65443d0f97a29f Mon Sep 17 00:00:00 2001 From: Jeldrik Gaal Date: Thu, 6 May 2021 13:48:44 +0200 Subject: [PATCH 4/9] Manualy adding generic Amplitude to .obs files Due to the obspy write function not including the generic Amplitude/A0 in the .obs file (NonLinLoc) even when the Event holds this Data. Obspy Team has been informed by opening an issue on Github --- pylot/core/io/data.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pylot/core/io/data.py b/pylot/core/io/data.py index d7faced9..e497783b 100644 --- a/pylot/core/io/data.py +++ b/pylot/core/io/data.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env pyth n # -*- coding: utf-8 -*- import copy @@ -353,6 +353,14 @@ class Data(object): header = '# EQEVENT: Label: EQ%s Loc: X 0.00 Y 0.00 Z 10.00 OT 0.00 \n' % evid nllocfile = open(fnout + fnext) l = nllocfile.readlines() + # Adding A0/Generic Amplitude to .obs file + l2 = [] + for li in l: + for amp in evtdata_org.amplitudes: + if amp.waveform_id.station_code == li[0:5].strip(): + li = li[0:64] + '{:0.2e}'.format(amp.generic_amplitude) + li[73:-1] + '\n' + l2.append(li) + l = l2 nllocfile.close() l.insert(0, header) nllocfile = open(fnout + fnext, 'w') From 67e2ba3ad7df6d7a463cae1414c76f62b9227e6e Mon Sep 17 00:00:00 2001 From: Ludger Kueperkoch Date: Tue, 15 Jun 2021 11:18:24 +0200 Subject: [PATCH 5/9] Additional screen output, temporarily comment amplitude info for obs-file. --- pylot/core/analysis/magnitude.py | 13 ++++++++++--- pylot/core/io/data.py | 14 +++++++------- pylot/core/io/phases.py | 1 + 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/pylot/core/analysis/magnitude.py b/pylot/core/analysis/magnitude.py index 40e98a48..ac6705ac 100644 --- a/pylot/core/analysis/magnitude.py +++ b/pylot/core/analysis/magnitude.py @@ -282,12 +282,13 @@ class LocalMagnitude(Magnitude): for a in self.arrivals: if a.phase not in 'sS': continue + pick = a.pick_id.get_referred_object() + station = pick.waveform_id.station_code # make sure calculating Ml only from reliable onsets # NLLoc: time_weight = 0 => do not use onset! if a.time_weight == 0: + print("Uncertain pick at Station {}, do not use it!".format(station)) continue - pick = a.pick_id.get_referred_object() - station = pick.waveform_id.station_code wf = select_for_phase(self.stream.select( station=station), a.phase) if not wf: @@ -399,7 +400,13 @@ class MomentMagnitude(Magnitude): print("WARNING: No instrument corrected data available," " no magnitude calculation possible! Go on.") continue - scopy = self.stream.copy() + try: + scopy = self.stream.copy() + except AssertionError: + print("WARNING: Something's wrong with the data," + "station {}," + "no calculation of moment magnitude possible! Go on.".format(station)) + continue wf = scopy.select(station=station) if not wf: continue diff --git a/pylot/core/io/data.py b/pylot/core/io/data.py index 87434a3c..3a9fc19e 100644 --- a/pylot/core/io/data.py +++ b/pylot/core/io/data.py @@ -354,13 +354,13 @@ class Data(object): nllocfile = open(fnout + fnext) l = nllocfile.readlines() # Adding A0/Generic Amplitude to .obs file - l2 = [] - for li in l: - for amp in evtdata_org.amplitudes: - if amp.waveform_id.station_code == li[0:5].strip(): - li = li[0:64] + '{:0.2e}'.format(amp.generic_amplitude) + li[73:-1] + '\n' - l2.append(li) - l = l2 + #l2 = [] + #for li in l: + # for amp in evtdata_org.amplitudes: + # if amp.waveform_id.station_code == li[0:5].strip(): + # li = li[0:64] + '{:0.2e}'.format(amp.generic_amplitude) + li[73:-1] + '\n' + # l2.append(li) + #l = l2 nllocfile.close() l.insert(0, header) nllocfile = open(fnout + fnext, 'w') diff --git a/pylot/core/io/phases.py b/pylot/core/io/phases.py index 8442ed7f..8e902677 100644 --- a/pylot/core/io/phases.py +++ b/pylot/core/io/phases.py @@ -543,6 +543,7 @@ def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None): try: if arrivals[key]['P']['weight'] >= 4: pweight = 0 # do not use pick + print("Station {}: Uncertain pick, do not use it!".format(key)) except KeyError as e: print(e.message + '; no weight set during processing') fid.write('%s ? ? ? P %s %d%02d%02d %02d%02d %7.4f GAU 0 0 0 0 %d \n' % (key, From 6e40811b012d45c4ac2ba52f9f92d871cc63a866 Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 17 Jun 2021 15:34:23 +0200 Subject: [PATCH 6/9] [minor] small bugfix --- pylot/core/util/widgets.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index fd2b4eab..07be120b 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -2703,8 +2703,11 @@ class PickDlg(QDialog): ax.plot(mpp, ylims[0], color=color, marker='^', zorder=baseorder + 3) # append phase text (if textOnly: draw with current ylims) self.phaseText.append(ax.text(mpp, ylims[1], phase, color=color, zorder=baseorder + 10)) - # indicate first motion - self.phaseText.append(ax.text(mpp - 0.03 * mpp, ylims[1] - ylims[1] / 12, picks['fm'], color=color, zorder=baseorder + 10)) + # indicate first motion + fm = picks.get('fm') + if fm: + self.phaseText.append(ax.text(mpp - 0.03 * mpp, ylims[1] - ylims[1] / 12, fm, color=color, + zorder=baseorder + 10)) ax.legend(loc=1) def connect_mouse_motion(self): From a6af015f05c7a4bd380a8237b88d780c302508bb Mon Sep 17 00:00:00 2001 From: Ludger Kueperkoch Date: Fri, 18 Jun 2021 12:59:38 +0200 Subject: [PATCH 7/9] For some data scopy is not working (??), captured that. --- pylot/core/analysis/magnitude.py | 14 ++++++-------- pylot/core/pick/utils.py | 3 +++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pylot/core/analysis/magnitude.py b/pylot/core/analysis/magnitude.py index ac6705ac..3b8119c4 100644 --- a/pylot/core/analysis/magnitude.py +++ b/pylot/core/analysis/magnitude.py @@ -400,30 +400,28 @@ class MomentMagnitude(Magnitude): 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 = self.stream.copy() + 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 - wf = scopy.select(station=station) - if not wf: - continue onset = pick.time distance = degrees2kilometers(a.distance) azimuth = a.azimuth incidence = a.takeoff_angle - w0, fc = calcsourcespec(wf, onset, self.p_velocity, distance, + w0, fc = calcsourcespec(scopy, onset, self.p_velocity, distance, azimuth, incidence, self.p_attenuation, self.plot_flag, self.verbose) if w0 is None or fc is None: if self.verbose: print("WARNING: insufficient frequency information") continue - WF = select_for_phase(self.stream.select( - station=station), a.phase) - WF = select_for_phase(WF, "P") + WF = select_for_phase(scopy, "P") m0, mw = calcMoMw(WF, w0, self.rock_density, self.p_velocity, distance, self.verbose) self.moment_props = (station, dict(w0=w0, fc=fc, Mo=m0)) diff --git a/pylot/core/pick/utils.py b/pylot/core/pick/utils.py index 0c6df20d..6591b5f6 100644 --- a/pylot/core/pick/utils.py +++ b/pylot/core/pick/utils.py @@ -7,6 +7,7 @@ :author: Ludger Kueperkoch, BESTEC GmbH """ + import warnings import matplotlib.pyplot as plt import numpy as np @@ -595,6 +596,8 @@ def select_for_phase(st, phase): alter_comp = compclass.getCompPosition(comp) alter_comp = str(alter_comp[0]) sel_st += st.select(component=comp) + if len(sel_st) < 1: + sel_st += st.select(component="Q") sel_st += st.select(component=alter_comp) elif phase.upper() == 'S': comps = 'NE' From 8b03aab381dd283263934aa152d7e9e82b40b360 Mon Sep 17 00:00:00 2001 From: Ludger Kueperkoch Date: Mon, 5 Jul 2021 11:29:44 +0200 Subject: [PATCH 8/9] [Bugfix] Take into account if only local or moment magnitude has been derived to write event list properly. --- PyLoT.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/PyLoT.py b/PyLoT.py index c9e67b9c..55a22762 100755 --- a/PyLoT.py +++ b/PyLoT.py @@ -3269,12 +3269,24 @@ class MainWindow(QMainWindow): item_depth.setText(str(origin.depth)) if hasattr(event, 'magnitudes'): if event.magnitudes: - moment_magnitude = event.magnitudes[0] - moment_magnitude.mag = '%4.1f' % moment_magnitude.mag - local_magnitude = event.magnitudes[1] - local_magnitude.mag = '%4.1f' % local_magnitude.mag - item_momentmag.setText(str(moment_magnitude.mag)) - item_localmag.setText(str(local_magnitude.mag)) + if len(event.magnitudes) > 1: + moment_magnitude = event.magnitudes[0] + moment_magnitude.mag = '%4.1f' % moment_magnitude.mag + item_momentmag.setText(str(moment_magnitude.mag)) + local_magnitude = event.magnitudes[1] + local_magnitude.mag = '%4.1f' % local_magnitude.mag + item_localmag.setText(str(local_magnitude.mag)) + else: + # check type of magnitude + if event.magnitudes[0].magnitude_type == 'Mw': + moment_magnitude = event.magnitudes[0] + moment_magnitude.mag = '%4.1f' % moment_magnitude.mag + item_momentmag.setText(str(moment_magnitude.mag)) + elif event.magnitudes[0].magnitude_type == 'ML': + local_magnitude = event.magnitudes[0] + local_magnitude.mag = '%4.1f' % local_magnitude.mag + item_localmag.setText(str(local_magnitude.mag)) + item_notes.setText(event.notes) set_enabled(item_path, True, False) From 30eb8fbbbde5a0f51f0acb25ea1d5eec2a67c95a Mon Sep 17 00:00:00 2001 From: Ludger Kueperkoch Date: Wed, 7 Jul 2021 11:10:23 +0200 Subject: [PATCH 9/9] [Bugifx] Taup model was hard coded as iasp91. --- pylot/core/io/default_parameters.py | 2 +- pylot/core/util/widgets.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pylot/core/io/default_parameters.py b/pylot/core/io/default_parameters.py index 0a5996c1..62e59536 100644 --- a/pylot/core/io/default_parameters.py +++ b/pylot/core/io/default_parameters.py @@ -511,7 +511,7 @@ defaults = {'rootpath': {'type': str, 'taup_model': {'type': str, 'tooltip': 'Define TauPy model for traveltime estimation. Possible values: 1066a, 1066b, ak135, ak135f, herrin, iasp91, jb, prem, pwdk, sp6', - 'value': 'iasp91', + 'value': None, 'namestring': 'TauPy model'}, 'taup_phases': {'type': str, diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index 07be120b..a2aff5ef 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -1594,7 +1594,7 @@ class PickDlg(QDialog): def __init__(self, parent=None, data=None, station=None, network=None, location=None, picks=None, autopicks=None, rotate=False, parameter=None, embedded=False, metadata=None, - event=None, filteroptions=None, model='iasp91', wftype=None): + event=None, filteroptions=None, model=None, wftype=None): super(PickDlg, self).__init__(parent, 1) self.orig_parent = parent self.setAttribute(Qt.WA_DeleteOnClose) @@ -1719,7 +1719,7 @@ class PickDlg(QDialog): # init expected picks using obspy Taup try: - if self.metadata: + if self.metadata and model is not None: self.model = TauPyModel(model) self.get_arrivals() self.drawArrivals()