[Numpy-discussion] Numpy interpolate: cut through 2D matrix

Vincent Schut schut at sarvision.nl
Thu Mar 1 06:43:05 EST 2012


On 03/01/2012 12:35 PM, Pierre Barthelemy wrote:
> Hello,
>
> for a data analysis tool i am programming, i need to plot a cut through
> a 2D graph. I then have a 2D array, and the indices
> start=(start_x,start_y) and stop=(stop_x,stop_y) that are the position
> of the starting point and stop point of the cut. The code i programmed
> is placed on the bottom.
>
> This code returns only value existing in the original array: if the cut
> should pass between the column index i and column index i+1, it returns
> anyway the value at column index i.
> Is it possible to use the numpy.interpolate library to make such that
> when passing between i and i+1, the function returns an interpolation of
> the graph between the points [row,column] and [row,column+1] ?

Pierre,

if you have scipy next to numpy, have a look at 
scipy.ndimage.map_coordinates. In short, you define the coordinates you 
want your array to be interpolated at, and it will give you the 
interpolated values, using spline interpolation.

Best,
Vincent.




More information about the NumPy-Discussion mailing list