コード例 #1
0
inj_wfs = Bank.from_sims(sims, inj_approx, noise_model, flow)
del xmldoc2, sims[:]
if verbose:
    print "Loaded %d injections" % len(inj_wfs)
    inj_format = "".join("%s: %s   " % name_format for name_format in zip(inj_approx.param_names, inj_approx.param_formats))

# main worker loop
match_map = np.empty(len(inj_wfs), dtype=[("inj_index", np.uint32), ("inj_sigmasq", np.float32), ("match", np.float32), ("best_match_tmplt_index", np.uint32)])
for inj_ind, inj_wf in enumerate(inj_wfs):

    if verbose:
        print "injection %d/%d" % (inj_ind+1, len(inj_wfs))
        print inj_format % inj_wf.params

    # NB: sigmasq set during argmax_match
    match_tup = bank.argmax_match(inj_wf)

    if verbose:
        print "\tbest matching template:  ",
        print bank._templates[match_tup[1]].params
        print "\tbest match:  %f\n" % match_tup[0]

    match_map[inj_ind] = (inj_ind, inj_wf.sigmasq) + match_tup
    inj_wf.clear()  # prune inj waveform


if verbose:
    print "total number of match calculations:", bank._nmatch

# merge process and process_params tables, then complete ourselves
table.reset_next_ids((lsctables.ProcessTable, lsctables.ProcessParamsTable))
コード例 #2
0
# FIXME: this (potentially) breaks using mixed template bank approximants
match_map = np.empty(len(sims),
                     dtype=[("match", np.float32),
                            ("inj_sigmasq", np.float32)])
inj_bank = Bank(noise_model, flow)
tmplts = lsctables.SnglInspiralTable()
for j, sim in enumerate(sims):

    inj_wf = inj_approx.from_sim(sim, bank=inj_bank)
    inj_ind = opts.injection_min + j
    if verbose:
        print("injection %d/%d" % (j + 1, len(sims)))
        print(inj_format % inj_wf.params)

    # NB: sigmasq set during argmax_match
    match_tup = bank.argmax_match(inj_wf)

    if verbose:
        print("\tbest matching template:  ", end=' ')
        print(bank._templates[match_tup[1]].params)
        print("\tbest match:  %f\n" % match_tup[0])

    match_map[j] = (match_tup[0], inj_wf.sigmasq)
    tmplts.append(bank._templates[match_tup[1]].to_sngl())

if verbose:
    print("total number of match calculations:", bank._nmatch)

# write out results
h5file = H5File("%s.h5" % usertag, "w")
h5file.create_dataset("/sim_inspiral",