-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AltAz radial_velocity transformation fails #12594
Comments
Basically, I would expect that a transformation from import astropy
from astropy.coordinates import EarthLocation, SpectralCoord, SkyCoord, AltAz, ICRS
from astropy.time import Time
import astropy.units as u
location = EarthLocation.of_site("ALMA")
obstime = Time('2021-12-13T21:10:00.624')
target = AltAz(az=170.0*u.deg, alt=40.0*u.deg, location=location,
obstime=obstime, radial_velocity=0.0*u.km/u.s)
target_icrs = target.transform_to(ICRS())
# Fails with noted error
# I would expect an ICRS coordinate with a radial velocity given
# by `radial_velocity_correction`. For example:
target = SkyCoord(az=170.0*u.deg, alt=40.0*u.deg, location=location,
obstime=obstime, frame="altaz")
target_radial_velocity = 0.0*u.km/u.s
barycorr = target.radial_velocity_correction()
expected_target_icrs = SkyCoord(
target.icrs, radial_velocity=target_radial_velocity + barycorr) |
For the first error you note, your interpretation is right: ICRS is defined with an origin at the SS barycenter whereas AltAz is defined from a location on the WGS84 ellipsoid (~Earth surface). In order to transform a barycentric, spherical velocity between these frames, astropy.coordinates must know the full 3D velocity and position of the source. I think the error message is confusing and we should probably improve that! The huge proper motions you get even after specifying the full 3d position and velocity I think are correct, and they're telling you what Earth's rotation is (2π rad/day ~= 1e11 mas/yr). The radial velocity looks wrong though... that could be a bug! Pinging @eteq who probably knows more about the AltAz implementation off the top of his head. |
One thing that I would note is that "proper_motion" in AltAz is just the rate of change of the coordinates. More proper units would be arcsec per second, the conversion factor being 1 / 3.15576e+10. This yields the right order of magnitude, but the numbers still seem a bit off as I would expect the square root of the sum of the squares to be 15 arcsec per second. |
Regarding the radial velocity, if the target's radial velocity wrt the SSB is 0, the most it can be is ~30 km/sec wrt an observer on Earth. |
So there is definitely a bug here. |
And CIRS yields something completely different, which it shouldn't.
|
And CIRS at the geocenter:
No way is ALMA moving 15.2 km/s wrt the geocenter. Not to mention the totally bogus difference in proper motion. |
I have never looked at velocities in Astropy as they are done with differentials, which seems over complicated, but I guess I should. |
Looking into this, I see that the issue is documented here: https://docs.astropy.org/en/stable/coordinates/velocities.html#finite-difference-transformations, so it's a known problem. |
It seems to me that the problem here is the way that velocities are computed and intimately coupled to space motion. Using finite differences is rather compute intensive and clearly wildly inaccurate for anything beyond the solar system. Maybe I'm missing something, but it seems that finite differences are only needed for calculating the velocities of solar system objects that don't have an ephemeris such as comets, solar flares, etc. In fact, this is what stymied my ill-fated attempt at getting an astrometric frame implemented. Many stars have a known distance along with components of proper motion and radial velocity. For these, position and velocity vectors can be constructed and full 3D space motion can be derived. Parallax can be computed by subtracting the observer's position vector wrt the SSB from that of the target body and redshift can be computed by adding in the component of the observer's velocity wrt the SSB along the line of site to the radial velocity. Please note here that components of the observer's velocity wrt the SSB should NOT be added in to the components of proper motion. Proper motion is defined as the secular rates of change in right ascension and declination (Explanatory Supplement, 3rd Edition, pg. 28). On the other hand, many objects have no given distance, but still have a radial velocity and perhaps proper motion associated with them. For these, no true position and velocity vectors can be constructed. Parallax cannot be computed, but 2D space motion can be derived from the proper motion (if any) applied to the position unit vectors and redshift can be derived from the radial velocity. Solar system bodies such as planets, asteroids and comets can be included in the first case. In the case of planets, position and velocity vectors can be read from the ephemerides. For asteroids and comets, orbital elements can be used to construct a model which yields short term position and velocity predictions. Radial velocities can be computed in order to observe lines in the atmospheres of planets and the head and tail of comets. All of this without a single finite difference. In radio astronomy, we normally only deal with the second case. We are given a set of RA/Dec coordinates along with a VLSR (LSR usually being what Astropy calls LSRK) for each source. From this, we would like to compute the radial velocity of the source in the rest frame of the observer and the sky frequency for a given line in order to tune our receiver. It is a bit of a peeve of mine that the Anyway, I experimented around with this and it can be done. First I defined a
Then I defined a
This gave a warning, but it worked.
I chose RA 271, Dec 30 for the target as that is the direction that the SSB is moving in relative to the LSRK frame at J2000. This makes it easy to verify the radial velocity of the target wrt the SSB.
Close enough to the -10 km / s that I expected. The documentation for the LSRK frame is incorrect, btw.
should read:
Then I did this:
This is the correct sky frequency for a line with a rest frequency of 100 GHz in a source with a velocity of 10 km / s wrt LSRK. So, what I would propose is adding a I will raise a separate issue regarding Astropy's computation of velocities and cross post much of what I have posted here. Sorry about the "wall of words", but I wanted to thoroughly address your issues. |
Description
Transforming coordinates that include a
radial_velocity
to or fromAltAz
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 theAltAz
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
I suspect that the issue is that
AltAz
andICRS
have different origins (the former atlocation
, and the later at the solar system barycenter). Sure enough, there is no error if you supply additional information when creating theICRS
coordinate: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
andAltAz
coordinates for coordinates that include aradial_velocity
.Actual behavior
ICRS
toAltAz
fails with an obscure error message when only aradial_velocity
is supplied. Ifradial_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
The text was updated successfully, but these errors were encountered: