Simple Lookup function in 2D
millot1
Note that wx and wy are not regularly spaced.
I simply want to lookup the interpolated value (bilinear) of ww at a given point (xx,yy).
What is the most direct and efficient way?
Looking at the help content I only came up with using imageinterpolate , create a finer grid 2dwave and then use the values of ww corresponding to the wx_interp and wy_interp values closest to xx and yy.
Many thanks
If it doesn't take too much memory, the ImageInterpolate method might be faster.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
March 13, 2013 at 09:38 am - Permalink
variable H_T_i=52000
make/o GDFT_Rho={4.5,5,6,7,8,9}
make/o GDFT_T={20e3,30e3,40e3,5e4,6e4,7e4,8e4,9e4}
make/o GDFT={{0.91746, 0.92231 , 0.91806 , 0.9063, 0.88945},{0.83054 ,0.84908, 0.8469, 0.84473, 0.83536},{0.75753 ,0.78101, 0.78431, 0.79047 ,0.78952},{0.71312 ,0.73159, 0.74684, 0.75585, 0.7586},{0.67847 ,0.69593, 0.71717, 0.72416, 0.72929},{0.64918 ,0.66895, 0.68493, 0.69903, 0.70339},{0.62686 ,0.64619, 0.66138, 0.67573 ,0.68661},{0.60679 ,0.62896, 0.64265 ,0.65011 ,0.66453}}
How do I get the interpolated value of GDFT corresponding to H_T_i and H_Rho_i ?
Many thanks
March 13, 2013 at 09:43 am - Permalink
Variable xx, yy
Wave xwave, ywave, wave2d
Variable xp = BinarySearchInterp(xwave, xx)
Variable yp = BinarySearchInterp(ywave, yy)
return Interp2D (wave2d, xp, yp)
end
But I see a problem- your wx and wy waves have one extra point. They were clearly made for our unevenly-spaced image display. But I'm afraid that isn't really suitable for interpolation (and certainly doesn't work well with my function). The distinction is whether the 2D wave values are interpreted to be values between one X value and the next X value (our image display) or if they are a value at a given value of X (which is how an interpolation interprets the matrix).
I suspect that you intend for the interpolation to work from the second interpretation, but you will have to come up with X and Y waves having one fewer point.
What value do you expect to get for (4.5, 20000)? Probably 0.91746. What value do you expect for (5,20000)? Probably 0.92231. What value do you expect to get for (9,20000)? For (8,20000)? It makes a difference whether the values are "values between" or "values at". For interpolation you need "values at".
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
March 13, 2013 at 12:35 pm - Permalink
I think i'll figure out something from there
March 13, 2013 at 01:39 pm - Permalink
http://www.igorexchange.com/node/4398
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
March 13, 2013 at 03:26 pm - Permalink
A.G.
WaveMetrics, Inc.
March 13, 2013 at 03:32 pm - Permalink
Thanks John, I was about to post that BinarySearchInterp seemed to be truncating its answers...
Sounds good, I will install 6.3.1 and this should be fine
March 13, 2013 at 05:50 pm - Permalink