Skip to content

Stop SpectralTraceList.meta dict overwriting individual SPectralTrace.meta dicts - #986

Open
astronomyk wants to merge 1 commit into
mainfrom
fix/trace-catalogue-precedence
Open

Stop SpectralTraceList.meta dict overwriting individual SPectralTrace.meta dicts#986
astronomyk wants to merge 1 commit into
mainfrom
fix/trace-catalogue-precedence

Conversation

@astronomyk

@astronomyk astronomyk commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

The Toaster-generated description is actually pretty ok for this one - summarised with the problem statement:

most instrument YAMLs give the effect a `description`, every individual `SpectralTrace` had its catalogue 
description replaced by the list-level one (e.g. all eight MICADO traces described as 
*"list of spectral order trace geometry on the focal plane"* instead of `ORDER_3_1` etc.)

This PR swaps the params.update(self.meta) to dict(self.meta).update(params) to preserve individual SpectralTrace meta info

It seems fine and the tests bare it out. In practice it seems it's limited to the "description" key, but in general, we want each individual SpectralTrace to retain it's own settings. So this seems to, in the words of Martin, "reduce the future bug cross-section"


What

make_spectral_traces built each trace's parameters as catalogue row columns, then overwritten by the list's meta:

params = {col: row[col] for col in row.colnames}
params.update(self.meta)          # meta clobbers the row on any collision

Since most instrument YAMLs give the effect a description, every individual SpectralTrace had its catalogue description replaced by the list-level one (e.g. all eight MICADO traces described as "list of spectral order trace geometry on the focal plane" instead of ORDER_3_1 etc.). The same applies to any future collision between effect kwargs and the per-trace catalogue columns (description, extension_id, aperture_id, image_plane_id).

Precedence is now: list meta provides the defaults, the trace-specific catalogue values win. Applied to SpectralTraceList and the same pattern in MosaicSpectralTraceList.

Behaviour note

This is a (mild) behaviour change by design: previously, an effect kwarg colliding with a catalogue column silently overrode it per trace. No instrument package in the IRDB relies on that — the colliding key in practice is only description — and the full basic_instrument spectroscopy/IFU end-to-end suite passes unchanged.

Testing

  • New test TestInit::test_trace_values_win_over_list_meta: per-trace descriptions survive a list-level description kwarg.
  • Notebook demonstrating the effect on the MICADO trace catalogue is attached below.

make_spectral_traces built each trace's parameters as row columns
updated with self.meta, so any key collision (notably 'description',
which most instrument YAMLs set for the effect as a whole) clobbered
the per-trace catalogue value. Trace-specific columns (description,
extension_id, aperture_id, image_plane_id) now win; list meta remains
the source for everything else.

Applied to SpectralTraceList and the same pattern in
MosaicSpectralTraceList.

Adds a test that per-trace descriptions survive a list-level
description kwarg. Full basic_instrument spectroscopy/ifu suite passes
unchanged.
@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.45%. Comparing base (3cdfc14) to head (2d04d0b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #986   +/-   ##
=======================================
  Coverage   76.45%   76.45%           
=======================================
  Files          69       69           
  Lines        9021     9021           
=======================================
  Hits         6897     6897           
  Misses       2124     2124           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@astronomyk
astronomyk requested a review from oczoske August 24, 2026 13:48
@astronomyk astronomyk changed the title Let catalogue-row values take precedence over list meta for traces Stop SpectralTraceList.meta dict overwriting individual SPectralTrace.meta dicts Aug 24, 2026
@teutoburg teutoburg moved this to 🏗 In progress in ScopeSim-development Aug 24, 2026
@astronomyk
astronomyk marked this pull request as ready for review August 24, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🏗 In progress

Development

Successfully merging this pull request may close these issues.

2 participants