Grid#

class cherab.lhd.emc3.grid.Grid(zone: str, dataset: str = 'emc3/grid-360.nc', grid_file: str | Path | None = None, **kwargs)Source#

Bases: object

Class for dealing with grid coordinates defined by EMC3-EIRENE.

This class handles originally defined EMC3-EIRENE grid coordinates in \((R, Z)\), and offers methods to produce cell vertices in \((X, Y, Z)\) coordinates and their indices, which a cell means a cubic-like mesh with 8 vertices. Using these data, procedure of generating a TetraMeshData instance is also implemented.

Total number of grids coordinates is L x M x N, each letter of which means:
L: Radial grid resolution
M: Poloidal grid resolution
N: Toroidal grid resolution.
Parameters:
zone{“zone0”, …, “zone21”}

Name of grid zone. Users can select only one option of "zone0" - "zone21".

datasetstr, optional

Name of dataset, by default "emc3/grid-360.nc".

grid_filePath | str | None, optional

Path to the grid file. If specified, the grid dataset is loaded from the file preferentially. Otherwise, the grid file is fetched from the repository.

**kwargs

Keyword arguments to pass to fetch_file.

Examples

>>> grid = Grid("zone0")
>>> grid
Grid(zone='zone0', dataset='/path/to/cache/cherab/lhd/emc3/grid-360.nc')
>>> str(grid)
'Grid for (zone: zone0, L: 82, M: 601, N: 37, number of cells: 1749600)'

Methods

__getitem__(key)

Return grid coordinates indexed by (l, m, n, RZ).

generate_cell_indices()

Generate cell indices array.

generate_vertices()

Generate grid vertices array.

plot([fig, ax, n_phi, rz_range, show_phi, ...])

Plotting EMC3-EIRENE-defined grids in \(R–Z\) plane.

plot_coarse(**kwargs)

Plotting EMC-EIRENE-defined coarse grids in \(R–Z\) plane.

plot_outline([phi, fig, ax, show_phi])

Plotting EMC3-EIRENE-defined grid outline in \(R–Z\) plane.

Attributes

data_array

DataArray instance.

grid_data

Raw Grid coordinates data array.

path

Path to dataset.

shape

Shape of grid (L, M, N).

zone

Name of zone.