-
Notifications
You must be signed in to change notification settings - Fork 35
Resample speedup #488
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
base: main
Are you sure you want to change the base?
Resample speedup #488
Conversation
for more information, see https://pre-commit.ci
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #488 +/- ##
==========================================
- Coverage 90.12% 89.92% -0.21%
==========================================
Files 65 65
Lines 10180 10151 -29
==========================================
- Hits 9175 9128 -47
- Misses 1005 1023 +18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
emolter
left a comment
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.
The jwst repository calls gwcs_blot and the Resample class. So in order for this to be accessible to jwst, I think the two new parameters stepsize and order need to be propagated one more step and become optional inputs to those two.
For changelog fragments, you'll need a few different ones, something like the following:
- 488.alignment.rst: Rename
calc_pixmaptocalc_gwcs_pixmap, and add interpolation options tocalc_gwcs_pixmapto speed up resample computations. (something about the amount of speedup here). - 488.alignment.rst: Remove util.reproject method
- 488.outlier_detection.rst: Remove utils.reproject method. Remove utils.calc_gwcs_pixmap; use alignment.resample_utils.calc_gwcs_pixmap instead.
- 488.breaking.rst: Remove alignment.util.reproject, outlier_detection.utils.reproject, and outlier_detection.utils.calc_gwcs_pixmap. Rename alignment.util.calc_pixmap to alignment.util.calc_gwcs_pixmap
|
I added two changelog fragments attempting to match the current filenames and the spirit of your suggestions, I propagated stepsize and order up as needed, and I fixed the formatting. Tests are passing. This PR still needs unit tests of the interpolation aspect of calc_pixmap. |
|
Thanks for doing so! It looks like I have what I need to ensure this looks good on multiple types of JWST data. RE the changelog, what you have looks good. We are about to change some of the categories - this is part of what we were arguing about at hack day - so they unfortunatley may need to be renamed and split by step if #486 gets in before this does. |
changes/488.apichange.rst
Outdated
| @@ -0,0 +1 @@ | |||
| Change ``calc_pixmap`` in ``alignment.resample_utils`` to match the version in ``drizzle.utils`` and then add interpolation options to speed up resampling calculations. Coordinate transformations can dominate the runtime of ``resample`` and, for well-behaved distortion corrections, they may be sped up by a factor of several tens with negligible loss of accuracy. Propagate interpolation options to ``gwcs_blot`` and ``Resample``. | |||
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.
#486 is now merged so these two existing change log entries will probably need to be split into changes/488.alignment.rst and changes/488.resample.rst
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.
(see https://github.com/spacetelescope/stcal/tree/main/changes#news-fragment-change-types for instructions)
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.
FWIW I think my original suggestion was tailored to the new way of doing things, so that may be helpful again.
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.
Please check if my changes are sufficient. I think it just needs a proper unit test or two.
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 they look good. Maybe we should also add a fragment for Resample, something like "Add options to interpolate pixel map...something something" since the resample step is the most highly affected one? But I'm happy as-is.
|
@t-brandt I started testing this by hooking it into the jwst repository (see this early PR draft). I think I found a small bug, which is that the output pixel map seems to be the wrong shape for non-square data. For example, for the unit test Changing the last line of |
|
Thanks, @emolter -- the x and y order were reversed in one call. It didn't matter if they were the same as for a square array. I think it should be fixed now. |
|
Fix looks like it works, thanks. I'm still testing this on different jwst datasets, will update when that's done. |
|
I've now tested this on all jwst imaging regression test data. Things are looking excellent- the differences in output data are almost all smaller than our tolerances, and those that aren't are still small enough that I'm not worried. I've also confirmed that the runtime improvements can be substantial for large JWST mosaics. See comments on spacetelescope/jwst#10137 for details. I'm ready to approve this pending two things:
|
|
There are three failures in the regression tests (https://github.com/spacetelescope/RegressionTests/actions/runs/21004645391) pointing to jwst/main and this PR branch. They look small so I'm not super worried, but we didn't expect any changes at all, so I think it'd be worth at least understanding where they are coming from. I presume it is indeed related to some difference between the old stcal
Does anyone have insight here? edit with more details: So the four points the regtest flagged (the four in the upper left) are indeed substantially larger differences than the rest. Still unclear to me what caused this.
For the failing second exposure in the MultiExposureModel in
|
|
Looking again at the analysis I did above, I think it's fine to chalk it up to just small numerical differences between the old and new |


Partially resolves JP-3997
Resolves JP-4216
Resolves RCAL-1311
Closes spacetelescope/jwst#10115
This PR supersedes #485 and #367
The reproject functions and calc_pixmap and calc_gwcs_pixmap functions in alignment and outlier_detection are all removed in favor of a copy of the calc_pixmap function from drizzle which now lives in alignment. The rewritten calc_pixmap accepts two new inputs: stepsize (duplicating an argument in drizzlepac), which performs the full WCS pixel mapping only every stepsize pixels in each direction, and order, either 1 or 3, to perform either bilinear or bicubic interpolation in between. These parameters should be exposed at the top-level calls to outlier detection and resample.
Tasks
docs/pageno-changelog-entry-needed)changes/:echo "changed something" > changes/<PR#>.<changetype>.rst(see changelog readme for instructions)"git+https://github.com/<fork>/stcal@<branch>")jwstregression testromancalregression test