Derivative#

class cherab.inversion.derivative.Derivative(grid, grid_map=None)Source#

Bases: object

Class for derivative matrices.

This class is used to generate various derivative matrices using grid coordinates information.

Derivative matrices are applied to spatial profiles defined on the grid coordinates (cartesian, cylindrical, etc.) and are created with their grid coordinates.

Parameters:
grid(…, L, M, ndim) or (N, ), array_like

The grid coordinates. The shape of the array means the resolution of the grid. For example, in 3-D spatial grid, the shape is (L, M, N, 3), where 3 is the dimension of the grid. If the grid is 1-D like (N,), it is automatically reshaped to (N, 1).

grid_map(…, L, M) array_like, optional

The map of the grid index with int type. The shape of the array must be the same as the grid shape except for the last dimension. The masked area is represented by negative values. If None, the grid_map is automatically created by the order of the grid array.

Examples

>>> import numpy as np
>>> from cherab.inversion import Derivative
>>> x = np.linspace(-10, 10, 21)
>>> derivative = Derivative(x)
>>> derivative
Derivative(grid=array(21, 1), grid_map=array(21,))

Methods

matrix_along_axis(axis[, diff_type, boundary])

Derivative matrix along the specified axis.

matrix_gradient(func[, diagonal])

Derivative matrices based on the gradient of the given function.

Attributes

grid

The grid coordinates.

grid_map

The map of the grid index.