# Let's define a quadratic function in one dimension, and evaluate it on an evenly-spaced grid of 5 points:
c = 2.3 # center
a = 8.1 # quadratic coefficient
o = 1.6 # vertical offset
qfunc = x -> a*(x-c).^2 + o
xg = Float64[1:5]
y = qfunc(xg)
yi = InterpGrid(y, BCnil, InterpQuadratic)
Hello,
I don't think, that this works on a non-uniform grid. The array xg is evenly spaced, and it
is NOT passed to the function InterpGrid.
using Interpolations
itp = interpolate((P_NOM,), ETA, Gridded(Linear())) # You pass the x-values as a tuple, since this generalizes to multi-dimensional coordinates
println(itp[3.5])
x = linspace(1.5, 14.9, 1024)
y = itp[x]
plot(x,y)Grid.jl has some support for irregular grids, but is not documented (If I recall). I'm using it with linear interpolation on irregular grids, but don't remember if it can do irregular splines.
Interpolations.jl now has a superset of the functionality in Grid.jl, but is (a lot!) faster, so if you're on Julia 0.4 (Interpolations.jl is not supported on 0.3) there's no reason to use Grid.jl.
// T
Gridded here is the interpolation scheme, as opposed to (implicitly uniform) BSpline interpolation; it’s simply the way Interpolations.jl lets you specify which algorithm you want to use. Compare the following incantations:
itp = interpolate(A, BSpline(Linear()), OnGrid()) # linear b-spline interpolation; x is implicitly 1:length(A)
itp = interpolate((x,), A, Gridded(Linear())) # linear, "gridded" interpolation; x can be irregular
itp = interpolate(A, BSpline(Cubic(Flat())), OnCell()) # cubic b-spline with free boundary condition
That is; you give the data to be interpolated (A and, where applicable, x) as well as one or more arguments specifying the algortihm you want to use (for details on OnGrid/OnCell, see the readme). Gridded is what just we’ve called the family of algorithms that support irregular grids.
This is all documented in the readme, but documentation is not just about putting the information in writing - it’s also about putting it in the correct place, where it seems obvious to look for it. If you have suggestions on how this information can be made easier to find and digest, please file an issue or PR. All feedback is most welcome! :)
// T