pynbody.transformation#
Module for describing, applying and reverting Galilean transformations on simulations.
Generally it is not necessary to access this module directly, but it is used by
SimSnap
class to implement e.g.
rotate_x()
etc, and also by analysis
transformations such as center()
and
faceon()
etc.
The main feature of this module is the Transformation
class, which performs
transformations of various kinds on simulations then reverts them. You can use these objects
as context managers, which means you can write code like this:
>>> with f.translate(fshift) :
>>> print(f['pos'][0])
which is equivalent to
>>> try:
>>> f['pos']+=shift
>>> print(f['pos'][0])
>>> finally:
>>> f['pos']-=shift
You can also chain transformations together, like this:
>>> with f.translate(fshift).rotate_x(45):
>>> print(f['pos'][0])
This implies a translation followed by a rotation. When reverting the transformation, they are of course undone in the opposite order.
Functions
|
Deprecated alias for |
|
Deprecated alias for |
|
Deprecated alias for |
|
Deprecated alias for |
|
Deprecated alias for |
|
Deprecated alias for |
|
Deprecated alias for |
|
Deprecated alias for |
Classes
alias of |
|
|
A translation on a specified array of a simulation |
A transformation that does nothing, provided for convenience where a transformation is expected. |
|
|
A rotation on all 3d vectors in a simulation, by a given orthogonal 3x3 matrix |
A mixin class for objects that can generate a Transformation object |
|
|
The base class for all transformations. |