RadioAstronomySoftwareGroup / RadioAstronomySoftwareGroup/pyuvdata
RA wrapping in `interpolate_ephem`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 102
- Forks
- 35
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 14
Description
Problem
interpolate_ephem interpolates ephem_ra directly. A track crossing RA of 0 is stored wrapped into [0, 2pi), so the samples contain a 2pi jump that the interpolant reads as real motion, and it sends the target the "long way" around the sky. Found while implementing moving near-field support (#1710). Deliberately not fixed in that PR series because it is a pre-existing bug that affects ephem phase centers and deserves its own PR.
Because the interpolatant is a cubic spline for 4 or more samples, this is not a local error at the crossing; the discontinuity rings across the entire track.
Evidence
A target drifting steadily at 0.05 rad/sample through RA = 0, with 5 samples:
stored ephem_ra : [6.2 6.25 0.0168 0.0668 0.1168]
continuous form : [6.2 6.25 6.3 6.35 6.4 ]
Interpolated at every midpoint between samples, compared as angles on the circle so the wrap itself is not counted as error:
| midpoint | expected RA | interpolated RA | error |
|---|---|---|---|
| 1 | 6.2250 | 1.8071 | 106.9 deg |
| 2 | 6.2750 | 2.8389 | 163.1 deg |
| 3 (crosses 0h) | 0.0418 | 5.6378 | 39.4 deg |
| 4 | 0.0918 | 0.7790 | 39.4 deg |
All four midpoints are wrong, including even the two before the crossing.
Fix
Interpolate an unwrapped copy of ephem_ra, and fold the result back into [0, 2pi) range on return.
Add tests of ephem and near_field tracks crossing RA of 0 are interpolated correctly, assert non-wrapping track results remain unchanged, and that interpolated returned RA is in [0, 2pi) range.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/pyuvdata/utils/phasing.py at interpolate_ephem and trace how ephem_ra is interpolated and returned. Add coverage for ephem and near_field tracks crossing RA 0, plus a non-wrapping track and the returned [0, 2pi) range. Done means midpoint interpolation follows the continuous track without changing non-wrapping results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100