diff --git a/PyLoT.py b/PyLoT.py index 55a22762..d186016b 100755 --- a/PyLoT.py +++ b/PyLoT.py @@ -2866,10 +2866,7 @@ class MainWindow(QMainWindow): event.pylot_autopicks = {} picksdict = picksdict_from_picks(evt=self.get_data().get_evt_data()) event.addPicks(picksdict['manual']) - if picksdict['auto'] == {}: - event.addAutopicks(picksdict) - else: - event.addAutopicks(picksdict['auto']) + event.addAutopicks(picksdict['auto']) def drawPicks(self, station=None, picktype=None, stime=None): diff --git a/pylot/core/io/data.py b/pylot/core/io/data.py index 3a9fc19e..122459c6 100644 --- a/pylot/core/io/data.py +++ b/pylot/core/io/data.py @@ -220,7 +220,7 @@ class Data(object): def replacePicks(self, event, picktype): """ - Replace own picks with the one in event + Replace picks in event with own picks :param event: Event that supplies information for comparison :type event: pylot.core.util.event.Event :param picktype: 'auto' or 'manual' picks @@ -228,20 +228,23 @@ class Data(object): :return: :rtype: None """ - checkflag = 0 + checkflag = 1 picks = event.picks # remove existing picks for j, pick in reversed(list(enumerate(picks))): try: if picktype in str(pick.method_id.id): picks.pop(j) - checkflag = 1 + checkflag = 2 except AttributeError as e: msg = '{}'.format(e) print(e) checkflag = 0 - if checkflag: - print("Found %s pick(s), remove them and append new picks to catalog." % picktype) + if checkflag > 0: + if checkflag == 1: + print("Write new %s picks to catalog." % picktype) + if checkflag == 2: + print("Found %s pick(s), remove them and append new picks to catalog." % picktype) # append new picks for pick in self.get_evt_data().picks: @@ -269,8 +272,11 @@ class Data(object): raise FormatError(errmsg) if hasattr(self.get_evt_data(), 'notes'): - with open(os.path.join(os.path.dirname(fnout), 'notes.txt'), 'w') as notes_file: - notes_file.write(self.get_evt_data().notes) + try: + with open(os.path.join(os.path.dirname(fnout), 'notes.txt'), 'w') as notes_file: + notes_file.write(self.get_evt_data().notes) + except Exception as e: + print('Warning: Could not save notes.txt: ', str(e)) # check for already existing xml-file if fnext == '.xml': @@ -537,7 +543,7 @@ class Data(object): def setEvtData(self, event): self.evtdata = event - def applyEVTData(self, data, typ='pick', authority_id='rub'): + def applyEVTData(self, data, typ='pick'): """ Either takes an `obspy.core.event.Event` object and applies all new information on the event to the actual data if typ is 'event or diff --git a/pylot/core/io/phases.py b/pylot/core/io/phases.py index 8e902677..a6329697 100644 --- a/pylot/core/io/phases.py +++ b/pylot/core/io/phases.py @@ -244,13 +244,13 @@ def picksdict_from_picks(evt): else: filter_id = None try: - picker = str(pick.method_id) - if picker.startswith('smi:local/'): - picker = picker.split('smi:local/')[1] + pick_method = str(pick.method_id) + if pick_method.startswith('smi:local/'): + pick_method = pick_method.split('smi:local/')[1] except IndexError: - picker = 'manual' # MP MP TODO maybe improve statement - if picker == 'None': - picker = 'manual' + pick_method = 'manual' # MP MP TODO maybe improve statement + if pick_method == 'None': + pick_method = 'manual' try: #onsets = picksdict[picker][station] onsets = picksdict[station] @@ -289,7 +289,7 @@ def picksdict_from_picks(evt): phase['weight'] = weight phase['channel'] = channel phase['network'] = network - phase['picker'] = picker + phase['picker'] = pick_method try: if pick.polarity == 'positive': phase['fm'] = 'U' @@ -303,7 +303,7 @@ def picksdict_from_picks(evt): phase['filter_id'] = filter_id if filter_id is not None else '' onsets[pick.phase_hint] = phase.copy() - picksdict[station] = onsets.copy() + picksdict[pick_method][station] = onsets.copy() return picksdict