Skip to content

Model data writer - readability and dict-table output#2121

Merged
GernotMaier merged 3 commits into
mainfrom
model-data-writer
Apr 17, 2026
Merged

Model data writer - readability and dict-table output#2121
GernotMaier merged 3 commits into
mainfrom
model-data-writer

Conversation

@GernotMaier
Copy link
Copy Markdown
Contributor

@GernotMaier GernotMaier commented Apr 16, 2026

Two issues are addressed:

Functional: model parameters in dict-table files are not written in a readable table-like format when the parameter dict is pulled from settings workflows. Make sure now that the same write function is used in all cases.

Readability: model_data_writer had a very confusing API and it is hard to see the differences between the public functions (I buy you an icecream if you can explain the differences without checking the code / doc strings):
- dump()
- dump_model_parameter()
- write()
- write_model_parameter()
- write_dict_to_mode_parameter()
I’ve tried to separate public / private functions and improved the naming.

@GernotMaier GernotMaier self-assigned this Apr 16, 2026
@ctao-sonarqube
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors ModelDataWriter to clarify its public API and ensures consistent JSON serialization for model-parameter files (notably “dict-table” style parameters), including when parameters are pulled from settings-workflow repositories.

Changes:

  • Rename and separate writer entry points (e.g., dump*write_*, write()write_data()), and update call sites accordingly.
  • Centralize JSON writing options via ModelDataWriter.write_model_parameter_json() to improve dict-table readability/consistency.
  • Update unit tests to reflect the new API and patch points.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/unit_tests/ray_tracing/test_psf_parameter_optimisation.py Update mocks/assertions to use write_model_parameter.
tests/unit_tests/ray_tracing/test_mirror_panel_psf.py Patch write_model_parameter instead of dump_model_parameter.
tests/unit_tests/ray_tracing/test_incident_angles.py Update expectations for new static writer methods.
tests/unit_tests/model/test_model_repository.py Patch write_model_parameter_json/write_model_parameter and adjust assertions.
tests/unit_tests/layout/test_array_layout_utils.py Update expected call from dump_model_parameter to write_model_parameter.
tests/unit_tests/data_model/test_model_data_writer.py Align tests with renamed writer API and JSON-writing helpers.
tests/unit_tests/camera/test_single_photon_electron_spectrum.py Patch write_product_data instead of dump.
tests/unit_tests/camera/test_camera_efficiency.py Patch write_model_parameter instead of dump_model_parameter.
src/simtools/ray_tracing/psf_parameter_optimisation.py Use write_model_parameter for PSF parameter export.
src/simtools/ray_tracing/mirror_panel_psf.py Use write_model_parameter for RNDA export.
src/simtools/ray_tracing/incident_angles.py Switch to static write_product_data + write_model_parameter.
src/simtools/model/model_repository.py Use centralized write_model_parameter_json for workflow-downloaded parameters and rename writer call.
src/simtools/layout/array_layout_utils.py Switch to write_model_parameter for layout/element parameter writes.
src/simtools/data_model/model_data_writer.py Refactor/rename API and introduce write_model_parameter_json.
src/simtools/camera/single_photon_electron_spectrum.py Use write_product_data for output writing.
src/simtools/camera/camera_efficiency.py Use write_model_parameter for NSB pixel rate parameter output.
src/simtools/applications/submit_model_parameter_from_external.py Switch to write_model_parameter API.
src/simtools/applications/submit_data_from_external.py Switch to write_product_data API.
src/simtools/applications/generate_regular_arrays.py Use write_product_data and adjust downstream output path for the info YAML.
src/simtools/applications/derive_pulse_shape_parameters.py Use write_model_parameter API for derived parameters.
src/simtools/applications/db_get_array_layouts_from_db.py Switch to write_product_data API.
src/simtools/applications/convert_model_parameter_from_simtel.py Switch to write_model_parameter API.
src/simtools/applications/convert_geo_coordinates_of_array_elements.py Switch to write_product_data API.
src/simtools/applications/convert_all_model_parameters_from_simtel.py Switch to write_model_parameter API.
docs/changes/2121.maintenance.md Add changelog fragment for the writer refactor + dict-table fix.

Comment thread src/simtools/data_model/model_data_writer.py
@GernotMaier GernotMaier marked this pull request as ready for review April 17, 2026 09:57
Copy link
Copy Markdown
Collaborator

@tobiaskleiner tobiaskleiner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @GernotMaier, good improvement, can be merged.

@GernotMaier
Copy link
Copy Markdown
Contributor Author

Thanks @tobiaskleiner

@GernotMaier GernotMaier merged commit 28f3171 into main Apr 17, 2026
27 of 28 checks passed
@GernotMaier GernotMaier deleted the model-data-writer branch April 17, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants