I am trying to interpolate f : \mathbb{R_{units}} \to \mathbb{R_{units}}^3 where there are unitful units on both the grid and the data.
I found this example that showed me how to get f : \mathbb{R} \to \mathbb{R}^3 interpolation working without units, but when I add units it errors out.
This works fine:
f(a) = 2*a * u"A"
agrid = (0:0.5:5) * u"A"
vals = [f(a) for a in agrid]
itp = interpolate((agrid,), vals, Gridded(Linear()))
And so does this:
f(a) = [1*a, 2*a, 3*a]
agrid = (0:0.5:5)
vals = [f(a) for a in agrid]
itp = interpolate((agrid,), vals, Gridded(Linear()))
But when I combine multi-dim and Units it doesnβt work:
f(a) = [2*a, 1*a, 3*a] * u"A"
agrid = (0:0.5:5) * u"A"
vals = [f(a) for a in agrid]
itp = interpolate((agrid,), vals, Gridded(Linear()))
It throws:
MethodError: no method matching Interpolations.GriddedInterpolation(::Type{Unitful.Quantity{Float64, π^2, Unitful.FreeUnits{(A^2,), π^2, nothing}}}, ::Tuple{StepRangeLen{Unitful.Quantity{Float64, π, Unitful.FreeUnits{(A,), π, nothing}}, Base.TwicePrecision{Unitful.Quantity{Float64, π, Unitful.FreeUnits{(A,), π, nothing}}}, Base.TwicePrecision{Unitful.Quantity{Float64, π, Unitful.FreeUnits{(A,), π, nothing}}}, Int64}}, ::Vector{Vector{Unitful.Quantity{Float64, π^2, Unitful.FreeUnits{(A^2,), π^2, nothing}}}}, ::Interpolations.Gridded{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}})
The type `Interpolations.GriddedInterpolation` exists, but no method is defined for this combination of argument types when trying to construct it.
Is there something I am doing wrong or is Unitful not yet fully supported in Interpolations? (I have run into that with other packages, most work surprisingly well with units but not always)