diff --git a/docs/changes/2181.feature.md b/docs/changes/2181.feature.md new file mode 100644 index 0000000000..ca5cae6df3 --- /dev/null +++ b/docs/changes/2181.feature.md @@ -0,0 +1 @@ +Add an event-level production comparison application with multi-production trigger-distribution plots. diff --git a/docs/source/api-reference/index.md b/docs/source/api-reference/index.md index 38691d832b..1526cfe8ec 100644 --- a/docs/source/api-reference/index.md +++ b/docs/source/api-reference/index.md @@ -25,6 +25,7 @@ reporting runners sim_events sim_telarray +statistics simulators testing trigger diff --git a/docs/source/api-reference/sim_events.md b/docs/source/api-reference/sim_events.md index e046313b85..566c222578 100644 --- a/docs/source/api-reference/sim_events.md +++ b/docs/source/api-reference/sim_events.md @@ -49,3 +49,12 @@ Provide tools for reading, writing, and processing simulated shower and telescop .. automodule:: simtools.sim_events.output_validator :members: ``` + +## Production comparison + +(sim_events_production_comparison-1)= + +```{eval-rst} +.. automodule:: simtools.sim_events.production_comparison + :members: +``` diff --git a/docs/source/api-reference/statistics.md b/docs/source/api-reference/statistics.md new file mode 100644 index 0000000000..54e60c0b9b --- /dev/null +++ b/docs/source/api-reference/statistics.md @@ -0,0 +1,14 @@ +(statistics)= + +# Statistics + +Statistical helper functions for comparing distributions and aligned histograms. + +## statistics + +(statisticsmodule)= + +```{eval-rst} +.. automodule:: simtools.statistics + :members: +``` diff --git a/docs/source/api-reference/visualization.md b/docs/source/api-reference/visualization.md index b2b36eea11..45caf71a98 100644 --- a/docs/source/api-reference/visualization.md +++ b/docs/source/api-reference/visualization.md @@ -114,3 +114,10 @@ the visualization module. .. automodule:: visualization.camera_plot_utils :members: ``` + +## plot_event_level_production_comparison + +```{eval-rst} +.. automodule:: visualization.plot_event_level_production_comparison + :members: +``` diff --git a/docs/source/conf.py b/docs/source/conf.py index 38f5e03393..00dd594748 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -85,6 +85,7 @@ def get_python_version_from_pyproject(): nitpick_ignore = [ ("py:class", "astropy.table.table.Table"), ("py:class", "astropy.units.quantity.Quantity"), + ("py:class", "collections.Counter"), ("py:class", "logging.Logger"), ("py:class", "numpy.float64"), ("py:class", "numpy.ndarray"), diff --git a/docs/source/user-guide/applications.md b/docs/source/user-guide/applications.md index 76c277c7de..b8d38cacba 100644 --- a/docs/source/user-guide/applications.md +++ b/docs/source/user-guide/applications.md @@ -49,6 +49,7 @@ Parameters with the same functionality are named consistently the same among all :glob: true :maxdepth: 1 +simtools-compare-productions simtools-convert-all-model-parameters-from-simtel simtools-convert-geo-coordinates-of-array-elements simtools-convert-model-parameter-from-simtel diff --git a/docs/source/user-guide/applications/simtools-compare-productions.rst b/docs/source/user-guide/applications/simtools-compare-productions.rst new file mode 100644 index 0000000000..76acf76fbe --- /dev/null +++ b/docs/source/user-guide/applications/simtools-compare-productions.rst @@ -0,0 +1,6 @@ + +simtools-compare-productions +============================ + +.. automodule:: compare_productions + :members: diff --git a/pyproject.toml b/pyproject.toml index 6bd86626a6..d253530718 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,6 +73,7 @@ optional-dependencies.tests = [ urls."bug tracker" = "https://github.com/gammasim/simtools/issues" urls.documentation = "https://gammasim.github.io/simtools/" urls.repository = "https://github.com/gammasim/simtools" +scripts.simtools-compare-productions = "simtools.applications.compare_productions:main" scripts.simtools-convert-all-model-parameters-from-simtel = "simtools.applications.convert_all_model_parameters_from_simtel:main" scripts.simtools-convert-geo-coordinates-of-array-elements = "simtools.applications.convert_geo_coordinates_of_array_elements:main" scripts.simtools-convert-model-parameter-from-simtel = "simtools.applications.convert_model_parameter_from_simtel:main" diff --git a/src/simtools/applications/compare_productions.py b/src/simtools/applications/compare_productions.py new file mode 100644 index 0000000000..df6517b627 --- /dev/null +++ b/src/simtools/applications/compare_productions.py @@ -0,0 +1,75 @@ +#!/usr/bin/python3 + +r"""Compare simulation productions at different comparison levels. + +The application accepts repeated production descriptors and dispatches to +comparison-level specific implementations. + +Command line arguments +---------------------- +production (repeated, required) + Production descriptor in two fields: + 1) label + 2) comma-separated event data file patterns +comparison_level (str, optional) + Comparison level selector. Supported values are: + - events + - signals + - compute +output_path (str, required) + Output directory for generated comparison plots. +""" + +from simtools.application_control import build_application +from simtools.sim_events.production_comparison import ( + collect_production_metrics, + parse_production_arguments, +) +from simtools.visualization import plot_event_level_production_comparison + + +def _add_arguments(parser): + """Register application-specific command line arguments.""" + parser.initialize_application_arguments(["output_path"]) + parser.add_argument( + "--production", + action="append", + nargs="+", + metavar=("LABEL", "EVENT_DATA_FILES"), + required=True, + help=( + "Production descriptor. " + "Use as: --production