On Sun, Aug 30, 2009 at 15:35, Lorenzo Isella<lorenzo.isella@gmail.com> wrote:
Dear All, What I am after is not exactly an interpolation in the usual sense. Consider the following arrays
A=[1,2,4,5,6,8,9] B=[2,4,5,8] C=[24,45,77,99]
The array A stands for a set of discrete times (NB: some values may be missing), B is a subset of A and C is a set of values of a variable Q taken at times in B. I would like to create an array D with the values the values of Q at the times given by A according to this rule (not exactly a mathematical interpolation): if A[i] falls in the right-open interval [B[j],B[j+1]) for some j, then D[i]=C[j]. To avoid troubles for the end values (using Python array indexing), D[0]=C[0] and if B[j+1] does not exist, then D[i]=C[-1]. For the arrays given above, I would have
D=[24, 24,45,77,77,99,99].
Does anyone know how to code this efficiently?
This corresponds to the "block" mode of interpolation that we at Enthought have been using for well log data. We have had interns try to clean it up for contribution to scipy, but it is still in a rough state: http://svn.scipy.org/svn/scipy/branches/interpolate/ -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco