[add] new method to load multiple XML files at once for all events, WIP: picks loaded from XML files cannot be saved afterwards

This commit is contained in:
Marcel Paffrath 2017-06-22 16:30:22 +02:00
parent 8e8b3e0462
commit c44f351636
2 changed files with 37 additions and 12 deletions

View File

@ -637,7 +637,29 @@ class MainWindow(QMainWindow):
fname_dict = dict(phasfn=fn_phases, locfn=fn_loc) fname_dict = dict(phasfn=fn_phases, locfn=fn_loc)
self.load_data(fname_dict, type=type) self.load_data(fname_dict, type=type)
def load_data(self, fname=None, type='manual', loc=False): def load_multiple_data(self, type='manual'):
if not self.okToContinue():
return
refresh=False
events = self.project.eventlist
fext = '.xml'
for event in events:
path = event.path
eventname = path.split('/')[-1]
filename = os.path.join(path, 'picks_'+eventname+fext)
if os.path.isfile(filename):
self.load_data(filename, draw=False, event=event, overwrite=True)
refresh=True
if not refresh:
return
if self.get_current_event().picks:
self.plotWaveformDataThread()
self.drawPicks(picktype=type)
self.draw()
self.setDirty(True)
def load_data(self, fname=None, type='manual', loc=False, draw=True, event=None, overwrite=False):
if not overwrite:
if not self.okToContinue(): if not self.okToContinue():
return return
if fname is None: if fname is None:
@ -647,8 +669,10 @@ class MainWindow(QMainWindow):
self.set_fname(fname, type) self.set_fname(fname, type)
data = dict(auto=self.autodata, manual=self.data) data = dict(auto=self.autodata, manual=self.data)
data[type] += Data(self, evtdata=fname) data[type] += Data(self, evtdata=fname)
print('Loading {} picks from file {}.'.format(type, fname))
if not loc: if not loc:
self.updatePicks(type=type) self.updatePicks(type=type, event=event)
if draw:
if self.get_current_event().picks: if self.get_current_event().picks:
self.plotWaveformDataThread() self.plotWaveformDataThread()
self.drawPicks(picktype=type) self.drawPicks(picktype=type)
@ -979,7 +1003,6 @@ class MainWindow(QMainWindow):
if not exform and selected_filter or not exform in OUTPUTFORMATS: if not exform and selected_filter or not exform in OUTPUTFORMATS:
exform = selected_filter.split('*')[1][:-1] exform = selected_filter.split('*')[1][:-1]
if not exform in OUTPUTFORMATS:
return fname, exform return fname, exform
return fbasename, exform return fbasename, exform
@ -1723,13 +1746,15 @@ class MainWindow(QMainWindow):
# raise Exception('FATAL: Should never occur!') # raise Exception('FATAL: Should never occur!')
# MP MP prompt redundant because new picks have to be accepted in the first place closing PickDlg # MP MP prompt redundant because new picks have to be accepted in the first place closing PickDlg
def updatePicks(self, type='manual'): def updatePicks(self, type='manual', event=None):
if not event:
event = self.get_current_event()
picks = picksdict_from_picks(evt=self.get_data(type).get_evt_data()) picks = picksdict_from_picks(evt=self.get_data(type).get_evt_data())
if type == 'manual': if type == 'manual':
self.get_current_event().addPicks(picks) event.addPicks(picks)
self.picks.update(picks) self.picks.update(picks)
elif type == 'auto': elif type == 'auto':
self.get_current_event().addAutopicks(picks) event.addAutopicks(picks)
self.autopicks.update(picks) self.autopicks.update(picks)
self.check4Comparison() self.check4Comparison()

View File

@ -1 +1 @@
f91e1-dirty 8e8b-dirty