pisces.particles.base.ParticleDataset.offset_particle_positions#

ParticleDataset.offset_particle_positions(offset: unyt_array, groups: list[str] = None)[source]#

Apply a constant offset to particle positions in specified groups.

The method adds the given offset vector to the particle position field. This is the correct way to shift particle coordinates around via translation.

Note

The name of the particle position field is assumed to be that specified by the class’s _POSITION_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 offset to apply. Must have units compatible with the particle_position field(s). The offset may be any 1D array; however, it must match the shape of the particle positions. Thus, if the particles are in 3D space, the offset must be a 3-element vector.

  • groups (list of str, optional) – Names of groups to apply the offset to. If None, all particle groups are used.

Raises:

ValueError – If offset is not a 3-element vector.

Notes

To ensure that this method functions properly across subclasses with various naming conventions, we require that the position field be named according to the class attribute _POSITION_FIELD_NAME. Subclasses may change this attribute to match a particular naming convention.