Exemple #1
0
def plotDecBand(bandnum):
  fig_band=plt.figure()
  ax=plt.gca()
  histdec_data=histlite.plot1d(ax,histlite.hist(muex86I_data[bandmask_data[bandnum]],**hargs1), color='r', label='data')
#use gamma=2,bandnum=0
  histdec_sim=histlite.plot1d(ax,energyhist_sim(fsim_86_1,2,bandnum), color='b', label='MC')
  ax.loglog()
  ax.set_xlabel('MuEx')
  ax.set_ylabel('events')
  ax.legend(loc='upper right')
  ax.set_ylim(ymin=0)
  ax.set_title('energy pdf in IC86-I, gamma=2: '+decrange[bandnum])
  fig_band.savefig(projfolder+'Plots/AGNCore/Stacking/IC86I_energydist: band '+str(bandnum))
Exemple #2
0
    def tsds(self):
        """Plot TSDist's."""

        plot_dir = misc.ensure_dir('{0}/plots/tsds'.format(self.mode_dir))

        tsds = self.bg_tsds

        for zenith_deg in sorted(tsds):
            tsd = tsds[zenith_deg]

            fig = getfig(aspect=16 / 10., width=6)
            ax = fig.add_subplot(111)
            ax.semilogy()
            hl.plot1d(ax,
                      tsd.get_hist(bins=40).normalize(integrate=True),
                      color='b')
            ts = np.linspace(1e-3, tsd.ts_values.max(), 100)
            ax.plot(ts, tsd.chi2.pdf(ts), color='.8', ls='--')
            ax.set_xlabel('TS')
            ax.set_ylabel('probability density')
            fig.subplots_adjust(bottom=.14, top=.91, right=.97)
            savingfig(fig, plot_dir,
                      'fscale_bg_tsd_zen_{:07.3f}'.format(zenith_deg))
            plt.close(fig)
Exemple #3
0
                                                  weights=np.array(flux),
                                                  bins=bins,
                                                  range=range),
                                    integrate=True)
redshift_hist = histlite.Hist.normalize(histlite.hist(sindec,
                                                      weights=np.power(
                                                          redshift, -2),
                                                      bins=bins,
                                                      range=range),
                                        integrate=True)

#Now plot.

fig_sindec = plt.figure(figsize=(w, .75 * w))
ax = plt.gca()
histlite.plot1d(ax, unif_hist, histtype='step', color='k', label='equal')
histlite.plot1d(ax, flux_hist, histtype='step', color='green', label='flux')
histlite.plot1d(ax,
                redshift_hist,
                histtype='step',
                color='red',
                label='redshift')
