pynbody.transformation.NullTransformation#
- class pynbody.transformation.NullTransformation(f)[source]#
Bases:
Transformation
A transformation that does nothing, provided for convenience where a transformation is expected.
- Attributes:
sim
The simulation to which this transformation applies
Methods
apply
([force])Apply the transformation to the simulation it is associated with.
Apply the inverse of this transformation to a specified simulation.
apply_to
(f)Apply this transformation to a specified simulation.
offset_velocity
(offset)Shift the velocity by the given offset.
revert
()Revert the transformation.
rotate
(matrix[, description])Rotates using a specified matrix.
rotate_x
(angle)Rotates about the current x-axis by 'angle' degrees.
rotate_y
(angle)Rotates about the current y-axis by 'angle' degrees.
rotate_z
(angle)Rotates about the current z-axis by 'angle' degrees.
transform
(matrix)Deprecated alias for
rotate()
.translate
(offset)Translate by the given offset.
- __init__(f)[source]#
Initialise a transformation, and apply it if not explicitly deferred
- Parameters:
f (SimSnap or Transformation) – The simulation or transformation to act on. If a transformation is given, this transformation will be chained to it, i.e. the result will represent the composed transformation.
defer (bool) – If True, the transformation is not applied immediately. Otherwise, as soon as the object is constructed the transformation is applied to the simulation
description (str) – A description of the transformation to be returned from str() and repr()
- apply(force=True)#
Apply the transformation to the simulation it is associated with.
This is either the simulation passed to the constructor or the one passed to the last transformation in the chain. If the transformation has already been applied, a RuntimeError is raised unless force is True, in which case the transformation is applied again.
- Parameters:
force (bool) – If True, the transformation is applied even if it has already been applied. Otherwise, a RuntimeError is raised if the transformation has already been applied.
- Returns:
The simulation after the transformation has been applied
- Return type:
- apply_inverse_to(f)#
Apply the inverse of this transformation to a specified simulation.
Chained transformations are applied recursively.
- apply_to(f: snapshot.SimSnap) snapshot.SimSnap #
Apply this transformation to a specified simulation.
Chained transformations are applied recursively.
- offset_velocity(offset)#
Shift the velocity by the given offset.
Returns a
pynbody.transformation.GenericTranslation
object which can be used as a context manager to ensure that the translation is undone.For more information, see the
pynbody.transformation
documentation.
- revert()#
Revert the transformation. If it has not been applied, a RuntimeError is raised.
- rotate(matrix, description=None)#
Rotates using a specified matrix.
Returns a
pynbody.transformation.GenericTranslation
object which can be used as a context manager to ensure that the translation is undone.For more information, see the
pynbody.transformation
documentation.- Parameters:
matrix (array_like) – The 3x3 orthogonal matrix to rotate by
description (str) – A description of the rotation to be returned from str() and repr()
- rotate_x(angle)#
Rotates about the current x-axis by ‘angle’ degrees.
Returns a
pynbody.transformation.GenericTranslation
object which can be used as a context manager to ensure that the translation is undone.For more information, see the
pynbody.transformation
documentation.
- rotate_y(angle)#
Rotates about the current y-axis by ‘angle’ degrees.
Returns a
pynbody.transformation.GenericTranslation
object which can be used as a context manager to ensure that the translation is undone.For more information, see the
pynbody.transformation
documentation.
- rotate_z(angle)#
Rotates about the current z-axis by ‘angle’ degrees.
Returns a
pynbody.transformation.GenericTranslation
object which can be used as a context manager to ensure that the translation is undone.For more information, see the
pynbody.transformation
documentation.
- property sim: snapshot.SimSnap | None#
The simulation to which this transformation applies
- translate(offset)#
Translate by the given offset.
Returns a
pynbody.transformation.GenericTranslation
object which can be used as a context manager to ensure that the translation is undone.For more information, see the
pynbody.transformation
documentation.