discretize.utils.interpmat

discretize.utils.interpmat(locs, x, y=None, z=None)[source]

Local interpolation computed for each receiver point in turn

Parameters
  • loc (numpy.ndarray) – Location of points to interpolate to

  • x (numpy.ndarray) – Tensor of 1st dimension of grid.

  • y (numpy.ndarray) – Tensor of 2nd dimension of grid. None by default.

  • z (numpy.ndarray) – Tensor of 3rd dimension of grid. None by default.

Return type

scipy.sparse.csr_matrix

Returns

Interpolation matrix

import discretize
import numpy as np
import matplotlib.pyplot as plt
locs = np.random.rand(50)*0.8+0.1
x = np.linspace(0, 1, 7)
dense = np.linspace(0, 1, 200)
fun = lambda x: np.cos(2*np.pi*x)
Q = discretize.utils.interpmat(locs, x)
plt.plot(x, fun(x), 'bs-')
plt.plot(dense, fun(dense), 'y:')
plt.plot(locs, Q*fun(x), 'mo')
plt.plot(locs, fun(locs), 'rx')
plt.show()

(Source code, png, pdf)

../../_images/discretize-utils-interpmat-1.png