Ejemplo n.º 1
0
##I'll seed some common values for testing for now, but take these out in the final thing.##

parser = OptionParser ( usage = '%prog [options]')
parser.add_option ('--gamma', dest = 'gamma', type = float,
                default = 2.0, metavar = 'GAMMA',
                help = 'spectral index for injection')

opts,args = parser.parse_args ()
Gamma=opts.gamma

##Remember, weighted sensitivity requires src dec in radians.#
src_dec= np.radians(src_dec)
src_ra = np.radians(src_ra)
## NOTE: ADD WEIGHTS HERE FOR THE INJECTED EVENTS!! (Naturally only for flux, redshift. (Attempted to with theo_weight, will have to see if this is accepted.
inj = PointSourceInjector(Gamma, sinDec_bandwidth=.05, src_dec= src_dec, theo_weight = list(np.power(redshift,-2)), seed=0) 

results = PointSourceLLH.weighted_sensitivity(llh_redshift,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/redshift/E0_100/disc/')

# save the output
outfile = out_dir + 'gamma{}.array'.format(Gamma)
print 'Saving', outfile, '...'
cache.save(results, outfile)


Gamma=3.0

##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)

Ejemplo n.º 3
0
##We also need to input an argument, 'trials', which takes a number of mean_mu as an argument (optional).

##I'll seed some common values for testing for now, but take these out in the final thing.##
parser = OptionParser ( usage = '%prog [options]')
parser.add_option ('--gamma', dest = 'gamma', type = float,
                default = 2.0, metavar = 'GAMMA',
                help = 'spectral index for injection')

opts,args = parser.parse_args ()
Gamma=opts.gamma

##Remember, weighted sensitivity requires src dec in radians.#
src_dec= np.radians(src_dec)
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/E0_100/disc/')

# save the output
outfile = out_dir + 'gamma{}.array'.format(Gamma)
print 'Saving', outfile, '...'
cache.save(results, outfile)