def equatorial_to_galactic(alpha, delta): """ Convert equatorial coordinates to galactic system. """ cbcX, cbsX, sb = np.dot(MATRIXT, [cosd(delta)*cosd(alpha), cosd(delta)*sind(alpha), sind(delta)]) b = np.arcsin(sb) l = np.arctan2(cbsX/cosd(b),cbcX/cosd(b)) if l < 0.: l = l + np.pi * 2 return np.degrees(l), np.degrees(b)
def convert_all(ra, de, pmra, pmde, dpmra, dpmde, vr, dvr, distance, e_distance): """ """ rotRA = np.array([[cosd(ra), -sind(ra), 0.], [sind(ra), cosd(ra), 0.], [0., 0., 1.]]) rotDE = np.array([[cosd(de), 0., -sind(de)], [0., 1., 0.], [sind(de), 0., cosd(de)]]) l, b = equatorial_to_galactic(ra, de) pos = np.array([cosd(b)*cosd(l), cosd(b)*sind(l), sind(b)]) matrixA = np.dot(rotRA, rotDE) XYZ = distance * np.dot(MATRIXT, pos) UVW = np.dot(MATRIXT, np.dot(matrixA, np.array([vr, K*distance * pmra, K*distance * pmde]))) #print cov_pmrapmdec_to_pmllpmbb(np.array([[dpmra**2, 0.], [0., dpmde**2]]), ra ,de, degree=True) # Now to uncertainces: #sinb = XYZ[2] / distance #cosb = np.sqrt(1. - sinb**2) #matrixP = get_P_matrix(ra, de, sinb, cosb) # eq. 76 #cov_mu = np.dot(matrixP, # np.dot(np.diag([dpmra * cosd(de), dpmde]), matrixP.T)) # eq. 70 jac_vavd = K * np.array([[pmra, distance, 0.], [pmde, 0., distance]]) # eq. 71 cov_d_pm = np.diag([e_distance**2, dpmra**2, dpmde**2]) cov_vpm = doubledot(jac_vavd, cov_d_pm) # eq. 72 cov_v = block_diag(dvr**2, cov_vpm) cov_UVW = doubledot(MATRIXT, doubledot(matrixA, cov_v)) return XYZ, UVW, cov_UVW
def get_P_matrix(ra, de, sinb, cosb): cos_phi = (SIN_DEC_NGP - sind(de)*sinb)/(cosd(de)*cosb) sin_phi = sind(ra - RA_NGP) * COS_DEC_NGP / cosb return np.array([[cos_phi, sin_phi], [-sin_phi, cos_phi]])
""" Created on Mon Oct 26 14:28:40 2015 @author: mints """ import numpy as np from sage.convert import R_SUN, V_SUN, cosd, sind, K from scipy.linalg import block_diag from galpy.util.bovy_coords import cov_pmrapmdec_to_pmllpmbb, cov_dvrpmllbb_to_vxyz THETA = 122.932 RA_NGP = 192.85948 DEC_NGP = 27.12825 COS_THETA = cosd(THETA) SIN_THETA = sind(THETA) COS_RA_NGP = cosd(RA_NGP) SIN_RA_NGP = sind(RA_NGP) COS_DEC_NGP = cosd(DEC_NGP) SIN_DEC_NGP = sind(DEC_NGP) MATRIXT = np.dot(np.array([[COS_THETA, SIN_THETA, 0.], [SIN_THETA, -COS_THETA, 0.], [0., 0., 1.]]), np.dot(np.array([[-SIN_DEC_NGP, 0., COS_DEC_NGP], [0., 1., 0.], [COS_DEC_NGP, 0., SIN_DEC_NGP]]), np.array([[ COS_RA_NGP, SIN_RA_NGP, 0.],