Dear all

I have a bunch of nonlinloc obs files (one file per event). I read them in with:

import glob
from obspy import read_events

path = ‘events/’
event_files = glob.glob(path + ‘*.hyp’)

for event_file in event_files:
cat = read_events(event_file)

event = cat[0]
for pick in event.picks:

sta = pick.waveform_id.station_code
phase = pick.phase_hint
year = pick.time.year

month = pick.time.month
day =
hh = pick.time.hour
minute = pick.time.minute
sec = pick.time.second
ms = pick.time.microsecond
time = pick.time.strftime("%Y%m%d%H%M%S.%f")

time = time[2:-4]

if len(sta)<=3:
print ‘%s%s %s %s %s’ %(" ",sta, phase, 0, time)
print ‘%s %s %s %s’ %(sta, phase, 0, time)

Now, I would like to create a file with phases in hypoellipse format. With the script I read each pick of the event but I dont know how to combine them into the hypoellipse format. Printed lines are:

JAVS P 0 060107084657.30
JAVS S 0 060107084659.41
CEY P 0 060107084659.39
CEY S 0 060107084703.10
CADS P 0 060107084703.67
VISS P 0 060107084704.14

I need to combine P and S line on the same station into one.

Thanks for the help.