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.ProtocolBase 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) –Trueif a backend is a valid backend for a Dataset andFalseotherwise.
-
classmethod
DatasetType.get_backends() → Dict[str, nata.types.BackendType]¶ Obtain information over stored backends.
Returns a
dictwith information of the stored backends inside a dataset. The keys are of typestrand are the names of the backends. The values of the dictionary are the backendsBackendType.
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) – ReturnsTrueif an instance of a datasets is equivalent with another datasets,Falseotherwise.
-
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.ProtocolBase protocol for GridDatasets.
Extends
DatasetTypeto include additional information for grids.-
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 typeGridDatasetAxes.
-
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.ProtocolBase protocol for ParticleDatasets.
Extends
DatasetTypeto 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 typeParticleDatasetAxes.
-
Particle datasets are in general containers which store particle quantities
which follow the QuantityType protocol.
-
class
nata.types.QuantityType(*args, **kwds)¶ Bases:
typing_extensions.ProtocolBase protocol for particle quantities.
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) – ReturnsTrueif an instance of a particle quantity is equivalent with another particle quantity,Falseotherwise.
-
QuantityType.append(other: nata.types.QuantityType) → None¶ Appends another a particle quantity.
- Parameters
other (
QuantityType) – The other quantity which will be appended.