pumapy.utilities

pumapy.utilities.boundary_conditions

class pumapy.utilities.boundary_conditions.ConductivityBC(x, y, z)[source]

Bases: object

classmethod from_workspace(workspace)[source]

Generate ConductivityBC from a Workspace.

Parameters

workspace (Workspace) – domain

get_shape()[source]
show()[source]
class pumapy.utilities.boundary_conditions.ElasticityBC(x, y, z)[source]

Bases: object

classmethod from_workspace(workspace)[source]

Generate ElasticityBC from a Workspace.

Parameters

workspace (Workspace) – domain

get_shape()[source]
show()[source]
class pumapy.utilities.boundary_conditions.Isotropic_periodicBC(len_x, len_y, len_z)[source]

Bases: object

indexAt_3D(i, j, k)[source]
class pumapy.utilities.boundary_conditions.Isotropic_symmetricBC(len_x, len_y, len_z)[source]

Bases: object

indexAt_3D(i, j, k)[source]

pumapy.utilities.generic_checks

pumapy.utilities.generic_checks.check_ws_cutoff(workspace, cutoff)[source]
pumapy.utilities.generic_checks.greater_than_exc(var, lim, var_name)[source]
pumapy.utilities.generic_checks.greater_than_inc(var, lim, var_name)[source]
pumapy.utilities.generic_checks.less_than_exc(var, lim, var_name)[source]
pumapy.utilities.generic_checks.less_than_inc(var, lim, var_name)[source]
pumapy.utilities.generic_checks.range_exc(var, var_range, var_name)[source]
pumapy.utilities.generic_checks.range_inc(var, var_range, var_name)[source]
pumapy.utilities.generic_checks.size_check(size)[source]

pumapy.utilities.isosurface

class pumapy.utilities.isosurface.Isosurface(workspace, cutoff, flag_closed_edges, flag_gaussian)[source]

Bases: object

apply_gaussian()[source]
buffer_matrix()[source]
compute()[source]
error_check()[source]
flip_matrix()[source]
log_input()[source]
log_output()[source]
class pumapy.utilities.isosurface.TriMesh[source]

Bases: object

copy(other)[source]
create_mesh()[source]
save(filename, binary=True)[source]
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

TriMesh

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'
class pumapy.utilities.logger.Logger[source]

Bases: object

log_bool(var_name, val)[source]
log_item(val)[source]
log_line(val)[source]
log_section(name)[source]
log_value(var_name, val)[source]
new_line()[source]
set_location(location)[source]
write_log()[source]
pumapy.utilities.logger.print_warning(warning_text)[source]

pumapy.utilities.property_maps

class pumapy.utilities.property_maps.AnisotropicConductivityMap[source]

Bases: pumapy.utilities.property_maps.MaterialPropertyMap

add_isotropic_material(cutoff, k)[source]
add_material(cutoff, kxx, kyy, kzz, kxy, kxz, kyz)[source]
add_material_to_orient(cutoff, k_axial, k_radial)[source]
add_orthotropic_material(cutoff, kxx, kyy, kzz)[source]
class pumapy.utilities.property_maps.ElasticityMap[source]

Bases: pumapy.utilities.property_maps.MaterialPropertyMap

add_isotropic_material(cutoff, E_youngmod, nu_poissrat)[source]
add_material(cutoff, C11, C12, C13, C14, C15, C16, C22, C23, C24, C25, C26, C33, C34, C35, C36, C44, C45, C46, C55, C56, C66)[source]
add_material_to_orient(cutoff, E_axial, E_radial, nu_poissrat_12, nu_poissrat_23, G12)[source]
show()[source]
class pumapy.utilities.property_maps.IsotropicConductivityMap[source]

Bases: pumapy.utilities.property_maps.MaterialPropertyMap

add_material(cutoff, conductivity)[source]
class pumapy.utilities.property_maps.MaterialPropertyMap[source]

Bases: object

error_check(cutoff, conductivity)[source]
get_material(i)[source]
get_size()[source]
show()[source]

pumapy.utilities.raycasting

class pumapy.utilities.raycasting.RayCasting(workspace, degree_accuracy, source_locations, valid_phase, boundary_behavior=0, exportparticles_filepathname='')[source]

Bases: object

error_check()[source]
expand_sources()[source]
generate_spherical_walkers()[source]

pumapy.utilities.timer

class pumapy.utilities.timer.Timer[source]

Bases: object

current = 0
elapsed()[source]
print_elapsed(msg='')[source]
reset()[source]
start()[source]

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

average()[source]
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

copy()[source]

Create a copy of the workspace

Returns

copy of workspace

Return type

Workspace

create_orientation()[source]

Create orientation field of the same size as the matrix

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

Workspace

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

Workspace

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

Workspace

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

Workspace

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

Workspace

get_shape()[source]
get_size()[source]
len_x()[source]
len_y()[source]
len_z()[source]
max()[source]
min()[source]
ndim()[source]
orientation_magnitude()[source]
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

set_voxel_length(voxel_length)[source]

Set voxel size, which by default is set to 1e-6

Parameters

voxel_length (float) – size of a voxel side

Returns

None

show_matrix()[source]
show_orientation(dec=1)[source]
unique_values()[source]
unique_values_counts()[source]