Exemplo n.º 1
0
def astroEvent_galaxy(f_diff=1.):
    gs = GALAXY_LIBRARY.get_sample('analy')
    eg = EventGenerator(year='IC86-2012', astroModel='observed_numu_fraction')
    N_astro_north_obs = np.random.poisson(eg.nevts * 1 *
                                          eg.f_astro_north_truth)
    N_astro_north_exp = [
        N_astro_north_obs[i] /
        np.sum(eg._astro_gen.prob_reject()[i] * gs.density)
        for i in range(Defaults.NEbin)
    ]
    astro_map = eg.astroEvent_galaxy(np.array(N_astro_north_exp), gs.density)
    file_utils.write_maps_to_fits(astro_map, astropath)

    if MAKE_TEST_PLOTS:
        figs = FigureDict()
        figs.mollview_maps('astro', astro_map)
        figs.save_all(testfigpath, 'pdf')
Exemplo n.º 2
0
def atmBG():
    eg = EventGenerator()
    eventmap = eg.atmEvent(1.)
    eventmap2 = np.zeros((Defaults.NEbin, Defaults.NPIXEL))

    file_utils.write_maps_to_fits(eventmap, bgpath)
    for i in range(Defaults.NEbin):
        eventmap2[i] = eventmap[i]
        eventmap2[i][Defaults.idx_muon] = hp.UNSEEN

    mask = np.zeros(Defaults.NPIXEL)
    mask[Defaults.idx_muon] = 1.
    for i in range(Defaults.NEbin):
        test = np.ma.masked_array(eventmap[i], mask=mask)
        print(test.sum())

    if MAKE_TEST_PLOTS:
        figs = FigureDict()
        figs.mollview_maps('eventmap_atm', eventmap2)
        figs.save_all(testfigpath, 'pdf')
Exemplo n.º 3
0
coszenith_path = os.path.join(Defaults.NUXGAL_IRF_DIR, 'N_coszenith{i}.txt')
aeff_path = os.path.join(Defaults.NUXGAL_IRF_DIR, 'Aeff{i}.fits')
nevents_path = os.path.join(Defaults.NUXGAL_IRF_DIR, 'eventNumber_Ebin_perIC86year.txt')
gg_sample_path = os.path.join(Defaults.NUXGAL_ANCIL_DIR, 'galaxySampleOverdensity.fits')


aeff = file_utils.read_maps_from_fits(aeff_path, Defaults.NEbin)
cosz = file_utils.read_cosz_from_txt(coszenith_path, Defaults.NEbin)
nevts = np.loadtxt(nevents_path)
gg_overdensity = hp.fitsfunc.read_map(gg_sample_path)
gg_density = 1. + gg_overdensity
gg_density /= gg_density.sum()

nastro = 0.003 * nevts

atm_gen = AtmGenerator(Defaults.NEbin, coszenith=cosz, nevents_expected=nevts)

astro_gen = AstroGenerator(Defaults.NEbin, aeff=aeff, nevents_expected=nastro, pdf=gg_density)

astro_maps = astro_gen.generate_event_maps(1)
atm_maps = atm_gen.generate_event_maps(1)

figs.mollview_maps("astro", astro_maps[0])
figs.mollview_maps("atm", atm_maps[0])

testfigpath = os.path.join(Defaults.NUXGAL_PLOT_DIR, 'test')  
testfigfile = os.path.join(testfigpath, 'gen')
Utilityfunc.makedir_safe(testfigfile)

figs.save_all(testfigfile, 'pdf')