def eval_overlap(grid,P_list, IP,indx):
    global opts
#    if opts.verbose: 
#        print " Evaluating for ", indx
    global use_external_EOB
    global Lmax
    global opts
    P2 = P_list[indx]
    T_here = 1./IP.deltaF
    P2.deltaF=1./T_here
#    P2.print_params()
    if not opts.skip_overlap:
        if not use_external_EOB:
            hf2 = lalsimutils.complex_hoff(P2)
        else:
            print("  Waiting for EOB waveform ....", indx, " with duration  ", T_here)
            wfP = eobwf.WaveformModeCatalog(P2,lmax=Lmax)  # only include l=2 for us.
            hf2 = wfP.complex_hoff(force_T=T_here)
        nm2 = IP.norm(hf2);  hf2.data.data *= 1./nm2
#    if opts.verbose:
#        print " Waveform normalized for ", indx
        ip_val = IP.ip(hfBase,hf2)
    line_out = []
    line_out = list(grid[indx])
    if not opts.skip_overlap:
        line_out.append(ip_val)
    else:
        line_out.append(-1)
    if opts.verbose:
        print(" Answer ", indx, line_out)
    return line_out
 def ip_here(x):
     PT.assign_param(param_now,x)
     PT.deltaF = IP.deltaF
     hf_now = lalsimutils.complex_hoff(PT)
     nm_now = IP.norm(hf_now)
     val = IP.ip(hfBase,hf_now)/nm_now
     if opts.verbose:
         print(param_now, x, val)
     return val - opts.match_value
    def my_distance(P1, P2):
        global IP
        global opts
        P1.approx = P2.approx = lalsim.GetApproximantFromString(opts.approx)
        P1.fmin = P2.fmin = opts.fmin
        P1.deltaF = P2.deltaF = 1. / T_window

        # if opts.verbose:
        #     print " ---> Inside distance function < "
        #     P1.print_params()
        #     P2.print_params()
        dist = 1e5
        try:
            hF1 = lalsimutils.complex_hoff(P1)
            hF2 = lalsimutils.complex_hoff(P2)
            rho1 = IP.norm(hF1)
            rho2 = IP.norm(hF2)
            dist = 1 - np.abs(IP.ip(hF1, hF2) / rho1 / rho2)
        except:
            print(" Distance evaluation failure ")
        if np.isnan(dist):
            return 1e5
        return dist
Esempio n. 4
0
def eval_overlap(grid, P_list, IP, indx):
    #    if opts.verbose:
    #        print " Evaluating for ", indx
    global Lmax
    global opts
    P2 = P_list[indx]
    #    P2.print_params()
    line_out = []
    line_out = list(grid[indx])
    if not opts.skip_overlap:
        T_here = 1. / IP.deltaF
        P2.deltaF = 1. / T_here
        hf2 = lalsimutils.complex_hoff(P2)
        nm2 = IP.norm(hf2)
        hf2.data.data *= 1. / nm2
        ip_val = IP.ip(hfBase, hf2)
        line_out.append(ip_val)
    else:
        line_out.append(-1)
    if opts.verbose:
        print(" Answer ", indx, line_out)
    return line_out
        analyticPSD_Q = True
    else:
        print(" Importing PSD file ", opts.psd_file)
        eff_fisher_psd = lalsimutils.load_resample_and_clean_psd(
            opts.psd_file, 'H1', 1. / opts.seglen)
        analyticPSD_Q = False

    ###
    ###  Create the  inner product function, etc needed (distance =match)
    ###
    P = lalsimutils.ChooseWaveformParams()
    P.m1 = P.m2 = 50 * lal.MSUN_SI
    P.approx = lalsim.GetApproximantFromString(opts.approx)
    P.deltaT = 1. / srate
    P.deltaF = 1. / opts.seglen
    hfBase = lalsimutils.complex_hoff(P)
    IP = lalsimutils.CreateCompatibleComplexOverlap(
        hfBase,
        analyticPSD_Q=analyticPSD_Q,
        psd=eff_fisher_psd,
        fMax=opts.fmax,
        interpolate_max=True)

    def my_distance(P1, P2):
        global IP
        global opts
        P1.approx = P2.approx = lalsim.GetApproximantFromString(opts.approx)
        P1.fmin = P2.fmin = opts.fmin
        P1.deltaF = P2.deltaF = 1. / T_window

        # if opts.verbose:
Esempio n. 6
0
samples_in = np.genfromtxt(opts.fname_lalinference,names=True)
print(" Done loading samples ")
deltaT = 1./4096
T_window =int(opts.seglen)

# Create overlap 
P=lalsimutils.ChooseWaveformParams()
P.deltaT = deltaT
P.deltaF = 1./T_window
P.fmin = samples_in["flow"][0]
P.approx=lalsim.SpinTaylorT2
P.print_params()
print(lalsimutils.estimateDeltaF(P), P.deltaF)
if P.deltaF > lalsimutils.estimateDeltaF(P):
    sys.exit(0)
hfBase = lalsimutils.complex_hoff(P) # Does not matter what this is.
print(" Done generating waveform")
IP = lalsimutils.CreateCompatibleComplexOverlap(hfBase,analyticPSD_Q=analyticPSD_Q,psd=eff_fisher_psd,fMax=opts.fmax,interpolate_max=True)
print(" Done populating inner product")


# Similar code: convert_output_format_inference2ile
fac_reduce=1
for indx in np.arange(len(samples_in["m1"])):
#    print indx
    ###
    ###  Define the system
    ###
    m1 = samples_in["m1"][indx]*lal.MSUN_SI
    m2 = samples_in["m2"][indx]*lal.MSUN_SI
    d = samples_in["distance"][indx]*lal.PC_SI*1e6