ctlearn_manager.utils.DL2_processing
- ctlearn_manager.utils.DL2_processing.get_energy_dependent_mask_data(DL2_file, pointing_table, pointing_alt_key, pointing_az_key, CTLearn, data, source_position, energy_key, gammaness_key, tri_model, reco_coord, theta_cut=True, cuts=<ctlearn_manager.utils.utils.Cuts object>)[source]
- Parameters:
tri_model (CTLearnTriModelManager)
cuts (Cuts)
- class ctlearn_manager.utils.DL2_processing.DL2DataProcessor(DL2_files, CTLearn_TriModel_Manager, cuts=[<ctlearn_manager.utils.utils.Cuts object>], source_position=<SkyCoord (ICRS): (ra, dec) in deg (83.6324, 22.0174)>, source_name='Crab Nebula', pointing_table='dl1/monitoring/telescope/pointing/tel_001', default_E_bins=<Quantity [ 0.02 , 0.03169786, 0.05023773, 0.07962143, 0.12619147, 0.2 , 0.31697864, 0.50237729, 0.79621434, 1.26191469, 2. , 3.16978638, 5.02377286, 7.96214341, 12.61914689, 20. ] TeV>, e_edges=(-inf, inf), intensity_cut=80, global_gammaness_cut=0.0, workers=None, reco_field_suffix=None, reconstruction_method='CTLearn')[source]
Bases:
objectA class to process DL2 data and perform various analyses such as plotting theta^2 distributions and computing on-off counts.
- Parameters:
DL2_files (list[str])
CTLearn_TriModel_Manager (CTLearnTriModelManager)
cuts (list[Cuts])
source_name (str)
intensity_cut (int)
global_gammaness_cut (float)
- DL2_files
List of DL2 file paths to be processed.
- Type:
list
- CTLearnTriModelManager
An instance of CTLearnTriModelManager containing telescope information.
- Type:
- source_position
The sky coordinates of the source position. Default is the Crab Nebula.
- Type:
SkyCoord
- telescope_ids
List of telescope IDs from CTLearnTriModelManager.
- Type:
list
- telescope_names
List of telescope names from CTLearnTriModelManager.
- Type:
list
- stereo
Indicates if stereo mode is used.
- Type:
bool
- gammaness_cut
The gammaness cut value for event selection. Default is 0.9.
- Type:
float
- reconstruction_method
The method used for reconstruction. Default is “CTLearn”.
- Type:
str
- reco_field_suffix
Suffix for the reconstruction field, based on stereo mode.
- Type:
str
- telescope_location
The location of the telescope, if LST1 is in the telescope names.
- Type:
EarthLocation
- reco_directions
List of reconstructed sky directions.
- Type:
list
- pointings
List of pointing directions.
- Type:
list
- dl2s
List of loaded DL2 data.
- Type:
list
- dl2s_cuts
List of DL2 data after applying cuts.
- Type:
list
- __init__(self, DL2_files, CTLearnTriModelManager, gammaness_cut=0.9, source_position=SkyCoord.from_name("Crab")):
Initializes the DL2DataProcessor with the given parameters and processes the DL2 data.
- process_DL2_data(self):
Processes the DL2 data files, applying cuts and computing sky positions.
- plot_theta2_distribution(self, bins, n_off=5):
Plots the theta^2 distribution for the processed DL2 data.
- compute_off_regions(self, pointing, n_off):
Computes the off-source regions for background estimation.
- compute_eff_time(self, events):
Computes the effective observation time and elapsed time from the event data.
- compute_on_off_counts(self, events, reco_coord, pointing_coord, n_off, theta2_cut=0.04*u.deg**2, gcut=0.5, E_min=0, E_max=100, I_min=None, I_max=None):
Computes the on-source and off-source counts, as well as the Li & Ma significance.
- compute_on_off_counts_array_nul(events, on_sep, off_sep, theta2_cut, gcut, E_min=0, E_max=100)[source]
- compute_on_off_counts(events, reco_coord, pointing_coord, n_off, theta2_cut=<Quantity 0.04 deg2>, gcut=0.5, E_min=0, E_max=100, I_min=None, I_max=None)[source]
- optimize_cuts_on_crab(n_off=5, output_suffix='', max_gammaness_cut=1.0, max_theta2_cut=0.2, gcut_step=0.01, theta2_cut_step=0.001, E_bins=None)[source]
Compute and store optimal gammaness/theta2 cuts for even and odd events for each energy bin.
- static read_cuts_optimized_on_crab_from_csv(csv_filename)[source]
Read optimal gammaness/theta2 cuts for even and odd events from a CSV file. Returns a dict with keys: ‘even’ and ‘odd’, each containing a dict with keys ‘gammaness’, ‘theta2’, ‘E_bins’. The bins are sorted by bin_index.
- plot_sensitivity(n_off=5, ax=None, label='CTLearn', output_file=None, export_to_h5=None, import_from_h5=None, import_label=None, optimized_on_crab=False, output_suffix='')[source]
- Parameters:
export_to_h5 (str)
import_from_h5 (str)
import_label (str)
optimized_on_crab (bool)
output_suffix (str)
- plot_PSF(n_off=5, ax=None, label='CTLearn', output_file=None, plot_MC=[], export_to_h5=None, import_from_h5=None, import_label=None, ylim=(0, 0.6))[source]
- Parameters:
plot_MC (list[str])
export_to_h5 (str)
import_from_h5 (str)
import_label (str)
- get_gammaness_cuts_for_efficiencies(MC_dl2, efficiencies, E_min=None, E_max=None, I_min=None, I_max=None)[source]
- get_efficiency_for_gamaness_cuts(MC_dl2, gammaness_cuts, E_min=None, E_max=None, I_min=None, I_max=None)[source]
- plot_everything(output_directory, suffix='')[source]
- Parameters:
output_directory (str)
suffix (str)
- produce_dl3(output_dl3_directory, source_name='Crab', source_ra=<Quantity 83.633 deg>, source_dec=<Quantity 22.01 deg>, cuts_index=0, overwrite=False, dl3_file_pattern='LST-1.Run*.dl3.fits')[source]
- Parameters:
output_dl3_directory (str)
source_name (str)
source_ra (float)
source_dec (float)
cuts_index (int)
overwrite (bool)
dl3_file_pattern (str)