Interpolations.jl icon indicating copy to clipboard operation
Interpolations.jl copied to clipboard

Nodes used when interpolating a node on grid

Open fredrikpaues opened this issue 4 years ago • 3 comments

I have been frustrated by the code below returning NaN---presumably as the first two nodes ([Inf, 1.0]) are used to interpolate the queried value (2). Is there some way to change which nodes are used when querying a value on the grid?

using Interpolations
itp = LinearInterpolation([1, 2, 3], [Inf, 1.0, 0.5], extrapolation_bc=Line())
itp(2)

fredrikpaues avatar Mar 28 '22 12:03 fredrikpaues

Would this work?

julia> itp = LinearInterpolation([1, 2 - eps(2.0), 2, 3], [Inf, 1.0, 1.0, 0.5], extrapolation_bc=Line())
4-element extrapolate(interpolate((::Vector{Float64},), ::Vector{Float64}, Gridded(Linear())), Line()) with element type Float64:
  Inf
 NaN
   1.0
   0.5

julia> itp(2)
1.0

mkitti avatar Mar 28 '22 14:03 mkitti

Good idea! That ought to work. Thanks!

fredrikpaues avatar Mar 29 '22 11:03 fredrikpaues

Cross-referencing https://github.com/JuliaMath/Interpolations.jl/issues/459

eirikbrandsaas avatar May 18 '22 20:05 eirikbrandsaas