Ejemplo n.º 1
0
## Time to define my modelweights in a dictionary. ##

modelweights = {'flux':flux, 'redshift': list(np.power(redshift,-2)), 'uniform':list(np.ones_like(redshift))}

##Remember, weighted sensitivity requires src dec in radians.#
src_dec= np.radians(src_dec)
src_ra = np.radians(src_ra)

##Now, I'll input my injection weighting scheme from the commandline. ##
if injweight == 'uniform':
  inj = PointSourceInjector(Gamma, sinDec_bandwidth=.05, src_dec= src_dec, seed=0)
else:
  inj = PointSourceInjector(Gamma, sinDec_bandwidth=.05, src_dec= src_dec, theo_weight = modelweights['{}'.format(injweight)], seed=0) 

sensitivity = StackingPointSourceLLH.weighted_sensitivity(llh86I,src_ra=src_ra,src_dec=src_dec,alpha=.5,beta=.9,inj=inj,trials={'n_inj':[],'TS':[],'nsources':[],'gamma':[]},longrun=True,bckg_trials=bckg_trials,eps=0.02,n_iter=250, w_theo=None)
print sensitivity

#discovery = PointSourceLLH.weighted_sensitivity(llhmodel,src_ra=src_ra,src_dec=src_dec,alpha=2.867e-7,beta=.5,inj=inj,trials={'n_inj':[],'TS':[],'nsources':[],'gamma':[]},bckg_trials=bckg_trials,eps=0.01,n_iter=250)
#print discovery

#choose an output dir, and make sure it exists
this_dir = os.path.dirname(os.path.abspath (__file__))
sens_dir = misc.ensure_dir ('/data/user/brelethford/Output/stacking_sensitivity/SwiftBAT70m/{0}yr/{1}/{2}_inj/sensitivity/'.format(str(n),llhweight, injweight))

# save the output
outfile_sens = sens_dir + 'gamma{}.array'.format(Gamma)

print 'Saving', outfile_sens, '...'
cache.save(sensitivity, outfile_sens)
#cache.save(discovery, outfile_disc)
Ejemplo n.º 2
0
##Remember, weighted sensitivity requires src dec in radians.#
src_dec = np.radians(src_dec)
src_ra = np.radians(src_ra)

inj = StackingPointSourceInjector(Gamma,
                                  sinDec_bandwidth=.05,
                                  src_dec=src_dec,
                                  seed=0)
#CURRENT PROBLEM  -never goes to the 'Estimation sens in region' phase. problem of too many events? wrong n_iter variable?
sensitivity = StackingPointSourceLLH.weighted_sensitivity(
    llhmodel,
    src_ra=src_ra,
    src_dec=src_dec,
    alpha=.5,
    beta=.9,
    inj=inj,
    mc=MC,
    TSval=TSval,
    w_theoMC=modelweights['{}'.format(llhweight)],
    w_theo=modelweights['{}'.format(injweight)],
    w_theo_fit=modelweights['{}'.format(injweight)],
    eps=0.05,
    n_iter=100)
print sensitivity

#discovery = PointSourceLLH.weighted_sensitivity(llhmodel,src_ra=src_ra,src_dec=src_dec,alpha=2.867e-7,beta=.5,inj=inj,trials={'n_inj':[],'TS':[],'nsources':[],'gamma':[]},bckg_trials=bckg_trials,eps=0.01,n_iter=250)
#print discovery

#choose an output dir, and make sure it exists
this_dir = os.path.dirname(os.path.abspath(__file__))
sens_dir = misc.ensure_dir(
    '/data/user/brelethford/Output/stacking_sensitivity/4yr_Starburst/{0}yr/{1}_mhuber_git/{2}_inj/sensitivity/'