nanomesh.metrics๏ƒ

Module to compute cell quality metrics.

Classes:

Metric(metric)

Factory function for metrics using pyvista.

Functions:

calculate_all_metrics(mesh[,ย inplace])

Calculate all available metrics.

histogram(mesh,ย *,ย metric[,ย ax])

Create a mesh plot with the cells are colored by the cell quality.

max_min_edge_ratio(mesh)

Calculate the ratio between the longest and shortest edge lengths of a triangle.

plot2d(mesh,ย *,ย metric[,ย ax])

Create a mesh plot with the cells are colored by the cell quality.

class nanomesh.metrics.Metric(metric: str)[source]

Bases: object

Factory function for metrics using pyvista.

Parameters

metric (str) โ€“ Metric to calculate. For a full list, see pyvista.DataSet.compute_cell_quality().

nanomesh.metrics.calculate_all_metrics(mesh: Mesh, inplace: bool = False) dict[source]

Calculate all available metrics.

Parameters
  • mesh (Mesh) โ€“ Input mesh

  • inplace (bool, optional) โ€“ Updates the Mesh.cell_data attribute on the mesh with the metrics.

Returns

metrics โ€“ Return a dict with all the metrics

Return type

dict

nanomesh.metrics.histogram(mesh: Mesh, *, metric: str, ax: Optional[Axes] = None, **kwargs) Axes[source]

Create a mesh plot with the cells are colored by the cell quality.

Parameters
  • mesh (Mesh) โ€“ Input mesh

  • metric (str) โ€“ Metric to calculate.

  • ax (matplotlib.axes.Axes) โ€“ If specified, ax will be used to create the subplot.

  • vmin (int, float) โ€“ Set the lower/upper boundary for the color value.

  • vmax (int, float) โ€“ Set the lower/upper boundary for the color value.

  • cmap (str) โ€“ Set the color map.

  • **kwargs โ€“ Keyword arguments passed on to matplotlib.pyplot.hist().

Returns

ax

Return type

matplotlib.axes.Axes

nanomesh.metrics.max_min_edge_ratio(mesh: Mesh) ndarray[source]

Calculate the ratio between the longest and shortest edge lengths of a triangle.

Parameters

mesh (Mesh) โ€“ Input mesh

Returns

quality โ€“ Array with cell qualities.

Return type

numpy.ndarray

nanomesh.metrics.plot2d(mesh: Mesh, *, metric: str, ax: Optional[Axes] = None, **kwargs) Axes[source]

Create a mesh plot with the cells are colored by the cell quality.

Parameters
  • mesh (Mesh) โ€“ Input mesh

  • metric (str) โ€“ Metric to calculate.

  • ax (matplotlib.axes.Axes) โ€“ If specified, ax will be used to create the subplot.

  • vmin (int, float) โ€“ Set the lower/upper boundary for the color value. Defaults to the 1st and 99th percentile, respectively.

  • vmax (int, float) โ€“ Set the lower/upper boundary for the color value. Defaults to the 1st and 99th percentile, respectively.

  • cmap (str) โ€“ Set the color map.

  • **kwargs โ€“ Keyword arguments passed on to matplotlib.pyplot.tripcolor().

Returns

ax

Return type

matplotlib.axes.Axes