[bugfix] avoid forming invalid pickID strings (line 194)

do not use altered resource identifier for all kinds of event  objects
This commit is contained in:
Sebastian Wehling-Benatelli 2015-06-10 15:45:49 +02:00
parent ba7ab07473
commit 1d70a236d1

View File

@ -191,7 +191,7 @@ def createPick(origintime, picknum, picktime, eventnum, cinfo, phase, station,
:type authority_id: str :type authority_id: str
:return: An ObsPy :class: `~obspy.core.event.Pick` object :return: An ObsPy :class: `~obspy.core.event.Pick` object
''' '''
pickID = eventnum + '_' + station + '/{0:3d}'.format(picknum) pickID = eventnum + '_' + station.strip() + '/{0:03d}'.format(picknum)
pickresID = createResourceID(origintime, 'pick', authority_id, pickID) pickresID = createResourceID(origintime, 'pick', authority_id, pickID)
pick = ope.Pick() pick = ope.Pick()
pick.resource_id = pickresID pick.resource_id = pickresID
@ -202,8 +202,7 @@ def createPick(origintime, picknum, picktime, eventnum, cinfo, phase, station,
return pick return pick
def createArrival(origintime, pickresID, eventnum, cinfo, phase, station, def createArrival(pickresID, cinfo, phase, azimuth=None, dist=None):
authority_id, azimuth=None, dist=None):
''' '''
createArrival - function to create an Obspy Arrival createArrival - function to create an Obspy Arrival
:param pickresID: Resource identifier of the created pick :param pickresID: Resource identifier of the created pick
@ -226,42 +225,34 @@ def createArrival(origintime, pickresID, eventnum, cinfo, phase, station,
:type dist: float or int, optional :type dist: float or int, optional
:return: An ObsPy :class: `~obspy.core.event.Arrival` object :return: An ObsPy :class: `~obspy.core.event.Arrival` object
''' '''
arriresID = createResourceID(origintime, 'arrival', authority_id, eventnum)
arrival = ope.Arrival() arrival = ope.Arrival()
arrival.resource_id = arriresID
arrival.creation_info = cinfo arrival.creation_info = cinfo
arrival.pick_id = pickresID arrival.pick_id = pickresID
arrival.phase = phase arrival.phase = phase
if azimuth is not None: if azimuth is not None:
arrival.azimuth = float(azimuth) if azimuth > -180 else azimuth + 360 arrival.azimuth = float(azimuth) if azimuth > -180 else azimuth + 360.
else: else:
arrival.azimuth = azimuth arrival.azimuth = azimuth
arrival.distance = None arrival.distance = dist
return arrival return arrival
def createMagnitude(originID, origintime, cinfo, authority_id=None): def createMagnitude(originID, cinfo):
''' '''
createMagnitude - function to create an ObsPy Magnitude object createMagnitude - function to create an ObsPy Magnitude object
:param originID: :param originID:
:param origintime:
:param cinfo: :param cinfo:
:param authority_id: :param authority_id:
:return: :return:
''' '''
magnresID = createResourceID(origintime, 'mag', authority_id)
magnitude = ope.Magnitude() magnitude = ope.Magnitude()
magnitude.resource_id = magnresID
magnitude.creation_info = cinfo magnitude.creation_info = cinfo
magnitude.origin_id = originID magnitude.origin_id = originID
return magnitude return magnitude
def createAmplitude(pickID, amp, unit, category, origintime, cinfo, def createAmplitude(pickID, amp, unit, category, cinfo):
authority_id=None):
amplresID = createResourceID(origintime, 'ampl', authority_id)
amplitude = ope.Amplitude() amplitude = ope.Amplitude()
amplitude.resource_id = amplresID
amplitude.creation_info = cinfo amplitude.creation_info = cinfo
amplitude.generic_amplitude = amp amplitude.generic_amplitude = amp
amplitude.unit = ope.AmplitudeUnit(unit) amplitude.unit = ope.AmplitudeUnit(unit)