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

Jump masked groups counting #317

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mwregan2
Copy link
Collaborator

Resolves JP-3793

This PR addresses a problem in the two point difference code where it determines if there are enough groups for the code to run. The logic was not correct and has now been corrected.

Tasks

  • [ X ] update or add relevant tests
  • update relevant docstrings and / or docs/ page
  • Does this PR change any API used downstream? (if not, label with no-changelog-entry-needed)
    • write news fragment(s) in changes/: echo "changed something" > changes/<PR#>.<changetype>.rst (see below for change types)
    • run regression tests with this branch installed ("git+https://github.com/<fork>/stcal@<branch>")
news fragment change types...
  • changes/<PR#>.apichange.rst: change to public API
  • changes/<PR#>.bugfix.rst: fixes an issue
  • changes/<PR#>.general.rst: infrastructure or miscellaneous change

@mwregan2 mwregan2 requested a review from a team as a code owner November 12, 2024 15:23
Copy link

codecov bot commented Nov 12, 2024

Codecov Report

Attention: Patch coverage is 71.23288% with 21 lines in your changes missing coverage. Please review.

Project coverage is 86.44%. Comparing base (5772579) to head (fb6bfea).
Report is 205 commits behind head on main.

Files with missing lines Patch % Lines
tests/test_twopoint_difference.py 62.26% 20 Missing ⚠️
src/stcal/jump/twopoint_difference.py 95.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #317      +/-   ##
==========================================
+ Coverage   83.79%   86.44%   +2.65%     
==========================================
  Files          35       49      +14     
  Lines        6998     8964    +1966     
==========================================
+ Hits         5864     7749    +1885     
- Misses       1134     1215      +81     

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

for grp in range(dat.shape[1]):
if np.all(np.bitwise_and(gdq[integ, grp, :, :], dnu_flag)):
num_flagged_grps += 1
if num_flagged_grps > max_flagged_grps:
Copy link
Collaborator

Choose a reason for hiding this comment

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

The adjustment of max_flagged_grps can be done after the grp loop. Doing this check for every loop over grp is inefficient.

dummy = np.zeros((dataa.shape[1] - 1, dataa.shape[2], dataa.shape[3]),
dtype=np.float32)
return gdq, row_below_gdq, row_above_gdq, 0, dummy
dummy = np.zeros((dataa.shape[1] - 1, dataa.shape[2], dataa.shape[3]), dtype=np.float32)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Descriptive variable names for the dataa shape is defined here:

nints, ngroups, nrows, ncols = dataa.shape

Use these variable names, instead of shape[k].

dummy = np.zeros((dataa.shape[1] - 1, dataa.shape[2], dataa.shape[3]), dtype=np.float32)
return gdq, row_below_gdq, row_above_gdq, -99, dummy
#
# if ((only_use_ints and nints < minimum_sigclip_groups) # sigclip across ints with not enough ints
Copy link
Collaborator

Choose a reason for hiding this comment

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

These comments should be deleted.

@@ -239,7 +259,7 @@ def find_crs(
# use mask on data, so the results will have sat/donotuse groups masked
first_diffs = np.diff(dat, axis=1)

if total_usable_diffs >= min_diffs_single_pass:
if min_usable_diffs >= min_diffs_single_pass: # There are enough diffs in all ints to look for more than one jump
Copy link
Collaborator

Choose a reason for hiding this comment

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

Put comment on the next line.

@@ -21,6 +21,98 @@ def _cube(ngroups, nints=1, nrows=204, ncols=204, readnoise=10):

return _cube

def test_sigclip_not_enough_groups(setup_cube):
ngroups = 10
nints = 9
Copy link
Collaborator

Choose a reason for hiding this comment

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

Variables nints, nrows, and ncols are not used, so should be deleted.


def test_sigclip_not_enough_groups(setup_cube):
ngroups = 5
nints = 9
Copy link
Collaborator

Choose a reason for hiding this comment

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

Variables nints, nrows, and ncols are not used, so should be deleted.


def test_sigclip_not_enough_groups(setup_cube):
ngroups = 12
nints = 9
Copy link
Collaborator

Choose a reason for hiding this comment

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

Variables nints, nrows, and ncols are not used, so should be deleted.

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.

2 participants