pumapy.visualization

pumapy.visualization.render

class pumapy.visualization.render.Renderer(existing_plot, filter_type, workspace, cutoff, solid_color, style, origin, window_size, opacity, background, show_grid, plot_directly, show_axes, show_outline, cmap, scale_factor, notebook)[source]

Bases: object

build_plotter()[source]
render()[source]
pumapy.visualization.render.render_contour(workspace, cutoff, solid_color=(1.0, 1.0, 1.0), style='surface', origin=(0.0, 0.0, 0.0), window_size=(1920, 1200), opacity=1.0, background=(0.3, 0.3, 0.3), show_grid=True, plot_directly=True, show_axes=True, show_outline=True, add_to_plot=None, notebook=False)[source]

Contour render using Pyvista Contour filter

Parameters
  • workspace (Workspace or ndarray) – domain

  • cutoff (tuple(int, int)) – specifying the values at which the isosurface is created

  • solid_color (tuple(float, float, float), optional) – a solid color to color the surface (e.g. for white (1., 1., 1.))

  • style (string, optional) – specifying the representation style (‘surface’, ‘edges’, ‘wireframe’, ‘points’)

  • origin (tuple(float, float, float), optional) – origin of the data as

  • window_size (tuple(int, int), optional) – with the popup window size

  • opacity (float, optional) – opacity of contour

  • background – color of the background from (0., 0., 0.) (black) to (1., 1., 1.) (white)

  • show_grid (bool, optional) – show the grid with the size of the sides

  • plot_directly (bool, optional) – whether to return a Plotter object (to make further changes to it) or show the plot directly

  • show_axes (bool, optional) – show orientation axis in the bottom left corner

  • show_outline (bool, optional) – show the bounding box outline of the domain

  • add_to_plot (pyvista.Plotter, optional) – pass an already existing plotter object to add on top of this plot

  • notebook (bool, optional) – plotting interactively in a jupyter notebook (overwrites show_grid to False)

Type

background: tuple(float, float, float)

Returns

None is plot_directly is True, otherwise a plotter object

Return type

pyvista.Plotter object or None

Example

>>> import pumapy as puma
>>> ws_contour = puma.import_3Dtiff(puma.path_to_example_file("50_artfibers.tif"))
>>> puma.render_contour(ws_contour, (128,255))
pumapy.visualization.render.render_contour_multiphase(workspace, cutoffs, solid_colors=None, style='surface', origin=(0.0, 0.0, 0.0), window_size=(1920, 1200), opacity=1.0, background=(0.3, 0.3, 0.3), show_grid=True, plot_directly=True, show_axes=True, show_outline=True, add_to_plot=None, notebook=False)[source]

Contour render for multi-phase materials using Pyvista

Parameters
  • workspace (Workspace or ndarray) – domain

  • cutoffs (tuple(tuple(int, int), tuple(int, int) ..)) – n cutoffs is the number of materials. specifies the low and high cutoff ranges

  • solid_colors (tuple(tuple(float, float, float), tuple(float, float, float) ..), optional) – solid colors to color the different phases’ surface e.g. for white ((1., 1., 1.), (0., 0., 0.), …)

  • style (string, optional) – specifying the representation style (‘surface’, ‘edges’, ‘wireframe’, ‘points’)

  • origin (tuple(float, float, float), optional) – origin of the data as

  • window_size (tuple(int, int), optional) – with the popup window size

  • opacity (float, optional) – opacity of contour

  • background – color of the background from (0., 0., 0.) (black) to (1., 1., 1.) (white)

  • show_grid (bool, optional) – show the grid with the size of the sides

  • plot_directly (bool, optional) – whether to return a Plotter object (to make further changes to it) or show the plot directly

  • show_axes (bool, optional) – show orientation axis in the bottom left corner

  • show_outline (bool, optional) – show the bounding box outline of the domain

  • add_to_plot (pyvista.Plotter, optional) – pass an already existing plotter object to add on top of this plot

  • notebook (bool, optional) – plotting interactively in a jupyter notebook (overwrites show_grid to False)

