coincs = skylocutils.Coincidences(files, opts.input_type) dt = [] dD = [] for coinc in coincs: inj_pt = (coinc.latitude_inj, coinc.longitude_inj) if len(coinc.ifo_list) < 3: continue else: if opts.snr_threshold: rhosquared = 0.0 for ifo in coinc.ifo_list: rhosquared += coinc.snr[ifo] * coinc.snr[ifo] dtrss_inj = sqrt(rhosquared) * skylocutils.get_delta_t_rss(inj_pt, coinc, opts.reference_frequency) / 10.0 else: dtrss_inj = skylocutils.get_delta_t_rss(inj_pt, coinc, opts.reference_frequency) dDrss_inj = skylocutils.get_delta_D_rss(inj_pt, coinc) dt.append(dtrss_inj) dD.append(dDrss_inj) # for the kdes npts = opts.Npts dtbw = compute_bw(dt, npts) dtdat = np.array(dt, "float").reshape(len(dt), 1) pdtx = np.linspace(0.0, max(dt), npts) pdty = [skylocutils.gaussian_kde(dtdat, xn, dtbw) for xn in pdtx] pdtnorm = np.trapz(pdty, pdtx) Ptx = pdtx
coincs = skylocutils.Coincidences(files, opts.input_type) dt = [] dD = [] for coinc in coincs: inj_pt = (coinc.latitude_inj, coinc.longitude_inj) if len(coinc.ifo_list) < 3: continue else: if opts.snr_threshold: rhosquared = 0.0 for ifo in coinc.ifo_list: rhosquared += coinc.snr[ifo] * coinc.snr[ifo] dtrss_inj = sqrt(rhosquared) * skylocutils.get_delta_t_rss( inj_pt, coinc, opts.reference_frequency) / 10.0 else: dtrss_inj = skylocutils.get_delta_t_rss(inj_pt, coinc, opts.reference_frequency) dDrss_inj = skylocutils.get_delta_D_rss(inj_pt, coinc) dt.append(dtrss_inj) dD.append(dDrss_inj) #for the kdes npts = opts.Npts dtbw = compute_bw(dt, npts) dtdat = np.array(dt, 'float').reshape(len(dt), 1) pdtx = np.linspace(0.0, max(dt), npts) pdty = [skylocutils.gaussian_kde(dtdat, xn, dtbw) for xn in pdtx] pdtnorm = np.trapz(pdty, pdtx)
#open up the necessary pickle with info on the galaxy prior if opts.galaxy_priors_dir: mineffD = ceil(min(coinc.eff_distances.values())) if mineffD > 50.: mineffD = 50 f = open(opts.galaxy_priors_dir+'/galaxy_prior_'+str(int(mineffD))+'Mpc.pkl','r') gal_prior = cPickle.load(f) f.close() print >>sys.stdout, 'Processing trigger at '+str(coinc.time) #main loop over the coarse grid for coarse_pt in grid.keys(): #use timing alone to determine if we should move to the fine grid dtrss_coarse = dtsnrfac*skylocutils.get_delta_t_rss(coarse_pt,coinc,ref_freq) Pdt_coarse = 1 - Pdt.get_rank(dtrss_coarse) if Pdt_coarse >= opts.coarse_cut: #loop over points on the fine grid for fine_pt in grid[coarse_pt]: dtrss_fine = dtsnrfac*skylocutils.get_delta_t_rss(fine_pt,coinc,ref_freq) dtrank = dtr.get_rank(dtrss_fine) dDrss_fine = skylocutils.get_delta_D_rss(fine_pt,coinc) dDrank = dDr.get_rank(dDrss_fine) L = dtrank*dDrank pval = 0.0 if opts.galaxy_priors_dir: try: pval = gal_prior[fine_pt] except KeyError: pass