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

Move outlier detection utility functions from jwst to stcal #270

Merged
merged 21 commits into from
Jul 30, 2024

Conversation

braingram
Copy link
Collaborator

@braingram braingram commented Jul 8, 2024

This PR moves a number of utility functions related to outlier detection from jwst to stcal.

This PR is required for spacetelescope/jwst#8613

As this PR adds a few new dependencies (and these are added to the devdeps) the run devdeps tests label was added. It's expected that the jwst devdeps will fail as they are failing on main: https://github.com/spacetelescope/stcal/actions/runs/9836681142/job/27152917937

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)

Copy link

codecov bot commented Jul 8, 2024

Codecov Report

Attention: Patch coverage is 96.73913% with 6 lines in your changes missing coverage. Please review.

Project coverage is 84.32%. Comparing base (58018d4) to head (2112773).
Report is 1 commits behind head on main.

Files Patch % Lines
src/stcal/outlier_detection/utils.py 96.55% 3 Missing ⚠️
tests/outlier_detection/test_utils.py 96.90% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #270      +/-   ##
==========================================
+ Coverage   84.01%   84.32%   +0.31%     
==========================================
  Files          39       41       +2     
  Lines        7345     7529     +184     
==========================================
+ Hits         6171     6349     +178     
- Misses       1174     1180       +6     

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

@braingram braingram force-pushed the outlier_detection branch 2 times, most recently from ad63436 to 4733fb9 Compare July 10, 2024 00:02
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jul 10, 2024
@braingram braingram changed the title WIP: Outlier detection Move outlier detection utility functions from jwst to stcal Jul 10, 2024
@braingram
Copy link
Collaborator Author

Closing and opening to re-trigger CI since the run devdeps tests label didn't seem to take.

@braingram braingram closed this Jul 10, 2024
@braingram braingram reopened this Jul 10, 2024
@braingram braingram marked this pull request as ready for review July 10, 2024 17:15
@braingram braingram requested a review from a team as a code owner July 10, 2024 17:15
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.

Looking good, just a few small things.

src/stcal/outlier_detection/utils.py Outdated Show resolved Hide resolved
src/stcal/outlier_detection/utils.py Outdated Show resolved Hide resolved
src/stcal/outlier_detection/utils.py Show resolved Hide resolved
src/stcal/outlier_detection/utils.py Show resolved Hide resolved
src/stcal/outlier_detection/utils.py Outdated Show resolved Hide resolved
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.

All my comments have been addressed, looks good to me

src/stcal/outlier_detection/utils.py Show resolved Hide resolved
src/stcal/outlier_detection/utils.py Outdated Show resolved Hide resolved
Copy link
Member

@mcara mcara left a comment

Choose a reason for hiding this comment

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

LGTM

tox.ini Outdated Show resolved Hide resolved
@emolter
Copy link
Collaborator

emolter commented Jul 26, 2024

looks like mypy needs an override in pyproject.toml for drizzle



def _abs_deriv(array):
tmp = np.zeros(array.shape, dtype=np.float64)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing docstring.

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 added short docstrings in 2112773

This function (and _absolute_subtract) should likely not be used since they appear to introduce erroneous cr flags due to treating off-edge pixels as 0. However, fixing this bug would result in changes to regression test results and I think makes more sense in a separate PR (where the new results can be verified). There is a JP ticket for this spacetelescope/jwst#8636 and candidate new code here https://github.com/spacetelescope/jwst/pull/8635/files

For the scope of this PR I added "Do not use this function" to the docstrings as moving this code to stcal did not introduce the bug.



def _absolute_subtract(array, tmp, out):
tmp = np.abs(array - tmp)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing docstring.

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 added a brief docstring to this function (see #270 (comment) for more details).

I attempted to add more but given the number of lines of code and the array "switch-a-roo" that this function is performing I think reading the code is the best bet for trying to understand what's happening.

Also this function will be removed if the candidate code for fixing spacetelescope/jwst#8636 is acceptable.

Tests were unable to produce a situation
where the filtered warning could be produced.
The goal was to add a more specific filter
(one that uses a message). If the warning
can be reproduced the filter with a message
can be re-added. It's possible this warning
is no longer produced and so this commit
removes the filter.
@braingram braingram merged commit 809de23 into spacetelescope:main Jul 30, 2024
28 of 32 checks passed
@braingram braingram deleted the outlier_detection branch July 30, 2024 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation installation run devdeps tests testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants