Filter

nata.containers.ParticleDataset.filter(dataset: nata.containers.ParticleDataset, mask: List[bool] = None, quantities: List[str] = None, slicing: slice = None) → nata.containers.ParticleDataset

Filters a nata.containers.ParticleDataset according to a selection of quantities.

Parameters
  • mask (np.ndarray, optional) – Array of booleans indicating the particles to be filtered. Particles with True (False) mask entries are selected (hidden). The shape of mask must match that of each particle quantity.

  • slicing (slice, optional) – Slice of particles to be filtered. Acts only on particle indices and not on time, as time slicing should be done on the dataset. When provided together with the mask argument, slicing is done on the masked array.

  • quantities (list, optional) – List of quantities to be filtered, ordered by the way they should be sorted in the returned dataset.

Returns

nata.containers.ParticleDataset – Filtered dataset with only the quantities selected in quantities.

Examples

The filter plugin is used to get dataset with only a selection, say 'x1' and 'x2', of its quantities.

>>> from nata.containers import ParticleDataset
>>> ds = ParticleDataset("path/to"file")
>>> ds_flt = ds.filter(quantities=["x1","p1"])