Skip to content

JP-4242: Extend trace model to NIRSpec and MIRI slit and slitless modes#10264

Merged
melanieclarke merged 32 commits into
spacetelescope:mainfrom
melanieclarke:jp-4242
May 27, 2026
Merged

JP-4242: Extend trace model to NIRSpec and MIRI slit and slitless modes#10264
melanieclarke merged 32 commits into
spacetelescope:mainfrom
melanieclarke:jp-4242

Conversation

@melanieclarke

@melanieclarke melanieclarke commented Feb 17, 2026

Copy link
Copy Markdown
Collaborator

Resolves JP-4242

Adds support for NIRSpec MOS, FS, and BOTS modes as well as MIRI LRS slit and slitless modes to the adaptive_trace_model step. Updates resample_spec to allow for oversampled input data.

To use resample_spec to re-downsample the oversampled input, specify the inverse of the oversample factor as the pixel_scale_ratio. For example, use --steps.adaptive_trace_model.oversample=2 with --steps.resample_spec.pixel_scale_ratio=0.5.

Needs stdatamodels changes: spacetelescope/stdatamodels#697

Notes:

  • NIRCam and NIRISS spectral modes are not yet supported. If desired, we can look into adding them in the future.
  • MIRI and NIRSpec TSO modes are supported. For those modes, oversampling is disabled and the trace model is fit to the median image across integrations. For pixel_replace purposes, the 2D trace model might need to be scaled to each integration somehow.
  • Parameters for fitting are tweaked for every mode. The number of spline breakpoints and minimum number of points necessary to fit the data is computed dynamically for NIRSpec modes, since slit sizes vary widely.
  • The fit_threshold has a different meaning when we're fitting one slit at a time: it uses the S/N within the slit to make the decision. For IFU, it still compares the mean for the slice to the overall mean for the image.
  • Multiprocessing is used only for IFU for now, for implementation simplicity. It might be useful to expand it to other slit modes later.

Tasks

  • If you have a specific reviewer in mind, tag them.
  • add a build milestone, i.e. Build 12.0 (use the latest build if not sure)
  • Does this PR change user-facing code / API? (if not, label with no-changelog-entry-needed)
    • write news fragment(s) in changes/: echo "changed something" > changes/<PR#>.<changetype>.rst (see changelog readme for instructions)
      • if your change breaks step-level or public API (as defined in the docs), also add a changes/<PR#>.breaking.rst news fragment
    • update or add relevant tests
    • update relevant docstrings and / or docs/ page
    • start a regression test and include a link to the running job (click here for instructions)
      • Do truth files need to be updated ("okified")?
        • after the reviewer has approved these changes, run okify_regtests to update the truth files
  • if a JIRA ticket exists, make sure it is resolved properly

@melanieclarke melanieclarke changed the title JP-4242: Extend trace model to NIRSpec and MIRI slit and slitless modes WIP JP-4242: Extend trace model to NIRSpec and MIRI slit and slitless modes Feb 17, 2026
@codecov

codecov Bot commented Feb 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.57%. Comparing base (6d8b4de) to head (074b38d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10264      +/-   ##
==========================================
+ Coverage   86.48%   86.57%   +0.08%     
==========================================
  Files         374      374              
  Lines       40217    40406     +189     
==========================================
+ Hits        34782    34981     +199     
+ Misses       5435     5425      -10     

☔ View full report in Codecov by Sentry.
📢 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.

@melanieclarke melanieclarke added this to the Build 13.0 milestone Apr 1, 2026
@melanieclarke melanieclarke force-pushed the jp-4242 branch 6 times, most recently from 1461fc3 to d49b2b9 Compare May 5, 2026 15:38
@melanieclarke melanieclarke force-pushed the jp-4242 branch 2 times, most recently from 04b87d5 to 109ab62 Compare May 7, 2026 18:31
@melanieclarke melanieclarke force-pushed the jp-4242 branch 3 times, most recently from 90d671c to 0bc4b55 Compare May 11, 2026 22:18
@melanieclarke melanieclarke changed the title WIP JP-4242: Extend trace model to NIRSpec and MIRI slit and slitless modes JP-4242: Extend trace model to NIRSpec and MIRI slit and slitless modes May 12, 2026
@melanieclarke

melanieclarke commented May 21, 2026

Copy link
Copy Markdown
Collaborator Author

Rerunning regtests after bug fix for area scaling:
https://github.com/spacetelescope/RegressionTests/actions/runs/26244306985

Results are as expected. In addition to new SKIPPED status for spec2 products and minor changes for MIRI and NIRSpec IFU trace model tests, there are now diffs for the new tests:

  • some keyword comments have changed since the last time I generated the truth files
  • the pixel area keywords have changed in the adaptive_trace_model and s2d products for oversampling tests
  • the x1d files have different flux values for spectra for which the input s2d image was oversampled and in surface brightness units (spectra extracted from flux density units was not affected by the bug).

@melanieclarke melanieclarke requested a review from tapastro May 21, 2026 19:35
@melanieclarke melanieclarke enabled auto-merge (squash) May 27, 2026 15:46
@melanieclarke melanieclarke merged commit 1a9e62f into spacetelescope:main May 27, 2026
30 checks passed
@melanieclarke melanieclarke deleted the jp-4242 branch May 27, 2026 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants