-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
interp and reindex should work for 1d -> nd indexing #3252
Comments
I have some numba code which does this for linear interpolation. Does |
We could implement linear interpolation just as |
In my experience, computing |
Linear interpolation for 1d -> nd is just a matter of averaging two
indexing selections. If we leverage xarray's vectorized indexing operations
to do the hard work, it should work automatically for dask arrays, sparse
arrays and xarray's internal backend array types, all with any number of
dimensions.
…On Fri, Aug 23, 2019 at 2:17 PM Noah D Brenowitz ***@***.***> wrote:
In my experience, computing w efficiently is the tricky part. The
function is slightly different, but metpy
<https://unidata.github.io/MetPy/latest/api/generated/metpy.interpolate.interpolate_1d.html>
uses a lot of tricks to make this work efficiently. A manual for-loop is
much cleaner for this kind of stencil calculation IMO. What kind of duck
arrays were you thinking of?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3252?email_source=notifications&email_token=AAJJFVQMRK7YOBW6LGJSXM3QGBAUHA5CNFSM4IPBQQPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5BHDBY#issuecomment-524448135>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJJFVUICIWBNW3EILTCQ53QGBAUHANCNFSM4IPBQQPA>
.
|
After reading the |
So when would |
We could probably use this our own version for all linear and nearest neighbor interpolation. Then we won’t need scipy installed for that. |
Ok. I started playing around with this, but I am getting errors when indexing arrays with ND variables.
|
Ok. I realized this problem occurs only because |
Just got bit by this as well. Computing monthly quantile correction factors, so I have an array with dimensions (month, quantile, lon, lat). I then want to apply these correction factors to a time series (time, lon, lat), so I compute the month and quantile of my time series, and want to |
I recently wrote a version of scipy.ndimage.map_coordinates for JAX in pure
NumPt that I think could be straightforwardly ported into xarray.
…On Thu, Feb 6, 2020 at 7:00 AM David Huard ***@***.***> wrote:
Just got bit by this as well. Computing monthly quantile correction
factors, so I have an array with dimensions (month, quantile, lon, lat). I
then want to apply these correction factors to a time series (time, lon,
lat), so I compute the month and quantile of my time series, and want to
interp into the quantile correction factors. This doesn't work because
both the factors and the time series have (lat, lon) dimensions.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3252?email_source=notifications&email_token=AAJJFVWXXHT6ISDFN6ETRO3RBQQ2VA5CNFSM4IPBQQPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEK7QWSA#issuecomment-582945608>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJJFVUF4COJXNL377B3FZDRBQQ2VANCNFSM4IPBQQPA>
.
|
@shoyer I'm having trouble wrapping my head around this. The example above is essentially a 1D interpolation over |
This works with
isel
andsel
(see below). There's no particular reason why it can't work withreindex
andinterp
, too, though we would need to implement our own vectorized version of linear interpolation (should not be too bad, it's mostly a matter of indexing twice and calculating weights from the difference in coordinate values).Apparently this is quite important for vertical regridding in weather/climate science (cc @rabernat, @nbren12 )
The text was updated successfully, but these errors were encountered: