Axes

Note

This section characterizes protocols for axes. The purpose of a protocol is to provide support for nominal and structural subtyping.

Axis protocols

One essential building block for datasets like GridDatasetType and ParticleDatasetType are AxisType and GridAxisType. Similar to datasets, protocols are in place to provide available attributes.

class nata.types.AxisType(*args, **kwds)

Bases: typing_extensions.Protocol

Base protocol for an axis.

name: str

Name of the axis. It has to be identifiable, e.g. "some_axis_name".

label: str

Descriptive label of the axis. Can be an arbitrary string, e.g. "some long label for an axis".

unit: str

Unit of the correspinding axis. Can be an string including some latex symbols, e.g. "m_e c \\omega_p e^{-1}".

axis_dim: int

Dimensionality of an axis.

In addition, AxisType provides methods to check for equivalence between axes and to append another axis.

AxisType.equivalent(other: nata.types.AxisType)bool

Checks for equivalence of two axes.

Parameters

other (AxisType) – The other axis which will be checked.

Returns

out (bool) – Returns True if an instance of a is equivalent with another particle quantity, False otherwise.

AxisType.append(other: nata.types.AxisType)None

Appends another axis.

Parameters

other (AxisType) – The other axis which will be appended.

As grid axes provide uniformity for each dimension of a grid, the GridAxisType extends AxisType.

class nata.types.GridAxisType(*args, **kwds)

Bases: nata.types.AxisType, typing_extensions.Protocol

axis_type: str

Axis type of a grid axis.

Axes container

Axes serve the purpose of providing meta information for DatasetType and are in general occurring in a combination with other axes. For this, two special purpose axes container exist, GridDatasetAxes and ParticleDatasetAxes.

class nata.types.GridDatasetAxes(**kwargs)

Bases: dict

Typed dictionary containing axes for grid datasets.

Typed dictionary typing.TypedDict which correspond to a dict at runtime are merely there for type checking. The attributes correspond to required keys inside a dictionary.

iteration: Optional[nata.types.AxisType]

Axis to store iteration information.

time: Optional[nata.types.AxisType]

Axis to store time information.

grid_axes: Sequence[nata.types.GridAxisType]

Sequence of GridAxisType representing an axis for each grid dimension.

class nata.types.ParticleDatasetAxes(**kwargs)

Bases: dict

Typed dictionary containing axes for particle datasets.

Typed dictionary typing.TypedDict which correspond to a dict at runtime are merely there for type checking. The attributes correspond to required keys inside a dictionary.

iteration: Optional[nata.types.AxisType]

Axis to store iteration information.

time: Optional[nata.types.AxisType]

Axis to store time information.