Type

background: tuple(float, float, float)

Returns

None is plot_directly is True, otherwise a plotter object

Return type

pyvista.Plotter object or None

>>> import pumapy as puma
>>> ws_multiphase = puma.import_3Dtiff(puma.path_to_example_file("100_fiberform.tif"), 1.3e-6)
>>> puma.render_contour_multiphase(ws_multiphase, ((100, 150), (150, 255)))
pumapy.visualization.render.render_orientation(workspace, scale_factor=1.0, solid_color=(1.0, 1.0, 1.0), style='surface', origin=(0.0, 0.0, 0.0), window_size=(1920, 1200), opacity=1.0, background=(0.3, 0.3, 0.3), show_grid=True, plot_directly=True, show_axes=True, show_outline=True, add_to_plot=None, notebook=False)[source]

Orientation render using Pyvista Glyph filter

Parameters
  • workspace (Workspace or ndarray) – domain

  • scale_factor (float) – scale the arrows by a factor

  • solid_color (tuple(float, float, float), optional) – a solid color to color the surface (e.g. for white (1., 1., 1.))

  • style (string, optional) – specifying the representation style (‘surface’, ‘edges’, ‘wireframe’, ‘points’)

  • origin (tuple(float, float, float), optional) – origin of the data as

  • window_size (tuple(int, int), optional) – with the popup window size

  • opacity (float, optional) – opacity of arrows

  • background – color of the background from (0., 0., 0.) (black) to (1., 1., 1.) (white)

  • show_grid (bool, optional) – show the grid with the size of the sides

  • plot_directly (bool, optional) – whether to return a Plotter object (to make further changes to it) or show the plot directly

  • show_axes (bool, optional) – show orientation axis in the bottom left corner

  • show_outline (bool, optional) – show the bounding box outline of the domain

  • add_to_plot (pyvista.Plotter, optional) – pass an already existing plotter object to add on top of this plot

  • notebook (bool, optional) – plotting interactively in a jupyter notebook (overwrites show_grid to False)

Type

background: tuple(float, float, float)

Returns

None is plot_directly is True, otherwise a plotter object

Return type

pyvista.Plotter object or None

Example

>>> import pumapy as puma
>>> ws_orientation = puma.import_3Dtiff(puma.path_to_example_file("100_fiberform.tif"), 1.3e-6)
>>> puma.compute_orientation_st(ws_orientation, 0.7, 1.4, (90, 255))
>>> puma.render_orientation(ws_orientation)
pumapy.visualization.render.render_volume(workspace, cutoff=None, solid_color=(1.0, 1.0, 1.0), style='surface', origin=(0.0, 0.0, 0.0), window_size=(1920, 1200), opacity=1.0, background=(0.3, 0.3, 0.3), show_grid=True, plot_directly=True, show_axes=True, show_outline=True, cmap='gray', add_to_plot=None, notebook=False)[source]

Volume render using Pyvista Threshold filter

Parameters
  • workspace (Workspace or ndarray) – domain

  • cutoff (tuple(int, int), optional) – specifying the values to render

  • solid_color (tuple(float, float, float), optional) – if set to None, the material is colored by the matrix’s values. Otherwise, a solid color can be specified (e.g. for white (1., 1., 1.))

  • style (string, optional) – specifying the representation style (‘surface’, ‘edges’, ‘wireframe’, ‘points’)

  • origin (tuple(float, float, float), optional) – origin of the data as

  • window_size (tuple(int, int), optional) – with the popup window size

  • opacity (float, optional) – opacity of volume

  • background – color of the background from (0., 0., 0.) (black) to (1., 1., 1.) (white)

  • show_grid (bool, optional) – show the grid with the size of the sides

  • plot_directly (bool, optional) – whether to return a Plotter object (to make further changes to it) or show the plot directly

  • show_axes (bool, optional) – show orientation axis in the bottom left corner

  • show_outline (bool, optional) – show the bounding box outline of the domain

  • cmap (str, optional) – matplotlib colormap to use (overwritten by solid_color if specified)

  • add_to_plot (pyvista.Plotter, optional) – pass an already existing plotter object to add on top of this plot

  • notebook (bool, optional) – plotting interactively in a jupyter notebook (overwrites show_grid to False)

