triangulate#

cherab.lhd.emc3.indices.triangulate(grid: Grid, phi: float | None = None, n_phi: int = 0, index_type: Literal['cell', 'physics', 'coarse'] = 'coarse')Source#

Triangulate grid data at a specific toroidal angle.

This method returns vertices and triangles at ploidal plane (R-Z plane) at a specific toroidal angle. The grid is interpolated linearly between two nearest toroidal angles if specifying arbitrary toroidal angle phi. Also, indices of triangles are returned according to the index type.

Parameters:
gridGrid

Grid object.

phifloat, optional

Toroidal angle in [degree], by default None. If specified, the grid is interpolated linearly and prioritized over n_phi.

n_phiint, optional

Index of toroidal angle, by default 0. If specified, the grid is not interpolated and used as is.

index_type{“cell”, “physics”, “coarse”}, optional

Index type, by default “coarse”.

Returns:
verts(N, 2) ndarray

Vertices at poloidal plane. N is the number of vertices.

tri(M, 3) ndarray

Triangles at poloidal plane. M is the number of triangles.

indices(M,) ndarray

Indices of triangles.

Examples

>>> grid = Grid("zone0")
>>> verts, tris, indices = triangulate(grid, phi=4.2)
>>> verts.shape
(55200, 2)
>>> tri.shape
(48600, 3)
>>> indices.shape
(48600,)