In some Python code that I am trying to translate to Julia, I have a numpy array of interpolations, the data starts off as a structured grid (i.e., not rectangular), and there is one variable that points to the sample locations and another variable that points to the sample values, say “locations” and “variable”. I then replace the 3D variable array with a 2D array, containing linear interpolations along the rays in the 3rd dimension. I then use this to locate some planes perpendicular to the third dimension for extraction as images.
Next, I’m describing what I am attempting, not trying to convince you it is a good idea …
In Julia, I wasn’t sure that storing the interpolations in a Matrix with Any
type was a good idea, so I tried to capture the type with a simple call:
using Interpolations
approximate(x, y) = extrapolate(interpolate((x,), y, Gridded(Linear())), Flat())
T = typeof(approximate([0., 1.], [0., 1.]))
s = Matrix{T}(undef, 10, 10)
What the matrix buys me is the ability to look up an interpolation by (row, col) … is there a better way to do this?