[closes #145], [addresses #146] this commit introduces the handling of picks as obspy event objects

This commit is contained in:
Sebastian Wehling-Benatelli 2015-07-18 16:09:50 +02:00
parent 17933c75f0
commit fc86179c39

View File

@ -5,7 +5,7 @@ import os
from obspy.core import read, Stream, UTCDateTime from obspy.core import read, Stream, UTCDateTime
from obspy import readEvents, read_inventory from obspy import readEvents, read_inventory
from obspy.core.event import Event, Catalog, ResourceIdentifier from obspy.core.event import Event, ResourceIdentifier, Pick, WaveformStreamID
from pylot.core.read.io import readPILOTEvent from pylot.core.read.io import readPILOTEvent
from pylot.core.util.utils import fnConstructor, getGlobalTimes from pylot.core.util.utils import fnConstructor, getGlobalTimes
@ -46,6 +46,7 @@ class Data(object):
else: # create an empty Event object else: # create an empty Event object
self.newevent = True self.newevent = True
self.evtdata = Event() self.evtdata = Event()
self.getEvtData().picks = []
self.wforiginal = None self.wforiginal = None
self.cuttimes = None self.cuttimes = None
self.dirty = False self.dirty = False
@ -160,27 +161,47 @@ class Data(object):
def applyPicks(picks): def applyPicks(picks):
firstonset = None firstonset = None
for phase in picks: for station, onsets in picks.items():
onset = picks[phase]['epp'] print 'Reading picks on station %s' % station
if firstonset is None or firstonset > onset: for label, phase in onsets.items():
firstonset = onset onset = phase['mpp']
epp = phase['epp']
lpp = phase['lpp']
error = phase['spe']
pick = Pick()
pick.time = onset
pick.time_errors.lower_uncertainty = onset - epp
pick.time_errors.upper_uncertainty = lpp - onset
pick.time_errors.uncertainty = error
pick.phase_hint = label
pick.waveform_id = WaveformStreamID(station_code=station)
self.getEvtData().picks.append(pick)
try:
polarity = phase['fm']
except KeyError, e:
print 'No polarity information found for %s' % phase
if firstonset is None or firstonset > onset:
firstonset = onset
if 'smi:local' in self.getID(): if 'smi:local' in self.getID():
fonset_str = firstonset.strftime('%Y_%m_%d_%H_%M_%S') fonset_str = firstonset.strftime('%Y_%m_%d_%H_%M_%S')
ID = ResourceIdentifier(fonset_str) ID = ResourceIdentifier('event/' + fonset_str)
ID.convertIDToQuakeMLURI(authority_id=authority_id) ID.convertIDToQuakeMLURI(authority_id=authority_id)
self.getEvtData().resource_id = ID
def applyArrivals(arrivals): def applyArrivals(arrivals):
pass pass
def applyEvent(event): def applyEvent(event):
pass pass
applydata = {'pick':applyPicks, applydata = {'pick': applyPicks,
'arrival':applyArrivals, 'arrival': applyArrivals,
'event':applyEvent} 'event': applyEvent}
applydata[type](data) applydata[type](data)
class GenericDataStructure(object): class GenericDataStructure(object):
''' '''
GenericDataBase type holds all information about the current data- GenericDataBase type holds all information about the current data-