def main(): ctaplot.set_style() output_dir = args.output_dir.absolute() output_dir.mkdir(exist_ok=True, parents=True) output_file = output_dir / r0_to_dl1_filename(args.input_file.name) r0_to_dl1.allowed_tels = {1, 2, 3, 4} if args.config_file is not None: try: config = read_configuration_file(args.config_file.absolute()) except Exception as e: log.error(f'Config file {args.config_file} could not be read: {e}') sys.exit(1) else: config = get_standard_config() # This benchmark needs true pe image config['write_pe_image'] = True # directly jump to the benchmarks if the dl1 file already exists if not os.path.exists(output_file): r0_to_dl1.r0_to_dl1( args.input_file, output_filename=output_file, custom_config=config, ) with tables.open_file(output_file) as f: sim_table = Table(f.root.dl1.event.simulation.LST_LSTCam.read()) im_table = Table(f.root.dl1.event.telescope.image.LST_LSTCam.read()) if len(sim_table) != len(im_table): raise ValueError( 'the number of events with simulation info is not equal to the number of dl1 events' ) pdf_filename = os.path.join( args.output_dir, f"charge_bench_{os.path.basename(output_file).replace('.h5', '')}.pdf") with PdfPages(pdf_filename) as pdf: plot_pixels_pe_spectrum(sim_table['true_image'], im_table['image']) plt.tight_layout() pdf.savefig() plt.close() plot_photoelectron_true_reco(sim_table['true_image'], im_table['image']) plt.tight_layout() pdf.savefig() plt.close() ax = plot_charge_resolution(sim_table['true_image'], im_table['image']) ax.set_ylim(-1, 10) plt.tight_layout() pdf.savefig() plt.close()
def test_plot_pixels_pe_spectrum(): true_pe = 100 * np.random.rand(1000) reco_pe = -50 + 100 * np.random.rand(len(true_pe)) calib.plot_pixels_pe_spectrum(true_pe, reco_pe, bins=100) calib.plot_pixels_pe_spectrum(true_pe, reco_pe, bins=np.logspace(-2, 4, 50))
def test_plot_pixels_pe_spectrum(): true_pe = 100 * np.random.rand(1000) reco_pe = true_pe * np.random.rand(len(true_pe)) calib.plot_pixels_pe_spectrum(true_pe, reco_pe)