`SkyOffsetFrame` transformations do not account for frame attributes
- Dominant language
- Python
- Stars
- 5.3k
- Forks
- 2.2k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 75
Description
Transforming a `SkyOffsetFrame` instance based on a frame with a frame attribute (e.g., `HCRS`) can produce the wrong result when the frame attribute is not the same across the transformation. That's because the `SkyOffsetFrame` transformations (e.g., `SkyOffsetHCRS`->`HCRS`) fail to check whether the target frame is equivalent to `origin` (e.g., that `obstime` is the same value).
```python
>>> import astropy.units as u
>>> from astropy.coordinates import HCRS, SkyCoord, SkyOffsetFrame
>>> hcrs1 = HCRS(obstime='2000-01-01')
>>> hcrs2 = HCRS(obstime='2025-01-01')
>>> origin = SkyCoord(20*u.deg, 30*u.deg, 1*u.AU, frame=hcrs1)
# Define an offset coordinate that isn't actually offset
>>> coord = SkyCoord(0*u.deg, 0*u.deg, 1*u.AU, frame=SkyOffsetFrame(origin=origin, rotation=45*u.deg))
# The transformation back to the origin coordinate frame gives the expected answer
>>> coord.transform_to(hcrs1)
# The transformation to a non-equivalent frame of the same type gives the wrong answer
>>> coord.transform_to(hcrs2)
# By manually working around the bugged transformation, we can get the correct answer
>>> coord.transform_to(hcrs1).transform_to(hcrs2)
```
The `SkyOffsetFrame` transformations cannot be simple `DynamicMatrixTransform` functions, but instead must call loopback transformations (e.g., `HCRS`->`HCRS`) as needed.
Contributor guide
Research direction
Start by reproducing the HCRS/SkyOffsetFrame example in the issue, comparing direct transformation to the two-step HCRS transformation. Inspect the SkyOffsetFrame transformations and their HCRS-to-HCRS loopback behavior; done means equivalent frames preserve the existing result while differing frame attributes produce the corrected transformed coordinates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100