derive_psf_parameters#
Derives the mirror alignment parameters using cumulative PSF measurement.
This includes parameters mirror_reflection_random_angle, mirror_align_random_horizontal and mirror_align_random_vertical.
The telescope zenith angle and the source distance can be set by command line arguments.
The measured cumulative PSF should be provided by using the command line argument data. A file name is expected, in which the file should contain 3 columns: radial distance in mm, differential value of photon intensity and its integral value.
The derivation is performed through a random search. A number of random combination of the parameters are tested and the best ones are selected based on the minimum value of the Root Mean Squared Deviation between data and simulations. The range in which the parameter are drawn uniformly are defined based on the previous value on the telescope model.
The assumption are:
mirror_align_random_horizontal and mirror_align_random_vertical are the same.
mirror_align_random_horizontal/vertical have no dependence on the zenith angle.
One example of the plot generated by this applications are shown below.
Command line arguments#
- site (str, required)
North or South.
- telescope (str, required)
Telescope model name (e.g. LST-1, SST-D, …).
- model_version (str, optional)
Model version.
- src_distance (float, optional)
Source distance in km.
- zenith (float, optional)
Zenith angle in deg.
- data (str, optional)
Name of the data file with the measured cumulative PSF.
- plot_all (activation mode, optional)
If activated, plots will be generated for all values tested during tuning.
- fixed (activation mode, optional)
Keep the first entry of mirror_reflection_random_angle fixed.
- test (activation mode, optional)
If activated, application will be faster by simulating fewer photons.
Example#
LSTN-01 5.0.0
Runtime < 3 min.
Get PSF data from the DB:
simtools-db-get-file-from-db --file_name PSFcurve_data_v2.txt
Run the application:
simtools-derive-psf-parameters --site North --telescope LSTN-01 \\
--model_version 6.0.0 --data PSFcurve_data_v2.txt --plot_all --test
The output is saved in simtools-output/derive_psf_parameters.
Expected final print-out message:
Best parameters:
mirror_reflection_random_angle = [0.006, 0.133, 0.005]
mirror_align_random_horizontal = [0.005, 28.0, 0.0, 0.0]
mirror_align_random_vertical = [0.005, 28.0, 0.0, 0.0]
- derive_psf_parameters.add_parameters(all_parameters, mirror_reflection, mirror_align, mirror_reflection_fraction=0.15, mirror_reflection_2=0.035)[source]#
Transform and add parameters to the all_parameters list.
- Parameters:
- mirror_reflectionfloat
The random angle of mirror reflection.
- mirror_alignfloat
The random angle for mirror alignment (both horizontal and vertical).
- mirror_reflection_fractionfloat, optional
The fraction of the mirror reflection. Default is 0.15.
- mirror_reflection_2float, optional
A secondary random angle for mirror reflection. Default is 0.035.
- Returns:
- None
Updates the all_parameters list in place.
- derive_psf_parameters.calculate_rmsd(data, sim)[source]#
Calculate Root Mean Squared Deviation to be used as metric to find the best parameters.
- derive_psf_parameters.find_best_parameters(all_parameters, tel_model, args_dict, data_to_plot, radius, pdf_pages)[source]#
Find the best parameters from all parameter sets.
- Returns:
- Tuple of best parameters and their D80 value.
- derive_psf_parameters.generate_random_parameters(all_parameters, n_runs, args_dict, mrra_0, mfr_0, mrra2_0, mar_0, logger)[source]#
Generate random parameters for tuning.
- Parameters:
- all_parameterslist
List to store all parameter sets.
- n_runsint
Number of random parameter combinations to test.
- args_dictdict
Dictionary containing parsed command-line arguments.
- mrra_0float
Initial value of mirror_reflection_random_angle.
- mfr_0float
Initial value of mirror_reflection_fraction.
- mrra2_0float
Initial value of the second mirror_reflection_random_angle.
- mar_0float
Initial value of mirror_align_random_horizontal/vertical.
- loggerlogging.Logger
Logger object for logging messages.
- derive_psf_parameters.get_previous_values(tel_model, logger)[source]#
Retrieve previous parameter values from the telescope model.
- Parameters:
- tel_modelTelescopeModel
Telescope model object.
- loggerlogging.Logger
Logger object for logging messages.
- Returns:
- tuple
Tuple containing the previous values of mirror_reflection_random_angle (first entry), mirror_reflection_fraction, second entry), mirror_reflection_random_angle (third entry), and mirror_align_random_horizontal/vertical.
- derive_psf_parameters.load_and_process_data(args_dict)[source]#
Load and process data if specified in the command-line arguments.
- Returns:
- data_to_plot: OrderedDict containing loaded and processed data.
- radius: Radius data from loaded data (if available).