simtools-derive-psf-parameters#
Derives the mirror alignment parameters using cumulative PSF measurement.
This includes parameters mirror_align_random_horizontal and mirror_align_random_vertical.
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 gradient descent optimization that minimizes either the Root Mean Squared Deviation (RMSD) between measured and simulated PSF curves (default) or the Kolmogorov-Smirnov (KS) statistic when the –ks_statistic flag is used.
The optimization workflow includes:
Loading and preprocessing PSF data from measurement files
Running gradient descent optimization to minimize RMSD
Generating cumulative PSF plots for each iteration showing optimization progression
Logging parameter evolution through gradient descent steps
Creating convergence plots showing RMSD and D80 evolution
Automatically generating D80 vs off-axis angle analysis for best parameters
Optionally exporting optimized parameters as simulation model files
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.
- parameter_version (str, optional)
Parameter version for model parameter file export.
- source_distance (float or quantity, optional)
Source distance in km.
- zenith_angle (float or quantity, 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.
- test (activation mode, optional)
If activated, application will be faster by simulating fewer photons.
- write_psf_parameters (activation mode, optional)
Write the optimized PSF parameters as simulation model parameter files.
- rmsd_threshold (float, optional)
RMSD threshold for gradient descent convergence (default: 0.007).
- learning_rate (float, optional)
Learning rate for gradient descent optimization (default: 0.01).
- max_iterations (int, optional)
Maximum number of gradient descent iterations (default: 200).
- monte_carlo_analysis (activation mode, optional)
Run Monte Carlo analysis to find statistical uncertainties.
Example
–telescope LSTN-01 –model_version 6.0.0
Run the application:
simtools-derive-psf-parameters --site North --telescope LSTN-01 \\
--model_version 6.0.0 --data tests/resources/PSFcurve_data_v2.ecsv --plot_all --test
Run with parameter export:
simtools-derive-psf-parameters --site North --telescope LSTN-01 --model_version 7.0.0 \\
--plot_all --test --rmsd_threshold 0.01 --learning_rate 0.001 \\
--data tests/resources/PSFcurve_data_v2.ecsv \\
--write_psf_parameters
Run monte carlo analysis:
simtools-derive-psf-parameters --site North --telescope LSTN-01 --model_version 7.0.0 \\
--plot_all --test --monte_carlo_analysis \\
--data tests/resources/PSFcurve_data_v2.ecsv \\
--write_psf_parameters
The output is saved in simtools-output/derive_psf_parameters.
Output files include:
Gradient descent progression log in psf_gradient_descent_[telescope].log
Gradient descent convergence plots in gradient_descent_convergence_[telescope].png
PSF progression plots showing evolution through iterations (if –plot_all is specified)
D80 vs off-axis angle plots (d80_vs_offaxis_cm.png, d80_vs_offaxis_deg.png)
Optimized simulation model parameter files (if –write_psf_parameters is specified)
Independent finite-difference evaluations within each gradient calculation and Monte Carlo repetitions run concurrently on the selected execution backend. Gradient-descent iterations remain sequential. The controller runs the initial and candidate-step simulations and creates the final plots, so it also needs the simulation software and model source. HTCondor receives one job per independent evaluation, rather than one job for the whole workflow; scheduler latency can outweigh the benefit for short simulations.
Local execution defaults to half the system CPUs, rounded down
with a minimum of one worker. Set --max_workers 1 for serial execution or choose a
positive worker count explicitly. Zero or negative values use all system CPUs. This limit controls local processes; HTCondor
concurrency is controlled by the scheduler. Each evaluation reconstructs its own
model and writes under a unique parallel_evaluations/ subdirectory. With --cleanup,
all evaluation files are removed when the batch finishes, including failed
evaluations and backend errors. Without it, evaluation files are retained.
Final application outputs are preserved. Allow for additional memory and temporary
disk use when increasing the number of workers.
Command line arguments#
options#
- –help
show this help message and exit
- –plot_all
On: plot cumulative PSF for all tested combinations, Off: plot it only for the best set of values
- –write_psf_parameters
Write the optimized PSF parameters as simulation model parameter files
- –rmsd_threshold
RMSD threshold for gradient descent convergence (not used with –monte_carlo_analysis).
Default: 0.01.
- –learning_rate
Learning rate for gradient descent optimization (not used with –monte_carlo_analysis).
Default: 0.0001.
- –max_iterations
Maximum number of gradient descent iterations (not used with –monte_carlo_analysis).
Default: 200.
- –monte_carlo_analysis
Run analysis to find monte carlo uncertainties.
- –ks_statistic
Use KS statistic for monte carlo uncertainty analysis.
- –cleanup
Remove intermediate *.log and *.lis* files after optimization.
application#
- –source_distance
Source distance in km (unitless values are interpreted as km).
Default: 10.0 km.
- –zenith_angle
Zenith angle in degrees (between 0 and 180).
Default: 20.0 deg.
- –data
Data file name.
- –fraction
PSF containment fraction for diameter calculation (e.g., 0.8 for D80, 0.95 for D95).
Default: 0.8.
- –show_options
Print available values for a supported option and exit.
simulation model#
- –model_version
Simulation production model version(s). Use –show_options model_version.
- –parameter_version
model parameter version
- –overwrite_model_parameters
JSON string with model parameters to overwrite
- –site
Observatory site (e.g., North, South). Use –show_options site.
- –telescope
telescope model name (e.g., LSTN-01, SSTS-design, …)
ray tracing configuration#
- –ray_tracing_backend
Optical ray-tracing backend (environment: SIMTOOLS_RAY_TRACING_BACKEND).
Choices: sim_telarray, obdeect.
simulation configuration#
- –instrument_seed
Seed of the random instrument setup (e.g. mirror deviations, gains); with several random instrument instances, their seeds are derived from it (default: random).
- –random_instrument_instances
Number of random instrument instances (random mirror realisations) per image.
Default: 20.
- –simulation_seed
Seed of the simulation (events, photons) (default: random). Two values: [instrument_seed, simulation_seed] (use for testing only).
model repository#
- –simulation_models_path
Path containing the simulation-model repository to read.
- –simulation_models_git_path
Path to a local normal, bare, or mirror Git repository containing simulation models.
- –simulation_models_git_revision
Git tag, ref, or commit to read from the simulation-model repository.
Example#
Derive LST optical PSF parameters#
Fit ray-tracing parameters to measured LST point-spread-function data at 20 deg zenith angle.
Application: simtools-derive-psf-parameters
Integration test: derive_psf_parameters_run.yml
Command
simtools-derive-psf-parameters --config tests/integration_tests/config/derive_psf_parameters_run.yml
Configuration
data: ${downloaded:PSFcurve_data_v2.ecsv}
model_version: 6.0.2
output_path: simtools-output/derive_psf_parameters/ray_tracing/
site: North
telescope: LSTN-01
test: true
backend: local
max_workers: 1
zenith_angle: 20
rmsd_threshold: 0.1
max_iterations: 20