Divimp module#

lines#

cherab.iter.divimp.lines.power2phot(W_m3, wavelength)#
cherab.iter.divimp.lines.lines(case, labels=None, unit='photon/m3', **kwargs)#
Parameters:
Return type:

ndarray

Read divimp#

class cherab.iter.divimp.read_divimp.TriMask(x, y, simplices)#

Masks redundant triangles in Delaunay triangulation of DIVIMP mesh

Parameters:
  • x (ndarray) – \(X\) coordinates of verticies.

  • y (ndarray) – \(Y\) coordinates of verticies.

  • simplices (NDArray[np.int_]) – Indices of the points forming the simplices in the triangulation, the shape of which is (N, 3)

__call__(feature='perimeter', factor=3.5, factor_div=1.5)#

Creates the mask for redundant triangles. All triangles are compared by their features (perimeter, area or longest edge) with the average value. Triangles with feature > factor * average_feature in the main chamber and feature > factor_div * average_feature in the divertor are considered as redundant.

Parameters:
  • feature (str) – Compare the triangles by their “perimeters”, “areas” or “longestedges”, by default “perimeter”

  • factor (float) – Factor for the main chamber, by default 3.5

  • factor_div (float) – Factor for the divertor, by default 1.5

Returns:

mask array

Return type:

ndarray

cherab.iter.divimp.read_divimp.grind_mesh(ln, r, z, profiles, factor=8, kind='linear')#

Grinds original divimp mesh along the grid lines

Parameters:
  • ln (ndarray) – Grid line numbers

  • r (ndarray) – R coordinates

  • z (ndarray) – Z coordinates

  • profiles (dict[str, numpy.ndarray]) – Plasma profiles

  • factor (int) – Grinding factor. For factor=X, the final mesh is X times denser, by default 8

  • kind (str) – Kind of interpolation (“linear”, “cubic”, etc.) to use along the grid lines for the profiles, by default “linear”. See interp1d document.

Returns:

Refined R, Z coordinate and Plasma profiles on the refined mesh

Return type:

tuple[ndarray, ndarray, dict[str, ndarray]]

cherab.iter.divimp.read_divimp.read_divimp_reg(filename, r, z, profcols={'0': 8, '1': 9}, interp_kind='linear', **kwargs)#

Reads divimp mesh and interpoales it on a regular RZ grid

Parameters:
  • filename (str) – Grid line numbers

  • r (ndarray) – R coordinates of the cell borders of regular grid

  • z (ndarray) – Z coordinates of the cell borders of regular grid

  • profcols (dict[str, int]) – Plasma profile names and respective columns in divimp file

  • interp_kind (str) – Kind of interpolation

  • **kwargsnumpy.loadtxt parameters

Returns:

Plasma profiles on the regular grid (same keys as in profcols)

Return type:

dicct[str, ndarray]

cherab.iter.divimp.read_divimp.divimp_fit_to_3d_wall(data, r, z, zminr=-3.39, zminl=-3.93, zmaxr=(-2.54, -2.51, -2.49, -2.46, -2.42, 2.84, 2.96, 3.77, 3.82, 3.89, 3.96, 4.06, 4.1, 4.13, 4.19), zmaxl=(-3.87, -3.62, -3.34, -3.24, -3.14, -3.04, -3.02), rmax=4.8, rmin=5.35, rshift=(0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.07, 0.06, 0.05, 0.04, 0.03, 0.02, 0.01), lshift=(0.01, 0.02, 0.03, 0.04, 0.03, 0.02, 0.01))#

Use this function only for the data obtained on the extended 2D grid (OSM + DIVIMP).

Read divimp_mesh#

class cherab.iter.divimp.read_divimp_mesh.TriMask(x, y, simplices)#

Masks redundant triangles in Delaunay triangulation of DIVIMP mesh

Parameters:
  • x (ndarray) – \(X\) coordinates of verticies.

  • y (ndarray) – \(Y\) coordinates of verticies.

  • simplices (NDArray[np.int_]) – Indices of the points forming the simplices in the triangulation, the shape of which is (N, 3)

__call__(feature='perimeter', factor=3.5, factor_div=1.5)#

Creates the mask for redundant triangles. All triangles are compared by their features (perimeter, area or longest edge) with the average value. Triangles with feature > factor * average_feature in the main chamber and feature > factor_div * average_feature in the divertor are considered as redundant.

Parameters:
  • feature (str) – Compare the triangles by their “perimeters”, “areas” or “longestedges”, by default “perimeter”

  • factor (float) – Factor for the main chamber, by default 3.5

  • factor_div (float) – Factor for the divertor, by default 1.5

Returns:

mask array

Return type:

ndarray

cherab.iter.divimp.read_divimp_mesh.grind_mesh(ln, r, z, data, factor=8, kind='linear')#

Grinds original divimp mesh along the grid lines

Parameters:
  • ln (ndarray) – Grid line numbers

  • r (ndarray) – R coordinates

  • z (ndarray) – Z coordinates

  • data (ndarray) – Plasma profiles

  • factor (int) – Grinding factor. For factor=X, the final mesh is X times denser, by default 8

  • kind (str) – Kind of interpolation (“linear”, “cubic”, etc.) to use along the grid lines for the profiles, by default “linear”. See interp1d document.

Returns:

Refined R, Z coordinate and Plasma profiles on the refined mesh

Return type:

tuple[ndarray, ndarray, ndarray]

cherab.iter.divimp.read_divimp_mesh.fit_to_3d_wall(data, r, z, zminr=-3.39, zminl=-3.93, zmaxr=(-2.54, -2.51, -2.49, -2.46, -2.42, 2.84, 2.96, 3.77, 3.82, 3.89, 3.96, 4.06, 4.1, 4.13, 4.19), zmaxl=(-3.87, -3.62, -3.34, -3.24, -3.14, -3.04, -3.02), rmax=4.8, rmin=5.35, rshift=(0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.07, 0.06, 0.05, 0.04, 0.03, 0.02, 0.01), lshift=(0.01, 0.02, 0.03, 0.04, 0.03, 0.02, 0.01))#
cherab.iter.divimp.read_divimp_mesh.read_divimp_mesh(case, r, z, labels=None, factor=8, kind='linear', unit='photon/m3', **kwargs)#

Reads divimp mesh and interpoales it on a regular RZ grid

Parameters:
  • case (str) – grid case

  • r (ndarray) – R coordinates of the cell borders of regular grid

  • z (ndarray) – Z coordinates of the cell borders of regular grid

  • labels (Optional[list[str]]) – Plasma profile names that are respective labels in divimp file

  • factor (int) – Grinding factor. For factor=X, the final mesh is X times denser, by default 8

  • kind (str) – Kind of interpolation (“linear”, “cubic”, etc.) to use along the grid lines for the profiles, by default “linear”. See interp1d document.

  • unit (str) – unit of line, by default “photon/m3”

  • **kwargsnumpy.loadtxt parameters

Returns:

Plasma profiles on the regular grid (same keys as in profcols)

Return type:

dict[str, ndarray]