def mese_followup(**kwargs): livetime = 988.54 livetime += 358.402 livetime += 368.381 print("\tLoading MESE with 2 follow-up years...") exp = np.append(np.load(os.path.join(path, "MESE_exp.npy")), np.load(os.path.join(path, "MESE_followup_exp.npy"))) mc = np.load(os.path.join(path, "MESE_MC.npy")) if "dist" in exp.dtype.names: exp = drop_fields(exp, ["dist"], usemask=False) if "dist" in mc.dtype.names: mc = drop_fields(mc, ["dist"], usemask=False) sinDec = kwargs.pop("sinDec", [-1., hem]) exp = exp[(exp["sinDec"] > sinDec[0]) & (exp["sinDec"] < sinDec[-1])] mc = mc[(mc["sinDec"] > sinDec[0]) & (mc["sinDec"] < sinDec[-1])] dec_bins = np.unique( np.concatenate([ np.linspace(-1., -0.93, 4 + 1), np.linspace(-0.93, hem, 12 + 1), ])) dec_bins = dec_bins[(dec_bins >= sinDec[0]) & (dec_bins <= sinDec[1])] dec_bins = np.unique(np.concatenate([sinDec, dec_bins])) dec_bins_logE = np.linspace(-1., hem, 4 + 1) dec_bins_logE = dec_bins_logE[(dec_bins_logE >= sinDec[0]) & (dec_bins_logE <= sinDec[1])] dec_bins_logE = np.unique(np.concatenate([sinDec, dec_bins_logE])) energy_bins = [ np.linspace(2., 8.5, 67 + 1), np.linspace(-1., hem, 4 + 1), ] mc = mc[mc["logE"] > 1.] llh_model = EnergyLLH(twodim_bins=energy_bins, sinDec_bins=dec_bins) if "upscale" in kwargs and kwargs["upscale"] is not None and ( kwargs["upscale"] or not type(kwargs["upscale"]) == bool): lt = kwargs.pop("livetime", livetime) kwargs["upscale"] = (int(kwargs.pop("upscale")), lt) kwargs.pop("livetime", None) kwargs.setdefault("mode", "all") kwargs.setdefault("seed", 20101112) llh = StackingPointSourceLLH(exp, mc, livetime, llh_model=llh_model, **kwargs) print("{0:>80s}".format("[done]")) return llh
def ic86_I(**kwargs): livetime = 332.61 print("\tLoading IC86 data...") decorr = kwargs.pop("no_mese", False) if decorr: print("\t\tRemove MESE from exp and MC") exp = np.load(os.path.join(path, "IC86_noMESE_exp.npy")) mc = np.load(os.path.join(path, "IC86_noMESE_corrected_MC.npy")) else: exp = np.load(os.path.join(path, "IC86_exp.npy")) mc = np.load(os.path.join(path, "IC86_corrected_MC.npy")) sinDec = kwargs.pop("sinDec", [-1., 1.]) exp = exp[(exp["sinDec"] > sinDec[0]) & (exp["sinDec"] < sinDec[-1])] mc = mc[(mc["sinDec"] > sinDec[0]) & (mc["sinDec"] < sinDec[-1])] dec_bins = np.unique( np.concatenate([ np.linspace(-1., -0.2, 10 + 1), np.linspace(-0.2, hem, 4 + 1), np.linspace(hem, 0.2, 5 + 1), np.linspace(0.2, 1., 10), ])) dec_bins = dec_bins[(dec_bins >= sinDec[0]) & (dec_bins <= sinDec[1])] dec_bins = np.unique(np.concatenate([sinDec, dec_bins])) energy_bins = [np.linspace(1., 10., 40 + 1), dec_bins] mc = mc[mc["logE"] > 1.] llh_model = EnergyLLH(twodim_bins=energy_bins, sinDec_bins=dec_bins) if "upscale" in kwargs and kwargs["upscale"] is not None and ( kwargs["upscale"] or not type(kwargs["upscale"]) == bool): lt = kwargs.pop("livetime", livetime) kwargs["upscale"] = (int(kwargs.pop("upscale")), lt) kwargs.pop("livetime", None) kwargs.setdefault("seed", 2011) llh = StackingPointSourceLLH(exp, mc, livetime, llh_model=llh_model, **kwargs) print("{0:>80s}".format("[done]")) return llh
def ic86_2012_bdt(**kwargs): livetime = 331.88 print("\tLoading IC86-II...") exp = np.load(os.path.join(path, "IC86-2012_exp.npy")) mc = np.load(os.path.join(path, "IC86-2012_MC.npy")) sinDec = kwargs.pop("sinDec", [-1., 1.]) exp = exp[(exp["sinDec"] > sinDec[0]) & (exp["sinDec"] < sinDec[-1])] mc = mc[(mc["sinDec"] > sinDec[0]) & (mc["sinDec"] < sinDec[-1])] exp = drop_fields(exp, ["BDT2", "perc"]) mc = drop_fields(mc, ["BDT2", "perc"]) dec_bins = np.unique( np.concatenate([ np.linspace(-1., -0.92, 5 + 1), np.linspace(-0.92, -0.15, 10 + 1), np.linspace(-0.15, 0.01, 10 + 1), np.linspace(0.01, 1., 20 + 1), ])) dec_bins = dec_bins[(dec_bins >= sinDec[0]) & (dec_bins <= sinDec[1])] dec_bins = np.unique(np.concatenate([sinDec, dec_bins])) X = np.concatenate([exp["BDT"], mc["BDT"]]) bdt_bins = np.percentile(X, [0., 20., 40., 60., 80., 100.]) energy_bdt_bins = [ np.linspace(1., 10., 40 + 1), np.concatenate([[bdt_bins[0] - (bdt_bins[1] - bdt_bins[0])], bdt_bins, [bdt_bins[-1] + bdt_bins[-1] - bdt_bins[-2]]]), dec_bins ] llh_model = EnergyBDTLLH(bins=energy_bdt_bins, sinDec_bins=dec_bins) if "upscale" in kwargs and kwargs["upscale"] is not None and ( kwargs["upscale"] or not type(kwargs["upscale"]) == bool): lt = kwargs.pop("livetime", livetime) kwargs["upscale"] = (int(kwargs.pop("upscale")), lt) kwargs.pop("livetime", None) kwargs.setdefault("seed", 2012) llh = StackingPointSourceLLH(exp, mc, livetime, llh_model=llh_model, **kwargs) print("{0:>80s}".format("[done]")) return llh
def init59(energy=False, mode='all', **kwargs): arr_exp = cache.load(filename_pickle+"IC59/exp.pickle") arr_mc = cache.load(filename_pickle+"IC59/mc.pickle") dec_bins = np.unique(np.concatenate([ np.linspace(-1., -0.95, 2 + 1), np.linspace(-0.95, -0.25, 25 + 1), np.linspace(-0.25, 0.05, 15 + 1), np.linspace(0.05, 1., 10 + 1), ])) dec_bins_logE = np.unique(np.concatenate([ np.linspace(-1., -0.05, 20 + 1), np.linspace(0.05, 1., 10 + 1), ])) energy_bins = [np.linspace(2., 9.5, 67 + 1), dec_bins_logE] if energy: llh_model = EnergyLLH(energy_bins, sinDec_bins=dec_bins) #llh_model = EnergyLLH(sinDec_bins=dec_bins(50),#min(50, Nexp // 50), # sinDec_range=[-1., 1.], # logE_bins=min(50, Nexp // 50), #energybins(50) # logE_range=[[0.9 * min(arr_exp["logE"].min(), # arr_mc["logE"].min()), # 1.1 * max(arr_exp["logE"].max(), # arr_mc["logE"].max())], # [-1., 1.]]) else: llh_model = ClassicLLH(#["logE"], min(50, Nexp // 50), #twodim_range=[0.9 * arr_mc["logE"].min(), # 1.1 * arr_mc["logE"].max()], sinDec_bins=dec_bins, sinDec_range=[-1., 1.]) #Why a different sindec binning? Curious... llh = StackingPointSourceLLH(arr_exp, arr_mc, livetime=livetime_IC59, llh_model=llh_model, mode=mode, #hemispheres=dict(Full=[-np.inf, np.inf]), #nsource=Nexp / 100., #nsource_bounds=(-Nexp / 2., Nexp / 2.) # if not energy else (0., Nexp / 2.), seed=np.random.randint(2**32), **kwargs) return llh
def init86I(energy=False, mode='all', **kwargs): arr_exp = cache.load(filename_pickle+"IC86I/exp.pickle") arr_mc = cache.load(filename_pickle+"IC86I/mc.pickle") #This hem... not sure about what it means, but stefan uses it in load.py. #Obviously it's for the hemisphere line - but why doesn't he use it for every year? hem = np.sin(np.radians(-5.)) dec_bins = np.unique(np.concatenate([ np.linspace(-1., -0.2, 10 + 1), np.linspace(-0.2, hem, 4 + 1), np.linspace(hem, 0.2, 5 + 1), np.linspace(0.2, 1., 10), ])) #check this later, BEN! energy_bins = [np.linspace(1., 10., 67 + 1), dec_bins] if energy: llh_model = EnergyLLH(energy_bins, sinDec_bins=dec_bins) #llh_model = EnergyLLH(sinDec_bins=dec_bins(50),#min(50, Nexp // 50), # sinDec_range=[-1., 1.], # logE_bins=min(50, Nexp // 50), #energybins(50) # logE_range=[[0.9 * min(arr_exp["logE"].min(), # arr_mc["logE"].min()), # 1.1 * max(arr_exp["logE"].max(), # arr_mc["logE"].max())], # [-1., 1.]]) else: llh_model = ClassicLLH(#["logE"], min(50, Nexp // 50), #twodim_range=[0.9 * arr_mc["logE"].min(), # 1.1 * arr_mc["logE"].max()], sinDec_bins=dec_bins, sinDec_range=[-1., 1.]) #Why a different sindec binning? Curious... llh = StackingPointSourceLLH(arr_exp, arr_mc, livetime=livetime_IC86I, llh_model=llh_model, mode=mode, #hemisphere=dict(Full=[-np.inf, np.inf]), #nsource=Nexp / 100., #nsource_bounds=(-Nexp / 2., Nexp / 2.) # if not energy else (0., Nexp / 2.), seed=np.random.randint(2**32), **kwargs) return llh
def ic40(**kwargs): livetime = 375.539 print("\tLoading IC40 data...") exp = np.load(os.path.join(path, "IC40_exp.npy")) mc = np.load(os.path.join(path, "IC40_MC.npy")) #dec_bins = np.linspace(-1., 1., 25 + 1) dec_bins = np.unique( np.concatenate([ np.linspace(-1., -0.25, 10 + 1), np.linspace(-0.25, 0.0, 5 + 1), np.linspace(0.0, 1., 10 + 1), ])) dec_bins_logE = np.unique( np.concatenate([ np.linspace(-1., -0.25, 10 + 1), np.linspace(-0.25, 0.0, 10 + 1), np.linspace(0.0, 1., 10 + 1), ])) energy_bins = [np.linspace(1., 10., 35 + 1), dec_bins_logE] mc = mc[mc["logE"] > 1.] llh_model = EnergyLLH(twodim_bins=energy_bins, sinDec_bins=dec_bins) if "upscale" in kwargs and kwargs["upscale"] is not None and ( kwargs["upscale"] or not type(kwargs["upscale"]) == bool): lt = kwargs.pop("livetime", livetime) kwargs["upscale"] = (int(kwargs.pop("upscale")), lt) kwargs.pop("livetime", None) kwargs.setdefault("seed", 2008) llh = StackingPointSourceLLH(exp, mc, livetime, llh_model=llh_model, **kwargs) print("{0:>80s}".format("[done]")) return llh
def ic79(**kwargs): livetime = 315.506 print("\tLoading IC79 data...") decorr = kwargs.pop("no_mese", False) if decorr: print("\t\tRemove MESE from exp and MC") exp = np.load(os.path.join(path, "IC79_noMESE_exp.npy")) mc = np.load(os.path.join(path, "IC79_noMESE_corrected_MC.npy")) else: exp = np.load(os.path.join(path, "IC79_exp.npy")) mc = np.load(os.path.join(path, "IC79_corrected_MC.npy")) dec_bins = np.unique( np.concatenate([ np.linspace(-1., -0.75, 10 + 1), np.linspace(-0.75, 0., 15 + 1), np.linspace(0., 1., 20 + 1) ])) energy_bins = [np.linspace(2., 9., 40 + 1), dec_bins] mc = mc[mc["logE"] > 1.] llh_model = EnergyLLH(twodim_bins=energy_bins, sinDec_bins=dec_bins) if "upscale" in kwargs and kwargs["upscale"] is not None and ( kwargs["upscale"] or not type(kwargs["upscale"]) == bool): lt = kwargs.pop("livetime", livetime) kwargs["upscale"] = (int(kwargs.pop("upscale")), lt) kwargs.pop("livetime", None) kwargs.setdefault("seed", 2010) llh = StackingPointSourceLLH(exp, mc, livetime, llh_model=llh_model, **kwargs) print("{0:>80s}".format("[done]")) return llh
def init40(energy=False, mode='all', **kwargs): arr_exp = cache.load(filename_pickle+"IC40/exp.pickle") arr_mc = cache.load(filename_pickle+"IC40/mc.pickle") dec_bins = np.unique(np.concatenate([ np.linspace(-1., -0.25, 10 + 1), np.linspace(-0.25, 0.0, 5 + 1), np.linspace(0.0, 1., 10 + 1), ])) dec_bins_logE = np.unique(np.concatenate([ np.linspace(-1., -0.25, 10 + 1), np.linspace(-0.25, 0.0, 10 + 1), np.linspace(0.0, 1., 10 + 1), ])) #These binnings are done, year specifically, in load.py from stefan. energy_bins = [np.linspace(2., 9., 75 + 1), dec_bins_logE] if energy: llh_model = EnergyLLH(energy_bins, sinDec_bins=dec_bins) else: llh_model = ClassicLLH(#["logE"], min(50, Nexp // 50), #twodim_range=[0.9 * arr_mc["logE"].min(), # 1.1 * arr_mc["logE"].max()], sinDec_bins=dec_bins, sinDec_range=[-1., 1.]) #Why a different sindec binning? Curious... llh = StackingPointSourceLLH(arr_exp, arr_mc, livetime=livetime_IC40, llh_model=llh_model, mode=mode, #hemispheres=dict(Full=[-np.inf, np.inf]), #nsource=Nexp / 100., #nsource_bounds=(-Nexp / 2., Nexp / 2.) # if not energy else (0., Nexp / 2.), seed=np.random.randint(2**32), **kwargs) return llh
def mese(**kwargs): livetime = 988.54 print("\tLoading MESE...") exp = np.load(os.path.join(path, "MESE_exp.npy")) mc = np.load(os.path.join(path, "MESE_MC.npy")) dec_bins = np.unique( np.concatenate([ np.linspace(-1., -0.92, 3 + 1), np.linspace(-0.92, hem, 10 + 1), ])) energy_bins = [ np.linspace(2., 8.5, 40 + 1), np.linspace(-1., hem, 4 + 1), ] mc = mc[mc["logE"] > 1.] llh_model = EnergyLLH(twodim_bins=energy_bins, sinDec_bins=dec_bins) if "upscale" in kwargs and kwargs["upscale"] is not None and ( kwargs["upscale"] or not type(kwargs["upscale"]) == bool): lt = kwargs.pop("livetime", livetime) kwargs["upscale"] = (int(kwargs.pop("upscale")), lt) kwargs.pop("livetime", None) kwargs.setdefault("mode", "all") kwargs.setdefault("seed", 20101112) llh = StackingPointSourceLLH(exp, mc, livetime, llh_model=llh_model, **kwargs) print("{0:>80s}".format("[done]")) return llh
def ic86_2012(dataset=[2012, 2013], **kwargs): lt12 = 331.358 lt13 = 359.768 lt14 = 367.209 livetime = 0. exp = list() decorr = kwargs.pop("no_mese", False) if 2012 in dataset: livetime += lt12 print("\tLoading IC86-2012 ...") if decorr: print("\t\tRemove MESE from IC86-2012 exp") exp.append(np.load(os.path.join(path, "IC86-2012_noMESE_exp.npy"))) else: exp.append(np.load(os.path.join(path, "IC86-2012_exp.npy"))) if 2013 in dataset: livetime += lt13 print("\tLoading IC86-2013 ...") exp.append(np.load(os.path.join(path, "IC86-2013_exp.npy"))) if 2014 in dataset: livetime += lt14 print("\tLoading IC86-2014 ...") exp.append(np.load(os.path.join(path, "IC86-2014_exp.npy"))) exp = np.concatenate(exp) if decorr: print("\t\tRemove MESE from IC86-2012 MC") mc = np.load(os.path.join(path, "IC86-2012_noMESE_MC.npy")) else: mc = np.load(os.path.join(path, "IC86-2012_MC.npy")) sinDec = kwargs.pop("sinDec", [-1., 1.]) exp = exp[(exp["sinDec"] > sinDec[0]) & (exp["sinDec"] < sinDec[-1])] mc = mc[(mc["sinDec"] > sinDec[0]) & (mc["sinDec"] < sinDec[-1])] exp = drop_fields(exp, ["BDT"]) mc = drop_fields(mc, ["BDT"]) dec_bins = np.unique( np.concatenate([ np.linspace(-1., -0.93, 4 + 1), np.linspace(-0.93, -0.3, 10 + 1), np.linspace(-0.3, 0.05, 9 + 1), np.linspace(0.05, 1., 18 + 1), ])) dec_bins = dec_bins[(dec_bins >= sinDec[0]) & (dec_bins <= sinDec[1])] dec_bins = np.unique(np.concatenate([sinDec, dec_bins])) energy_bins = [np.linspace(1., 9.5, 50 + 1), dec_bins] llh_model = EnergyLLH(twodim_bins=energy_bins, sinDec_bins=dec_bins) if "upscale" in kwargs and kwargs["upscale"] is not None and ( kwargs["upscale"] or not type(kwargs["upscale"]) == bool): lt = kwargs.pop("livetime", livetime) kwargs["upscale"] = (int(kwargs.pop("upscale")), lt) kwargs.pop("livetime", None) kwargs.setdefault("seed", 2012) llh = StackingPointSourceLLH(exp, mc, livetime, llh_model=llh_model, **kwargs) print("{0:>80s}".format("[done]")) return llh
def ic86_2012_precut(**kwargs): livetime = 331.88 print("\tLoading IC86-II with precut applied...") exp = np.load(os.path.join(path, "IC86-2012-precut_exp.npy")) mc = np.load(os.path.join(path, "IC86-2012-precut_MC.npy")) sinDec = kwargs.pop("sinDec", [-1., 1.]) exp = exp[(exp["sinDec"] > sinDec[0]) & (exp["sinDec"] <= sinDec[-1])] mc = mc[(mc["sinDec"] > sinDec[0]) & (mc["sinDec"] <= sinDec[-1])] if "perc" in kwargs: perc = kwargs.pop("perc") print("\tCutting on percentage {0:8.3%}".format(perc)) nbins = 400 h, bins = np.histogram(exp["sinDec"], bins=nbins, range=sinDec) NpB = perc * np.sum(h, dtype=np.float) / nbins eps = np.zeros_like(h, dtype=np.float) eps[h > 0] = NpB / h[h > 0] eps[eps > 1] = 1. xdec = np.array([]) ybdt = np.array([]) for eps_i, lbin, ubin in zip(eps, bins[:-1], bins[1:]): m = (exp["sinDec"] > lbin) & (exp["sinDec"] < ubin) if not np.any(m): print("No events in", lbin, ubin) continue bdt_cut = np.percentile(exp["BDT"][m], 100. * (1. - eps_i)) np.set_printoptions(precision=4) xdec = np.append(xdec, (lbin + ubin) / 2.) ybdt = np.append(ybdt, bdt_cut) pol = np.polyfit(xdec, ybdt, 6) N1 = len(exp) polexp = np.polyval(pol, exp["sinDec"]) polmc = np.polyval(pol, mc["sinDec"]) mexp = exp["BDT"] > polexp mmc = mc["BDT"] > polmc exp = exp[mexp] mc = mc[mmc] N2 = len(exp) print("\tCut: {0:7.2%}".format(float(N2) / N1)) elif "bdt" in kwargs and "bdt2" in kwargs: comp = kwargs.pop("comp", np.logical_or) bdt = kwargs.pop("bdt") if not callable(bdt): print("\tCutting on bdt {0:5.3f}".format(bdt)) bdt_val = bdt bdt = lambda cz: bdt_val * np.ones_like(cz) else: print( "\tCutting bdt from {0:5.3f} to {1:5.3f} in dec range".format( *bdt(np.asarray(sinDec)))) bdt2 = kwargs.pop("bdt2") if not callable(bdt2): print("\tCutting on bdt2 {0:5.3f}".format(bdt2)) bdt_val2 = bdt2 bdt2 = lambda cz: bdt_val2 * np.ones_like(cz) else: print( "\tCutting bdt2 from {0:5.3f} to {1:5.3f} in dec range".format( *bdt2(np.asarray(sinDec)))) exp = exp[comp(exp["BDT"] > bdt(exp["sinDec"]), exp["BDT2"] > bdt2(exp["sinDec"]))] mc = mc[comp(mc["BDT"] > bdt(mc["sinDec"]), mc["BDT2"] > bdt2(mc["sinDec"]))] elif "bdt" in kwargs: bdt = kwargs.pop("bdt") if not callable(bdt): print("\tCutting on bdt {0:5.3f}".format(bdt)) bdt_val = bdt bdt = lambda cz: bdt_val * np.ones_like(cz) else: print( "\tCutting bdt from {0:5.3f} to {1:5.3f} in dec range".format( *bdt(np.asarray(sinDec)))) exp = exp[exp["BDT"] > bdt(exp["sinDec"])] mc = mc[mc["BDT"] > bdt(mc["sinDec"])] elif "bdt2" in kwargs: bdt = kwargs.pop("bdt2") if not callable(bdt): print("\tCutting on bdt2 {0:5.3f}".format(bdt)) bdt_val = bdt bdt = lambda cz: bdt_val * np.ones_like(cz) else: print( "\tCutting bdt from {0:5.3f} to {1:5.3f} in dec range".format( *bdt(np.asarray(sinDec)))) exp = exp[exp["BDT2"] > bdt(exp["sinDec"])] mc = mc[mc["BDT2"] > bdt(mc["sinDec"])] nmin = 10 nbins = 40 dec_bins = np.linspace(*sinDec, num=nbins) while np.any(np.histogram(exp["sinDec"], bins=dec_bins)[0] < nmin): print("Found close-to-empty bins, reduce binsize") h, b = np.histogram(exp["sinDec"], bins=dec_bins) b = np.array([b[1:], b[:-1]]) print(b[:, h < nmin]) if nbins < 2: raise ValueError("Need more than 2 bins!") nbins -= 1 dec_bins = np.linspace(*sinDec, num=nbins) energy_bins = [np.linspace(0., 9.5, 30 + 1), dec_bins] llh_model = EnergyLLH(twodim_bins=energy_bins, sinDec_bins=dec_bins) if "upscale" in kwargs and kwargs["upscale"] is not None and ( kwargs["upscale"] or not type(kwargs["upscale"]) == bool): lt = kwargs.pop("livetime", 332.61) #livetime) kwargs["upscale"] = (int(kwargs.pop("upscale")), lt) kwargs.pop("livetime", None) kwargs.setdefault("seed", 2012) llh = StackingPointSourceLLH(exp, mc, livetime, llh_model=llh_model, **kwargs) if "pol" in locals(): llh.pol = pol print("{0:>80s}".format("[done]")) return llh
## 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)
##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/'