Datasets

Note

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

Datasets, as a protocol, are mutable containers with the base type of DatasetType. The mutability arises naturally from the need of allowing data to be appended, e.g. a dataset which contain similar information, but at a different time. In addition to it, datasets have the possibility to interact with backends to obtain required data.

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

Bases: typing_extensions.Protocol

Base protocol for datasets.

Each dataset has one private attribute which stores the information about available backends and the possibility of storing/removing backends to the backend store.

_backends: AbstractSet[nata.types.BackendType]

Storage of available backends for a dataset.

To interact with the dataset store, each dataset has to provide the following class methods:

classmethod DatasetType.add_backend(backend: nata.types.BackendType)None

Attach a new backend to backend store.

Parameters

backend (BackendType) – Backend which will be stored in _backends.

classmethod DatasetType.remove_backend(backend: nata.types.BackendType)None

Remove an attached backend from backend store.

Parameters

backend (BackendType) – Backend which will be removed from _backends.

classmethod DatasetType.is_valid_backend(backend: nata.types.BackendType)bool

Checks if a backend is a valid backend for a dataset.

Parameters

backend (BackendType) – Backend which will be checked if it is a valid backend for a dataset.

Returns

out (bool) – True if a backend is a valid backend for a Dataset and False otherwise.

classmethod DatasetType.get_backends() → Dict[str, nata.types.BackendType]

Obtain information over stored backends.

Returns a dict with information of the stored backends inside a dataset. The keys are of type str and are the names of the backends. The values of the dictionary are the backends BackendType.

Next to having a tight connection to backends, datasets provide a way of interacting with other datasets, especially with similar datasets. For this, two methods are part the DatasetType protocol.

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

Checks for equivalence of two datasets.

Parameters

other (DatasetType) – The other dataset which will be checked.

Returns

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

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

Appends another dataset.

Parameters

other (DatasetType) – The other dataset which will be appended.

Datasets for grids

GridDatasetType extends the DatasetType protocol to include additional information for grids.

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

Bases: nata.types.DatasetType, typing_extensions.Protocol

Base protocol for GridDatasets.

Extends DatasetType to include additional information for grids.

name: str

Name of the grid dataset. It has to be identifiable, e.g. "some_grid_name".

label: str

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

unit: str

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

axes: nata.types.GridDatasetAxes

Axes for GridDatasetType. It is a dictionary of type GridDatasetAxes.

grid_shape: Tuple[int, ]

Shape of the grid. The grid shape corresponds to the underlaying grid and does not include temporal infortions.

Datasets for particles

ParticleDatasetType extends the DatasetType protocol to include additional information for grids.

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

Bases: nata.types.DatasetType, typing_extensions.Protocol

Base protocol for ParticleDatasets.

Extends DatasetType to include additional information for particles.

name: str

Name of the particle dataset. It has to be identifiable, e.g. "some_particle_species_name".

quantities: Mapping[str, nata.types.QuantityType]

Mapping storing information about stored quantaties. Keys represent are names for quantities and values are Store

axes: nata.types.ParticleDatasetAxes

Axes for ParticleDatasetType. It is a dictionary of type ParticleDatasetAxes.

Particle datasets are in general containers which store particle quantities which follow the QuantityType protocol.

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

Bases: typing_extensions.Protocol

Base protocol for particle quantities.

name: str

Name of the quantity. It has to be identifiable, e.g. "some_quantity_name".

label: str

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

unit: str

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

Particle quantities following the QuantityType protocol have in addition methods to append more data to them.

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

Checks for equivalence of two particle quantaties.

Parameters

other (QuantityType) – The other particle quantity which will be checked.

Returns

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

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

Appends another a particle quantity.

Parameters

other (QuantityType) – The other quantity which will be appended.