Fixed eventlist not working after locating twice
Changed exception when less then 2 horizontals are found to warning
This commit is contained in:
parent
21453159b7
commit
217fa330c1
18
PyLoT.py
18
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')
|
||||
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
@ -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()
|
||||
|
@ -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,
|
||||
|
@ -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 '
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user