Reconstruction (reco)

Introduction

Module containing functions and classes to reconstruct data. This includes: * r0 to dl1 functions, including charge integration and application of the calibration, data volume reduction and other utils * dl1 to dl2 functions, including disp calculation and random forest training and application

Reference/API

lstchain.reco.disp Module

Functions

disp(cog_x, cog_y, src_x, src_y, hillas_psi)

Compute the disp parameters

disp_parameters(cog_x, cog_y, hillas_psi, ...)

Compute disp parameters.

disp_parameters_event(hillas_parameters, ...)

Compute the disp_norm parameters from Hillas parameters in the event position in the camera frame Return a DispContainer

disp_to_pos(disp_dx, disp_dy, cog_x, cog_y)

Calculates source position in camera coordinates(x,y) from the reconstructed disp.

disp_vector(disp_norm, disp_angle, disp_sign)

Compute disp_norm.dx and disp_norm.dy vector from disp_norm.norm, disp_norm.angle and disp_norm.sign

miss(disp_dx, disp_dy, hillas_psi)

Compute miss

lstchain.reco.dl1_to_dl2 Module

Module with functions for Energy and disp_norm reconstruction and G/H separation. There are functions for raining random forest and for applying them to data. The RF can be saved into a file for later use.

Usage:

“import dl1_to_dl2”

Functions

apply_models(dl1, classifier, reg_energy[, ...])

Apply previously trained Random Forests to a set of data depending on a set of features.

build_models(filegammas, fileprotons[, ...])

Uses MC data to train Random Forests for Energy and DISP reconstruction and G/H separation and returns the trained RFs.

get_expected_source_pos(data, data_type, config)

Get expected source position for source-dependent analysis .

get_source_dependent_parameters(data, config)

Get parameters dict for source-dependent analysis.

train_disp_norm(train[, custom_config, ...])

Train a model for the regression of the disp_norm norm

train_disp_sign(train[, custom_config, ...])

Train a model for the classification of the disp_norm sign

train_disp_vector(train[, custom_config, ...])

Train a model (Random Forest Regressor) for the regression of the disp_norm vector coordinates dx,dy.

train_energy(train[, custom_config])

Train a Random Forest Regressor for the regression of the energy TODO: introduce the possibility to use another model

train_reco(train[, custom_config])

Trains two Random Forest regressors for Energy and disp_norm reconstruction respectively.

train_sep(train[, custom_config])

Trains a Random Forest classifier for Gamma/Hadron separation.

update_disp_with_effective_focal_length(data)

Update disp parameters using effective focal length

lstchain.reco.r0_to_dl1 Module

This is a module for extracting data from simtelarray and observed files and calculate image parameters of the events: Hillas parameters, timing parameters. They can be stored in HDF5 file. The option of saving the full camera image is also available.

Functions

add_disp_to_parameters_table(dl1_file, ...)

Reconstruct the disp parameters and source position from a DL1 parameters table and write the result in the file

get_dl1(calibrated_event, subarray, telescope_id)

Return a DL1ParametersContainer of extracted features from a calibrated event.

apply_lh_fit(event, telescope_id, ...)

Prepare and performs the extraction of DL1 parameters using a likelihood based reconstruction method.

r0_to_dl1([input_filename, output_filename, ...])

Chain r0 to dl1 Save the extracted dl1 parameters in output_filename

lstchain.reco.utils Module

Module with auxiliar functions:

  • Transform AltAz coordinates into Camera coordinates (This should be implemented already in ctapipe but I haven’t managed to find how to do it).

  • Calculate source position from disp_norm distance.

  • Calculate disp distance from source position.

Functions

add_delta_t_key(events)

Adds the time difference with the previous event to a real data dataframe.

alt_to_theta(alt)

Transforms altitude (angle from the horizon upwards) to theta (angle from z-axis) for simtel array coordinate systems.

apply_src_r_cut(events, src_r_min, src_r_max)

apply src_r cut to filter out large off-axis MC events

az_to_phi(az)

Transforms azimuth (angle from north towards east) to phi (angle from x-axis towards y-axis) for simtel array coordinate systems.

camera_to_altaz(pos_x, pos_y, focal, ...[, ...])

Compute camera to Horizontal frame (Altitude-Azimuth system).

cartesian_to_polar(x, y)

Cartesian to polar transformation As a convention, angle is always included in [-pi/2:pi/2].

clip_alt(alt)

Make sure altitude is not larger than 90 deg (it happens in some MC files for zenith=0), to keep astropy happy

compute_alpha(data)

Computes the angle between the shower major axis and polar angle of the shower centroid

compute_rf_event_weights(events)

Compute event-wise weights.

compute_theta2(data, source_position[, ...])

Computes a square of theta (angle from z-axis) from camera frame coordinates

expand_tel_list(tel_list, max_tels)

transform for the telescope list (to turn it into a telescope pattern) un-pack var-length list of tel_ids into fixed-width bit pattern by tel_index

extract_source_position(data, ...[, ...])

Extract source position from data

filter_events(events[, filters, finite_params])

Apply data filtering to a pandas dataframe or astropy Table.

get_effective_time(events)

Calculate the effective observation time of a set of real data events from a sky observation.

get_event_pos_in_camera(event, tel)

Return the position of the source in the camera frame.

get_geomagnetic_delta(zen, az[, geomag_dec, ...])

From a given geomagnetic declination and inclination angle along with telescope zenith and azimuth pointing to get the angle between the geomagnetic field and the shower axis, for a single telescope.

impute_pointing(dl1_data[, missing_values])

Impute missing pointing values using linear_imputer and replace them inplace

linear_imputer(y[, missing_values, copy])

Replace missing values in y with values from a linear interpolation on their position in the array.

polar_to_cartesian(norm, angle, sign)

Polar to cartesian transformation.

predict_source_position_in_camera(cog_x, ...)

Compute the source position in the camera frame

radec_to_camera(sky_coordinate, obstime, ...)

Coordinate transform from sky coordinate to camera coordinates (x, y) in distance

reco_source_position_sky(cog_x, cog_y, ...)

Compute the reconstructed source position in the sky

rotate(flat_object[, degree, origin])

Rotate 2D object around given axle

sky_to_camera(alt, az, focal, pointing_alt, ...)

Coordinate transform from aky position (alt, az) (in angles) to camera coordinates (x, y) in distance.

source_dx_dy(source_pos_x, source_pos_y, ...)

Compute the coordinates of the vector (dx, dy) from the center of gravity to the source position

source_side(source_pos_x, cog_x)

Compute on what side of the center of gravity the source is in the camera.

get_events_in_GTI(events, CatB_cal_table)

Select events in good time intervals (GTI) on the base of the GTI defined the catB calibration table (dl1_mon_tel_CatB_cal_key)

lstchain.reco.volume_reducer Module

TEMPORARY module with functions to perform a volume reduction to LST data:

This is a temporary implementation of the ‘tailcut and dilation’ volume reduction method. The volume reduction produces reduced waveforms and write them in the DL0 container.

To date, the DL0 container is overwritten if the volume reduction is applied.

Usage

In the configuration file:

"volume_reducer":{
    "algorithm": "zero_suppression_tailcut_dilation",
    "parameters": { # add here the desired tailcut parameters. See function's help for default parameters.
    }
}

Functions

apply_volume_reduction(event, subarray, config)

Checks the volume reduction algorithm defined in the config file, and if not None, it applies to a calibrated event the volume reduction method.

get_volume_reduction_method(config_file)

Checks in the configuration file if a volume reduction method has been set.

zero_suppression_tailcut_dilation(geom, image)

Zero suppression and tailcut cleaning with dilation.