several bugfixes for the read routine for PILOT event data (testing not yet completed, see also tickets #145 and #146)

This commit is contained in:
Sebastian Wehling-Benatelli 2015-02-13 11:35:00 +01:00
parent 1b86d3bfa4
commit c35eea4588

View File

@ -64,7 +64,7 @@ def readPILOTEvent(phasfn=None, locfn=None, authority_id=None, **kwargs):
minute = int(loc['mm']) minute = int(loc['mm'])
second = int(loc['ss']) second = int(loc['ss'])
if UTCDateTime(year=year + 2000) < UTCDateTime.utcnow(): if year + 2000 < UTCDateTime.utcnow().year:
year += 2000 year += 2000
else: else:
year += 1900 year += 1900
@ -83,6 +83,7 @@ def readPILOTEvent(phasfn=None, locfn=None, authority_id=None, **kwargs):
origin = createOrigin(eventDate, loccinfo, lat, lon, dep, eventNum) origin = createOrigin(eventDate, loccinfo, lat, lon, dep, eventNum)
for n, pick in enumerate(phases['Ptime']): for n, pick in enumerate(phases['Ptime']):
if pick[0] > 0:
kwargs = {'year': int(pick[0]), kwargs = {'year': int(pick[0]),
'month': int(pick[1]), 'month': int(pick[1]),
'day': int(pick[2]), 'day': int(pick[2]),
@ -105,24 +106,24 @@ def readPILOTEvent(phasfn=None, locfn=None, authority_id=None, **kwargs):
ppicktime = UTCDateTime(**kwargs) ppicktime = UTCDateTime(**kwargs)
for picktime, phase in [(ppicktime, 'P'), (spicktime, 'S')]: for picktime, phase in [(ppicktime, 'P'), (spicktime, 'S')]:
if picktime is not None:
if phase == 'P': if phase == 'P':
wffn = os.path.join([sdir, '{0}*{1}*'.format(stations[n], wffn = os.path.join(sdir, '{0}*{1}*'.format(
'z')]) stations[n].strip(), 'z'))
else: else:
wffn = os.path.join([sdir, '{0}*{1}*'.format(stations[n], wffn = os.path.join(sdir, '{0}*{1}*'.format(
'[ne]')]) stations[n].strip(), '[ne]'))
print wffn
pick = createPick(eventDate, np, picktime, eventNum, pickcinfo, pick = createPick(eventDate, np, picktime, eventNum, pickcinfo,
phase, phase, stations[n], wffn, authority_id)
stat[n], wffn, authority_id)
event.picks.append(pick) event.picks.append(pick)
pickID = pick.get('resource_id') pickID = pick.get('id')
arrival = createArrival(pickID, eventNum, pickcinfo, phase, arrival = createArrival(eventDate, pickID, eventNum, pickcinfo,
stat[n], authority_id) phase, stations[n], authority_id)
origin.arrivals.append(arrival) origin.arrivals.append(arrival)
np += 1 np += 1
magnitude = createMagnitude(origin.get('resource_id'), eventDate, magnitude = createMagnitude(origin.get('id'), eventDate, loccinfo,
loccinfo,
authority_id) authority_id)
magnitude.mag = float(loc['Mnet']) magnitude.mag = float(loc['Mnet'])
magnitude.magnitude_type = 'Ml' magnitude.magnitude_type = 'Ml'
@ -130,10 +131,10 @@ def readPILOTEvent(phasfn=None, locfn=None, authority_id=None, **kwargs):
event.picks.append(pick) event.picks.append(pick)
event.origins.append(origin) event.origins.append(origin)
event.magnitudes.append(magnitude) event.magnitudes.append(magnitude)
return event
except AttributeError, e: except AttributeError, e:
raise AttributeError('{0} - Matlab LOC files {1} and {2} contains \ raise AttributeError('{0} - Matlab LOC files {1} and {2} contains \
insufficient data!'.format(e, phasfn, locfn)) insufficient data!'.format(e, phasfn, locfn))