-
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
Copy input datamodel in source_catalog step #1457
Conversation
When I was thinking about this I imagined only copying model.data (to avoid copying all of the other image planes that aren't really relevant). But I don't know to what extent photutils might touch input data, or if only the model.data -= bkg.background is expected to be relevant. |
The model.err array is also modified in-place in |
If the source_catalog code is responsible for all of the modifications and so we can safely save a couple of copies in it and restore them at the end, let's do that. If photutils is "allowed" to modify the arrays we're passing it in the model then let's go ahead and do the full model copy. Maybe let's also document in the docstring to some function that source_catalog is allowed to change fields data & err by a scale factor (numerical precision differences only). Thanks! |
The modifications are happening before any inputs to |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1457 +/- ##
==========================================
- Coverage 76.24% 76.21% -0.04%
==========================================
Files 115 115
Lines 7650 7639 -11
==========================================
- Hits 5833 5822 -11
Misses 1817 1817 ☔ View full report in Codecov by Sentry. |
Great, then let's try to only save the planes we are explicitly modifying. |
@schlafly I've updated this PR to copy only the |
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 looks good to me, pending successful completion of the regression tests.
assert_allclose(original_data, mosaic_model.data, atol=5.0e-5) | ||
assert_allclose(original_err, mosaic_model.err, atol=5.0e-5) | ||
assert_equal(original_data, mosaic_model.data) | ||
assert_equal(original_err, mosaic_model.err) |
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.
Thanks for this test!
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.
I only have one concern about using assert_equal()
to compare float32
arrays.
assert_allclose(original_data, image_model.data, atol=5.0e-5) | ||
assert_allclose(original_err, image_model.err, atol=5.0e-5) | ||
assert_equal(original_data, image_model.data) | ||
assert_equal(original_err, image_model.err) |
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.
I think it would be safer to use assert_allclose()
because both arrays are of type float32
.
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.
With this PR the arrays really are identical, so assert_equal
should always work.
This "fails" regtests but I think that's just saying that this is working and it's a numerical noise thing that is now fixed that we should okify. The only failures are pipeline tests that run source cataloging with small numerical differences. |
This was out-of-sync with main, so I just rebased. I'll merge when CI passes again. |
With this PR the input datamodel to the
source_catalog
step is copied before being operated on so that it is left completely unaltered.Tasks
24Q4_B15
(use the latest build if not sure)no-changelog-entry-needed
)changes/
:echo "changed something" > changes/<PR#>.<changetype>.rst
(see below for change types)docs/
pageokify_regtests
to update the truth filesnews fragment change types...
changes/<PR#>.general.rst
: infrastructure or miscellaneous changechanges/<PR#>.docs.rst
changes/<PR#>.stpipe.rst
changes/<PR#>.associations.rst
changes/<PR#>.scripts.rst
changes/<PR#>.mosaic_pipeline.rst
changes/<PR#>.patch_match.rst
steps
changes/<PR#>.dq_init.rst
changes/<PR#>.saturation.rst
changes/<PR#>.refpix.rst
changes/<PR#>.linearity.rst
changes/<PR#>.dark_current.rst
changes/<PR#>.jump_detection.rst
changes/<PR#>.ramp_fitting.rst
changes/<PR#>.assign_wcs.rst
changes/<PR#>.flatfield.rst
changes/<PR#>.photom.rst
changes/<PR#>.flux.rst
changes/<PR#>.source_detection.rst
changes/<PR#>.tweakreg.rst
changes/<PR#>.skymatch.rst
changes/<PR#>.outlier_detection.rst
changes/<PR#>.resample.rst
changes/<PR#>.source_catalog.rst