pisces.particles.base.ParticleDataset.extend_group#
- ParticleDataset.extend_group(group_name: str, num_particles: int, fields: dict[str, ndarray | unyt_array] = None)[source]#
Extend a particle group by adding new particles and updating all fields.
This method appends num_particles new entries to each existing field in the group. For fields provided in the fields dictionary, the new particle values are appended. For fields not provided, the new values are filled with NaN (if supported).
The group’s
NUMBER_OF_PARTICLES
attribute is updated accordingly.- Parameters:
group_name (
str
) – The name of the group to extend.num_particles (
int
) – The number of new particles to append to the group.fields (
dict
, optional) – A dictionary mapping field names to new particle data arrays of shape (num_particles, …) to append. Any fields not specified here will be extended with NaN fill values if their dtype supports it.
- Raises:
KeyError – If the specified group does not exist.
ValueError – If the new data for any field has incompatible shape.
TypeError – If an existing field cannot be filled with NaNs and no new data is provided.