def elbert_only(slice_val=1., kind='conv nu_mu'): plt.figure() if 'nu_e' in kind: echoices = [exthp.passrates] names = [r'$\mathcal{P}_{\rm pass}^{\rm uncor, GJKvS}$'] else: echoices = [exthp.corr, exthp.passrates] names = [extlabel(True), extlabel(False)] if slice_val > 1: cths = np.linspace(0, 1, 100) emu = extsv.minimum_muon_energy(extsv.overburden(cths)) for echoice, name in zip(echoices, names): plt.plot(cths, echoice(kind)(slice_val, emu, cths), '--', label=name) else: ens = np.logspace(2, 9, 100) emu = extsv.minimum_muon_energy(extsv.overburden(slice_val)) for echoice, name in zip(echoices, names): plt.plot(ens, echoice(kind)(ens, emu, slice_val), '--', label=name) plt.title(r'{}, {}'.format(tex(kind), tex(slice_val))) plt.ylim(0., 1.) plt.ylabel(r'Passing fraction') plt.xlim(10**3, 10**7) plt.xscale('log') plt.xlabel(r'$E_\nu$ [GeV]') plt.legend() plt.tight_layout(0.3)
def elbert_pmodels(slice_val=1., kind='conv nu_mu', hadr='DPMJET-III-3.0.6', prpl='ice_allm97_step_1', corr_only=False): pmodels = [(pm.HillasGaisser2012, 'H3a', 'H3a'), (pm.PolyGonato, False, 'poly-gonato'), (pm.GaisserHonda, None, 'GH')] echoice = exthp.corr if corr_only else exthp.passrates label = extlabel(corr_only) + ' {} {}'.format(tex(kind), tex(slice_val)) if slice_val > 1: cths = np.linspace(0, 1, 100) emu = extsv.minimum_muon_energy(extsv.overburden(cths)) plt.plot(cths, echoice(kind)(slice_val, emu, cths), 'k--', label=label) else: ens = np.logspace(2, 9, 100) emu = extsv.minimum_muon_energy(extsv.overburden(slice_val)) plt.plot(ens, echoice(kind)(ens, emu, slice_val), 'k--', label=label) for pmodel in pmodels: pr = fn(slice_val)(slice_val, kind, pmodel[:2], hadr, prpl=prpl, corr_only=corr_only, label='{} {} {}'.format(pmodel[2], tex(kind), tex(slice_val))) plt.legend() plt.tight_layout(0.3)
def elbert(slice_val=1., kind='conv nu_mu', pmodel=(pm.GaisserHonda, None), prpl='ice_allm97_step_1', corr_only=False): hadrs = ['DPMJET-III-3.0.6', 'SIBYLL2.3c'] echoice = exthp.corr if corr_only else exthp.passrates if slice_val > 1: cths = np.linspace(0, 1, 100) emu = extsv.minimum_muon_energy(extsv.overburden(cths)) plt.plot(cths, echoice(kind)(slice_val, emu, cths), 'k--', label='Analytic approx. {} {}'.format(tex(kind), tex(slice_val))) else: ens = np.logspace(2, 9, 100) emu = extsv.minimum_muon_energy(extsv.overburden(slice_val)) plt.plot(ens, echoice(kind)(ens, emu, slice_val), 'k--', label='Analytic approx. {} {}'.format(tex(kind), tex(slice_val))) for hadr in hadrs: fn(slice_val)(slice_val, kind, pmodel, hadr, prpl=prpl, corr_only=corr_only, label='{} {} {}'.format(hadr, tex(kind), tex(slice_val))) plt.legend() plt.tight_layout(0.3)
def fig_extsv(): kinds = ['conv_nue', 'pr_nue', 'conv_numu', 'pr_numu'] cos_ths = [0.25, 0.85] ens = np.logspace(2, 9, 100) useexts = [False, True] labels = ['This work', 'GJKvS'] for kind in kinds: plt.figure() plt.title(titling[kind]) for idx, useext in enumerate(useexts): for cos_th in cos_ths: if useext: emu = extsv.minimum_muon_energy(extsv.overburden(cos_th)) plt.plot(ens, exthp.passrates(kind)(ens, emu, cos_th), linestyles[idx]) else: clabel = r'$\cos \theta_z = {}$'.format( cos_th) if idx == 0 else None plots.fn(cos_th)(cos_th, kind, label=clabel) plt.axvline(np.nan, color='k', linestyle=linestyles[idx], label=labels[idx]) plt.gca().set_prop_cycle(None) plt.legend() plt.tight_layout(0.3) save('fig/extsv_{}.eps'.format(kind))
def corsika(cos_theta_bin=-1, kind='conv nu_mu', pmodel=(pm.HillasGaisser2012, 'H3a'), hadr='SIBYLL2.3', density=('CORSIKA', ('SouthPole', 'December')), prpl='ice_allm97_step_1', corsika_file='eff_maxmu', plot_nuveto_lines=False, plot_legacy_veto_lines=False): if isinstance(cos_theta_bin, list): [ corsika(cth, kind, pmodel, hadr, density, prpl, corsika_file, plot_nuveto_lines, plot_legacy_veto_lines) for cth in cos_theta_bin ] return cfile = pickle.load(open( resource_filename('nuVeto', os.path.join('/data/corsika', corsika_file + '.pkl')), 'rb'), encoding='latin1') fraction = 'eff' in corsika_file eff, elow, eup, xedges, yedges = cfile[mceq_categ_format(kind)] cos_theta = centers(yedges)[cos_theta_bin] clean = eff[:, cos_theta_bin] > 0 xcenters = 10**centers(xedges)[clean] pr = plt.errorbar(xcenters, eff[:, cos_theta_bin][clean], xerr=np.asarray( list( zip(xcenters - 10**xedges[:-1][clean], 10**xedges[1:][clean] - xcenters))).T, yerr=np.asarray( list( zip(elow[:, cos_theta_bin][clean], eup[:, cos_theta_bin][clean]))).T, label='CORSIKA {} {}'.format(tex(kind), tex(cos_theta)), fmt='.') if plot_legacy_veto_lines and fraction: ens = np.logspace(2, 9, 100) emu = extsv.minimum_muon_energy(extsv.overburden(cos_theta)) plt.plot(ens, exthp.passrates(kind)(ens, emu, cos_theta), 'k--', label='Analytic approx. {} {}'.format(tex(kind), tex(cos_theta))) if plot_nuveto_lines: pr_enu(cos_theta, kind, pmodel=pmodel, hadr=hadr, prpl=prpl, density=density, fraction=fraction, label='{} {} {}'.format(hadr, tex(kind), tex(cos_theta)), color=pr[0].get_color()) plt.legend()
def test_elbert(cth): ens = np.logspace(2,8.9,50) mine = np.asarray( [passing(en, cth, kind='conv nu_mu', hadr='DPMJET-III-3.0.6', pmodel=(pm.GaisserHonda, None), prpl=None, corr_only=True) for en in ens]) emu = extsv.minimum_muon_energy(extsv.overburden(cth)) theirs = exthp.corr('conv nu_mu')(ens, emu, cth) print('test_elbert', cth) assert np.all(np.abs(theirs-mine)<0.022)
def plot_prpl(interp_pkl, include_mean=False, include_cbar=True): depth = 1950 * Units.m prplfn = pickle.load(open(interp_pkl, 'rb'), encoding='latin1') emui_edges = np.logspace(2, 8, 101) l_ice_edges = np.linspace(1e3, 4e4, 101) emui = centers(emui_edges) l_ice = centers(l_ice_edges) xx, yy = np.meshgrid(emui, l_ice) prpls = prplfn(list(zip(xx.flatten(), yy.flatten()))) plt.figure() plt.pcolormesh(emui_edges, l_ice_edges / 1e3, prpls.reshape(xx.shape), cmap='magma') if include_cbar: plt.colorbar() if include_mean: small_ice = l_ice[l_ice < 2.7e4] plt.plot( extsv.minimum_muon_energy(small_ice), small_ice / 1e3, 'w--', label= r'$l_{\rm ice,\,median} (E_\mu^{\rm i}, E_\mu^{\rm th} = 1\,{\rm TeV})$' ) leg = plt.legend(frameon=False, prop={'weight': 'bold'}, loc='upper left') for text in leg.get_texts(): plt.setp(text, color='w', fontsize='medium') plt.xlabel(r'$E_\mu^{\rm i}$ [GeV]') plt.ylabel(r'$l_{\rm ice}$ [km]') plt.locator_params(axis='y', nbins=8) # # plt.yscale('log') # # plt.gca().yaxis.set_major_formatter(ScalarFormatter()) # plt.ticklabel_format(style='plain', axis='y') plt.gca().minorticks_off() plt.ylim(depth / Units.km, 40) # right y-axis with angles axr = plt.gca().twinx() axr.grid(False) geom = Geometry(depth) costhetas = geom.overburden_to_cos_theta(np.arange(10, 41, 10) * Units.km) axr.set_ylim(depth / Units.km, 40) axr.set_yticks(geom.overburden(costhetas) / 1e3) axr.set_yticklabels(np.round(costhetas, 2)) axr.set_ylabel(r'$\cos \theta_z$', rotation=-90) axr.set_xscale('log') axr.set_xlim(1e2, 1e8) axr.minorticks_off() xlocmaj = LogLocator(base=10, numticks=12) axr.get_xaxis().set_major_locator(xlocmaj) return emui_edges, l_ice_edges, prpls.reshape(xx.shape)
def test_elbert(): ens = np.logspace(2, 9, 50) cths = [0.1, 0.3, 0.8] for cth in cths: mine = np.asarray([ passing(en, cth, kind='conv_numu', hadr='DPMJET-III', pmodel=(pm.GaisserHonda, None), prpl=None, corr_only=True) for en in ens ]) emu = extsv.minimum_muon_energy(extsv.overburden(cth)) theirs = exthp.corr('conv_numu')(ens, emu, cth) assert np.all(np.abs(theirs - mine) < 0.02)