Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JP-3763: Fix crash combining full and subarray for background #8787

Merged
merged 2 commits into from
Sep 30, 2024

Conversation

thomaswilliamsastro
Copy link
Contributor

@thomaswilliamsastro thomaswilliamsastro commented Sep 16, 2024

Resolves JP-3763

This PR addresses combining full and subarray observations to accumulate a background. This fixes an issue introduced with #8326, where if you try to use a full frame observation to create a background for a subarray observation, it would crash. This instead uses the best of both worlds: if a multi-int exposure, it will use NINTS from the background obs to form a mean background. If you're mismatching full/subarray observations, it'll use the x/y size of the science to avoid array size mismatches.

I can't run regression tests, but have verified it works in my case

Tasks

  • add an entry to CHANGES.rst within the relevant release section (otherwise add the no-changelog-entry-needed label to this PR)
  • 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)

Copy link

codecov bot commented Sep 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.89%. Comparing base (e860360) to head (5868435).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8787      +/-   ##
==========================================
+ Coverage   61.86%   61.89%   +0.03%     
==========================================
  Files         377      377              
  Lines       38911    38954      +43     
==========================================
+ Hits        24071    24110      +39     
- Misses      14840    14844       +4     

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

CHANGES.rst Outdated Show resolved Hide resolved
@melanieclarke
Copy link
Collaborator

melanieclarke commented Sep 25, 2024

Thanks for sending this in! Do you have some test data you can point me to so I can try out your fix?

Never mind! I found your original ticket for this issue (#7807) with your example program.

@thomaswilliamsastro
Copy link
Contributor Author

@melanieclarke Yep, that's exactly the one :)

@melanieclarke
Copy link
Collaborator

@thomaswilliamsastro - thanks for confirming! I'm looking through the associations for that program, but I don't see one that specifies a background member for the SUB256 data. Did I miss one, or do you use a custom association for this task?

@thomaswilliamsastro
Copy link
Contributor Author

@melanieclarke I used a custom association, so all the M33 data with "SKY" in the name is the background, and is associated to anything that doesn't have that

@melanieclarke
Copy link
Collaborator

Thanks, I got it now and I'm able to reproduce the problem.

I think this could use either a unit test or a regression test, to make sure we don't break your use case again. Would you like to try adding a unit test to cover your changes? If you don't have the bandwidth, I can take a look.

@thomaswilliamsastro
Copy link
Contributor Author

I'm not well-versed in unit tests, so I'm very happy to leave it with you!

@melanieclarke
Copy link
Collaborator

I sent you a PR to your repo with some unit tests, and a few suggested fixes:
thomaswilliamsastro#1

@melanieclarke melanieclarke changed the title Fix crash combining full and subarray for background JP-3763: Fix crash combining full and subarray for background Sep 25, 2024
@melanieclarke melanieclarke added this to the Build 11.2 milestone Sep 25, 2024
@thomaswilliamsastro
Copy link
Contributor Author

I've merged, rebased onto main, and pushed

@melanieclarke
Copy link
Collaborator

Thanks! This looks good to me now, but I'm going to tag in another reviewer to take a quick look, since I contributed some tests.

melanieclarke
melanieclarke previously approved these changes Sep 30, 2024
Copy link
Collaborator

@emolter emolter left a comment

Choose a reason for hiding this comment

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

Looks good to me. Starting regression tests here and I'd approve this assuming no unexpected failures. My two questions are only minor

jwst/background/background_sub.py Show resolved Hide resolved
jwst/background/background_sub.py Show resolved Hide resolved
@melanieclarke
Copy link
Collaborator

Looks good to me. Starting regression tests here and I'd approve this assuming no unexpected failures. My two questions are only minor

Thanks Ned, I forgot I hadn't run a full set of regression tests yet!

@melanieclarke melanieclarke dismissed their stale review September 30, 2024 14:34

Missed regression test checks

Copy link
Collaborator

@melanieclarke melanieclarke left a comment

Choose a reason for hiding this comment

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

No failures in regtests.

@melanieclarke
Copy link
Collaborator

@emolter - are you happy with this one now?

@emolter emolter self-requested a review September 30, 2024 19:44
@melanieclarke melanieclarke merged commit 7248358 into spacetelescope:main Sep 30, 2024
30 checks passed
@thomaswilliamsastro thomaswilliamsastro deleted the subarray-bkg branch October 1, 2024 08:27
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.

4 participants