def __catalogue_creation(self, filename): fout = os.path.join(self.output_path, filename) nev, mev = num.shape(self.locations) evids = (self.input).events print('Location process completed, number of located events: %d ' % (nev)) catalogue = [] with open(fout + '.txt', 'w') as f: f.write('Id Lat Lon Depth Station(s) Ts-Tp Tp\n') for i in range(nev): lat, lon = LatLongUTMconversion.UTMtoLL( 23, self.locations[i, 1] + (self.input).origin[1], self.locations[i, 0] + (self.input).origin[0], (self.input).origin[2]) depth = self.locations[i, 2] / 1000 event = evids[i] t_string = ' ' for sta in (self.input).sel_sta: if sta in (self.input).data[event].keys(): tsp = (self.input).data[event][sta][-1] tid = (self.input).data[event][sta][0] t_string = t_string + sta + ' %5.3f ' % (tsp) + str( tid) + ' ' f.write(event + ' ' + '%6.4f ' % (lat) + ' ' + '%6.4f ' % (lon) + ' ' + '%3.1f ' % (depth) + ' ' + t_string + '\n') catalogue.append([event, lat, lon, depth]) self.catalogue = num.array(catalogue)
def catalogue_creation(self, evids, origin, nref, filename, output_path): fout=os.path.join(output_path,filename) nev,mev=num.shape(self.locations) print('number of located events',nev) with open(filename,'w') as f: f.write('Id Lat Lon Depth \n') for i in range(nev): lat,lon=LatLongUTMconversion.UTMtoLL(23, self.locations[i,1]+origin[1], self.locations[i,0]+origin[0],origin[2]) if evids[i]!='REFERENCE': event=evids[i].strftime('%Y%m%dT%H%M%S.%f') f.write(event +' '+str(lat)+' '+str(lon)+' '+str(self.locations[i,2]/1000)+'\n')
def catalogue_creation(self, event, lat0, lon0, ntrial, refell=23): (zorig,eorig,norig)=LatLongUTMconversion.LLtoUTM(refell, lat0, lon0) #da adeguare in python 3 ev_file=self.output_path+'/'+event+'/'+event+'.loc' data=num.loadtxt(ev_file) if (ntrial>1): w=num.sum(data[:,4]) xb= ((num.dot(data[:,1],data[:,4])/w)*1000)+eorig yb= ((num.dot(data[:,2],data[:,4])/w)*1000)+norig late,lone=LatLongUTMconversion.UTMtoLL(refell, yb, xb, zorig) zb= num.dot(data[:,3],data[:,4])/w cb= num.mean(data[:,4]) cmax=num.max(data[:,4]) merr=num.vstack((data[:,1],data[:,2],data[:,3])) err=num.cov(merr) errmax= num.sqrt(num.max(num.linalg.eigvals(err))) else: late,lone=LatLongUTMconversion.UTMtoLL(refell, (data[2]*1000)+norig, (data[1]*1000)+eorig, zorig) zb= data[3]; errmax='NA'; cb=data[4]; cmax=data[4]; f=open(self.output_path+'/'+'catalogue','a') f.write(event+' '+str(late)+' '+str(lone)+' '+str(zb)+' '+str(errmax)+' '+str(cb)+' '+str(cmax)+'\n') f.close()
def getCoordinateList(conn, cur, sniv1_id, sosiUTM, sosiUnit, sosiFilename): sortOrder = "" if float(sniv1_id) < 0: sortOrder = "ASC" # Query to read the coordinates into a list. cur.execute("SELECT public.tbl_koordinat.x, public.tbl_koordinat.y , public.tbl_koordinat.z \ FROM public.tbl_rel_fil_sniv1 \ INNER JOIN public.tbl_sniv1 ON (public.tbl_rel_fil_sniv1.ref_sniv1=public.tbl_sniv1.id) \ INNER JOIN public.tbl_fil ON (public.tbl_rel_fil_sniv1.ref_fil=public.tbl_fil.id) \ INNER JOIN public.tbl_rel_geoobj_koordinat ON (public.tbl_rel_geoobj_koordinat.ref_geoobj=public.tbl_sniv1.id) \ INNER JOIN public.tbl_koordinat ON (public.tbl_rel_geoobj_koordinat.ref_koordinat=public.tbl_koordinat.id) \ WHERE ((public.tbl_sniv1.content = '%s') \ AND (public.tbl_fil.filnavn = '%s')) \ ORDER BY \ public.tbl_rel_geoobj_koordinat.rekkefnr %s " \ % (sniv1_id,sosiFilename,sortOrder)) rows = cur.fetchall() #initiate koordliste = [] for row in rows: # find integer value and establish unit y = int(row[0]) y = y * sosiUnit # find integer value and establish unit x = int(row[1]) x = x * sosiUnit # find integer value and establish unit if (row[2]): z = int(row[2]) z = z * sosiUnit else: z = 0 (lat, lon) = LatLongUTMconversion.UTMtoLL(23, int(y), int(x), sosiUTM) koordliste.append([lat, lon, z]) return koordliste