Skip to content

Commit 04ad882

Browse files
Jammy2211claude
authored andcommitted
docs: precise frame-convention docstrings for rotate_back
Clarify that rotate_back is needed when vector components are expressed in the profile's rotated frame, not unconditionally for all vectors. Document scalar, vector, and spin-2 transformation conventions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a4762d7 commit 04ad882

1 file changed

Lines changed: 28 additions & 7 deletions

File tree

autoarray/structures/decorators/transform.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,40 @@ def convergence_2d_from(self, grid, xp=np, **kwargs): ...
2020
@transform(rotate_back=True)
2121
def deflections_yx_2d_from(self, grid, xp=np, **kwargs): ...
2222
23-
When ``rotate_back=True``, after the decorated function returns its result the decorator automatically
24-
rotates the output vector back from the profile's reference frame to the original observer frame.
25-
This eliminates the need for deflection methods to manually call
26-
``self.rotated_grid_from_reference_frame_from``.
23+
**Frame conventions and rotate_back**
24+
25+
This decorator transforms the input grid into the profile's reference frame (centred on the
26+
profile centre and rotated by its position angle) before calling the decorated function.
27+
28+
For **scalar** quantities (convergence, potential), the returned value is frame-invariant — no
29+
back-rotation is needed, so use ``@transform`` without ``rotate_back``.
30+
31+
For **vector** quantities (e.g. deflection angles), whether back-rotation is needed depends on
32+
which frame the returned components are expressed in:
33+
34+
- If the function computes vector components using the rotated grid coordinates (i.e. the
35+
components are expressed in the profile's frame), they must be rotated back to the observer
36+
frame before use in ray-tracing. Set ``rotate_back=True`` for this case.
37+
38+
- If the function reconstructs observer-frame components from scalar quantities (e.g. computing
39+
a radial deflection magnitude and converting to Cartesian using observer-frame geometry), the
40+
result is already in the observer frame and ``rotate_back`` should remain ``False``.
41+
42+
When ``rotate_back=True``, the decorator calls ``obj.rotated_grid_from_reference_frame_from``
43+
on the result after evaluation, applying the inverse rotation by the profile's position angle.
44+
45+
For **spin-2** quantities (shear), the transformation law uses twice the profile angle. This
46+
is not handled by ``rotate_back`` — shear methods must apply the 2-theta rotation manually.
2747
2848
Parameters
2949
----------
3050
func
3151
A function where the input grid is the grid whose coordinates are transformed.
3252
rotate_back
33-
If ``True``, the result is rotated back from the profile's reference frame after evaluation.
34-
Use this for functions that return vector quantities (e.g. deflection angles) computed in the
35-
profile's rotated frame.
53+
If ``True``, the result is rotated back from the profile's reference frame after
54+
evaluation. Use this when the decorated function returns vector components that were
55+
computed in the profile's rotated coordinate basis and need to be expressed in the
56+
original observer frame.
3657
3758
Returns
3859
-------

0 commit comments

Comments
 (0)