imod.prepare.Voxelizer#
- class imod.prepare.Voxelizer(method, use_relative_weights=False)[source]#
Object to repeatedly voxelize similar objects. Compiles once on first call, can then be repeatedly called without JIT compilation overhead.
- method#
The method to use for regridding. Default available methods are:
{"mean", "harmonic_mean", "geometric_mean", "sum", "minimum", "maximum", "mode", "median", "max_overlap"}
- Type:
str, function
Examples
Usage is similar to the regridding. Initialize the Voxelizer object:
>>> mean_voxelizer = imod.prepare.Voxelizer(method="mean")
Then call the
voxelize
method to transform a layered dataset into a voxel based one. The vertical coordinates of the layers must be provided bytop
andbottom
.>>> mean_voxelizer.voxelize(source, top, bottom, like)
If your data is already voxel based, i.e. the layers have tops and bottoms that do not differ with x or y, you should use a
Regridder
instead.It’s possible to provide your own methods to the
Regridder
, provided that numba can compile them. They need to take the argumentsvalues
andweights
. Make sure they deal withnan
values gracefully!>>> def p30(values, weights): >>> return np.nanpercentile(values, 30)
>>> p30_voxelizer = imod.prepare.Voxelizer(method=p30) >>> p30_result = p30_voxelizer.regrid(source, top, bottom, like)
The Numba developers maintain a list of support Numpy features here: https://numba.pydata.org/numba-doc/dev/reference/numpysupported.html
In general, however, the provided methods should be adequate for your voxelizing needs.
Methods
__init__
(method[, use_relative_weights])voxelize
(source, top, bottom, like)