Re: [Numpy-discussion] Vectorization of variant of piecewise or interpolation function

2017-10-16 Thread Seth Ghandi
Thanks so much Juan! I did not know about this np.digitize command. With this the vectorization of my function then reads as def ZeroOrderInterpolation(t,table): import numpy as np lookup, values = table[:, 0], table[:, 1:] values = np.concatenate((values[0:1], values), axis=0) indices = n

Re: [Numpy-discussion] Vectorization of variant of piecewise or interpolation function

2017-10-15 Thread Juan Nunez-Iglesias
Hi Seth, The function you’re looking for is `np.digitize`: In [1]: t = np.array([0.5,1,1.5,2.5,3,10])    ...: table = np.array([[0,3],[1,0],[2,5],[3,-1]])    ...: In [2]: lookup, values = table[:, 0], table[:, 1:] In [3]: values = np.concatenate((values[0:1], values), axis=0) In [4]: indices = n

[Numpy-discussion] Vectorization of variant of piecewise or interpolation function

2017-10-15 Thread Seth Ghandi
Hi everybody, I am new to newpy and am trying to define a variant of piecewise or zero holder interpolation function, say ZeroOrderInterpolation(t,a), where t is an 1D array of size, say p, consisting of real numbers, and a is a 2D array of size, say nxm, with first column consisting of increas