Esempio n. 1
0
def load7yr(energy=False, sirin=False, stacking=True, mode='all', **kwargs):
    print("Energy: " + str(energy))
    print("Mode: " + str(mode))
    print("Stacking?" + str(stacking))
    if stacking:
        llh = StackingMultiPointSourceLLH()
    else:
        llh = MultiPointSourceLLH()
    print("loading IC40...")
    IC40 = init40(energy=energy, mode=mode, stacking=stacking)
    print("loading IC59...")
    IC59 = init59(energy=energy, mode=mode, stacking=stacking)
    if sirin:
        print("loading IC79 - sirin's version...")
        IC79 = init79_sirin(energy=energy, mode=mode, stacking=stacking)
    else:
        print("loading IC79...")
        IC79 = init79(energy=energy, mode=mode, stacking=stacking)
    print("loading IC86I...")
    IC86I = init86I(energy=energy, mode=mode, stacking=stacking)
    print("loading IC86II - IC86IV...")
    IC86II_III_IV = init3yr(energy=energy, mode=mode, stacking=stacking)
    samples = [IC40, IC59, IC79, IC86I, IC86II_III_IV]

    for i in xrange(len(samples)):
        llh.add_sample(str(i), samples[i])
        print("Adding sample" + str(samples[i]))
    return llh
Esempio n. 2
0
def load3yr_no40(energy=False,
                 sirin=False,
                 stacking=True,
                 nopull=False,
                 mode='all',
                 **kwargs):
    print("Energy: " + str(energy))
    print("Mode: " + str(mode))
    print("No pull?" + str(nopull))
    print("Stacking?" + str(stacking))
    if stacking:
        llh = StackingMultiPointSourceLLH()
    else:
        llh = MultiPointSourceLLH()
    print("loading IC59...")
    IC59 = init59(energy=energy, mode=mode, stacking=stacking, nopull=nopull)
    if sirin:
        print("loading IC79 - sirin's version...")
        IC79 = init79_sirin(energy=energy,
                            mode=mode,
                            stacking=stacking,
                            nopull=nopull)
    else:
        print("loading IC79...")
        #Nopull is not used for kai's sample - the correction happened after his dataset started being used.
        IC79 = init79(energy=energy, stacking=stacking, mode=mode)
    print("loading IC86I...")
    IC86I = init86I(energy=energy, mode=mode, stacking=stacking, nopull=nopull)
    samples = [IC59, IC79, IC86I]

    for i in xrange(len(samples)):
        llh.add_sample(str(i), samples[i])
        print("Adding sample" + str(samples[i]))
    return llh
Esempio n. 3
0
def multi_init(n, stacking=True, **kwargs):
    #energy = kwargs.pop("energy", False)

    #Now it looks like we don't need llhmodel ahead of time? Maybe because we can use init to get it from each sample...
    if stacking:
        llh = StackingMultiPointSourceLLH(seed=np.random.randint(2**32),
                                          **kwargs)
    else:
        llh = MultiPointSourceLLH(seed=np.random.randint(2**32), **kwargs)

    for i in xrange(len(n)):
        llh.add_sample(str(i), n[i])
        print("Adding sample: {}".format(str(n[i])))
    return llh
Esempio n. 4
0
def multi_init(n, stacking=True, **kwargs):
    #energy = kwargs.pop("energy", False)

    #Now it looks like we don't need llhmodel ahead of time? Maybe because we can use init to get it from each sample...
    if stacking:
        llh = StackingMultiPointSourceLLH(  #hemispheres=dict(Full=[-np.inf, np.inf]),
            seed=np.random.randint(2**32),
            **kwargs)
    else:
        llh = MultiPointSourceLLH(  #hemispheres=dict(Full=[-np.inf, np.inf]),
            seed=np.random.randint(2**32),
            **kwargs)
    #Not sure why it's written this way... I'll try to make it work to preserve as much functionality that I don't understand as possible.
    #for i in xrange(n):
    #    llh.add_sample(str(i), init(energy=energy))
    #On second thought I'll make n a list of the samples I want to put in.

    for i in xrange(len(n)):
        llh.add_sample(str(i), n[i])
    return llh
Esempio n. 5
0
src_ra, src_dec = 0.0, np.arcsin(sindec)

import load_PS7yr as datascript
if years == 7:
  if mese:
    llhmodel = datascript.load7yr_mese(energy=True, stacking=False, mode='all', sirin=sirin)
  else:
    llhmodel = datascript.load7yr(energy=True, stacking=False, mode='all', sirin=sirin)
  #The following catalogs used sirins IC79 and no pull correct of 1.1774 for the first 4yrs of data.
elif years == 3:
  llhmodel = datascript.load3yr(energy=True, stacking=False,mode='all')
elif years == 4:
  llhmodel = datascript.load4yr(energy=True, stacking=False, mode='all')

bckg_trials = MultiPointSourceLLH.do_trials(llhmodel,src_ra,src_dec,n_iter=batchsize)

#choose an output dir, and make sure it exists
this_dir = os.path.dirname(os.path.abspath (__file__))
if mhubertest:
  if mese:
    out_dir = misc.ensure_dir ('/data/user/brelethford/Output/all_sky_sensitivity/mstacking_{0}yr_mese/mhubertest/background_trials/'.format(str(years)))
  else:
    out_dir = misc.ensure_dir ('/data/user/brelethford/Output/all_sky_sensitivity/mstacking_{0}yr/mhubertest/background_trials/'.format(str(years)))
else:
  if mese:
    out_dir = misc.ensure_dir ('/data/user/brelethford/Output/all_sky_sensitivity/mstacking_{0}yr_mese/background_trials/'.format(str(years)))
  else:
    out_dir = misc.ensure_dir ('/data/user/brelethford/Output/all_sky_sensitivity/mstacking_{0}yr/background_trials/'.format(str(years)))

Esempio n. 6
0
inj = PointSourceInjector(Gamma, sinDec_bandwidth=.05, src_dec=src_dec, seed=0)

if disc:
  print("Calculating Discovery Potential...")
  alpha = norm.sf(5)
  beta = 0.5
  TSval = TSval5sig
  calctype = "disc"
else:
  print("Calculating Sensitivity...")
  alpha = 0.5
  beta = 0.9
  TSval = TSval_median
  calctype = "sens"

sensitivity = MultiPointSourceLLH.weighted_sensitivity(llhmodel,src_ra=src_ra,src_dec=src_dec,ext=ext,alpha=alpha,beta=beta,inj=inj,mc=MC,TSval = TSval,eps=0.04,n_iter=100)
print sensitivity

#choose an output dir, and make sure it exists
this_dir = os.path.dirname(os.path.abspath (__file__))



if mhubertest:
  if mese:
    sens_dir = misc.ensure_dir ('/data/user/brelethford/Output/all_sky_sensitivity/mstacking_{0}yr_mese/mhubertest/{1}/'.format(str(years), calctype))
  else:
    sens_dir = misc.ensure_dir ('/data/user/brelethford/Output/all_sky_sensitivity/mstacking_{0}yr/mhubertest/{1}/'.format(str(years), calctype))
else:
  if mese:
    sens_dir = misc.ensure_dir ('/data/user/brelethford/Output/all_sky_sensitivity/mstacking_{0}yr_mese/{1}/'.format(str(years),calctype))