Fixed eventlist not working after locating twice

Changed exception when less then 2 horizontals are found to warning
This commit is contained in:
Jeldrik Gaal 2021-03-29 16:05:50 +02:00
parent 21453159b7
commit 217fa330c1
6 changed files with 27 additions and 25 deletions

View File

@ -1496,7 +1496,6 @@ class MainWindow(QMainWindow):
event = self.get_current_event()
if not type(outformats) == list:
outformats = [outformats]
def getSavePath(event, directory, outformats):
if not directory:
title = 'Save event data as {} to directory ...'.format(outformats)
@ -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,7 +3010,6 @@ 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()
@ -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')

View File

@ -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)))
# 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

View File

@ -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.
@ -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()

View File

@ -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 '

View File

@ -101,3 +101,4 @@ def make_pen(picktype, phase, key, quality):
linestyle, width = pick_linestyle_pg(picktype, key)
pen = pg.mkPen(rgba, width=width, style=linestyle)
return pen