pisces.particles.base.ParticleDataset.offset_particle_velocities#
- ParticleDataset.offset_particle_velocities(offset: unyt_array, groups: list[str] = None)[source]#
Apply a constant offset to particle velocities in specified groups.
The method adds the given offset vector to the particle velocity field. This is the correct way to shift particle coordinates around via translation.
Note
The name of the particle velocity field is assumed to be that specified by the class’s
_VELOCITY_FIELD_NAME
attribute. If your dataset does not have this field, you will need to manually apply the offset to the appropriate field or rename the field.- Parameters:
offset (
unyt.array.unyt_array
) – A vector specifying the velocity offset to apply. Must have units compatible with theparticle_velocity
field(s). The offset may be any 1D array; however, it must match the shape of the particle velocities. Thus, if the particles are in 3D space, the offset must be a 3-element vector.groups (
list
ofstr
, optional) – Names of groups to apply the offset to. If None, all particle groups are used.
- Raises:
ValueError – If offset is not the correct shape.