darsia.Geometry#

class Geometry(space_dim, num_voxels, dimensions=None, voxel_size=None, **kwargs)[source]#

Bases: object

Geometry of a physical domain, supporting geometric integration.

Examples

dimensions = {"width": 1.0, "height": 2.0, "depth": 0.1}
shape = (20, 10)
geometry = darsia.Geometry(shape, **dimensions)

Constructor.

Parameters:
space_dimint

Spatial dimensions of the geometry.

num_voxelstuple of int

Shape of the voxelisation of the geometry.

dimensionslist, optional

Dimensions of the entire geometry.

voxel_sizelist, optional

Dimensions of single voxel.

Methods

integrate(data)

Integrate data over the entire geometry.

make_extensive(data)

Convert intensive values to integrated per-cell values on geometry grid.

normalize(img, img_ref[, return_ratio])

Normalize image with respect to another one, such that both have the same integral.

subregion(roi)

Extract subregion of the geometry.

Attributes

space_dim

Spatial dimension of geometry.

num_voxels

Number of voxels in each spatial direction.

voxel_size

Dimensions of a single voxel.

dimensions

Dimensions of geometry.

voxel_volume

Volume (area in 2d) of a single voxel.

cached_voxel_volume

Internal copy of the voxel volume for efficient integration.

integrate(data)[source]#

Integrate data over the entire geometry.

Parameters:
datanp.ndarray

Data attached to voxels.

Returns:
float or array

Integral of data over geometry, array if time series and/or non-scalar data is provided.

Raises:
ValueError

In dimensions other than 2, if data and geometry incompatible and reshape is needed.

make_extensive(data)[source]#

Convert intensive values to integrated per-cell values on geometry grid.

Parameters:
datadarsia.Image

Image of intensive values.

Returns:
darsia.ExtensiveImage

Extensive image represented on geometry voxelization.

Raises:
ValueError

If data is not an image, dimensions are incompatible, or incompatible reshaping is requested in dimensions other than 2.

normalize(img, img_ref, return_ratio=False)[source]#

Normalize image with respect to another one, such that both have the same integral.

Parameters:
imgdarsia.Image

Image to be rescaled.

img_refdarsia.Image

Reference image.

return_ratiobool

Flag controlling whether the ratio between reference and original integrals is returned.

Returns:
darsia.Image

Rescaled image.

np.ndarray, optional

Ratio between reference and original integrals.

subregion(roi)[source]#

Extract subregion of the geometry.

Parameters:
roidarsia.CoordinateArray

Region of interest.

Returns:
Geometry

Subregion geometry.

cached_voxel_volume#

Internal copy of the voxel volume for efficient integration.

dimensions#

Dimensions of geometry.

num_voxels#

Number of voxels in each spatial direction.

space_dim#

Spatial dimension of geometry.

voxel_size#

Dimensions of a single voxel.

voxel_volume#

Volume (area in 2d) of a single voxel.