Exemple #1
0
# ##############################################################################
result = {
    "ts": [],
    "ns": [],
    "gamma": [],
    "pval": [],
    "sigma": [],
    "n_unblindings": n_unblindings,
    "scrambled": scramble,
}

# Get the unblinded result(s)
for i in tqdm(range(n_unblindings)):
    bf_ts, bf_params = multillh.fit_source(src_ra=ra,
                                           src_dec=dec,
                                           src_w=w,
                                           scramble=scramble)

    # Calculate the p-value and significance from the BG only TS distribution
    pval = bg_ts_dist.sf(bf_ts)
    sigma = prob2sigma(1. - pval)

    result["ts"].append(bf_ts)
    result["ns"].append(bf_params["nsources"])
    result["gamma"].append(bf_params["gamma"])
    result["pval"].append(pval[0])
    result["sigma"].append(sigma[0])

# ##############################################################################

# Print result
Exemple #2
0
ns = np.zeros(ntrials, dtype=float)
gamma = np.zeros(ntrials, dtype=float)
nsig_injected = np.zeros(ntrials, dtype=int)

tenth = ntrials // 10
for i in range(ntrials):
    # Sample signal events and insert into the trial method
    nsig = rndgen.poisson(lam=mu, size=1)
    signal_sam = multiinj.sample(nsig)

    # Convert to a form skylab understands and does not reject
    signal_sam = convert_signal_sample(signal_sam, multillh)

    res = multillh.fit_source(src_ra=src_ra,
                              src_dec=src_dec,
                              src_w=src_w,
                              scramble=True,
                              inject=signal_sam)
    bf_params = res[1]

    # Store results
    nsig_injected[i] = nsig
    ts[i] = res[0]
    ns[i] = bf_params["nsources"]
    gamma[i] = bf_params["gamma"]

    if (i + 1) % tenth == 0:
        print("{:.0%}".format((i + 1) / ntrials))

print(":: Done. {} ::".format(sec2str(time() - _t0)))