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-3502: Extend snowball flags to next integration #238

Merged
merged 21 commits into from
Feb 15, 2024

Conversation

mwregan2
Copy link
Collaborator

@mwregan2 mwregan2 commented Jan 5, 2024

Resolves JP-3502

Closes spacetelescope/jwst#8174

This PR addresses the problem that the saturated core of snowballs shows up in the next integration with an excess count rate that takes a long time to decay. The solution is to mark as jump a number of groups passed in from JWST Jump.

Checklist

  • added entry in CHANGES.rst (either in Bug Fixes or Changes to API)
  • updated relevant tests
  • updated relevant documentation
  • updated relevant milestone(s)
  • added relevant label(s)

@mwregan2 mwregan2 requested a review from a team as a code owner January 5, 2024 19:38
Copy link

codecov bot commented Jan 5, 2024

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (5cdca94) 85.98% compared to head (8f3dcb4) 85.90%.

Files Patch % Lines
tests/test_jump.py 50.00% 4 Missing ⚠️
src/stcal/jump/jump.py 85.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #238      +/-   ##
==========================================
- Coverage   85.98%   85.90%   -0.08%     
==========================================
  Files          35       35              
  Lines        6542     6557      +15     
==========================================
+ Hits         5625     5633       +8     
- Misses        917      924       +7     

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

@@ -54,6 +54,8 @@ def detect_jumps(
minimum_groups=3,
minimum_sigclip_groups=100,
only_use_ints=True,
mask_persist_grps_next_int=True,
persist_grps_flagged=25,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function now has roughly 30 arguments. Would it be better served by using a class to contain the parameters, rather than continue to add parameters to this function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree that it has a lot of parameters but users need to be able to tweak the parameters. Is there any cost to the large number of parameters?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The cost is readability and maintainability. Grouping various parameters into a class or classes makes the code easier to read, as well as easier to maintain, especially when adding a parameter that needs to be passed to subroutines. If you simply pass parameters, the function signature needs to be changed for all functions that need that parameter. If you use classes, those classes will be passed to the subroutines, so when you add a parameter to a class, no subroutine signature needs to be edited, since the parameter is contained in the class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

While it is true that passing objects instead of primitives has advantages there are also disadvantages. APIs with only primitive parameters are easier to understand where the primitives are coming from. At the extreme, a function that has a single class as input in a black box. Someone browsing the code has more work to do than with primitive parameters.
Also, If we want to consolidate the parameters passed to detect_jump.py, I feel that the change should be in a separate PR. That would give us a working master to compare against.
What do you think?

src/stcal/jump/jump.py Outdated Show resolved Hide resolved
-1,
)
persist_ellipse = persist_image[:, :, 2]
persist_saty, persist_satx = np.where(persist_ellipse == 22)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is special about 22 here? A comment or declaring a descriptive variable with the value 22 would be good here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I updated the comments in this section. Let me know, if you think it needs more details.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I still don't know why you use 22 instead of say 21 or 23.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No real reason that I can remember. There needs to be a number that I can use np.where to find the pixels that are affected. I'm sure there's a more elegant way to do it.

Copy link
Collaborator

@kmacdonald-stsci kmacdonald-stsci Feb 1, 2024

Choose a reason for hiding this comment

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

I think it would be fine to make a comment saying this number could change and that this number was determined though trial and error and could be changed if needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The value of 22 is arbitrary. It just needs to be something that can be tested for to create the mask of pixels within the ellipse.

@hbushouse hbushouse changed the title Extend snowball to next int JP-3502: Extend snowball flags to next integration Jan 25, 2024
CHANGES.rst Outdated Show resolved Hide resolved
src/stcal/jump/jump.py Outdated Show resolved Hide resolved
src/stcal/jump/jump.py Outdated Show resolved Hide resolved
mwregan2 and others added 5 commits January 26, 2024 15:22
took suggestion

Co-authored-by: Howard Bushouse <bushouse@stsci.edu>
fix spacing

Co-authored-by: Howard Bushouse <bushouse@stsci.edu>
fuxed

Co-authored-by: Howard Bushouse <bushouse@stsci.edu>
resolving comments
-1,
)
persist_ellipse = persist_image[:, :, 2]
persist_saty, persist_satx = np.where(persist_ellipse == 22)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I still don't know why you use 22 instead of say 21 or 23.

@@ -54,6 +54,8 @@ def detect_jumps(
minimum_groups=3,
minimum_sigclip_groups=100,
only_use_ints=True,
mask_persist_grps_next_int=True,
persist_grps_flagged=25,
Copy link
Collaborator

Choose a reason for hiding this comment

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

The cost is readability and maintainability. Grouping various parameters into a class or classes makes the code easier to read, as well as easier to maintain, especially when adding a parameter that needs to be passed to subroutines. If you simply pass parameters, the function signature needs to be changed for all functions that need that parameter. If you use classes, those classes will be passed to the subroutines, so when you add a parameter to a class, no subroutine signature needs to be edited, since the parameter is contained in the class.

@hbushouse
Copy link
Collaborator

Lots of CI failures that appear to be due to API changes in function calls.

Copy link
Collaborator

@hbushouse hbushouse left a comment

Choose a reason for hiding this comment

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

Given that the only outstanding (unresolved) comments are related to stylistic issues, and not actual problems with the code, I'm going to approve in order to get this moving.

@hbushouse hbushouse merged commit 44f50f2 into spacetelescope:main Feb 15, 2024
23 of 25 checks passed
@hbushouse
Copy link
Collaborator

@mwregan2 Doesn't this need a corresponding change in the jump_step.py module in the jwst package, in order to add the 2 new step arguments that've been implemented here and pass them to the detect_jumps function? I don't see an existing PR against jwst that contains such changes.

@mwregan2
Copy link
Collaborator Author

mwregan2 commented Feb 15, 2024 via email

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.

Snowballs cause persistence in the Integration after the Snowball
3 participants