pencil.visu.pv_plotter_utils

See pv_plotter.py docstring!

Functions

plotPreview(→ None)

Routine for interactive plot preview window showing the camera parameters.

randomSampleMeshPoints(n, mesh[, set_seed_1, ...])

Returns randomly (uniformly) sampled points from the given mesh,

randomSampleMesh(n, mesh)

PROBLEM: random samples individual cells which consists of 9 points. Hence ends up being

getCameraParamsRounded(→ tuple)

Returns camera parameters rounded to given precision.

gridFromCylCoords(→ pyvista.StructuredGrid)

cellBounds(→ numpy.ndarray)

Calculate coordinate cell boundaries.

create_sbar_args(settings, title, posx, posy)

Small convenience function to remove duplicate code. Combines all scalarbar

Module Contents

pencil.visu.pv_plotter_utils.plotPreview(plotter) None

Routine for interactive plot preview window showing the camera parameters. :param plotter: Instance of pv.Plotter :type plotter: pv.Plotter :param window_size: Windows size [width, height], by default None :type window_size: list, optional

Notes

Last updated: 18.6.2021

pencil.visu.pv_plotter_utils.randomSampleMeshPoints(n, mesh, set_seed_1=False, constant_seed=False, get_arrays=False, seed=None)

Returns randomly (uniformly) sampled points from the given mesh, i.e. a subset of mesh.points

Parameters:
  • n (int) – Number of points to choose from the mesh

  • mesh – Pyvista mesh

  • set_seed_1 (bool, optional) – If set_seed_1 set to True, sets seed used by the random generator to 1, i.e. each time.time this is called with the same mesh, function would return the same points. For debugging purposes. By default False

  • get_arrays (bool, optional) – If True, also samples all the point arrays that the given mesh contains, and adds them to the returned pyvista.PolyData

Returns:

Set of n randomly sampled points from the given mesh.

Return type:

pyvista.PolyData

pencil.visu.pv_plotter_utils.randomSampleMesh(n, mesh)

PROBLEM: random samples individual cells which consists of 9 points. Hence ends up being individual cells all around the plot each having 9 streamlines

pencil.visu.pv_plotter_utils.getCameraParamsRounded(plotter: pyvista.Plotter, precision=3) tuple

Returns camera parameters rounded to given precision. :param plotter: Instance of pv.Plotter :type plotter: pv.Plotter :param precision: Precision to round to, by default 3 :type precision: int, optional

Returns:

(camera_centre, focal_point, view_up)

Return type:

tuple

Notes

Last updated: 18.6.2021

pencil.visu.pv_plotter_utils.gridFromCylCoords(r, theta, z) pyvista.StructuredGrid

” Create PyVista StructuredGrid out of cylinder coordinates. :param r: Radial distances :type r: numpy.ndarray :param theta: Polar angles (in radians) :type theta: numpy.ndarray :param z: Z-coordinates (heights) :type z: numpy.ndarray

Returns:

Mesh given the coordinates

Return type:

pyvista.StructuredGrid

Notes

Last updated: 18.6.2021

pencil.visu.pv_plotter_utils.cellBounds(points, bound_position=0.5) numpy.ndarray

Calculate coordinate cell boundaries. :param points: One-dimensional array of uniformly spaced values of shape (M,) :type points: numpy.array :param bound_position: The desired position of the bounds relative to the position

of the points.

Returns:

bounds – Array of shape (M+1,)

Return type:

numpy.array

Examples

>>> a = np.arange(-1, 2.5, 0.5)
>>> a
array([-1. , -0.5,  0. ,  0.5,  1. ,  1.5,  2. ])
>>> cell_bounds(a)
array([-1.25, -0.75, -0.25,  0.25,  0.75,  1.25,  1.75,  2.25])
pencil.visu.pv_plotter_utils.create_sbar_args(settings, title, posx, posy)

Small convenience function to remove duplicate code. Combines all scalarbar arguments into one dictionary. Note that PlotSettings __post_init__ creates _sbar_args but it is still missing parameters that depend on whether one is showing field (stream | vectors) or scalars.