pisces.particles.base.ParticleDataset.reduce_group#

ParticleDataset.reduce_group(group_name: str, mask: ndarray | unyt_array)[source]#

Reduce a particle group by applying a boolean mask.

This method filters all fields in the specified group by the given mask, retaining only those particles where the mask is True. All other particles are discarded. The group’s NUMBER_OF_PARTICLES attribute is updated accordingly.

This is a destructive operation.

Parameters:
  • group_name (str) – Name of the particle group to apply the mask to.

  • mask (array_like of bool) – Boolean array of shape (N,) where N is the number of particles in the group. Must be 1D and have exactly one element per particle.

Raises:
  • KeyError – If the specified group does not exist.

  • ValueError – If the mask has an incorrect shape or is not boolean.