ax.set_title(r'Weighted Source Declinations')
ax.set_xlabel(r'$\sin{(\delta)}$')
plt.subplots_adjust(left=.2, bottom=.2)
ax.set_ylabel(r'Probability Density')
plt.legend(loc='upper left', prop=propsmall)
fig_sindec.savefig(
    '/data/user/brelethford/AGN_Core/Plots/catalog/SwiftBAT70m/weighted_decs.pdf'
)
fig_sindec.savefig(
Exemple #4
0
##I'll include a chi squared distribution w/ DOF=1 (and 2, just because). I'll also show the best fitting chi2 dist for each weighting scheme.##
chifit_flux = fitfun(bckg_flux['TS'], df=2., floc=0., fscale=1.).par[0]

## Now to plot. ##
fig_bckg = plt.figure(figsize=(w, .75 * w))
ax = plt.gca()

chi_degs = [1, 2, chifit_flux]
colors = ['black', 'gray', 'green']
for df, color in zip(chi_degs, colors):
    x = np.linspace(chi2.ppf(0.01, df), chi2.ppf(0.99999, df), 100)
    rv = chi2(df)
    chi_dist = rv.pdf(x)
    ax.plot(x,
            chi_dist / sum(chi_dist),
            linestyle=':',
            color=color,
            label=r'$\tilde{\chi}^2$: df=' + str(round(df, 2)))

histlite.plot1d(ax, flux_hist, histtype='step', label='flux', color='green')
ax.set_title(r'Background TS for 2LAC Survey - 2yr')
ax.set_xlabel(r'TS')
plt.subplots_adjust(left=.2, bottom=.2)
ax.set_ylabel(r'Normalized Counts')
ax.set_ylim(8e-5, 1)
ax.set_xlim(0, 16)
ax.semilogy()
plt.legend(loc='upper right', prop=propxsmall)
fig_bckg.savefig('/data/user/brelethford/AGN_Core/Plots/2LAC/bckg_TS_2LAC.pdf')
fig_bckg.savefig('/data/user/brelethford/AGN_Core/Plots/2LAC/bckg_TS_2LAC.png')
Exemple #5
0
### Energy ###
energyrange = (10, 1e7)
fig_energyhist = plt.figure(figsize=(w, .75 * w))
ax = plt.gca()

h_energy_86 = histlite.hist(muex86I_data,
                            bins=bins,
                            range=energyrange,
                            log=True)
h_energy_79 = histlite.hist(muex79_data,
                            bins=bins,
                            range=energyrange,
                            log=True)
h_energy_59 = histlite.hist(mue59_data, bins=bins, range=energyrange, log=True)
h_energy_40 = histlite.hist(mue40_data, bins=bins, range=energyrange, log=True)
histlite.plot1d(ax, h_energy_40, histtype='step', label='IC40', color='purple')
histlite.plot1d(ax, h_energy_59, histtype='step', label='IC59', color='green')
histlite.plot1d(ax, h_energy_79, histtype='step', label='IC79', color='blue')
histlite.plot1d(ax, h_energy_86, histtype='step', label='IC86', color='red')

#ax.set_title("4yr PS data - energy")
ax.set_xlabel(r"Energy Proxy (GeV)")
ax.set_ylabel("Counts per bin")
ax.loglog()
ax.set_ylim(1, 1e5)
plt.subplots_adjust(left=.2, bottom=.2)
ax.legend(loc="best", prop=propsmall)
fig_energyhist.savefig(plotfolder + 'energy_hists.pdf')

###Declination###
decrange = (-1., 1.)
weib_fits = [weib_flux_2LAC]
chi2_fits = [chi2fit_2LAC]
colors = ['blue']
for chi2_fit, weib_fit, color in zip(chi2_fits, weib_fits, colors):
    x = np.linspace(0, 20, 100)
    ax.plot(x,
            chi2_fit.pdf(x),
            linestyle=':',
            color=color,
            label=r'$\tilde{\chi}^2$')  #: df='+str(round(chi2_fit.par[0],2)))
    ax.plot(x, weib_fit.pdf(x), linestyle='--', color=color, label='weibull')

histlite.plot1d(ax,
                h_2LAC.normalize(integrate=True),
                histtype='step',
                label='flux-weighted',
                color='blue')
ax.set_title(r'2LAC Background TS - 3yr (59-86I)')
ax.set_xlabel(r'TS')
plt.subplots_adjust(left=.2, bottom=.2)
ax.set_ylabel(r'Normalized Counts')
ax.set_ylim(8e-5, 1)
ax.set_xlim(0, 16)
ax.semilogy()
plt.legend(loc='upper right', prop=propxsmall, ncol=2)
fig_bckg.savefig(
    '/data/user/brelethford/AGN_Core/Plots/backgroundTS/bckgTS_2LAC_3yr.pdf')
fig_bckg.savefig(
    '/data/user/brelethford/AGN_Core/Plots/backgroundTS/bckgTS_2LAC_3yr.png')
Exemple #7
0
mc = load_mstacking.monte_carlo(llh7yr)

##Now I have exp and mc for all 7 yrs. plot. The framework for plotting is already set up, so let's just make sure the info is in a manner it's used to.

bins = 80

### Energy ###

fig_energyhist = plt.figure(figsize=(w, .75 * w))
ax = plt.gca()
labels = ['IC40', 'IC59', 'IC79', 'IC86I', 'IC86II-IV']
colors = ['purple', 'green', 'blue', 'red', 'orange']

for i, l, c in zip(exp, labels, colors):
    h = histlite.hist(10**(i['logE']), bins=bins, log=True, range=(10, 1e7))
    histlite.plot1d(ax, h, histtype='step', label=l, color=c)
#ax.set_title("4yr PS data - energy")
ax.set_xlabel(r"Energy Proxy (GeV)")
ax.set_ylabel("Counts per bin")
ax.loglog()
ax.set_xlim(10, 1e7)
plt.subplots_adjust(left=.2, bottom=.2)
ax.legend(loc="best", prop=propxsmall)
fig_energyhist.savefig(plotfolder + 'energy_hists_7yr.pdf')

###Declination###

fig_dechist = plt.figure(figsize=(w, .75 * w))
ax = plt.gca()

for i, l, c in zip(exp, labels, colors):
Exemple #8
0
h_dec_86 = histlite.Hist.normalize(
    histlite.hist(sindec86I_sim[(np.degrees(dpsi_IC86I) > 160.)],
                  bins=bins,
                  range=bigrange))
h_dec_79 = histlite.Hist.normalize(
    histlite.hist(sindec79_sim[(np.degrees(dpsi_IC79) > 160.)],
                  bins=bins,
                  range=bigrange))
h_dec_59 = histlite.Hist.normalize(
    histlite.hist(sindec59_sim[(np.degrees(dpsi_IC59) > 160.)],
                  bins=bins,
                  range=bigrange))
h_dec_40 = histlite.Hist.normalize(
    histlite.hist(sindec40_sim[(np.degrees(dpsi_IC40) > 160.)],
                  bins=bins,
                  range=bigrange))

histlite.plot1d(ax, h_dec_40, histtype='step', label='IC40', color='purple')
histlite.plot1d(ax, h_dec_59, histtype='step', label='IC59', color='green')
histlite.plot1d(ax, h_dec_79, histtype='step', label='IC79', color='blue')
histlite.plot1d(ax, h_dec_86, histtype='step', label='IC86', color='red')

ax.set_title("4yr PS MC reco - dpsi over 160")
ax.set_xlabel(r"$\sin({\delta})$")
ax.set_ylabel("Counts per bin")
plt.subplots_adjust(left=.2, bottom=.2)
ax.set_xlim(bigrange)
ax.legend(loc="best", prop=propsmall)
fig_dechist.savefig(plotfolder + 'dec_hists_dpsi_large.pdf')
flux_hists = [hist_sirin]  #,hist_schatto]
chi2_fits = [chi_sirin]  #,chi_schatto]

sens_hists = [hist_sirin_sens]  #,hist_schatto_sens]
sens_fits = [chi_sirin_sens]  #,chi_schatto_sens]
disc_hists = [hist_sirin_disc]  #,hist_schatto_disc]
disc_fits = [chi_sirin_disc]  #,chi_schatto_disc]

colors = ['green', 'blue']
#First for bckg
for flux_hist, chi2_fit, color, label in zip(flux_hists, chi2_fits, colors,
                                             labels):
    x = np.linspace(0, 40, 100)
    histlite.plot1d(ax,
                    flux_hist.normalize(integrate=True),
                    histtype='step',
                    color=color,
                    label='{} - '.format(label) + r'$\tilde{\chi}^2$' +
                    ': df={}'.format(str(round(chi2_fit.par[0], 2))))
    ax.plot(
        x, chi2_fit.pdf(x), linestyle=':', color=color
    )  #, label='{} - '.format(label) + r'$\tilde{\chi}^2$' + ': df={}'.format(str(round(chi2_fit.par[0],2))))
#now for sens, then disc
for flux_hist, chi2_fit, color in zip(sens_hists, sens_fits, colors):
    histlite.plot1d(ax,
                    flux_hist.normalize(integrate=True),
                    histtype='step',
                    color=color)
    #plt.axvline(chi2_fit.isf(0.1), color = color, linestyle = ':')

for flux_hist, chi2_fit, color in zip(disc_hists, disc_fits, colors):
    histlite.plot1d(ax,
Exemple #10
0
##I'll include a chi squared distribution w/ DOF=1 (and 2, just because). I'll also show the best fitting chi2 dist for each weighting scheme.##
chifit_single = chi2.fit(bckg_single[0])[0]

chi_degs = [1, 2, chifit_single]
colors = ['black', 'gray', 'blue']
for df, color in zip(chi_degs, colors):
    x = np.linspace(chi2.ppf(0.01, df), chi2.ppf(0.99999, df), 100)
    rv = chi2(df)
    chi_dist = rv.pdf(x)
    ax.plot(x,
            chi_dist / sum(chi_dist),
            linestyle=':',
            color=color,
            label=r'$\tilde{\chi}^2$: df=' + str(round(df, 2)))

histlite.plot1d(ax,
                single_hist,
                histtype='step',
                label='single source',
                color='blue')
ax.set_title(r'Background TS for 70m Survey')
ax.set_xlabel(r'TS')
plt.subplots_adjust(left=.2, bottom=.2)
ax.set_ylabel(r'Normalized Counts')
ax.set_ylim(8e-5, 1)
ax.set_xlim(0, 16)
ax.semilogy()
plt.legend(loc='upper right', prop=propxsmall)
fig_bckg.savefig(
    '/data/user/brelethford/AGN_Core/Plots/bckg_TS_single_source.pdf')
Exemple #11
0
	fluence = flux (type_sim, energy_sim, np.cos(zen_sim))
	factor=2
	atmosweight = (OneWeight / n_gen) * factor * fluence
	astroweight = (OneWeight / n_gen)*(1/1e18)*(np.power((energy_sim/1e5),-1*gamma))
	return atmosweight #+ astroweight


#We'll need each MC set's livetime in order to weight properly.... not sure why?
liveTime86I=332.61*86400

#dec Hist (using gamma=2)
#The following just shows the populations per dec band of MC and Data.

fig_dec_compare=plt.figure()
ax=plt.gca()
histdec_data=histlite.plot1d(ax,histlite.hist(np.sin(dec86I_data),bins=30), color='r', label='data')
histdec_sim=histlite.plot1d(ax,histlite.hist(np.sin(dec86I_sim), bins=30, weights=liveTime86I*simweight(fsim_86_1,2)),color='b', label='MC')
ax.set_xlabel('sin(dec)')
ax.set_ylabel('events')
ax.legend(loc='upper right')
ax.set_ylim(ymin=0)
ax.set_title('event population per dec band in IC86-I - data')
fig_dec_compare.savefig(projfolder+'Plots/AGNCore/Stacking/IC86I_populations_by_dec')

#Now that I have the dec distribution, I want to divide into dec bands (let's say 6 bands of 30 deg each), and plot the energy (MuEx) of both data and MC for a given spectral parameter (gamma = 1,2,2.5,3)

#The following two lines are masks corresponding to dec bands - the first bandmask is a mask to retrieve data which lies in the lowest decband, the second bandmask the second lowest dec band, etc.
def decdiv(divisions):
	return np.arange(-np.pi/2.,np.pi/2.,np.pi/float(divisions))

decbands = decdiv(7)
Exemple #12
0
chi_degs = [1, 2, chifit_uniform, chifit_redshift, chifit_flux]
colors = ['black', 'gray', 'blue', 'red', 'green']
for df, color in zip(chi_degs, colors):
    x = np.linspace(chi2.ppf(0.01, df), chi2.ppf(0.99999, df), 100)
    rv = chi2(df)
    chi_dist = rv.pdf(x)
    ax.plot(x,
            chi_dist / sum(chi_dist),
            linestyle=':',
            color=color,
            label=r'$\tilde{\chi}^2$: df=' + str(round(df, 2)))

histlite.plot1d(ax,
                uniform_hist,
                histtype='step',
                label='uniform',
                color='blue')
histlite.plot1d(ax,
                redshift_hist,
                histtype='step',
                label='redshift',
                color='red')
histlite.plot1d(ax, flux_hist, histtype='step', label='flux', color='green')
ax.set_title(r'Background TS for 70m Survey')
ax.set_xlabel(r'TS')
plt.subplots_adjust(left=.2, bottom=.2)
ax.set_ylabel(r'Normalized Counts')
ax.set_ylim(8e-5, 1)
ax.set_xlim(0, 16)
ax.semilogy()
Exemple #13
0
def aeff1d (year):
   """
   Plot and tabulate Aeff.
   """

   #nu = self.nu ..... xn is the mc sample of a certain year. let's start with IC86I and work our way forward.
   if year == 86:
     full_xn = data_multi.MC86I()
     ngen = ngen_86I
   elif year ==79:
     full_xn = data_multi.MC79()
     ngen = ngen_79
   elif year ==59:
     full_xn = data_multi.MC59()
     ngen = ngen_59
   elif year ==40:
     full_xn = data_multi.MC40()
     ngen = ngen_40
   
   logEmin, logEmax = 1., 8.
   dlogE = 0.1
   n_bins_E = (logEmax - logEmin) / dlogE

   #I'll use the same curves as the IC86I page: https://wiki.icecube.wisc.edu/index.php/IC86_I_Point_Source_Analysis/Performance_Plots
   #Now we gotta do each of a number of ranges to match existing plots.
   decedges = np.array([-90.,-60.,-30.,0.,30.,60.,90.])
   
   aeff_hists = []

   for (dec_min, dec_max) in zip (decedges[:-1],decedges[1:]):
     dsd = np.sin(np.radians(dec_max - dec_min))
     dOmega = 2 * np.pi * dsd
     n_bins_sd = 2 / dsd
     print(dec_min,dec_max) 
     #first, define xn from the full set, before we pare it down by sindec.
     xn = full_xn    
     #Whichever year we have, the following occurs:
     mask = ((np.sin(np.radians(dec_min)) < np.sin(xn['trueDec'])) & (np.sin(xn['trueDec'])< np.sin(np.radians(dec_max))))
     xn = xn[mask]
     nu = arrays.Arrays (dict (
          (k,xn[k])
          for k in ('ra', 'sinDec', 'sigma', 'logE',
                  'trueRa', 'trueDec', 'trueE', 'ow')))
     #nu = self.nu
     #nu.cz = -np.sin (nu.trueDec)
     nu.sd = np.sin (nu.trueDec)
     w_aeff = 1 / (1e4 * np.log (10)) * nu.ow / nu.trueE / dOmega / dlogE
     h_aeff = histlite.hist (
       (nu.trueE), w_aeff,
       bins=(n_bins_E),
       range=(10**logEmin, 10**logEmax),
       log=(True)
     )
     aeff_hists.append(h_aeff)
   #that should give us all the hists we want. Now let's plot them on one axis.
   fig = plt.figure(figsize=(w, .75*w))
   ax = fig.add_subplot (111)
   fig.subplots_adjust (bottom=.15, left=.18)
   colors = ['red', 'green', 'orange', 'purple', 'blue', 'black']
   for i in range(len(decedges)-1):
     histlite.plot1d (ax, aeff_hists[i], log=True, color=colors[i],
                       vmin=5e-6, vmax=1e4, label =  r'${0:.1f} < \delta < {1:.1f}$'.format(decedges[i], decedges[i+1]))
   ax.set_title('Aeff - IC{}'.format(str(year)))
   ax.set_xlabel ('neutrino energy [GeV]')
   ax.set_ylabel (r'Effective Area $[\textrm{m}^2]$')
   ax.legend(loc='best',prop=propxsmall)
   ax.loglog()
   plot_dir = misc.ensure_dir ('/data/user/brelethford/AGN_Core/Plots/data')
   fig.savefig(plot_dir+'/aeff{}_1d.pdf'.format(str(year)))
Exemple #14
0
                     range=(energyrange, sigmarange),
                     log=(True, False))
h_59 = histlite.hist((energy59_true, np.degrees(dpsi_IC59)),
                     bins=bins2d,
                     weights=weight_59,
                     range=(energyrange, sigmarange),
                     log=(True, False))
h_40 = histlite.hist((energy40_true, np.degrees(dpsi_IC40)),
                     bins=bins2d,
                     weights=weight_40,
                     range=(energyrange, sigmarange),
                     log=(True, False))

histlite.plot1d(ax,
                h_40.median(1),
                drawstyle='lines',
                label='IC40',
                color='blue')
histlite.plot1d(ax,
                h_59.median(1),
                drawstyle='lines',
                label='IC59',
                color='green')
histlite.plot1d(ax,
                h_79.median(1),
                drawstyle='lines',
                label='IC79',
                color='red')
histlite.plot1d(ax,
                h_86.median(1),
                drawstyle='lines',
Exemple #15
0
chi2_fits = [chi_bckg]

sens_hists = [hist_sens]
sens_fits = [chi_sens]
disc_hists = [hist_disc]
disc_fits = [chi_disc]

colors = ['k']
#First for bckg
for flux_hist, chi2_fit, color, label in zip(flux_hists, chi2_fits, colors,
                                             labels):
    x = np.linspace(0, 40, 100)
    histlite.plot1d(ax,
                    flux_hist.normalize(integrate=True),
                    histtype='step',
                    color=color,
                    label='{} - '.format(label) + r'$\tilde{\chi}^2$' +
                    ': df={}'.format(str(round(chi2_fit.par[0], 2))) +
                    r', $\eta = $' + str(np.round(eta, 2)))
    ax.plot(
        x, chi2_fit.pdf(x), linestyle=':', color=color
    )  #, label='{} - '.format(label) + r'$\tilde{\chi}^2$' + ': df={}'.format(str(round(chi2_fit.par[0],2))))
#now for sens, then disc
for flux_hist, chi2_fit, color in zip(sens_hists, sens_fits, colors):
    histlite.plot1d(ax,
                    flux_hist.normalize(integrate=True),
                    histtype='step',
                    color='red',
                    label='mu = ' + str(np.round(printflux(sens)[1][0], 2)) +
                    ', flux = {0:.2E}'.format(Decimal(printflux(sens)[0][0])))
    #plt.axvline(chi2_fit.isf(0.1), color = color, linestyle = ':')
Exemple #16
0
sindec_sim = mc['sinDec']

sigma_data = exp['sigma']
sigma_sim = mc['sigma']

weight = mc['ow'] * true**(-2)

bins = 80
bins2d = (80, 80)
### Energy ###
energyrange = (1e3, 200000)
fig_energyhist = plt.figure(figsize=(w, .75 * w))
ax = plt.gca()

h_energy = histlite.hist(muex_data, bins=bins, range=energyrange, log=True)
histlite.plot1d(ax, h_energy, histtype='step', label='MESE', color='k')

#ax.set_title("4yr PS data - energy")
ax.set_xlabel(r"Energy Proxy (GeV)")
ax.set_ylabel("Counts per bin")
ax.loglog()
ax.set_ylim(1, 1e2)
plt.subplots_adjust(left=.2, bottom=.2)
ax.legend(loc="best", prop=propsmall)
fig_energyhist.savefig(plotfolder + 'energy_hists_MESE.png')

###Declination###
decrange = (-1., 1.)
fig_dechist = plt.figure(figsize=(w, .75 * w))
ax = plt.gca()
Exemple #17
0
bad_exp_sigma =bad_exp['sigma']
bad_mc_sigma =bad_mc['sigma']

bad_hist_exp = histlite.hist(bad_exp_sigma,bins=100,log=True)
bad_hist_mc = histlite.hist(bad_mc_sigma,bins=100,log=True)

stefan_exp_sigma = stefan_exp['sigma']
stefan_mc_sigma = stefan_mc['sigma']

stefan_hist_exp = histlite.hist(stefan_exp_sigma,bins=100,log=True)
stefan_hist_mc = histlite.hist(stefan_mc_sigma,bins=100,log=True)

## Now to plot. ##
fig_sigma_exp = plt.figure()
ax=plt.gca()
histlite.plot1d(ax,ben_hist_exp,label = 'corrected', color = 'blue', linestyle = '-', errorbars=True) 
histlite.plot1d(ax,bad_hist_exp,label = 'original', color = 'red') 
histlite.plot1d(ax,stefan_hist_exp,label = 'stefan', color = 'k') 
ax.set_title(r'Sigma Distribution - Data')
ax.set_xlabel(r'$\sigma$')
ax.set_ylabel(r'density') 
#ax.set_xlim(-1.,1.)
#ax.set_ylim(1e-12,1e-10)
ax.loglog()
ax.grid() 
plt.legend(loc='upper right')
fig_sigma_exp.savefig('/home/brelethford/public_html/exp_sigmas.pdf')

fig_sigma_mc = plt.figure()
ax=plt.gca()
histlite.plot1d(ax,ben_hist_mc,label = 'corrected', color = 'blue',linestyle = '-', errorbars=True) 
Exemple #18
0
h_energy_3yr = histlite.hist(muex3yr_data,
                             bins=bins,
                             range=energyrange,
                             log=True)
h_energy_86 = histlite.hist(muex86I_data,
                            bins=bins,
                            range=energyrange,
                            log=True)
h_energy_79 = histlite.hist(muex79_data,
                            bins=bins,
                            range=energyrange,
                            log=True)
h_energy_59 = histlite.hist(mue59_data, bins=bins, range=energyrange, log=True)
h_energy_40 = histlite.hist(mue40_data, bins=bins, range=energyrange, log=True)
histlite.plot1d(ax, h_energy_40, histtype='step', label='IC40', color='blue')
histlite.plot1d(ax, h_energy_59, histtype='step', label='IC59', color='green')
histlite.plot1d(ax, h_energy_79, histtype='step', label='IC79', color='red')
histlite.plot1d(ax, h_energy_86, histtype='step', label='IC86I', color='cyan')
histlite.plot1d(ax,
                h_energy_3yr,
                histtype='step',
                label='IC86II-IV',
                color='magenta')

#ax.set_title("4yr PS data - energy")
ax.set_xlabel(r"Energy Proxy (GeV)")
ax.set_ylabel("Counts per bin")
ax.loglog()
ax.set_ylim(1, 1e5)
plt.subplots_adjust(left=.2, bottom=.2)
Exemple #19
0
labels = ['{0}'.format(str(llhweight)) for llhweight in llhweights]
flux_hists = hist_bckg
chi2_fits = chi_bckg

sens_hists = hist_sens
sens_fits = chi_sens
disc_hists = hist_disc
disc_fits = chi_disc
colors = ['k', 'g', 'r']
#First for bckg
for flux_hist, chi2_fit, label, color in zip(flux_hists, chi2_fits, labels,
                                             colors):
    x = np.linspace(0, 40, 100)
    histlite.plot1d(ax,
                    flux_hist.normalize(integrate=True),
                    histtype='step',
                    color=color,
                    label='{} - '.format(label) + r'$\tilde{\chi}^2$' +
                    ': df={}'.format(str(round(chi2_fit.par[0], 2))))
    ax.plot(
        x, chi2_fit.pdf(x), linestyle=':', color=color
    )  #, label='{} - '.format(label) + r'$\tilde{\chi}^2$' + ': df={}'.format(str(round(chi2_fit.par[0],2))))
#now for sens, then disc
for flux_hist, chi2_fit, sensfolder, llhweight, color in zip(
        sens_hists, sens_fits, sens, llhweights, colors):
    histlite.plot1d(
        ax,
        flux_hist.normalize(integrate=True),
        histtype='step',
        color=color,
        alpha=0.6
    )  #label='mu = '+str(np.round(printflux(sensfolder)[1][0],2)))
flux_hist =histlite.hist(bckg_flux['TS'],bins=bins,range=range)

#I'll include a chi squared distribution w/ DOF=1 (and 2, just because). I'll also show the best fitting chi2 dist for each weighting scheme.##
chi2fit_uniform = fitfun(bckg_uniform['TS'],df=2., floc=0., fscale=1.)
chi2fit_redshift = fitfun(bckg_redshift['TS'],df=2., floc=0., fscale=1.)
chi2fit_flux = fitfun(bckg_flux['TS'],df=2., floc=0., fscale=1.)

## Now to plot. ##
fig_bckg = plt.figure (figsize=(w, .75*w))
ax=plt.gca()

chi2_fits = [chi2fit_uniform,chi2fit_redshift,chi2fit_flux]
colors=['blue','red','green']
for chi2_fit,color in zip(chi2_fits,colors):
  x = np.linspace(0,20,100)
  ax.plot(x, chi2_fit.pdf(x), linestyle=':',color=color, label=r'$\tilde{\chi}^2$: df='+str(round(chi2_fit.par[0],2)))

histlite.plot1d(ax,uniform_hist.normalize(integrate=True),histtype='step',label='uniform',color='blue')
histlite.plot1d(ax,redshift_hist.normalize(integrate=True),histtype='step',label='redshift',color='red')
histlite.plot1d(ax,flux_hist.normalize(integrate=True),histtype='step',label='flux',color='green')
ax.set_title(r'70m Background TS - 3yr (59-86I)')
ax.set_xlabel(r'TS')
plt.subplots_adjust (left=.2, bottom=.2)
ax.set_ylabel(r'Normalized Counts') 
ax.set_ylim(8e-5,1)
ax.set_xlim(0,16)
ax.semilogy() 
plt.legend(loc='upper right', prop=propxsmall, ncol=2)
fig_bckg.savefig('/data/user/brelethford/AGN_Core/Plots/backgroundTS/bckgTS_70m_3yr.pdf')
fig_bckg.savefig('/data/user/brelethford/AGN_Core/Plots/backgroundTS/bckgTS_70m_3yr.png')
Exemple #21
0
TSdisc = np.percentile(bckg_uniform['TS'], (1 - (2.867e-7)) * 100)
##Now we make hists of the test statistics ##
bins = 80
range = (0.0, 30.0)
uniform_hist = histlite.Hist.normalize(
    histlite.hist(bckg_uniform['TS'], bins=bins, range=range))

#I'll do the same thing for the injected events to achieve sensitivity and discovery potential for uniform llh uniform inj.

## Now to plot. ##
fig_bckg = plt.figure(figsize=(w, .75 * w))
ax = plt.gca()

histlite.plot1d(ax,
                uniform_hist,
                histtype='step',
                label='background',
                color='blue')
histlite.plot1d(ax,
                senshist,
                histtype='step',
                label='sensitivity: n inj = {0:.2f}'.format(sensinj[0]),
                color='red')
histlite.plot1d(ax,
                dischist,
                histtype='step',
                label='discovery potential: n inj = {0:.2f}'.format(
                    discinj[0]),
                color='green')

plt.axvline(TSsens, linestyle='--', color='k')