src_ra = np.radians(src_ra) ## NOTE: ADD WEIGHTS HERE FOR THE INJECTED EVENTS!! (Naturally only for flux, redshift. (tried with theo_weight, haven't tested it yet) inj = PointSourceInjector(Gamma, sinDec_bandwidth=.05, src_dec=src_dec, theo_weight=flux, seed=0) results = PointSourceLLH.weighted_sensitivity(llh_flux, 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 results #choose an output dir, and make sure it exists this_dir = os.path.dirname(os.path.abspath(__file__)) out_dir = misc.ensure_dir( '/data/user/brelethford/Output/stacking_sensitivity/SwiftBAT70m/flux/disc/' )
##I need to have this src_dec=[np.radians(dec_deg)] src_ra=[0.0] ## NOTE: ADD WEIGHTS HERE FOR THE INJECTED EVENTS!! (Naturally only for flux, redshift. ##For now the weighted sensitivity function only works if there are at least two sources. to push it through for a single source, I'll copy the source location.## ### Mike - This is the step that allows the function weighted_sensitivity to process! ### #src_dec=[src_dec[0],src_dec[0]] #src_ra=[src_ra[0],src_ra[0]] inj = PointSourceInjector(Gamma, sinDec_bandwidth=.05, src_dec= src_dec,seed=0) results = PointSourceLLH.weighted_sensitivity(llh_single,src_ra=src_ra,src_dec=src_dec,alpha=.5,beta=.9,inj=inj,trials={'n_inj':[],'TS':[],'nsources':[],'gamma':[]},bckg_trials=bckg_trials,eps=0.01,n_iter=250, miniter=2500)# maxtrial=1000) #Currently have n_iter down from 1000 to reduce estimation time. Also lowering maxtrial from 1000 to 500. print results #choose an output dir, and make sure it exists this_dir = os.path.dirname(os.path.abspath (__file__)) out_dir = misc.ensure_dir (outfolder+'sensitivity/') # save the output outfile = out_dir + 'dec{0:+010.5}.array'.format(dec_deg) print 'Saving', outfile, '...' cache.save(results, outfile)
llhmodel = data_multi.init79(energy=True, mode='box') elif year == '86': llhmodel = data_multi.init86I(energy=True, mode='box') elif year == '59': llhmodel = data_multi.init59(energy=True, mode='box') #If I change the injection range I'll redefine the _e_range variable in ps_injector_stack.py. sensitivity = PointSourceLLH.weighted_sensitivity(llhmodel, src_ra=src_ra, src_dec=src_dec, alpha=.5, beta=.9, inj=inj, trials={ 'n_inj': [], 'TS': [], 'nsources': [], 'gamma': [] }, bckg_trials=bckg_trials, eps=0.02, n_iter=250) 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__))