def test_transformProperMotions(self): """ Verify the correct implementation of the direct transformation of proper motions. """ ct = CoordinateTransformation(Transformations.ICRS2GAL) nTests = 100 phi = 2.0*pi*rand(nTests) theta = -pi/2.0+pi*rand(nTests) parallax = rand(nTests)*99.0+1.0 muphistar = -30.0+60.0*rand(nTests) mutheta = -30.0+60.0*rand(nTests) vrad = -200.0+400.0*rand(nTests) x,y,z,vx,vy,vz = astrometryToPhaseSpace(phi,theta,parallax,muphistar,mutheta,vrad) xrot, yrot, zrot = ct.transformCartesianCoordinates(x,y,z) vxrot, vyrot, vzrot = ct.transformCartesianCoordinates(vx,vy,vz) phiRot, thetaRot, parRot, muphistarRotExpected, muthetaRotExpected, vradRot = \ phaseSpaceToAstrometry(xrot, yrot, zrot, vxrot, vyrot, vzrot) muphistarRot, muthetaRot = ct.transformProperMotions(phi, theta, muphistar, mutheta) assert_array_almost_equal(muphistarRotExpected, muphistarRot, decimal=2) assert_array_almost_equal(muthetaRotExpected, muthetaRot, decimal=2) # # Test scalar version of method. # for i in range(nTests): muphistarRot, muthetaRot = ct.transformProperMotions(phi[i], theta[i], muphistar[i], mutheta[i]) assert_almost_equal(muphistarRotExpected[i], muphistarRot, decimal=2) assert_almost_equal(muthetaRotExpected[i], muthetaRot, decimal=2)
def test_transformProperMotions(self): """ Verify the correct implementation of the direct transformation of proper motions. """ ct = CoordinateTransformation(Transformations.ICRS2GAL) nTests = 100 phi = 2.0*pi*rand(nTests) theta = -pi/2.0+pi*rand(nTests) parallax = rand(nTests)*99.0+1.0 muphistar = -30.0+60.0*rand(nTests) mutheta = -30.0+60.0*rand(nTests) vrad = -200.0+400.0*rand(nTests) x,y,z,vx,vy,vz = astrometryToPhaseSpace(phi,theta,parallax,muphistar,mutheta,vrad) xrot, yrot, zrot = ct.transformCartesianCoordinates(x,y,z) vxrot, vyrot, vzrot = ct.transformCartesianCoordinates(vx,vy,vz) phiRot, thetaRot, parRot, muphistarRotExpected, muthetaRotExpected, vradRot = \ phaseSpaceToAstrometry(xrot, yrot, zrot, vxrot, vyrot, vzrot) muphistarRot, muthetaRot = ct.transformProperMotions(phi, theta, muphistar, mutheta) assert_array_almost_equal(muphistarRotExpected, muphistarRot, decimal=2) assert_array_almost_equal(muthetaRotExpected, muthetaRot, decimal=2) # # Test scalar version of method. # for i in range(nTests): muphistarRot, muthetaRot = ct.transformProperMotions(phi[i], theta[i], muphistar[i], mutheta[i]) assert_almost_equal(muphistarRotExpected[i], muphistarRot, decimal=2) assert_almost_equal(muthetaRotExpected[i], muthetaRot, decimal=2)
def ICRS_to_GAL(phi, theta, muphistar, mutheta): """ phi - The longitude-like angle of the position of the source (radians). theta - The latitude-like angle of the position of the source (radians). muphistar - Value of the proper motion in the longitude-like angle, multiplied by cos(latitude). mutheta - Value of the proper motion in the latitude-like angle. """ # transformation ICRS to GAL ctICRS2GAL = CoordinateTransformation(Transformations.ICRS2GAL) # ell, bee = ctICRS2GAL.transformSkyCoordinates(phi, theta) muellstar, mubee = ctICRS2GAL.transformProperMotions( phi, theta, muphistar, mutheta) return ell, bee, muellstar, mubee
def GAL_to_ICRS(phi, theta, muphistar, mutheta): """ phi - The longitude-like angle of the position of the source (radians). theta - The latitude-like angle of the position of the source (radians). muphistar - Value of the proper motion in the longitude-like angle, multiplied by cos(latitude). mutheta - Value of the proper motion in the latitude-like angle. """ # transformation ICRS to GAL ctGAL2ICRS = CoordinateTransformation(Transformations.GAL2ICRS) # ra, dec = ctGAL2ICRS.transformSkyCoordinates(phi, theta) murastar, mudec = ctGAL2ICRS.transformProperMotions( phi, theta, muphistar, mutheta) return ra, dec, murastar, mudec