pumapy.utilities¶
pumapy.utilities.boundary_conditions¶
-
class
pumapy.utilities.boundary_conditions.
ConductivityBC
(x, y, z)[source]¶ Bases:
object
-
class
pumapy.utilities.boundary_conditions.
ElasticityBC
(x, y, z)[source]¶ Bases:
object
pumapy.utilities.generic_checks¶
pumapy.utilities.isosurface¶
-
class
pumapy.utilities.isosurface.
Isosurface
(workspace, cutoff, flag_closed_edges, flag_gaussian)[source]¶ Bases:
object
-
pumapy.utilities.isosurface.
generate_isosurface
(workspace, cutoff, flag_closed_edges=True, flag_gaussian=False)[source]¶ Generation of isosurface based on cutoff provided
- Parameters
workspace (Workspace or numpy.ndarray) – domain
cutoff (tuple(int, int)) – specify cutoff to binarize material
flag_closed_edges (bool, optional) – close edges of surfaces on the boundaries
flag_gaussian (bool, optional) – apply Gaussian filter before generating surface
- Returns
triangulated surface
- Return type
pumapy.utilities.logger¶
-
class
pumapy.utilities.logger.
Colors
[source]¶ Bases:
object
-
BOLD
= '\x1b[1m'¶
-
ENDC
= '\x1b[0m'¶
-
FAIL
= '\x1b[91m'¶
-
HEADER
= '\x1b[95m'¶
-
OKBLUE
= '\x1b[94m'¶
-
OKCYAN
= '\x1b[96m'¶
-
OKGREEN
= '\x1b[92m'¶
-
UNDERLINE
= '\x1b[4m'¶
-
WARNING
= '\x1b[93m'¶
-
pumapy.utilities.property_maps¶
-
class
pumapy.utilities.property_maps.
AnisotropicConductivityMap
[source]¶ Bases:
pumapy.utilities.property_maps.MaterialPropertyMap
-
class
pumapy.utilities.property_maps.
ElasticityMap
[source]¶ Bases:
pumapy.utilities.property_maps.MaterialPropertyMap
pumapy.utilities.raycasting¶
pumapy.utilities.timer¶
pumapy.utilities.workspace¶
-
class
pumapy.utilities.workspace.
Workspace
(**kwargs)[source]¶ Bases:
object
-
apply_mask
(mask, apply_to_orientation=False)[source]¶ Apply mask of same size as the matrix by leaving the mask’s 1s unchanged and setting mask’s 0s to 0
- Parameters
mask (ndarray) – array of type bool with same size as matrix
apply_to_orientation (bool, optional) – specifying whether the mask is to be applied to the orientation (if present)
- Returns
None
-
binarize
(threshold)[source]¶ Binarize the workspace according to threshold, inclusive for higher range set to 1, lower to 0
- Parameters
threshold (int) – grayscale value dividing the domain into 0s and 1s (threshold turns into 1)
- Returns
None
-
binarize_range
(ones_cutoff)[source]¶ Binarize the workspace according to range within cutoff, inclusive for cutoff ints set to 1, rest to 0
- Parameters
ones_cutoff (tuple(int, int)) – convert a range of grayscale values specified by the cutoff into 1s, rest into 0s
- Returns
None
-
classmethod
from_array
(nparray)[source]¶ Generate workspace matrix from numpy array.
- Parameters
nparray (ndarray) – array of shape (X,Y,Z) to be assigned to the matrix variable
- Returns
new workspace
- Return type
-
classmethod
from_shape
(shape, orientation=False)[source]¶ Generate workspace from shape, all matrix value set to zero.
- Parameters
shape (tuple(int, int, int)) – shape of workspace to be created
orientation (bool, optional) – specify if workspace contains orientation
- Returns
new workspace
- Return type
-
classmethod
from_shape_value
(shape, value, orientation=False)[source]¶ Generate workspace from shape, all matrix values set to the value passed.
- Parameters
shape (tuple(int, int, int)) – shape of workspace to be created
value (int) – value to be assigned to the matrix variable
orientation (bool, optional) – specify if workspace contains orientation
- Returns
new workspace
- Return type
-
classmethod
from_shape_value_vector
(shape, value, vector)[source]¶ Generate workspace from shape, all matrix and orientation set to the values passed.
- Parameters
shape (tuple(int, int, int)) – shape of workspace to be created
value (int) – value to be assigned to the matrix variable
vector (tuple(float, float, float)) – vector to be assigned to the orientation variable
- Returns
new workspace with orientation
- Return type
-
classmethod
from_shape_vector
(shape, vector)[source]¶ Generate workspace from shape, all orientation vectors set to the vector passed.
- Parameters
shape (tuple(int, int, int)) – shape of workspace to be created
vector (tuple(float, float, float)) – vector to be assigned to the orientation variable
- Returns
new workspace with orientation
- Return type
-
rescale
(scale, segmented, anti_aliasing=True, interpolation_order=1)[source]¶ Rescale both matrix and orientation (if present) by rescaling the content by a specified factor
- Parameters
scale (float) – specifying the scaling factor
segmented (bool) – specifying whether the domain is already segmented (True) or grayscales (False)
anti_aliasing (bool, optional) – if aliasing is to be prevented applying a Gaussian filter to smooth before scaling. If domain is segmented, automatically set to False in order to preserve domain
interpolation_order (int, optional) – order of the interpolation spline used. For segmented, it is enforced to be 0, which is ‘nearest neighbor’ to preserve the segmentation
- Returns
None
-
resize
(shape, segmented, anti_aliasing=True, interpolation_order=1)[source]¶ Resize both matrix and orientation (if present) by rescaling the content to specified size
- Parameters
shape (tuple(int, int, int)) – shape of workspace to be resized
segmented (bool) – specifying whether the domain is already segmented (True) or grayscales (False)
anti_aliasing (bool, optional) – if aliasing is to be prevented applying a Gaussian filter to smooth before scaling. If domain is segmented, automatically set to False in order to preserve domain
interpolation_order (int, optional) – order of the interpolation spline used. For segmented, it is enforced to be 0,which is ‘nearest neighbor’ to preserve the segmentation
- Returns
None
-
resize_new_matrix
(shape, value=None)[source]¶ Resize matrix numpy array
- Parameters
shape (tuple(int, int, int)) – shape of workspace to be resized
value (int, optional) – value to be assigned to the new resized matrix variable
-
resize_new_orientation
(shape, orientation_value=None)[source]¶ Resize orientation numpy array
- Parameters
shape (tuple(int, int, int)) – shape of workspace to be resized
orientation_value (tuple(float, float, float), optional) – vector to be assigned to the new resized orientation variable
-
rotate
(degrees, around_axis, reshape=False, boundary_mode='reflect', apply_to_orientation=True)[source]¶ Rotate domain by specified degrees
- Parameters
degrees (float) – degrees to rotate domain
around_axis (string) – specify around what axis to perform the rotation. It can be ‘x’, ‘y’ or ‘z’
reshape (bool, optional) – specify whether to reshape the domain to contain every voxel or keep it as original size
boundary_mode (string, optional) – specifying what to do with the boundaries. Options: ‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’
apply_to_orientation (bool, optional) – specify whether to apply rotation to the orientation, if present
- Returns
None
-
set
(matrix_value=None, orientation_value=None)[source]¶ Set all elements in matrix equal to value (and orientation to vectorvalue is passed)
- Parameters
matrix_value (np.uint16, optional) – value to fill to the matrix variable
orientation_value ((tuple(float, float, float), optional)) – vector to fill to the orientation variable
- Returns
None
-
set_material_id
(cutoff, value)[source]¶ Threshold the workspace according to cutoff (i.e. tuple with inclusive range to set)
- Parameters
cutoff (tuple(int, int)) – convert a range of grayscale values specified by the cutoff into an single ID number
value (int) – ID number to assign to range
- Returns
None
-
set_matrix
(nparray)[source]¶ Set matrix with numpy array
- Parameters
nparray (ndarray) – array of shape (X,Y,Z) to be assigned to the matrix variable
- Returns
None
-
set_orientation
(nparray)[source]¶ Set orientation with numpy array
- Parameters
nparray (ndarray) – array of shape (X,Y,Z, 3) to be assigned to the orientation variable
- Returns
None
-