FYI this is covered in the README: https://github.com/tlycken/Interpolations.jl#gridded-interpolation
--Tim On Saturday, February 27, 2016 07:57:07 AM Matt Bauman wrote: > Interpolations is very similar, but it currently only supports linear and > nearest-neighbor schemes for gridded interpolations: > > 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) > > On Saturday, February 27, 2016 at 10:10:28 AM UTC-5, Uwe Fechner wrote: > > Thanks. The following code works: > > > > using Dierckx > > > > P_NOM = [1.5, 2.2, 3.7, 5.6, 7.5, 11.2, 14.9] > > ETA = [93., 94., 94., 95., 95., 95.5, 95.5] > > calc_eta = Spline1D(P_NOM, ETA, k=1) > > > > println(calc_eta(3.5)) > > > > Nevertheless I would be interested how to do that with Interpolations.jl. > > Sometimes you don't have Fortran available. > > > > Best regards: > > > > Uwe > > > > On Saturday, February 27, 2016 at 3:58:11 PM UTC+1, Yichao Yu wrote: > >> On Sat, Feb 27, 2016 at 9:40 AM, Uwe Fechner <uwe.fec...@gmail.com> > >> > >> wrote: > >>> 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. > >> > >> I've recently tried Dierckx which support non-uniform interpolation. I > >> only need very basic functions so I don't know if it has all the > >> flexibility you need but it's probably worth a look if you haven't. > >> > >>> Uwe > >>> > >>> On Saturday, February 27, 2016 at 3:33:06 PM UTC+1, Cedric St-Jean wrote: > >>>> Hi Uwe, > >>>> > >>>> Have you tried Grid.jl? I haven't tried it, but this example looks like > >>>> it might work with a non-uniform grid. > >>>> > >>>> # 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) > >>>> > >>>> On Saturday, February 27, 2016 at 9:21:53 AM UTC-5, Uwe Fechner wrote: > >>>>> Hello, > >>>>> > >>>>> I am trying to port the following function from python to julia: > >>>>> > >>>>> # -*- coding: utf-8 -*- > >>>>> from scipy.interpolate import InterpolatedUnivariateSpline > >>>>> import numpy as np > >>>>> from pylab import plot > >>>>> > >>>>> P_NOM = [1.5, 2.2, 3.7, 5.6, 7.5, 11.2, 14.9] > >>>>> ETA = [93., 94., 94., 95., 95., 95.5, 95.5] > >>>>> > >>>>> calc_eta = InterpolatedUnivariateSpline(P_NOM, ETA, k=1) > >>>>> > >>>>> # plotting code, only for testing > >>>>> > >>>>> if __name__ == "__main__": > >>>>> X = np.linspace(1.5, 14.9, 1024, endpoint=True) > >>>>> ETA = [] > >>>>> > >>>>> for alpha in X: > >>>>> eta = calc_eta(alpha) > >>>>> ETA.append(eta) > >>>>> > >>>>> plot(X, ETA) > >>>>> > >>>>> The resulting plot is shown at the end of this posting. > >>>>> > >>>>> How can I port this to Julia? > >>>>> > >>>>> I am trying to use the package "Interpolations.jl", but I do not see > >>>>> any > >>>>> example, that shows the interpolation on a non-uniform grid. > >>>>> > >>>>> For now I need only linear interpolation, but I want to use B-Splines > >>>>> later. > >>>>> > >>>>> Any hint appreciated! > >>>>> > >>>>> Uwe Fechner > >>>>> > >>>>> > >>>>> > >>>>> <https://lh3.googleusercontent.com/-8OofwCQWohg/VtGwKR-1BOI/AAAAAAAAAQ > >>>>> I/UTLksCCMIPo/s1600/LinearInterpolation.png>