Measure tools (darsia.measure)#
Measuring of physical quantities in porous media is performed by integration over the domain. Thus, knowledge over physical information is required, as depth (for 2d images) and porosity. Several special cases are features for convenience. In addition, this subpackage holds tools to measure differences between images by considering the Earth mover’s distance.
Submodules#
darsia.measure.emd module#
Functionality to determine the Earth Mover’s distance between images via cv2.
darsia.measure.integration module#
Module collecting tools for geometric integration.
Various versions of the general algorithm are provided, taking into account width, height and depth of pixels.
- class ExtrudedGeometry(expansion, space_dim, num_voxels, dimensions=None, voxel_size=None, **kwargs)[source]#
Bases:
WeightedGeometryOne or two-dimensional geometry extruded to three dimensions.
- integrate(data)#
Integrate data over the entire geometry.
- Parameters:
data (np.ndarray) – data attached to voxels.
- Returns:
- integral of data over geometry, array if time series and/or
non-scalar data is provided.
- Return type:
float or array
- Raises:
ValueError – In dimensions other than 2, if data and geometry incompatible and reshape is needed.
- normalize(img, img_ref, return_ratio=False)#
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_ratio (bool) – flag controlling whether the ratio between reference and original integrals is returned
- Returns:
rescaled image np.ndarray, optional: ratio between reference and original integrals
- Return type:
darsia.Image
- subregion(roi)#
Extract subregion of the geometry.
- Parameters:
roi (darsia.CoordinateArray) – region of interest.
- Returns:
subregion geometry.
- Return type:
- 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#
Effective voxel volume in 3d.
- weight#
Weight of the geometry, can be a scalar or an array.
- class ExtrudedPorousGeometry(porosity, depth, space_dim, num_voxels, dimensions=None, voxel_size=None, **kwargs)[source]#
Bases:
WeightedGeometryClass containing information of a porous geometry.
- integrate(data)#
Integrate data over the entire geometry.
- Parameters:
data (np.ndarray) – data attached to voxels.
- Returns:
- integral of data over geometry, array if time series and/or
non-scalar data is provided.
- Return type:
float or array
- Raises:
ValueError – In dimensions other than 2, if data and geometry incompatible and reshape is needed.
- normalize(img, img_ref, return_ratio=False)#
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_ratio (bool) – flag controlling whether the ratio between reference and original integrals is returned
- Returns:
rescaled image np.ndarray, optional: ratio between reference and original integrals
- Return type:
darsia.Image
- subregion(roi)#
Extract subregion of the geometry.
- Parameters:
roi (darsia.CoordinateArray) – region of interest.
- Returns:
subregion geometry.
- Return type:
- update(depth)[source]#
Update effective depth and recompute weighted volume.
- Parameters:
depth (float or array) – effective depth.
- 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#
Effective voxel volume in 3d.
- weight#
Weight of the geometry, can be a scalar or an array.
- class Geometry(space_dim, num_voxels, dimensions=None, voxel_size=None, **kwargs)[source]#
Bases:
objectClass containing information of the geometry.
Also allows for geometrical integration.
Example:
dimensions = {“width”: 1., “height”: 2., “depth”: 0.1} shape = (20,10) geometry = darsia.Geometry(shape, **dimensions)
- integrate(data)[source]#
Integrate data over the entire geometry.
- Parameters:
data (np.ndarray) – data attached to voxels.
- Returns:
- integral of data over geometry, array if time series and/or
non-scalar data is provided.
- Return type:
float or array
- Raises:
ValueError – In dimensions other than 2, if data and geometry incompatible and reshape is needed.
- 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_ratio (bool) – flag controlling whether the ratio between reference and original integrals is returned
- Returns:
rescaled image np.ndarray, optional: ratio between reference and original integrals
- Return type:
darsia.Image
- subregion(roi)[source]#
Extract subregion of the geometry.
- Parameters:
roi (darsia.CoordinateArray) – region of interest.
- Returns:
subregion geometry.
- Return type:
- 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.
- class PorousGeometry(porosity, space_dim, num_voxels, dimensions=None, voxel_size=None, **kwargs)[source]#
Bases:
WeightedGeometryClass containing information of a porous geometry.
- integrate(data)#
Integrate data over the entire geometry.
- Parameters:
data (np.ndarray) – data attached to voxels.
- Returns:
- integral of data over geometry, array if time series and/or
non-scalar data is provided.
- Return type:
float or array
- Raises:
ValueError – In dimensions other than 2, if data and geometry incompatible and reshape is needed.
- normalize(img, img_ref, return_ratio=False)#
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_ratio (bool) – flag controlling whether the ratio between reference and original integrals is returned
- Returns:
rescaled image np.ndarray, optional: ratio between reference and original integrals
- Return type:
darsia.Image
- subregion(roi)#
Extract subregion of the geometry.
- Parameters:
roi (darsia.CoordinateArray) – region of interest.
- Returns:
subregion geometry.
- Return type:
- 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#
Effective voxel volume in 3d.
- weight#
Weight of the geometry, can be a scalar or an array.
- class WeightedGeometry(weight, space_dim, num_voxels, dimensions=None, voxel_size=None, **kwargs)[source]#
Bases:
GeometryGeometry with weighted volume.
- integrate(data)#
Integrate data over the entire geometry.
- Parameters:
data (np.ndarray) – data attached to voxels.
- Returns:
- integral of data over geometry, array if time series and/or
non-scalar data is provided.
- Return type:
float or array
- Raises:
ValueError – In dimensions other than 2, if data and geometry incompatible and reshape is needed.
- normalize(img, img_ref, return_ratio=False)#
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_ratio (bool) – flag controlling whether the ratio between reference and original integrals is returned
- Returns:
rescaled image np.ndarray, optional: ratio between reference and original integrals
- Return type:
darsia.Image
- subregion(roi)[source]#
Extract subregion of the geometry.
- Parameters:
roi (darsia.CoordinateArray) – region of interest.
- Returns:
subregion geometry.
- Return type:
- 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#
Effective voxel volume in 3d.
- weight#
Weight of the geometry, can be a scalar or an array.