-
-
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
SpectralCoord gives unexpected results with AltAz target #12593
Comments
Welcome to Astropy 👋 and thank you for your first issue! A project member will respond to you as soon as possible; in the meantime, please double-check the guidelines for submitting issues and make sure you've provided the requested details. GitHub issues in the Astropy repository are used to track bug reports and feature requests; If your issue poses a question about how to use Astropy, please instead raise your question in the Astropy Discourse user forum and close this issue. If you feel that this issue has not been responded to in a timely manner, please leave a comment mentioning our software support engineer @embray, or send a message directly to the development mailing list. If the issue is urgent or sensitive in nature (e.g., a security vulnerability) please send an e-mail directly to the private e-mail feedback@astropy.org. |
I've pinned down at least one issue to the following function:
from astropy.coordinates import EarthLocation, SpectralCoord, SkyCoord
from astropy.time import Time
import astropy.units as u
location = EarthLocation.of_site("ALMA")
obstime = Time('2021-12-13T21:10:00.624')
observer = location.get_itrs(obstime=obstime)
target = SkyCoord(170.0*u.deg, 40.0*u.deg, location=location,
obstime=obstime, frame="altaz")
observer = SpectralCoord._validate_coordinate(observer)
target = SpectralCoord._validate_coordinate(target)
print(SpectralCoord._calculate_radial_velocity(observer, target, as_scalar=True))
# 2032008.296875 km / s
observer = location.get_itrs(obstime=obstime)
target = SkyCoord(170.0*u.deg, 40.0*u.deg, location=location,
obstime=obstime, frame="altaz")
target = target.icrs
observer = SpectralCoord._validate_coordinate(observer)
target = SpectralCoord._validate_coordinate(target)
print(SpectralCoord._calculate_radial_velocity(observer, target, as_scalar=True))
# 11.231737842710979 km / s Since the first step in Indeed, if I try to set a target = SkyCoord(170.0*u.deg, 40.0*u.deg, location=location,
obstime=obstime, frame="altaz", radial_velocity=0.0*u.km/u.s)
target = SpectralCoord._validate_coordinate(target)
# ValueError: alt has unit "deg" with physical type "angle", but pm_alt has incompatible unit "km rad / s" with physical type "unknown" instead of the expected "angular frequency/angular speed/angular velocity". I will look into this further and, if I find the problem, I'll submit a PR! |
I think I've pinned down the problem to simply how For example, this fails and I don't think it should: import astropy
from astropy.coordinates import EarthLocation, ICRS, AltAz
from astropy.time import Time
import astropy.units as u
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)) I will submit another issue related to this bug. |
Description
Using
SpectralCoord
with atarget
specified in theAltAz
frame yields unexpected results. There are some invalid value warnings, NaNs, and incorrect transformation results. This does not happen when the same target is passed in theICRS
frame.Steps to Reproduce
Expected behavior
SpectralCoord
should yield the same results in both theAltAz
andICRS
frames.Actual behavior
System Details
Linux-3.10.0-1160.49.1.el7.x86_64-x86_64-with-glibc2.10
Python 3.8.3 (default, Jul 2 2020, 16:21:59)
[GCC 7.3.0]
Numpy 1.21.4
pyerfa 2.0.0.1
astropy 5.0
Scipy 1.6.2
Matplotlib 3.3.4
The text was updated successfully, but these errors were encountered: