Beispiel #1
0
check_dir(outpath, ask=False)

# Extract source info, use the same fixed spectral index -2 for all
sources = _loader.source_list_loader()
nsrcs = len(sources)
ra = [src["ra"] for src in sources]
dec = [src["dec"] for src in sources]
# Theo weights need to be normalized manually in skylab?
w = np.ones(nsrcs, dtype=float) / float(nsrcs)

# Create the multi LLH
rnd_seed = 1
multillh = MultiPointSourceLLH(seed=rnd_seed, ncpu=40)

livetimes = _loader.livetime_loader()
for name, livetime in sorted(livetimes.items()):
    print("\n# Setting up LLH for sample '{}'".format(name))
    # Get exp data and MC
    exp = _loader.exp_data_loader(name)[name]
    mc = _loader.mc_loader(name)[name]

    # Setup the energy LLH model with fixed index, only ns is fitted
    settings = _loader.settings_loader(name, skylab_bins=use_skylab_bins)[name]
    llh_model = EnergyLLH(**settings["llh_model_opts"])
    llh = PointSourceLLH(exp,
                         mc,
                         livetime,
                         llh_model,
                         scramble=scramble,
                         **settings["llh_opts"])
key2set = {
    "IC79": pstracks,
    "IC86_2011": pstracks,
    "IC86_2012-2014": pstracks,
    "IC86_2015": gfu,
}

key2skylab = {
    "IC79": "IC79",
    "IC86_2011": "IC86, 2011",
    "IC86_2012-2014": "IC86, 2012-2014",
    "IC86_2015": "IC86, 2015",
}

# Make settings for each module per sample
sample_names = sorted(_loader.livetime_loader().keys())
for key in sample_names:
    print("Building settings file for sample '{}'".format(key))
    # Load data that settings depend on
    mc = _loader.mc_loader(key)[key]

    # :: LLH model ::
    # This is kind of arbitrary, but seems to produce robust PDFs
    logE_bins = np.linspace(np.floor(np.amin(mc["logE"])),
                            np.ceil(np.amax(mc["logE"])), 30)

    # Get the official binnings from skylab instead
    if use_skylab_bins:
        sindec_bins = key2set[key].sinDec_bins(key2skylab[key])
        logE_bins = key2set[key].energy_bins(key2skylab[key])