Monotone cubic spline interpolation on an irregular grid

Is there a package in Julia for interpolation using a monotone cubic spline interpolation on an irregular grid? I seem to be failing to find one.

Interpolations.jl does provide monotone option, but only on a regular grid. On irregular grids it only supports linear constant and linear interpolations.

BSplineKit.jl does provide even higher-order interpolations on irregular grids, but does not offer monotone option.

Dierckx.jl does not seem to fit either.

Anything else?

For illustration, here comes some data and cubic spline interpolation, but not monotone, using BSplineKit.jl

M = [0.0, 0.4, 0.8, 0.9, 1.0, 1.2, 1.4, 1.6, 1.8]
η = [0.54, 0.54, 0.54, 0.75, 0.79, 0.78, 0.89, 0.93, 0.93]

using BSplineKit
itp_η = interpolate(M2, η, BSplineOrder(4))
M_range = LinRange(0.0,1.8,100)

scatter(M,η,xlabel="M [-]",ylabel="η")
plot!(M_range,itp_η.(M_range))

spline_julia

And here comes a solution of the same problem in Matlab – this is what I need in Julia:

M = [0.0, 0.4, 0.8, 0.9, 1.0, 1.2, 1.4, 1.6, 1.8]
eta = [0.54, 0.54, 0.54, 0.75, 0.79, 0.78, 0.89, 0.93, 0.93]

M_range = linspace(0,1.8,100)
eta_pchip = pchip(M,eta,M_range);

plot(M,eta,'o',M_range,eta_pchip)
xlabel('M')
ylabel('eta')

2 Likes

Thanks. Indeed, this will solve the particular univariate interpolation problem.

I was wondering if a multivariate (bivariate will be fine) version is available elsewhere.