Fix FITS bug for list-type metadata#748
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #748 +/- ##
=======================================
Coverage 90.70% 90.71%
=======================================
Files 99 99
Lines 4595 4597 +2
=======================================
+ Hits 4168 4170 +2
Misses 427 427 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
Regtests: All passing. |
1d254d4 to
4c13153
Compare
braingram
reviewed
May 27, 2026
Co-authored-by: Brett Graham <brettgraham@gmail.com>
braingram
approved these changes
May 28, 2026
braingram
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for finding and fixing the bug!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Toward JP-4313
To produce accurate rate values, some multistripe modes will require explicit read times for all readout frames in each group. See #739 for the draft implementation to support this, which stores the read time values in a list of lists inside
meta.exposure.read_times. This is similar to themeta.exposure.read_patternmetadata stored for Roman datamodels: https://github.com/spacetelescope/rad/blob/b7879d2c36bdac7006a57c9971b8ae8dbb157ee4/src/rad/resources/schemas/meta/exposure-1.2.0.yaml#L197Using this draft implementation, I noticed that RampModels saved as FITS files with
meta.exposure.read_timesset generated many extra FITS extensions, mostly empty. I tracked it down to the_fits_item_recursevalidator, which sets a sequence index whenever it encounters list-type attributes. This is appropriate for lists of objects, like slits or spectra, since this is how it knows to start a new extension version for a new slit or spectrum. It is not appropriate for list-type primary metadata: when encountered, the update to the sequence index makes any metadata defined later in the schema think it's supposed to go into a new primary header extension.The fix here is to update the sequence index only if the list-type item contains an object. This works for the use case I need it for, and shouldn't break any other existing JWST schemas, but it may be fragile to other kinds of stored metadata. I'm open to alternate fixes if anyone can think of a more general one, or a better way to store the necessary metadata in #739.
Tasks
docs/pageno-changelog-entry-needed)changes/:echo "changed something" > changes/<PR#>.<changetype>.rst(see below for change types)jwstregression tests with this branch installed ("git+https://github.com/<fork>/stdatamodels@<branch>")news fragment change types...
changes/<PR#>.feature.rst: new featurechanges/<PR#>.bugfix.rst: fixes an issuechanges/<PR#>.doc.rst: documentation changechanges/<PR#>.removal.rst: deprecation or removal of public APIchanges/<PR#>.misc.rst: infrastructure or miscellaneous change