darsia.Geometry#
- class Geometry(space_dim, num_voxels, dimensions=None, voxel_size=None, **kwargs)[source]#
Bases:
objectGeometry 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:
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
Spatial dimension of geometry.
Number of voxels in each spatial direction.
Dimensions of a single voxel.
Dimensions of geometry.
Volume (area in 2d) of a single voxel.
Internal copy of the voxel volume for efficient integration.
- integrate(data)[source]#
Integrate data over the entire geometry.
- Parameters:
- data
np.ndarray Data attached to voxels.
- data
- Returns:
- Raises:
ValueErrorIn 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:
- data
darsia.Image Image of intensive values.
- data
- Returns:
darsia.ExtensiveImageExtensive image represented on geometry voxelization.
- Raises:
ValueErrorIf 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:
- img
darsia.Image Image to be rescaled.
- img_ref
darsia.Image Reference image.
- return_ratiobool
Flag controlling whether the ratio between reference and original integrals is returned.
- img
- Returns:
darsia.ImageRescaled image.
np.ndarray,optionalRatio between reference and original integrals.
- subregion(roi)[source]#
Extract subregion of the geometry.
- Parameters:
- roi
darsia.CoordinateArray Region of interest.
- roi
- Returns:
GeometrySubregion 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.