LST1PredictionTool#
- class ctlearn.tools.LST1PredictionTool(*args: t.Any, **kwargs: t.Any)[source]#
Bases:
ToolTool to predict the gammaness, energy and arrival direction from lstchain DL1 data.
This tool is used to predict the gammaness, energy and arrival direction from pixel-wise image data in lstchain format. The tool loads the trained models from the specified paths and performs inference on the input data. The input data is expected to be in the DL1 format of lstchain and the output data is stored in the DL2 format of ctapipe. Besides the DL2 predictions, the tool creates the SubarrayDescription of the LST-1 telescope and stores it in the output file. In addition, the tool also creates the trigger, pointing and DL1 parameters tables and stores them in the output file.
CAUTION: The tool is designed to work with the DL1 data format of lstchain only.
Attributes Summary
Size of the batch to perform inference of the neural network.
Set the input channels to be loaded from the DL1 event data.
Set whether to include the dl1 feature vectors in the output file.
Set whether to include dl2 subarray-event-wise data in the output file.
Set whether to include dl2 telescope-event-wise data in the output file.
If both nominal and effective focal lengths are available, which one to use for the ~ctapipe.coordinates.CameraFrame attached to the ~ctapipe.instrument.CameraGeometry instances in the ~ctapipe.instrument.SubarrayDescription which will be used in CameraFrame to TelescopeFrame coordinate transforms.
Input LST-1 HDF5 files including pixel-wise image data
Path to a Keras model file (Keras3) for the regression of the primary particle arrival direction based on the camera coordinate offsets.
Path to a Keras model file (Keras3) for the regression of the primary particle energy.
Path to a Keras model file (Keras3) for the classification of the primary particle type.
Output path to save the dl2 prediction results
Use the given obs_id instead of the default one.
Overwrite output file if it exists
Name of the reconstruction algorithm used to generate the dl2 data for each task.
Methods Summary
finish()Perform final cleanup and save metadata after the core logic completes.
setup()Initialize the tool configuration, validate parameters, and setup data handlers.
start()Execute the core logic of the tool.
Attributes Documentation
- aliases = {('d', 'cameradirection_model'): 'LST1PredictionTool.load_cameradirection_model_from', ('e', 'energy_model'): 'LST1PredictionTool.load_energy_model_from', ('i', 'input_url'): 'LST1PredictionTool.input_url', ('o', 'output'): 'LST1PredictionTool.output_path', ('t', 'type_model'): 'LST1PredictionTool.load_type_model_from'}#
- batch_size#
Size of the batch to perform inference of the neural network.
- channels#
Set the input channels to be loaded from the DL1 event data. image: integrated charges, cleaned_image: integrated charges cleaned with the DL1 cleaning mask, peak_time: extracted peak arrival times, relative_peak_time: extracted relative peak arrival times, cleaned_peak_time: extracted peak arrival times cleaned with the DL1 cleaning mask, cleaned_relative_peak_time: extracted relative peak arrival times cleaned with the DL1 cleaning mask.
- classes = [<class 'dl1_data_handler.image_mapper.AxialMapper'>, <class 'dl1_data_handler.image_mapper.NearestNeighborMapper'>, <class 'dl1_data_handler.image_mapper.BilinearMapper'>, <class 'dl1_data_handler.image_mapper.BicubicMapper'>, <class 'dl1_data_handler.image_mapper.RebinMapper'>]#
- description = '\n Tool to predict the gammaness, energy and arrival direction from lstchain DL1 data.\n\n This tool is used to predict the gammaness, energy and arrival direction\n from pixel-wise image data in lstchain format. The tool loads the trained models\n from the specified paths and performs inference on the input data. The\n input data is expected to be in the DL1 format of lstchain and the output data is\n stored in the DL2 format of ctapipe. Besides the DL2 predictions, the tool creates\n the SubarrayDescription of the LST-1 telescope and stores it in the output file.\n In addition, the tool also creates the trigger, pointing and DL1 parameters tables\n and stores them in the output file.\n\n CAUTION: The tool is designed to work with the DL1 data format of lstchain only.\n '#
- dl1_features#
Set whether to include the dl1 feature vectors in the output file.
- dl2_subarray#
Set whether to include dl2 subarray-event-wise data in the output file.
- dl2_telescope#
Set whether to include dl2 telescope-event-wise data in the output file.
- examples = '\n To predict from DL1 lstchain data using trained CTLearn models:\n > ctlearn-predict-LST1 --input_url input.subrun.lstchain.dl1.h5 --LST1PredictionTool.batch_size=64 --LST1PredictionTool.channels=cleaned_image --LST1PredictionTool.channels=cleaned_relative_peak_time --LST1PredictionTool.image_mapper_type=BilinearMapper --type_model="/path/to/your/type/ctlearn_model(.keras/.pth)" --energy_model="/path/to/your/energy/ctlearn_model(.keras/.pth)" --cameradirection_model="/path/to/your/direction/ctlearn_model(.keras/.pth)" --output output.dl2.h5 --overwrite '#
- flags = {'dl1-features': ({'LST1PredictionTool': {'dl1_features': True}}, 'Include dl1 features'), 'dl2-subarray': ({'LST1PredictionTool': {'dl2_subarray': True}}, 'Include dl2 subarray-event-wise data in the output file'), 'dl2-telescope': ({'LST1PredictionTool': {'dl2_telescope': True}}, 'Include dl2 telescope-event-wise data in the output file'), 'no-dl1-features': ({'LST1PredictionTool': {'dl1_features': False}}, 'Exclude dl1 features'), 'no-dl2-subarray': ({'LST1PredictionTool': {'dl2_subarray': False}}, 'Exclude dl2 subarray-event-wise data in the output file'), 'no-dl2-telescope': ({'LST1PredictionTool': {'dl2_telescope': False}}, 'Exclude dl2 telescope-event-wise data in the output file')}#
- focal_length_choice#
If both nominal and effective focal lengths are available, which one to use for the ~ctapipe.coordinates.CameraFrame attached to the ~ctapipe.instrument.CameraGeometry instances in the ~ctapipe.instrument.SubarrayDescription which will be used in CameraFrame to TelescopeFrame coordinate transforms. The ‘nominal’ focal length is the one used during the simulation, the ‘effective’ focal length is computed using specialized ray-tracing from a point light source
- image_mapper_type#
. Possible values: []
- input_url#
Input LST-1 HDF5 files including pixel-wise image data
- load_cameradirection_model_from#
Path to a Keras model file (Keras3) for the regression of the primary particle arrival direction based on the camera coordinate offsets.
- load_energy_model_from#
Path to a Keras model file (Keras3) for the regression of the primary particle energy.
- load_type_model_from#
Path to a Keras model file (Keras3) for the classification of the primary particle type.
- name = 'ctlearn-predict-LST1'#
- output_path#
Output path to save the dl2 prediction results
- override_obs_id#
Use the given obs_id instead of the default one. Needed to merge subruns later with ctapipe-merge.
- overwrite#
Overwrite output file if it exists
- prefixes#
Name of the reconstruction algorithm used to generate the dl2 data for each task.
Methods Documentation
- finish()[source]#
Perform final cleanup and save metadata after the core logic completes.
This method writes provenance data (such as configuration and execution context) to the output file, finalizes tables, and ensures all file handlers are safely closed.
- setup()[source]#
Initialize the tool configuration, validate parameters, and setup data handlers.
This method is the first part of the tool execution lifecycle. It validates input arguments, sets up the configuration dictionary, configures the output file, and prepares the DataReader to ensure everything is ready before the core processing begins.