[closes #137] location out of QtPyLoT now possible

This commit is contained in:
Sebastian Wehling-Benatelli 2016-08-30 14:53:58 +02:00
parent ad91504211
commit 280e954cac
2 changed files with 11 additions and 12 deletions

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import copy
import glob import glob
import os import os
from obspy import read_events, read_inventory from obspy import read_events, read_inventory
@ -434,7 +435,8 @@ class Data(object):
#firstonset = find_firstonset(picks) #firstonset = find_firstonset(picks)
if self.getEvtData().picks: if self.getEvtData().picks:
raise OverwriteError('Actual picks would be overwritten!') raise OverwriteError('Actual picks would be overwritten!')
picks = picks_from_picksdict(picks) else:
picks = picks_from_picksdict(picks)
self.getEvtData().picks = picks self.getEvtData().picks = picks
# if 'smi:local' in self.getID() and firstonset: # if 'smi:local' in self.getID() and firstonset:
# fonset_str = firstonset.strftime('%Y_%m_%d_%H_%M_%S') # fonset_str = firstonset.strftime('%Y_%m_%d_%H_%M_%S')
@ -443,25 +445,22 @@ class Data(object):
# self.getEvtData().resource_id = ID # self.getEvtData().resource_id = ID
def applyArrivals(arrivals):
"""
:param arrivals:
"""
pass
def applyEvent(event): def applyEvent(event):
""" """
takes an `obspy.core.event.Event` object and applies all new
information on the event to the actual data
:param event: :param event:
""" """
if not self.isNew(): if not self.isNew():
self.setEvtData(event) self.setEvtData(event)
else: else:
raise OverwriteError('Acutal event would be overwritten!') # prevent overwriting uncertainty information
picks = copy.deepcopy(self.getEvtData().picks)
event.picks = picks
# apply event information from location
self.getEvtData().update(event)
applydata = {'pick': applyPicks, applydata = {'pick': applyPicks,
'arrival': applyArrivals,
'event': applyEvent} 'event': applyEvent}
applydata[type](data) applydata[type](data)

View File

@ -92,7 +92,7 @@ def read_location(fn):
if len(file) > 1: if len(file) > 1:
raise IOError('ambiguous location name {0}'.format(file)) raise IOError('ambiguous location name {0}'.format(file))
fn = os.path.join(path, file[0]) fn = os.path.join(path, file[0])
return read_events(fn) return read_events(fn)[0]
if __name__ == '__main__': if __name__ == '__main__':