def get_results(self): cids = [] clusters = [] results_file = "{}/{}".format(self.hypoDD_control.control_directory, self.hypoDD_control.relocated_hypocenters_output ) residuals_file = "{}/{}".format(self.hypoDD_control.control_directory, self.hypoDD_control.data_residual_output ) with open(results_file, "r") as f: for line in f: num = line.split() evid = num[0] lat = float(num[1]) lon = float(num[2]) dep = 1000 * float(num[3]) # km to m errx = num[7] erry = num[8] errz = num[9] yr = int(num[10]) mo = int(num[11]) dy = int(num[12]) hr = int(num[13]) mi = int(num[14]) sc = float(num[15]) mag = num[16] nccp = num[17] nccs = num[18] nctp = num[19] ncts = num[20] rcc = num[21] rct = num[22] cid = num[23] if cid not in cids: cids.append(cid) clusters.append(Cluster()) clusters[-1].hypoDD_id=cid clusters[-1].successful_relocation=True clusters[-1].catalog=Catalog() clusters[-1].event_ids=[] origin=Origin() isec = int ( math.floor( sc )) micsec = int ( ( sc - isec) * 1000000 ) origin.time = UTCDateTime(yr, mo, dy, hr, mi, isec, micsec) origin.longitude = lon origin.latitude = lat origin.depth = dep origin.method_id = "hypoDD" # TODO (@ogalanis): Add time/location errors (when # appropriate. Add quality and origin_uncertainty. Add arrivals. event=Event() event.creation_info=CreationInfo() event.creation_info.author = __package__ event.creation_info.version = info.__version__ event.origins=[origin] event.magnitude=Magnitude() event.magnitude.mag=mag idx=cids.index(cid) clusters[idx].catalog.events.append(event) clusters[idx].event_ids.append(evid) if self.hypoDD_control.cid != 0 : my_list = [] clusters[0].connectedness = Connectedness() with open(residuals_file, "r") as f: for line in f: num = line.split() evid_1 = num[2] evid_2 = num[3] obs_type = num[4] if obs_type == "1": my_list = clusters[0].connectedness.cross_corr_P elif obs_type == "2": my_list = clusters[0].connectedness.cross_corr_S elif obs_type == "3": my_list = clusters[0].connectedness.catalog_P elif obs_type == "4": my_list = clusters[0].connectedness.catalog_S else: continue in_list = [x for x in my_list if (( x[0] == evid_1 and x[1] == evid_2 ) or ( x[0] == evid_2 and x[1] == evid_1 ))] if in_list: for x in my_list: if (( x[0] == evid_1 and x[1] == evid_2 ) or ( x[0] == evid_2 and x[1] == evid_1 )): x[2] += 1 else: my_list.append([evid_1,evid_2,1]) return clusters