-
Notifications
You must be signed in to change notification settings - Fork 27
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
Faster interpolation in UVBeam.interp
#1464
Faster interpolation in UVBeam.interp
#1464
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1464 +/- ##
=======================================
Coverage 99.92% 99.92%
=======================================
Files 61 61
Lines 21319 21337 +18
=======================================
+ Hits 21304 21322 +18
Misses 15 15 ☔ View full report in Codecov by Sentry. |
UVBeam.interp
UVBeam.interp
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 @tyler-a-cox! One thought: is RegularGridInterpolator
exactly the same as RectBivariateSpline
(when then grid happens to be regular)? If so, we could either just replace the original RectBivariateSpline with the new regular interpolator, or, if we suspect that we might get irregular grids from time to time, at least make the default dynamic, i.e. choose the regular grid if the grid is regular, otherwise choose the bivariate spline.
Thanks for the reply, @steven-murray! As we discussed offline, I've swapped 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.
Thanks @tyler-a-cox. I think this is probably the way to go. We don't want to do anything API-breaking here, so it does have to be a keyword argument rather than choosing a default dynamically, because as you say the spline_opts
are different between the two.
8ee5d77
to
7beed70
Compare
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 @tyler-a-cox this all looks good to me. The only thing to still discuss I think is whether we need the check for regularity, given that as @bhazelton mentioned the data should always be regularly spaced.
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 is looking really good, thanks @tyler-a-cox! I just had a couple comments on docstrings. It looks like there are a couple of lines of missed coverage, but they're similar to lines being covered for the other interp method, so maybe a judiciously placed pytest parametrize call would take care of them pretty easily?
"description": "scipy RectBivariate spline interpolation", | ||
"func": "_interp_az_za_rect_spline", |
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.
We discussed maybe changing the name of this option (with deprecation!) to include something related to RectBivariateSpline. I think maybe it's best to push that to another PR, just wanted to mention it here.
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.
moved this to an issue: #1473
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 now.
"description": "scipy RectBivariate spline interpolation", | ||
"func": "_interp_az_za_rect_spline", |
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.
moved this to an issue: #1473
89ff57a
to
ed37d2a
Compare
Also update to use the utils method for checking array spacing
ed37d2a
to
3720f46
Compare
Adds new option to
UVBeam.interp
that improves the interpolation speed ofUVBeam._interp_az_za_rect_spline
Description
This PR adds additional functionality to
UVBeam.interp
that allows users to choose between two interpolators (scipy.interpolate.RectBivariateSpline
andscipy.ndimage.map_coordinates
) for interpolation along the spatial axis when runningUVBeam._interp_az_za_rect_spline
. Users can select between the two interpolators by using the newly addedspatial_interp_func
keyword argument inUVBeam.interp
, where the default isRectBivariateSpline
which is currently the interpolator used inUVBeam._interp_az_za_rect_spline
.Motivation and Context
When running visibility simulations with
hera_sim
, we noticed that beam interpolation was one of the most expensive steps. The current interpolatorscipy.interpolate.RectBivariateSpline
is quite flexible, but can be quite a bit slower than other gridded interpolators inscipy
. I ran this branch on HERA's Vivaldi beam file usingspatial_interp_func="map_coordinates"
and found a ~3x improvement in the interpolation time compared to whenspatial_interp_func="RectBivariateSpline"
.Types of changes
Checklist:
New feature checklist: