Skip to content
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

Interpolate #420

Open
DanDeepPhase opened this issue Nov 17, 2022 · 2 comments
Open

Interpolate #420

DanDeepPhase opened this issue Nov 17, 2022 · 2 comments

Comments

@DanDeepPhase
Copy link

Any interest in supporting interpolation along the axes?

I was able to hack it in my code with something like:

using Interpolations, DimensionalData
import Interpolations.interpolate

interpolate(da::DimArray) = interpolate(Array.(dims(da)), da, Gridded(Linear())) 

xs = ys = 1:10
zs = [rand() for x in xs, y in ys]
M = DimArray(zs, (Y(ys),X(xs)))

itp = interpolate(M)
itp[3.3, 5.1]
[itp[y,x] for y in 3.1:0.35:7.2, x in 2:4] 

I saw you use something in rasters for re-gridding, which i think this approach is best suited for. some tweaks would be needed to get reverse ordered vectors working.

There may be a more intrusive / better way to do this by extending or creating a variant of At()

@rafaqz
Copy link
Owner

rafaqz commented Nov 17, 2022

Rasters users gdalwarp because it handles projections and has a lot of options. But native interpolation is better eventually.

Unfortunately Interpolations.jl is a very heavy dependency, and this package is a dep of other packages so we have to keep things lean.

DimensionalDataInterpolations.jl could be useful.

@rafaqz
Copy link
Owner

rafaqz commented Jan 16, 2023

Revisiting this: with Julia 1.9 and this PR JuliaLang/julia#47695 we can add a weak dependency on Interpolations.jl.

If you want to make a PR that extends Intpolations.jl methods to work on AbstractDimArray in a weak dependency in this package, that would be a very useful addition.

Edit: also note that with Regular sampling you do not need to use Gridded interpolation - but you do if any LookupArray for the axes has Irregular sampling. We can really customize the interpolation method to match the traits of the LookupArray.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants