Skip to content

AltAz radial_velocity transformation fails #12594

Open
@tvwenger

Description

@tvwenger

Description

Transforming coordinates that include a radial_velocity to or from AltAz fails with an obscure error. This is related to #12593.

This functionality is useful for observation planning and Doppler corrections. For example, if I know that an object has a given radial velocity in the GalacticLSR frame, I might want to know what the position is in the AltAz frame, so I know where to point the telescope, and what the radial velocity is in the topocentric frame, so that I can set my receiver system to observe the correct frequency.

Steps to Reproduce

import astropy.units as u
from astropy.time import Time
from astropy.coordinates import EarthLocation, ICRS, AltAz
import astropy
print(astropy.__version__)
# 5.0 (also tried dev version: 5.1.dev251+gcd25e6329)

location = EarthLocation.of_site("ALMA")
obstime = Time('2021-12-13T21:10:00.624')

coord = ICRS(356.38*u.deg, -71.154*u.deg, radial_velocity=0.0*u.km/u.s)
coord = coord.transform_to(AltAz(location=location, obstime=obstime))
# UnitConversionError: Can only apply 'add' function to quantities with compatible dimensions

I suspect that the issue is that AltAz and ICRS have different origins (the former at location, and the later at the solar system barycenter). Sure enough, there is no error if you supply additional information when creating the ICRS coordinate:

coord = ICRS(356.38*u.deg, -71.154*u.deg, radial_velocity=0.0*u.km/u.s,
             pm_ra_cosdec=0.0*u.mas/u.yr, pm_dec=0.0*u.mas/u.yr,
             distance=1.0*u.Mpc)
coord = coord.transform_to(AltAz(location=location, obstime=obstime))
print(coord)
# <AltAz Coordinate (obstime=2021-12-13T21:10:00.624, location=(2225015.30883296, -5440016.41799762, -2481631.27428014) m, pressure=0.0 hPa, temperature=0.0 deg_C, relative_humidity=0.0, obswl=1.0 micron): (az, alt, distance) in (deg, deg, Mpc)
#    (169.99955542, 40.00005221, 1.)
# (pm_az_cosalt, pm_alt, radial_velocity) in (mas / yr, mas / yr, km / s)
#    (1.34282337e+11, 7.58579968e+10, 1151.58325584)>

It doesn't give an error, but it gives unrealistic values for the radial velocity and proper motions.

Expected behavior

We should be able to convert between ICRS and AltAz coordinates for coordinates that include a radial_velocity.

Actual behavior

ICRS to AltAz fails with an obscure error message when only a radial_velocity is supplied. If radial_velocity and proper motions are supplied, the conversion does not have an error, but the resulting kinematics are wildly incorrect.

System Details

Linux-5.10.60.1-microsoft-standard-WSL2-x86_64-with-glibc2.10
Python 3.8.5 (default, Sep 4 2020, 07:30:14)
[GCC 7.3.0]
Numpy 1.21.4
pyerfa 2.0.0.1
astropy 5.1.dev251+gcd25e6329

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions