pumapy.io

pumapy.io.export_texgen_weave

pumapy.io.export_texgen_weave.export_weave_vtu(filename, weave, domain, max_dim_nvox, round_vox_up=True, export_orientation=True)[source]

Exporting weave to vtu, to be read by pumapy

Parameters
  • filename (string) – filepath and name

  • weave (CTextile or child class of CTextile) – weave object, as defined in TexGen

  • domain (CDomainPlanes) – domain size object, as defined in TexGen

  • max_dim_nvox (int) – number of voxels to add in the largest domain dimension

  • round_vox_up (bool) – for the shorter dimensions, round number of voxels up (for +/-1 vox)

  • export_orientation (bool) – specify whether to export orientation

Returns

filename of weave exported (input filename + dimensions)

Return type

string

pumapy.io.input

pumapy.io.input.import_3Dtiff(filename, voxel_length=1e-06, import_ws=True)[source]

Function to io 3D tiff

Parameters
  • filename (string) – filepath and name

  • voxel_length (float) – size of a voxel side

  • import_ws (bool) – if True returns a puma.Workspace, otherwise a ndarray

Returns

domain

Return type

pumapy.Workspace or np.ndarray

Example

>>> import pumapy as puma
>>> ws_tiff = puma.import_3Dtiff(puma.path_to_example_file("50_artfibers.tif"), 1.3e-6, import_ws=True)
Importing ...
>>> ws_tiff.get_shape()
(50, 50, 50)
pumapy.io.input.import_bin(filename)[source]

Import a pumapy.Workspace to binary (.pumapy extension)

Parameters

filename (string) – filepath and name

Returns

domain

Return type

pumapy.Workspace

Example

>>> import pumapy as puma
>>> ws_binary = puma.import_bin(puma.path_to_example_file("fibers_with_orientation.pumapy"))
Importing ...
pumapy.io.input.import_vti(filename, voxel_length=None, import_ws=True)[source]

Function to import either legacy VTK file (.vtk) or vtkImageData (.vti)

Parameters
  • filename (string) – filepath and name

  • voxel_length (float) – voxel_length. If None, voxel_length from the vtk file is used

  • import_ws (bool) – True returns a puma.Workspace, otherwise a list of ndarrays

Returns

if import_ws is True, then it returns a Workspace. if import_ws is False, it returns a dictionary of ndarrays as {“name1”: data1, “name2”: data2 …}

Return type

pumapy.Workspace or {str: np.ndarray}

Example

>>> import pumapy as puma
>>> ws_vtk = puma.import_vti(puma.path_to_example_file("fibers_with_orientation.vti"))
Importing ...
pumapy.io.input.import_weave_vtu(filename, from_texgen_gui=False)[source]

Import TexGen vtu weave in a Workspace

Parameters
  • filename (string) – file path and name

  • from_texgen_gui (bool) – voxel grid exported from the TexGen GUI (Windows) or from TexGen inside PuMA

Returns

voxelized weave from TexGen

Return type

pumapy.Workspace

pumapy.io.input.io_logs(ws, filename, input=True)[source]

pumapy.io.output

pumapy.io.output.export_3Dtiff(filename, ws_or_nparray, to8bit=True)[source]

Export either a puma.Workspace or numpy array to 3Dtiff

Parameters
  • filename (string) – filepath and name

  • ws_or_nparray (Workspace or ndarray) – to be exported

  • to8bit (bool) – if True, it converts the image to 8bit, otherwise 16bit is exported

Example

>>> import pumapy as puma
>>> ws_tiff = puma.import_3Dtiff(puma.path_to_example_file("50_artfibers.tif"), 1.3e-6, import_ws=True)
Importing ...
>>> puma.export_3Dtiff("50_artfibers.tif", ws_tiff)
Exporting ...
pumapy.io.output.export_bin(filename, ws)[source]

Export a puma.Workspace to binary (.pumapy extension)

Parameters
  • filename (string) – filepath and name

  • ws – to be exported

Type

pumapy.Workspace

Example

>>> import pumapy as puma
>>> ws_binary = puma.import_bin(puma.path_to_example_file("fibers_with_orientation.pumapy"))
Importing ...
>>> puma.export_bin("fibers_with_orientation.vti", ws_binary)
Exporting ...
pumapy.io.output.export_sparta_implicit_surfaces(filename, ws)[source]

Export a puma.Workspace to binary (.pumapy extension)

Parameters
  • filename (string) – filepath and name

  • ws (pumapy.Workspace) – to be exported

pumapy.io.output.export_stl(filename, ws, cutoff, flag_closed_edges=True, flag_gaussian=False, binary=True)[source]

Export a puma.Workspace to STL

Parameters
  • filename (string) – filepath and name

  • ws (pumapy.Workspace) – to be exported

  • cutoff ((int, int)) – specify cutoff to binarize material

  • flag_closed_edges (bool) – close the surface edges on the boundaries

  • flag_gaussian (bool) – apply Gaussian filter before creating surface

Example

>>> import pumapy as puma
>>> ws_imported = puma.import_3Dtiff(puma.path_to_example_file("200_fiberform.tif"), 1.3e-6)
Importing ...
>>> puma.export_stl('200_fiberform', ws_imported, cutoff=(100, 255), flag_closed_edges=True)
Exporting ...
pumapy.io.output.export_vti(filename, dict_data, voxel_length=None)[source]

Export either a puma.Workspace or numpy array to vti

Parameters
  • filename (string) – filepath and name

  • dict_data (dict or Workspace or np.ndarray) – dictionary setup as {“name1”: data1, “name2”: data2 …} containing either Workspaces or ndarrays

  • voxel_length (float) – with voxel length to give to Numpy arrays (if any)

Example

>>> import pumapy as puma
>>> ws_vtk = puma.import_vti(puma.path_to_example_file("fibers_with_orientation.vti"))
Importing ...
>>> puma.export_vti("fibers_with_orientation.vti", ws_vtk)
Exporting ...