def eval_grid(t1, cells, intr_prms):

    t1_norm = None
    t1_copy = copy(t1)

    overlaps = []
    for cell in cells:

        try:
            prms = intr_prms
            tmp = numpy.array(cell._center)[numpy.newaxis,:]
            tmp = amrlib.apply_inv_transform(tmp, prms, opts.distance_coordinates).T
            for p, pval in zip(prms, tmp):
                #if p == "lam_tilde":
                    #t1_copy.psi0 = pval[0]
                    #t1_copy.psi3 = 0
                #else:
                setattr(t1_copy, p, pval[0])
        except AssertionError:
            rejected.append((cell, 0.0))
            continue

        # FIXME: Hardcoded waveforms
        olap, t1_norm, _ = lalsimutils.overlap(t1, t1_copy, ovrlp_obj, 0.125, 40, "TaylorF2", "TaylorF2", t1_norm=t1_norm)
        overlaps.append(olap)

    return overlaps
def eval_grid(t1, cells, intr_prms):

    t1_norm = None
    t1_copy = copy(t1)

    overlaps = []
    for cell in cells:

        try:
            prms = intr_prms
            tmp = numpy.array(cell._center)[numpy.newaxis, :]
            tmp = amrlib.apply_inv_transform(tmp, prms,
                                             opts.distance_coordinates).T
            for p, pval in zip(prms, tmp):
                #if p == "lam_tilde":
                #t1_copy.psi0 = pval[0]
                #t1_copy.psi3 = 0
                #else:
                setattr(t1_copy, p, pval[0])
        except AssertionError:
            rejected.append((cell, 0.0))
            continue

        # FIXME: Hardcoded waveforms
        olap, t1_norm, _ = lalsimutils.overlap(t1,
                                               t1_copy,
                                               ovrlp_obj,
                                               0.125,
                                               40,
                                               "TaylorF2",
                                               "TaylorF2",
                                               t1_norm=t1_norm)
        overlaps.append(olap)

    return overlaps
        continue

    dist, idx = tree.query(pt, k=npts, return_distance=True)

    t1 = tmplt_bank[i1]
    h1 = lalsimutils.generate_waveform_from_tmplt(t1, args.approximant1, delta_f, f_low)
    h1_norm = ovrlp.norm(h1)
    if args.verbose:
        print("--- %d (%f, %f) / (%f, %f)" % (int(t1.event_id), t1.mass1, t1.mass2, t1.mchirp, t1.eta))

    ovrlps = []
    for d, i2 in numpy.vstack((dist, idx)).T:
        i2 = int(i2)
        t2 = tmplt_bank[i2]

        o12, _, _ = lalsimutils.overlap(h1, t2, ovrlp, delta_f, f_low, args.approximant1, args.approximant2, t1_norm=h1_norm)
        ovrlps.append(o12)
        olapmat[i1, i2] = olapmat[i2, i1] = o12

        if args.too_verbose:
            print(d, t2.mass1, t2.mass2, t2.mchirp, t2.eta, o12)

    opts = amrlib.apply_inv_transform(pts[idx][0], intr_prms, "mchirp_eta")
    opts = numpy.vstack((opts.T, ovrlps, idx[0]))

    ovrlps = {"mass1": opt[0], "mass2": opt[1], "overlap": [list(a) for a in opts.T]}
    with open(fname, "w") as fout:
        json.dump(ovrlps, fout)

with open("tmplt_bank.json", "w") as fout:
    json.dump(toc, fout)
示例#4
0
    h1 = lalsimutils.generate_waveform_from_tmplt(t1, args.approximant1,
                                                  delta_f, f_low)
    h1_norm = ovrlp.norm(h1)
    if args.verbose:
        print("--- %d (%f, %f) / (%f, %f)" %
              (int(t1.event_id), t1.mass1, t1.mass2, t1.mchirp, t1.eta))

    ovrlps = []
    for d, i2 in numpy.vstack((dist, idx)).T:
        i2 = int(i2)
        t2 = tmplt_bank[i2]

        o12, _, _ = lalsimutils.overlap(h1,
                                        t2,
                                        ovrlp,
                                        delta_f,
                                        f_low,
                                        args.approximant1,
                                        args.approximant2,
                                        t1_norm=h1_norm)
        ovrlps.append(o12)
        olapmat[i1, i2] = olapmat[i2, i1] = o12

        if args.too_verbose:
            print(d, t2.mass1, t2.mass2, t2.mchirp, t2.eta, o12)

    opts = amrlib.apply_inv_transform(pts[idx][0], intr_prms, "mchirp_eta")
    opts = numpy.vstack((opts.T, ovrlps, idx[0]))

    ovrlps = {
        "mass1": opt[0],
        "mass2": opt[1],