[add] user prompt when event_id not matching on load_data
This commit is contained in:
parent
f1a9726f91
commit
f1f9295370
19
QtPyLoT.py
19
QtPyLoT.py
@ -675,7 +675,24 @@ class MainWindow(QMainWindow):
|
|||||||
if not event:
|
if not event:
|
||||||
event = self.get_current_event()
|
event = self.get_current_event()
|
||||||
data = Data(self, event)
|
data = Data(self, event)
|
||||||
data += Data(self, evtdata=fname)
|
try:
|
||||||
|
data_new = Data(self, evtdata=fname)
|
||||||
|
data += data_new
|
||||||
|
except ValueError:
|
||||||
|
qmb = QMessageBox(self, icon=QMessageBox.Question,
|
||||||
|
text='Warning: Missmatch in event identifiers {} and {}. Continue?'.format(
|
||||||
|
data_new.get_evt_data().resource_id,
|
||||||
|
data.get_evt_data().resource_id),
|
||||||
|
windowTitle='PyLoT - Load data warning')
|
||||||
|
qmb.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
|
||||||
|
qmb.setDefaultButton(QMessageBox.No)
|
||||||
|
ret = qmb.exec_()
|
||||||
|
if ret == qmb.Yes:
|
||||||
|
data_new.setNew()
|
||||||
|
data += data_new
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
self.data = data
|
self.data = data
|
||||||
print('Loading {} picks from file {}.'.format(type, fname))
|
print('Loading {} picks from file {}.'.format(type, fname))
|
||||||
if not loc:
|
if not loc:
|
||||||
|
@ -74,6 +74,8 @@ class Data(object):
|
|||||||
|
|
||||||
def __add__(self, other):
|
def __add__(self, other):
|
||||||
assert isinstance(other, Data), "operands must be of same type 'Data'"
|
assert isinstance(other, Data), "operands must be of same type 'Data'"
|
||||||
|
rs_id = self.get_evt_data().get('resource_id')
|
||||||
|
rs_id_other = other.get_evt_data().get('resource_id')
|
||||||
if other.isNew() and not self.isNew():
|
if other.isNew() and not self.isNew():
|
||||||
picks_to_add = other.get_evt_data().picks
|
picks_to_add = other.get_evt_data().picks
|
||||||
old_picks = self.get_evt_data().picks
|
old_picks = self.get_evt_data().picks
|
||||||
@ -85,7 +87,7 @@ class Data(object):
|
|||||||
self.evtdata = new.get_evt_data()
|
self.evtdata = new.get_evt_data()
|
||||||
elif self.isNew() and other.isNew():
|
elif self.isNew() and other.isNew():
|
||||||
pass
|
pass
|
||||||
elif self.get_evt_data().get('id') == other.get_evt_data().get('id'):
|
elif rs_id == rs_id_other:
|
||||||
other.setNew()
|
other.setNew()
|
||||||
return self + other
|
return self + other
|
||||||
else:
|
else:
|
||||||
@ -354,10 +356,16 @@ class Data(object):
|
|||||||
self.setEvtData(event)
|
self.setEvtData(event)
|
||||||
else:
|
else:
|
||||||
# prevent overwriting original pick information
|
# prevent overwriting original pick information
|
||||||
picks = copy.deepcopy(self.get_evt_data().picks)
|
event_old = self.get_evt_data()
|
||||||
|
print(event_old.resource_id, event.resource_id)
|
||||||
|
if not event_old.resource_id == event.resource_id:
|
||||||
|
print("WARNING: Missmatch in event resource id's: {} and {}".format(
|
||||||
|
event_old.resource_id,
|
||||||
|
event.resource_id))
|
||||||
|
picks = copy.deepcopy(event_old.picks)
|
||||||
event = merge_picks(event, picks)
|
event = merge_picks(event, picks)
|
||||||
# apply event information from location
|
# apply event information from location
|
||||||
self.get_evt_data().update(event)
|
event_old.update(event)
|
||||||
|
|
||||||
applydata = {'pick': applyPicks,
|
applydata = {'pick': applyPicks,
|
||||||
'event': applyEvent}
|
'event': applyEvent}
|
||||||
|
@ -15,8 +15,9 @@ class Event(ObsPyEvent):
|
|||||||
Pickable class derived from ~obspy.core.event.Event containing information on a single event.
|
Pickable class derived from ~obspy.core.event.Event containing information on a single event.
|
||||||
'''
|
'''
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
|
self.pylot_id = path.split('/')[-1]
|
||||||
# initialize super class
|
# initialize super class
|
||||||
super(Event, self).__init__(resource_id=ResourceIdentifier(path.split('/')[-1]))
|
super(Event, self).__init__(resource_id=ResourceIdentifier('smi:local/'+self.pylot_id))
|
||||||
self.path = path
|
self.path = path
|
||||||
self.database = path.split('/')[-2]
|
self.database = path.split('/')[-2]
|
||||||
self.datapath = path.split('/')[-3]
|
self.datapath = path.split('/')[-3]
|
||||||
|
Loading…
Reference in New Issue
Block a user