-
Notifications
You must be signed in to change notification settings - Fork 28
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
use resample many_to_many in outlier detection #1260
Conversation
509b088
to
819699a
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1260 +/- ##
==========================================
+ Coverage 79.24% 79.30% +0.06%
==========================================
Files 117 117
Lines 8075 8065 -10
==========================================
- Hits 6399 6396 -3
+ Misses 1676 1669 -7
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. |
This looks fine to me, but @mairanteodoro and you should discuss, and I suspect that there are related unit tests that will need updating. |
Thanks @schlafly! @mairanteodoro and I have a meeting tomorrow to discuss the sky subtraction (which is partially handled in this PR and partially in #1233). After updating the I'll open this PR for review once the unit and regtests finish (I expect at least the |
af5a19e
to
54994b4
Compare
@@ -34,7 +34,7 @@ dependencies = [ | |||
"tweakwcs >=0.8.6", | |||
"spherical-geometry >= 1.2.22", | |||
"stsci.imagestats >= 1.6.3", | |||
"drizzle >= 1.13.7", | |||
"drizzle >= 1.14.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was needed as an outlier at the very edge of the image wasn't being picked up in drizzle <1.14.0.
Presumably the regtests change meaningfully with this PR; would you mind including something like the new image, old image, and the difference? Thank you! |
I agree that I can't see anything in the preview images; the stars are too small and just look like hot pixels. I don't actually think the L2 files are that problematic; some of the structure in the background is from the non-linearity reference files having issues. The spatial gradient is a little unexpected but is probably very low amplitude. By eye it doesn't look to me like we're masking all of the stars, for example, but have you actually looked at the generated outlier masks? |
There was a problem hiding this 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! Thanks for the fix, @braingram!!
I looked at the outlier masks and there aren't large differences. Since main has seen some changes since I made those comparisons they'll need to be updated. The mosaic test only uses 3 images so the median across groups (many_to_many) vs the drizzled combinations of all groups (many_to_one) produces similar "median" data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks, approving!
@schlafly Is there more you'd like to see before merging? I re-ran the regtests here: Looking at the output image (a cropped region |
@schlafly Is there anything else you'd like to see for this PR? |
No, thanks, I thought I approved, thank you! |
This PR changes outlier detection to use
many_to_many
when resampling during median calculation. This PR produces 1 expected difference in regression test results.https://plwishmaster.stsci.edu:8081/job/RT/job/Roman-Developers-Pull-Requests/805/
With the current code on main the
test_level3_mos_pipeline
test runs an association with 3 models (each from a different exposure) through the mosaic pipeline. Setting a breakpoint just prior to the call tocreate_median
:romancal/romancal/outlier_detection/outlier_detection.py
Lines 108 to 111 in ed6187f
we can see that
len(drizzled_models) == 1
. This conflict with the algorithm description in the docs that states:Looking at the outlier detection unit tests I don't see one that both:
resample_data=True
The only unit test that reaches:
romancal/romancal/outlier_detection/outlier_detection.py
Lines 86 to 88 in e559890
is test_skymatch_always_returns_modelcontainer_with_updated_datamodels which doesn't introduce any outliers and runs the step with all 0 data.
Changing test_outlier_do_detection_find_outliers (which introduces and detects outliers) to use resampling is insufficient to show the impact of this PR. Without this PR, the introduced CRs (value=1E5) and 'drizzled' together with empty pixels from the other image (value=0). This produces a single
drizzled_model
with a value of 5E4 for each PR. The median (N=1) produces the same value, when blotted back to the input image wcs the 5E4 values are far enough below the 1E5 values of the CRs to allow them to be detected. This is true for any value used for the CR (since the input images are noiseless with all 0 error).Furthermore the test appears to be checking that all introduces CRs (even those introduced in
img2
) are flagged inimg1
:romancal/romancal/outlier_detection/tests/test_outlier_detection.py
Line 253 in e559890
returns 10 flagged CRs:
whereas only 5 were introduced into
img1
:romancal/romancal/outlier_detection/tests/test_outlier_detection.py
Lines 204 to 206 in e559890
Switching single (so that now
many_to_many
is used) revealed a few other issues included:The updated unit test in this PR uses 3 images with the first 2 having CRs, each having 1 "source" and checks that:
Checklist
CHANGES.rst
under the corresponding subsection