# phases2hypoellipse

**URL:** <https://discourse.obspy.org/t/phases2hypoellipse/560>\
**Category:** Users Mailing List Archive\
**Tags:** archive\
**Created:** [October 4, 2016, 6:06pm UTC](https://discourse.obspy.org/t/phases2hypoellipse/560 "2016-10-04T18:06:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![VICIC\_BLAZ\_PHD090001](https://discourse.obspy.org/letter_avatar_proxy/v4/letter/v/7993a0/32.png) [@VICIC\_BLAZ\_PHD090001](https://discourse.obspy.org/u/VICIC_BLAZ_PHD090001)\
**Post date:** [October 4, 2016, 6:06pm UTC](https://discourse.obspy.org/t/phases2hypoellipse/560/1 "2016-10-04T18:06:28Z")

</div>

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 = pick.time.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)  
else:  
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.  
Blaž
