From 61e4a63db14dde32efea862138ab04499bdbd216 Mon Sep 17 00:00:00 2001 From: Orel Gueta Date: Wed, 17 Dec 2025 11:50:01 +0100 Subject: [PATCH 1/2] Propagate the overwrite of parameters also in model_utils --- src/simtools/applications/validate_optics.py | 1 + src/simtools/model/model_utils.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/simtools/applications/validate_optics.py b/src/simtools/applications/validate_optics.py index cd0b5f2cf1..30b970b406 100644 --- a/src/simtools/applications/validate_optics.py +++ b/src/simtools/applications/validate_optics.py @@ -126,6 +126,7 @@ def main(): site=app_context.args["site"], telescope_name=app_context.args["telescope"], model_version=app_context.args["model_version"], + overwrite_model_parameters=app_context.args.get("overwrite_model_parameters"), ) ###################################################################### diff --git a/src/simtools/model/model_utils.py b/src/simtools/model/model_utils.py index c31536e93c..cef7f5c59b 100644 --- a/src/simtools/model/model_utils.py +++ b/src/simtools/model/model_utils.py @@ -10,7 +10,13 @@ def initialize_simulation_models( - label, db_config, model_version, site, telescope_name, calibration_device_name=None + label, + db_config, + model_version, + site, + telescope_name, + calibration_device_name=None, + overwrite_model_parameters=None, ): """ Initialize simulation models for a single telescope, site, and calibration device model. @@ -41,12 +47,14 @@ def initialize_simulation_models( db_config=db_config, model_version=model_version, label=label, + overwrite_model_parameters=overwrite_model_parameters, ) site_model = SiteModel( site=site, model_version=model_version, db_config=db_config, label=label, + overwrite_model_parameters=overwrite_model_parameters, ) if calibration_device_name is not None: calibration_model = CalibrationModel( @@ -55,6 +63,7 @@ def initialize_simulation_models( db_config=db_config, model_version=model_version, label=label, + overwrite_model_parameters=overwrite_model_parameters, ) else: calibration_model = None From 2ecedd1e13912987d72dbb6c4fc9251d0d740223 Mon Sep 17 00:00:00 2001 From: Orel Gueta Date: Wed, 17 Dec 2025 11:55:59 +0100 Subject: [PATCH 2/2] Pass the model version so it can be added to the plot --- .../applications/calculate_incident_angles.py | 1 + .../visualization/plot_incident_angles.py | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/simtools/applications/calculate_incident_angles.py b/src/simtools/applications/calculate_incident_angles.py index bf92395653..c6eeb9912d 100644 --- a/src/simtools/applications/calculate_incident_angles.py +++ b/src/simtools/applications/calculate_incident_angles.py @@ -158,6 +158,7 @@ def main(): output_dir, label_with_telescope, debug_plots=app_context.args.get("debug_plots", False), + model_version=app_context.args.get("model_version", None), ) total = sum(len(t) for t in results_by_offset.values()) summary_msg = ( diff --git a/src/simtools/visualization/plot_incident_angles.py b/src/simtools/visualization/plot_incident_angles.py index 9d2bb7c420..bca88bcda7 100644 --- a/src/simtools/visualization/plot_incident_angles.py +++ b/src/simtools/visualization/plot_incident_angles.py @@ -351,6 +351,7 @@ def _plot_component_angles( out_path, bin_width_deg, log, + model_version=None, ): arrays = _gather_angle_arrays(results_by_offset, column, log) if not arrays: @@ -365,6 +366,17 @@ def _plot_component_angles( ax.set_title(f"Incident angle {title_suffix} vs off-axis angle") ax.grid(True, alpha=0.3) ax.legend() + if model_version: + ax.text( + 0.03, + 0.97, + f"Model version: {model_version}", + transform=ax.transAxes, + fontsize=8, + verticalalignment="top", + horizontalalignment="left", + bbox={"boxstyle": "round", "facecolor": "white", "alpha": 0.5}, + ) plt.tight_layout() plt.savefig(out_path, dpi=300) plt.close(fig) @@ -378,6 +390,7 @@ def plot_incident_angles( radius_bin_width_m=0.01, debug_plots=False, logger=None, + model_version=None, ): """Plot overlaid histograms of focal, primary, secondary angles, and primary hit radius.""" log = logger or logging.getLogger(__name__) @@ -402,6 +415,17 @@ def plot_incident_angles( ax.set_title("Incident angle distribution vs off-axis angle") ax.grid(True, alpha=0.3) ax.legend() + if model_version: + ax.text( + 0.03, + 0.97, + f"Model version: {model_version}", + transform=ax.transAxes, + fontsize=8, + verticalalignment="top", + horizontalalignment="left", + bbox={"boxstyle": "round", "facecolor": "white", "alpha": 0.5}, + ) plt.tight_layout() plt.savefig(out_dir / f"incident_angles_multi_{label}.png", dpi=300) plt.close(fig) @@ -414,6 +438,7 @@ def plot_incident_angles( out_path=out_dir / f"incident_angles_primary_multi_{label}.png", bin_width_deg=bin_width_deg, log=log, + model_version=model_version, ) _plot_component_angles( results_by_offset=results_by_offset, @@ -422,6 +447,7 @@ def plot_incident_angles( out_path=out_dir / f"incident_angles_secondary_multi_{label}.png", bin_width_deg=bin_width_deg, log=log, + model_version=model_version, ) # Debug plots