Type

background: tuple(float, float, float)

Returns

None is plot_directly is True, otherwise a plotter object

Return type

pyvista.Plotter object or None

:Example >>> import pumapy as puma >>> ws_volume = puma.import_3Dtiff(puma.path_to_example_file(“200_fiberform.tif”), 1.3e-6) >>> puma.render_volume(ws_volume)

pumapy.visualization.slicer

class pumapy.visualization.slicer.CompareSlicer(img1, img2, slice_direction, color_range1, color_map1, color_range2, color_map2, index, axis_labels, slices1, slices2, rows1, cols1, rows2, cols2)[source]

Bases: pumapy.visualization.slicer.IndexTracker

update()[source]
class pumapy.visualization.slicer.IndexTracker(img, img2, slice_direction, index, axis_labels, slices, slices_titles)[source]

Bases: object

static error_checks(img, img2, slice_direction)[source]
static format_coord(x, y)[source]
onkey(event)[source]
onscroll(event)[source]
static rotate_domain_mpl(img, slice_direction)[source]
update()[source]
class pumapy.visualization.slicer.PlotSlicer(img, slice_direction, color_range, color_map, index, axis_labels, slices, rows, cols)[source]

Bases: pumapy.visualization.slicer.IndexTracker

update()[source]
pumapy.visualization.slicer.compare_slices(ws_nparray1, ws_nparray2, slice_direction='z', crange1=None, cmap1='gray', crange2=None, cmap2='gray', index=1)[source]

Plot slices of domain along a specified direction (z default)

Parameters
  • ws_nparray1 (Workspace or ndarray) – domain

  • ws_nparray2 (Workspace or ndarray) – domain

  • slice_direction (string) – ‘x’, ‘y’, ‘z’

  • crange1 (tuple(int, int)) – color range for plot 1, specify min and max grayscale

  • cmap1 (string) – color map for plot 1, ‘gray’ (default), ‘jet’ or refer to matplotlib for other colormaps

  • crange2 (tuple(int, int)) – color range for plot 2, specify min and max grayscale

  • cmap2 (string) – color map for plot 2, ‘gray’ (default), ‘jet’ or refer to matplotlib for other colormaps

  • index (int) – specifying the slice index in which the plot will be opened

Returns

slicer object

Return type

CompareSlicer

>>> import pumapy as puma
>>> ws = puma.import_3Dtiff(puma.path_to_example_file("100_fiberform.tif"), 1.3e-6)
>>> ws2 = ws.copy()
>>> ws2.binarize_range((100, 255))
>>> puma.compare_slices(ws, ws2)
pumapy.visualization.slicer.plot_slices(ws_nparray, slice_direction='z', crange=None, cmap='gray', index=1)[source]

Plot slices of domain along a specified direction (z default)

Parameters
  • ws_nparray (Workspace or ndarray) – domain

  • slice_direction (string) – ‘x’, ‘y’, ‘z’

  • crange (tuple(int, int)) – color range, i.e. specify min and max grayscale

  • cmap (string) – color map for the plot, ‘gray’ (default), ‘jet’ or refer to matplotlib for other colormaps

  • index – specifying the slice index in which the plot will be opened

Type

int

Returns

slicer object

Return type

PlotSlicer

>>> import pumapy as puma
>>> ws = puma.import_3Dtiff(puma.path_to_example_file("100_fiberform.tif"), 1.3e-6)
>>> puma.plot_slices(ws)