[SciPy-User] Calculation of weights depending on area
Tue Aug 30 08:10:01 CDT 2011
Tue, 30 Aug 2011 12:01:06 +0200, Andreas H. wrote:
> again a question coming from analysis of geodata. Say, I have 3d
> (lat/lon/z) data, in the easiest case on a rectangular grid. Now I would
> like to re-grid these data to a new (again rectangular, in the simplest
> case) grid by calculating the volume-weighted mean of the original grid.
For a rectangular grid, the operation in 3D seems to be a tensor
product of 1D operations. If so, you can write it as follows
data = regrid_volume_1d(x, x_new, data, axis=0)
data = regrid_volume_1d(y, y_new, data, axis=1)
data = regrid_volume_1d(z, z_new, data, axis=2)
So it would be enough to first write a 1D version of the algorithm,
and make it such that it can operate on one axis at a time.
An implementation of the 1D version can probably done first in Python.
Because it will (for 3D data) operate across slices with many points,
the result should be fast enough.
A function that may be useful here: numpy.searchsorted
More information about the SciPy-User