##['beta', 'TS_beta', 'beta_err', 'n_inj', 'nsources', 'TS', 'gamma']##
## Let's use a uniform weight (none) first to yield our bckg trials. ##

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

Gamma = 2

##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=.5,
                                              beta=.9,
                                              inj=inj,
                                              trials={
                                                  'n_inj': [],
                                                  'TS': [],
                                                  'nsources': [],
                                                  'gamma': []
                                              },
Gamma = 2

##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.05,
Esempio n. 3
0
## Like in the background trials, we have to define which llhmodel to use.
if llhweight == 'uniform':
    llhmodel = data.init(energy=True)
else:
    llhmodel = data.init(energy=True,
                         weighting=modelweights['{}'.format(llhweight)])

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

inj = PointSourceInjector(Gamma,
                          sinDec_bandwidth=.05,
                          src_dec=src_dec,
                          theo_weight=modelweights['{}'.format(injweight)],
                          seed=0)
#inj.e_range = [1.e4,1.e8]

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': []
Esempio n. 4
0
#We've loaded in the appropriate llh samples, now let's put them both in the blender (not sure about weighting)
samples = [llh40, llh59, llh79, llh86I]

llhmodel = data_multi.multi_init(samples, energy=True)

##Remember, weighted sensitivity requires src dec in radians.#

##Now, I'll input my injection weighting scheme from the commandline. APPARENTLY, I need these as radians, not sin(dec).##
#Also, I need to clip these just before they hit the pole - otherwise I'm gonna get out of bounds errors.
limit = np.round(np.pi / 2, 7)
#DONT change the rounding on limit - I chose it specifically because it rounds down.
src_dec = np.clip(np.arcsin(np.linspace(-1, 1, 21)), -limit, limit)

inj_array = [
    PointSourceInjector(2.0,
                        sinDec_bandwidth=0.05,
                        src_dec=np.atleast_1d(src_dec[i]))
    for i in range(len(src_dec))
]
flux_array = []
#fill the injarrays:
for i in range(len(src_dec)):
    inj = inj_array[i]
    MultiPointSourceLLH.weighted_sensitivity(llhmodel,
                                             src_ra=np.atleast_1d(0.),
                                             src_dec=np.atleast_1d(src_dec[i]),
                                             alpha=.5,
                                             beta=.9,
                                             inj=inj,
                                             trials={
                                                 'n_inj': [],
##['beta', 'TS_beta', 'beta_err', 'n_inj', 'nsources', 'TS', 'gamma']##
## Let's use a uniform weight (none) first to yield our bckg trials. ##

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

Gamma = 2

##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=.5,
                                              beta=.9,
                                              inj=inj,
                                              trials={
                                                  'n_inj': [],
                                                  'TS': [],
                                                  'nsources': [],
                                                  'gamma': []
                                              },
Esempio n. 6
0
src_ra = np.radians(src_ra)

## Time to define my modelweights in a dictionary. ##

## Now to import my llh model framework. ##
import data_multi

## Like in the background trials, we have to define which llhmodel to use.
llh79 = data_multi.init79(energy=True, mode='box')
llh86I = data_multi.init86I(energy=True, mode='box')
llh59 = data_multi.init59(energy=True, mode='box')
llh40 = data_multi.init40(energy=True, mode='box')

#We've loaded in the appropriate llh samples, now let's put them both in the blender (not sure about weighting)
samples = [llh40, llh59, llh79, llh86I]

llhmodel = data_multi.multi_init(samples, energy=True)

mc = llhmodel.mc

total_mu = 0
for i in range(len(src_dec)):
    inj = PointSourceInjector(gamma=2.0,
                              sinDec_bandwidth=0.05,
                              src_dec=src_dec[i],
                              seed=0)
    inj.fill(src_ra[i], src_dec[i], mc)
    total_mu += inj.flux2mu(5.61e-12 / 519.)

print(total_mu)
Esempio n. 7
0
    llh86I = data_multi.init86I(energy=True,
                                weighting=modelweights['{}'.format(llhweight)])
    llh59 = data_multi.init59(energy=True,
                              weighting=modelweights['{}'.format(llhweight)])

#We've loaded in the appropriate llh samples, now let's put them both in the blender (not sure about weighting)
samples = [llh40, llh59, llh79, llh86I]

llhmodel = data_multi.multi_init(samples, energy=True)

##Remember, weighted sensitivity requires src dec in radians.#

##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 = MultiPointSourceLLH.weighted_sensitivity(llhmodel,
                                                       src_ra=src_ra,
                                                       src_dec=src_dec,
                                                       alpha=.5,
                                                       beta=.9,
                                                       inj=inj,
                                                       trials={