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,13 +83,14 @@ 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']):
kwargs = {'year': int(pick[0]), if pick[0] > 0:
'month': int(pick[1]), kwargs = {'year': int(pick[0]),
'day': int(pick[2]), 'month': int(pick[1]),
'hour': int(pick[3]), 'day': int(pick[2]),
'minute': int(pick[4]), 'hour': int(pick[3]),
'second': int(str(pick[5]).split('.')[0]), 'minute': int(pick[4]),
'microsecond': int(str(pick[5]).split('.')[1][0:6])} 'second': int(str(pick[5]).split('.')[0]),
'microsecond': int(str(pick[5]).split('.')[1][0:6])}
spick = phases['Stime'][n] spick = phases['Stime'][n]
if spick[0] > 0: if spick[0] > 0:
skwargs = {'year': int(spick[0]), skwargs = {'year': int(spick[0]),
@ -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 phase == 'P': if picktime is not None:
wffn = os.path.join([sdir, '{0}*{1}*'.format(stations[n], if phase == 'P':
'z')]) wffn = os.path.join(sdir, '{0}*{1}*'.format(
else: stations[n].strip(), 'z'))
wffn = os.path.join([sdir, '{0}*{1}*'.format(stations[n], else:
'[ne]')]) wffn = os.path.join(sdir, '{0}*{1}*'.format(
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))