ft: add gridded interpolation to DimensionalData#1126
Conversation
Add functions `gridded_interpolate` and `interpolate!` in a project extension to interpolate `DimArray`s using the `Interpolations.jl` package. - `gridded_interpolate` creates a `DimGriddedInterpolation` object, which can be used to interpolate the data in-place or out-of-place. - out-of-place interpolation is supported by calling the `DimGriddedInterpolation` object with the desired dimensions. - in-place interpolation is supported by calling `interpolate!` with the `DimGriddedInterpolation` object and an existing `DimArray`.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1126 +/- ##
==========================================
- Coverage 86.90% 86.11% -0.80%
==========================================
Files 55 57 +2
Lines 5338 5387 +49
==========================================
Hits 4639 4639
- Misses 699 748 +49 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Oh no... Im working on integrating DataInterpolationsND.jl here! (And working on that package quite a lot too) Mostly because it will allow arbitrary mixed interpolation types by dimension, and will be faster and more flexible (e.g. GPU compatible) than Interpolations.jl due to KernelAbstractions.jl core, and becaise Im going to optimise the kernels pretty hard over the next week or two. And unfortunately I also think we should go with one specific interpolations integration to minimise future maintenance. |
|
Ah gotcha. Well in that case, please feel free to ping me once you've got a PR ready. I'd be happy to provide feedback and discuss how it could work for some use cases I would find valuable. |
|
Think I'm back on board with using Interpolations.jl. But I want to make this a lot more flexible and have everything by dimension. I will have a go at refactoring this PR to see how easy it is to do. |
This pull request adds support for gridded interpolation of
AbstractDimArrays usingInterpolations.jl, while ensuring that the new functionality is only available whenInterpolations.jlis loaded. The main changes introduce a new extension module, user-facing API, and integration points.New gridded interpolation support:
DimensionalDataInterpolationsExtextension module (ext/DimensionalDataInterpolationsExt.jl) that defines aDimGriddedInterpolationtype for gridded interpolation ofAbstractDimArrays, agridded_interpolateconstructor, and aninterpolate!method for in-place interpolation. This module also includes comprehensive documentation and a custom display method.This PR is inspired by previous efforts and discussions to support interpolation in
DimensionalData, includingInterpolations.jlas an extension.DimensionalDataInterpolationsExt.jlforAbstractDimVectors #1091, adds an extension for 1D interpolation ofDimVectors usingDataInterpolations.jl.I'm very open to discussing the API, bikeshed names and details, etc.
This is very much a first draft that hopefully can stimulate some discussion and feedback before I put in the additional effort to add docs, tests, and clean up the interface and edge-cases. That said, I have used a version of this for a while for an ongoing project, including a variant that works for
DimStacks, but haven't gotten around to trying to get it merged intoDimensionalDataitself.There's a few caveats to this draft, including:
UnrolledUtilities, to ensure that out-of-place interpolation is type-stable. Notably, it is used to move scalar-like dimensions torefdimsso that the returnedDimArrayonly contains vector-like dimensions. Unfortunately, I think this means end-users would have to explicitly load both packages for the extension to load.UnrolledUtilitiesas an ordinary dependency (it's quite light, after all and potentially useful elsewhere).