def reco_energy_plot(config, out=False, batch=False): # Load median file information simBase = getSimBase(config) inFile = '%s_median.npy' % simBase d = np.load(inFile) d = d.item() xbins, ybins, ebins = d['xbins'], d['ybins'], d['ebins'] # Calculate median energy value from bin energies = d['medians'] energies = energies.T # Trim down the top of the grid ycts = energies.sum(axis=1) yidx = np.where(ycts==0)[0][0] + 2 ybins = ybins[:yidx] energies = energies[:yidx] emin, emax = energies[energies!=0].min(), energies[energies!=0].max() emin, emax = 3.75, 8 ebins = [emin] + getEbins() + [emax] fig = plt.figure(figsize=(8,6)) ax = fig.add_subplot(111) X, Y = np.meshgrid(xbins, ybins) cmap = plt.cm.jet cmap = cmap_discretize(cmap, ebins) cmap.set_under('white') tPars = {'fontsize':16} p = ax.pcolor(X, Y, energies, cmap=cmap, vmin=emin, vmax=emax) cb = fig.colorbar(p, ax=ax, ticks=ebins) cb.ax.set_yticklabels(['%.2f' % ebin for ebin in ebins]) cb.set_label(r'$\mathrm{log}_{10}(E/\mathrm{GeV})$', rotation=270, labelpad=20, **tPars) #ax.set_title('Median Energy vs Zenith and Nchannel') ax.set_xlabel(r'$\mathrm{cos}(\theta_\mathrm{reco})$', **tPars) ax.set_ylabel(r'$\mathrm{log}_{10}(N_\mathrm{channel})$', **tPars) ax.set_xlim(xbins.min(), xbins.max()) ax.set_ylim(ybins.min(), ybins.max()) if out != False: #outFile = '%s/%s_Median_Energy' % (outPrefix, config) plt.savefig(out, dpi=300, bbox_inches='tight') if not batch: plt.show()
help='Detector configuration') p.add_argument('--nx', dest='nx', default=60, help='Number of bins in cos(zenith)') p.add_argument('--ny', dest='ny', default=40, help='Number of bins in log10(Nchannel)') p.add_argument('--estep', dest='estep', default=.05, help='Energy step size in log10(E/GeV)') p.add_argument('-o', '--out', dest='out', help='Option for outfile name') args = p.parse_args() if not args.out: simBase = getSimBase(args.config) outFile = '%s_median.npy' % simBase else: outFile = '%s/%s.npy' % (my.ani_sim, args.out) # Create histogram xbins = np.linspace(0.3, 1, args.nx+1) ybins = np.linspace(1, 3.2, args.ny+1) ebins = np.arange(2.75, 9+args.estep/2., args.estep) h = np.zeros((args.nx, args.ny, len(ebins)-1)) #w = np.zeros((args.nx, args.ny, len(ebins)-1)) # Get list of simulation files simBase = getSimBase(args.config) simList = glob.glob('%s.npy' % simBase) if len(simList) == 0: