def read_nlloc_sum(file_in): """ Function made to read a nlloc hypocenter-file and store it into a simple LOTOS_class Catalog The ID is read from the event.comments part """ from obspy.io.nlloc.core import read_nlloc_hyp from lotos.LOTOS_class import Catalog, Event, Phase from general import util as gutil #file_in='/media/baillard/Shared/Dropbox/_Moi/Projects/Axial/PROG/NLLOC_AXIAL/loc3/AXIAL.20170130.005908.grid0.loc.hyp' #file_in='/media/baillard/Shared/Dropbox/_Moi/Projects/Axial/PROG/NLLOC_AXIAL/loc3/sum.nlloc' Ray = Catalog() cat = read_nlloc_hyp(file_in) stations_dic = Ray.stations_realname for event in cat: id_event = event.comments[0].text origin = event.preferred_origin() OT = origin.time #### Initialize Event Event_p = Event() Event_p.x = origin.longitude Event_p.y = origin.latitude Event_p.z = origin.depth / 1000 Event_p.id = id_event Event_p.ot = OT Event_p.num_phase = origin.quality.used_phase_count Picks_p = event.picks for arrival in origin.arrivals: Phase_p = Phase() if arrival.phase in ['P', 'Pn']: Phase_p.type = 1 else: Phase_p.type = 2 Pick_p = gutil.getPickForArrival(Picks_p, arrival) Phase_p.station = stations_dic[Pick_p.waveform_id.station_code] Phase_p.t_obs = Pick_p.time - OT Phase_p.t_tho = Phase_p.t_obs - arrival.time_residual Event_p.phases.append(Phase_p) Ray.events.append(Event_p) return Ray