0

I have a numpy array of

dtype=[('offset', '<i8'), ('data', '<f8', (2000,))]

the offset terms can be in any order and terms can be repeated.

I would like to regularlise the data for visualisation so that each vector is visualised at its relative spatial location. This should involve:

  • summing vectors with the same offset term and normalising
  • interpolation of missing vectors from existing vectors

for the first part I've been doing

size = np.amax(gathers['offset'] - np.amin(gathers['offset']))
panel = np.zeros(size, dtype=np.float)
fold = np.zeros(size, dtype=np.float)
for trace in gathers:
    panel[trace['offset']-np.amin(gathers['offset'])] += trace
    fold[trace['offset']-np.amin(gathers['offset'])] += 1
for index, trace in enumerate(panel):
    panel[index] /= fold[index]
plt.imshow(panel, aspect='auto')
plt.show()

which is slow.

for the second part i've been attempting to use scipy.griddata without success, as i cant figure out how to create the data coordinates for interpolation.

Saullo G. P. Castro
  • 56,802
  • 26
  • 179
  • 234
scrooge
  • 141
  • 1
  • 1
  • 7
  • I would interpolate each horizontal row separately (as a first pass). See http://stackoverflow.com/questions/13167040/interpolate-in-one-direction/13168371#13168371 – tacaswell May 02 '13 at 05:31
  • I would also suggest saving the value of `np.amin(..)` so you don't have to re-compute it (twice!) everytime through the loop. – tacaswell May 02 '13 at 05:33
  • you can also replace your second loop with `panel /= fold` – tacaswell May 02 '13 at 05:34

0 Answers0