[change] exportEvent now checks for existing picks of type 'fcheck' in xml file and replaces them with new picks
This commit is contained in:
parent
90e27f1d08
commit
b286290797
@ -1111,7 +1111,8 @@ class MainWindow(QMainWindow):
|
||||
# return False
|
||||
# MP MP changed to suppress unnecessary user prompt
|
||||
try:
|
||||
self.get_data().exportEvent(fbasename, exform, upperErrors=[uppererrorP[3], uppererrorS[3]])
|
||||
self.get_data().exportEvent(fbasename, exform, fcheck='manual',
|
||||
upperErrors=[uppererrorP[3], uppererrorS[3]])
|
||||
except FormatError as e:
|
||||
fbasename, exform = getSavePath(e, directory, outformat)
|
||||
except AttributeError as e:
|
||||
@ -1134,8 +1135,10 @@ class MainWindow(QMainWindow):
|
||||
|
||||
# export to given path
|
||||
#self.get_data().exportEvent(fbasename, exform, upperErrors=[uppererrorP[3], uppererrorS[3]])
|
||||
self.get_data().exportEvent(fbasename, exform[0], upperErrors=[uppererrorP[3], uppererrorS[3]])
|
||||
self.get_data().exportEvent(fbasename, exform[1], upperErrors=[uppererrorP[3], uppererrorS[3]])
|
||||
self.get_data().exportEvent(fbasename, exform[0], fcheck='manual',
|
||||
upperErrors=[uppererrorP[3], uppererrorS[3]])
|
||||
self.get_data().exportEvent(fbasename, exform[1], fcheck='manual',
|
||||
upperErrors=[uppererrorP[3], uppererrorS[3]])
|
||||
#self.get_data().exportEvent(fbasename, exform[2], upperErrors=[uppererrorP[3], uppererrorS[3]])
|
||||
# all files save (ui clean)
|
||||
self.update_status('Picks saved as %s, %s, and %s' % (fbasename + exform[0], fbasename + exform[1],
|
||||
|
@ -168,23 +168,32 @@ class Data(object):
|
||||
if fnext == '.xml':
|
||||
if os.path.isfile(fnout + fnext):
|
||||
print("xml-file already exists! Check content ...")
|
||||
cat_old = read_events(fnout + fnext)
|
||||
cat = read_events(fnout + fnext)
|
||||
if len(cat) > 1:
|
||||
raise IOError('Ambigious event information in file {}'.format(fnout + fnext))
|
||||
if len(cat) < 1:
|
||||
raise IOError('No event information in file {}'.format(fnout + fnext))
|
||||
event = cat[0]
|
||||
if not event.resource_id == self.get_evt_data().resource_id:
|
||||
raise IOError("Missmatching event resource id's: {} and {}".format(event.resource_id,
|
||||
self.get_evt_data().resource_id))
|
||||
checkflag = 0
|
||||
picks = cat_old.events[0].picks
|
||||
picks = event.picks
|
||||
#remove existing picks
|
||||
for j, pick in reversed(list(enumerate(picks))):
|
||||
if pick.method_id.id.split('/')[1] == fcheck:
|
||||
picks.remove(j)
|
||||
print("Found %s pick(s), remove them and append new picks to catalog." % fcheck)
|
||||
picks.pop(j)
|
||||
checkflag = 1
|
||||
if checkflag == 1:
|
||||
event = self.get_evt_data().write(fnout + fnext, format=evtformat)
|
||||
cat_new = read_events(fnout + fnext)
|
||||
cat_new.append(cat_old.events[0])
|
||||
cat_new.write(fnout + fnext, format=evtformat)
|
||||
else:
|
||||
self.get_evt_data().write(fnout + fnext, format=evtformat)
|
||||
else:
|
||||
self.get_evt_data().write(fnout + fnext, format=evtformat)
|
||||
if checkflag:
|
||||
print("Found %s pick(s), remove them and append new picks to catalog." % fcheck)
|
||||
|
||||
#append new picks
|
||||
for pick in self.get_evt_data().picks:
|
||||
if pick.method_id.id.split('/')[1] == fcheck:
|
||||
picks.append(pick)
|
||||
|
||||
self.setEvtData(event)
|
||||
self.get_evt_data().write(fnout + fnext, format=evtformat)
|
||||
|
||||
# try exporting event via ObsPy
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user