Created
April 16, 2024 15:43
-
-
Save iancze/8249be1b25c7f5cf13dfe486d5d41872 to your computer and use it in GitHub Desktop.
Use astropy to convert from LSRK to BARY reference frame.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from astropy.coordinates import SkyCoord, ICRS, LSR | |
import astropy.units as u | |
import numpy as np | |
from numpy.linalg import norm | |
# convert from degrees to radian | |
deg = np.pi / 180.0 | |
# coordinates of AK Sco | |
# 16 54 44.8497760618 -36 53 18.560813962 | |
sc_icrs = SkyCoord(ra=253.686874, dec=-36.88849, unit=(u.deg, u.deg)) | |
# print(sc_icrs.ra.hms) | |
# print(sc_icrs.dec) | |
ua = sc_icrs.ra.degree | |
ud = sc_icrs.dec.degree | |
# define "cartesian" coordinates where Z = North, X = 0 deg RA. | |
x = np.cos(ud * deg) * np.cos(ua * deg) | |
y = np.cos(ud * deg) * np.sin(ua * deg) | |
z = np.sin(ud * deg) | |
# from Alencar+03 | |
# barycentric velocity in cartesian coordinates | |
u_uvec = np.array([x, y, z]) | |
ak_bary = -1.97 | |
u_vec = ak_bary * u_uvec | |
print("AK Sco Vec: v = {:.3f}x + {:.3f}y + {:.3f}z km/s".format(*u_vec)) | |
# print("AK Sco Norm: {:.3f} km/s".format(norm(u_vec))) | |
print("AK Sco BARY velocity: {:.3f} km/s".format(ak_bary)) | |
# the direction of the LSRK frame | |
sc_lsrk = SkyCoord("18:03:50.29 +30:00:16.8", unit=(u.hourangle, u.deg)) | |
# from: http://www.gb.nrao.edu/~fghigo/gbtdoc/doppler.html | |
za = sc_lsrk.ra.degree | |
zd = sc_lsrk.dec.degree | |
x = np.cos(zd * deg) * np.cos(za * deg) | |
y = np.cos(zd * deg) * np.sin(za * deg) | |
z = np.sin(zd * deg) | |
lsrk_vec = 20.0 * np.array([x, y, z]) | |
print() | |
print("LSRK Vec: v = {:.3f}x + {:.3f}y + {:.3f}z".format(*lsrk_vec)) | |
# print("LSRK Norm: {:.3f} km/s".format(norm(lsrk_vec))) | |
print() | |
print("LSRK Vec dotted on to AK Sco norm") | |
# ak_lsrk = np.dot(lsrk_vec, u_uvec) | |
lsrk_dot = np.dot(lsrk_vec, u_uvec) | |
print("v_LSRK = v_BARY + {:.4} km/s".format(lsrk_dot)) | |
print("AK Sco LSRK velocity {:.4f} km/s".format(ak_bary + lsrk_dot)) | |
# My confusion in UZ Tau resulted from seeming to add the two vectors (which is true in a 3D space sense). | |
# However what we're really concerned about is the projection of the LSRK vector *onto* the vector directed | |
# towards UZ Tau E, since this is how much the *radial velocity* of UZ Tau will change. Testing this with | |
# NED helped sort things out, including the following equation | |
# V_con = V + V_apex [ sin(b) sin(b_apex) + cos(b) cos(b_apex) cos(l - l_apex)] which made me think this was | |
# a dot-product operation and got me thinking in the right direction towards radial velocities rather than | |
# true 3D space motions. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment