def GetMatch(waveform0p, waveform1p, psd_file, f_low=30., freq_step=4): flen = max(len(waveform0p), len(waveform1p)) waveform0p.resize(flen) waveform1p.resize(flen) # grab and use the psd file my_psd = pycbc.psd.read.from_txt(filename=psd_file, length=flen, delta_f=1.0 / 4, low_freq_cutoff=f_low, is_asd_file=False) m, i = match(waveform0p, waveform1p, psd=my_psd, low_frequency_cutoff=f_low) return m
def GetMatch (template0,template1, psd_file =args.psd_filename, f_low=30): #resize two templates tlen = max(len(template0),len(template1)) template1.resize(tlen) template0.resize(tlen) #grab and use the psd file my_psd = pycbc.psd.read.from_txt(filename = psd_file, length = tlen, delta_f = template0.delta_f, low_freq_cutoff = f_low, is_asd_file = False) #calculate match m,i = match(template0,template1,psd=my_psd,low_frequency_cutoff=f_low) return m
def GetMatch(template0, template1, psd_file=args.psd_filename, f_low=30): #resize two templates flen = max(len(template0), len(template1)) #template1=template1.copy() template1.resize(flen) #template0=template0.copy() template0.resize(flen) #grab and use the psd file #df = 1.0/template1.duration my_psd = pycbc.psd.read.from_txt(filename=psd_file, length=flen, delta_f=1.0 / 4, low_freq_cutoff=f_low, is_asd_file=False) #calculate match m, i = match(template0, template1, psd=my_psd, low_frequency_cutoff=f_low) return m
def compare(psd, psd_path, hep, hec, distance, f_low, f_high, approx_e, EOS_e, hm_path): if psd_type == 'aLIGOZeroDetHighPower': inclination = 0.0 hhm = h5py.File(hm_path, 'r') EOS_m = hhm.attrs['EOS'] grav_m1 = hhm.attrs['grav_mass1'] grav_m2 = hhm.attrs['grav_mass2'] s1x = hhm.attrs['spin1x'] s1y = hhm.attrs['spin1y'] s1z = hhm.attrs['spin1z'] s2x = hhm.attrs['spin2x'] s2y = hhm.attrs['spin2y'] s2z = hhm.attrs['spin2z'] f_lower_hhm = hhm.attrs[ 'f_lower_at_1MSUN'] #/(2.0 * lal.TWOPI * lal.MTSUN_SI*(m1+m2)) hhm_freq = hhm.attrs['hybridize_freq'] hhm_shift_time = hhm.attrs['shift_time'] approx_m = hhm.attrs['approx'] h_matchm = hhm.attrs['hybrid_match'] sim_name = hhm.attrs['sim_name'] hhm.close() hmp, hmc = get_td_waveform(approximant='NR_hdf5', numrel_data=hm_path, mass1=grav_m1, mass2=grav_m2, spin1z=s1z, spin1x=s1x, spin1y=s1y, spin2z=s2z, spin2x=s2x, spin2y=s2y, delta_t=delta_t, distance=distance, f_lower=f_lower_hhm, inclination=inclination) ### multiply by stupid pycbc factor hmp = hmp * pycbc_factor hmc = hmc * pycbc_factor ### set a constant t_len. We do this because all the numerical waveforms will be padded to this length and a new fft plan will not be needed. Basically this makes everything ### MUCH faster. t_len = 300000 hep.resize(t_len) hmp.resize(t_len) #Generate the aLIGO ZDHP PSD delta_f = 1.0 / hmp.duration f_len = t_len / 2 + 1 psd = aLIGOZeroDetHighPower(f_len, delta_f, f_low) #calculate L2 distance l2_distance = hy.delta_h(hep, hmp) #calculate snr and match values hep_hmp_match, index = matchedfilter.match( hep, hmp, psd=psd, low_frequency_cutoff=f_low, high_frequency_cutoff=f_high) hmp_norm = matchedfilter.sigmasq(hmp, psd=psd, low_frequency_cutoff=f_low, high_frequency_cutoff=f_high) overlap = matchedfilter.overlap(hep, hmp, psd=psd, low_frequency_cutoff=f_low, high_frequency_cutoff=f_high) mismatch = 1.0 - overlap data = (l2_distance, hep_hmp_match, overlap, mismatch, hmp_norm, h_matchm, hhm_shift_time, hhe_freq, hhm_freq, approx_e, approx_m, EOS_e, EOS_m, sim_name) return data elif psd_type != 'aLIGOZeroDetHighPower': # similar to previous section inclination = 0.0 hhm = h5py.File(hm_path, 'r') EOS_m = hhm.attrs['EOS'] grav_m1 = hhm.attrs['grav_mass1'] grav_m2 = hhm.attrs['grav_mass2'] s1x = hhm.attrs['spin1x'] s1y = hhm.attrs['spin1y'] s1z = hhm.attrs['spin1z'] s2x = hhm.attrs['spin2x'] s2y = hhm.attrs['spin2y'] s2z = hhm.attrs['spin2z'] f_lower_hhm = hhm.attrs[ 'f_lower_at_1MSUN'] #/(2.0 * lal.TWOPI * lal.MTSUN_SI*(m1+m2)) hhm_freq = hhm.attrs['hybridize_freq'] hhm_shift_time = hhm.attrs['shift_time'] approx_m = hhm.attrs['approx'] h_matchm = hhm.attrs['hybrid_match'] sim_name = hhm.attrs['sim_name'] hhm.close() hmp, hmc = get_td_waveform(approximant='NR_hdf5', numrel_data=hm_path, mass1=grav_m1, mass2=grav_m2, spin1z=s1z, spin1x=s1x, spin1y=s1y, spin2z=s2z, spin2x=s2x, spin2y=s2y, delta_t=delta_t, distance=distance, f_lower=f_lower_hhm, inclination=inclination) ### multiply by stupid pycbc factor hmp = hmp * pycbc_factor hmc = hmc * pycbc_factor t_len = 300000 hep.resize(t_len) hmp.resize(t_len) #Generate the aLIGO ZDHP PSD delta_f = 1.0 / hmp.duration f_len = t_len / 2 + 1 ### reads in a custom psd file psd = pycbc.psd.read.from_txt(psd_path, f_len, delta_f, f_low, is_asd_file=True) l2_distance = hy.delta_h(hep, hmp) hep_hmp_match, index = matchedfilter.match( hep, hmp, psd=psd, low_frequency_cutoff=f_low, high_frequency_cutoff=f_high) hmp_norm = matchedfilter.sigmasq(hmp, psd=psd, low_frequency_cutoff=f_low, high_frequency_cutoff=f_high) overlap = matchedfilter.overlap(hep, hmp, psd=psd, low_frequency_cutoff=f_low, high_frequency_cutoff=f_high) mismatch = 1.0 - overlap data = (l2_distance, hep_hmp_match, overlap, mismatch, hmp_norm, h_matchm, hhm_shift_time, hhe_freq, hhm_freq, approx_e, approx_m, EOS_e, EOS_m, sim_name) return data