fast interpolation of a (50000,3000) numpy array along axis=-1
<p>I have a 2D array of seismic data of shape (50000, 3000)</p>

<p>I need to 1d interpolate everything in axis=-1</p>

<p>If z=values, t0=value times, tx= new times, I'm currently doing </p>

<pre><code>for i in range(dataset.size):
    result[i,:] = np.interp(tx[i,:], t0[i,:], z[i,:]) 
</code></pre>

<p>not surprisingly it takes hours.</p>

<ul>
<li><p>t0 is sorted but irregularly sampled</p></li>
<li><p>tx is sorted and regularly sampled</p></li>
</ul>

<p>any suggestions on significantly speeding up the code?</p>

<p>am limited to numpy/scipy solutions only</p>

<p>Depends on what you're trying to achieve. You can use array slicing to interpolate just a small subset of your data, if you know where the interesting region is. Or you may want to see the big picture by using statistical metrics.</p>

<p>I don't think there is a way to significantly speed up the <code>np.interp()</code> itself, since it essentially traverses all the points in your data. You can try <code>interp1d()</code> from <code>scipy.interpolate</code>, but again I think there will be no significant performance difference.</p>

python numpy scipy