Add functionality to assign valid telescope numbers to additional MSTs in legacy prod6 simulations.#2171
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the legacy sim_telarray metadata fallback logic to handle additional MSTs labeled as MST2 in legacy prod6 files by parsing them from the CORSIKA input card and attempting to map them onto valid MSTS/MSTN telescope names.
Changes:
- Updated input-card parsing to use a more structured regex and include
MST2entries in the returned telescope list. - Added
_legacy_merge_mststo rewrite/mergeMST2entries into site-specificMST{S|N}-NNnames for legacy guessing. - Added unit tests covering
MST2parsing and merge behavior, plus a changelog fragment.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/simtools/simtel/simtel_io_metadata.py |
Updates legacy telescope-name guessing by parsing MST2 and merging it into valid MSTS/MSTN naming. |
tests/unit_tests/simtel/test_simtel_io_metadata.py |
Extends coverage for parsing MST2 from input cards and adds tests for the merge helper. |
docs/changes/2171.feature.md |
Adds a changelog entry describing the new legacy-prod6 MST2 handling. |
Comments suppressed due to low confidence (1)
tests/unit_tests/simtel/test_simtel_io_metadata.py:245
- This test case appears internally inconsistent with the intended behavior: the input list does not contain a standalone "MSTN-01" entry (it is embedded in a malformed string), but the expected output includes "MSTN-01". As written, _legacy_merge_msts cannot recover "MSTN-01" from that malformed token. Either adjust the test input to include a separate MSTN entry or change the parsing logic to split/clean malformed tokens before processing.
def test_legacy_merge_msts_with_malformed_mst2_entry(monkeypatch):
msts = ["LSTM-01", 'MSTN-01, "MST2-02']
monkeypatch.setattr(
"simtools.utils.names.get_site_from_array_element_name",
lambda _: "North",
)
assert simtel_io_metadata._legacy_merge_msts(msts) == ["LSTM-01", "MSTN-01"]
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
|
I think SCTs are not included. The regex doesn't seem to include that case and running with the following file leads to unknown telescopes: I assume as well that it is by design that |
Wait, ignore that, my test was run in a python notebook and I didn't notice the cell was not updating. Another reminder why I don't trust those notebooks... I think it all looks good now. Just the following question remains and I can approve.
|
|
Yes - the common ids are from the identifier repo and set to 0 if a telescope is not found. And we should make more use of those IDs, as string comparison are not already idea. |
|
OK, perfect. Once this is merged and a new prod container is produced with it, I will run a larger statistics sample for a final test. |




This is very very fine tuned to the current legacy-style prod6 production with less metadata then the simtools produced files.
Additional MSTs labels 'MST2' are added with IDs beyond the nominal MSTs.
Please test and give feedback.