Coverage for python/lsst/sims/utils/CoordinateTransformations.py : 96%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" This file contains coordinate transformation methods that are very thin wrappers of palpy methods, or that have no dependence on palpy at all """
"_equatorialFromGalactic", "equatorialFromGalactic", "sphericalFromCartesian", "cartesianFromSpherical", "xyz_from_ra_dec", "_xyz_from_ra_dec", "_ra_dec_from_xyz", "ra_dec_from_xyz", "xyz_angular_radius", "_xyz_angular_radius", "rotationMatrixFromVectors", "rotAboutZ", "rotAboutY", "rotAboutX", "equationOfEquinoxes", "calcGmstGast", "calcLmstLast", "angularSeparation", "_angularSeparation", "haversine", "arcsecFromRadians", "radiansFromArcsec", "arcsecFromDegrees", "degreesFromArcsec"]
""" calculates local mean sidereal time and local apparent sidereal time
@param [in] mjd is the universal time (UT1) expressed as an MJD. This can be a numpy array or a single value.
@param [in] longRad is the longitude in radians (positive east of the prime meridian) This can be numpy array or a single value. If a numpy array, should have the same length as mjd. In that case, each longRad will be applied only to the corresponding mjd.
@param [out] lmst is the local mean sidereal time in hours
@param [out] last is the local apparent sideral time in hours """
"mjd and longRad as numpy arrays of the same length\n" \ "mjd as a numpy array and longRad as a number\n" \ "mjd as a number and longRad as a number\n" \ "You gave mjd: %s\n" % type(mjd) \ + "and longRad: %s\n" % type(longRad)
else: else:
'''Convert RA,Dec (J2000) to Galactic Coordinates
@param [in] ra is right ascension in degrees, either a number or a numpy array
@param [in] dec is declination in degrees, either a number or a numpy array
@param [out] gLong is galactic longitude in degrees
@param [out] gLat is galactic latitude in degrees '''
'''Convert RA,Dec (J2000) to Galactic Coordinates
All angles are in radians
@param [in] ra is right ascension in radians, either a number or a numpy array
@param [in] dec is declination in radians, either a number or a numpy array
@param [out] gLong is galactic longitude in radians
@param [out] gLat is galactic latitude in radians '''
else:
'''Convert Galactic Coordinates to RA, dec (J2000)
@param [in] gLong is galactic longitude in degrees, either a number or a numpy array (0 <= gLong <= 360.)
@param [in] gLat is galactic latitude in degrees, either a number or a numpy array (-90. <= gLat <= 90.)
@param [out] ra is right ascension in degrees
@param [out] dec is declination in degrees '''
'''Convert Galactic Coordinates to RA, dec (J2000)
@param [in] gLong is galactic longitude in radians, either a number or a numpy array (0 <= gLong <= 2*pi)
@param [in] gLat is galactic latitude in radians, either a number or a numpy array (-pi/2 <= gLat <= pi/2)
@param [out] ra is right ascension in radians (J2000)
@param [out] dec is declination in radians (J2000) '''
else:
""" Transforms between spherical and Cartesian coordinates.
@param [in] longitude is a numpy array or a number in radians
@param [in] latitude is a numpy array or number in radians
@param [out] a numpy array of the (three-dimensional) cartesian coordinates on a unit sphere.
if inputs are numpy arrays: output[i][0] will be the x-coordinate of the ith point output[i][1] will be the y-coordinate of the ith point output[i][2] will be the z-coordinate of the ith point
All angles are in radians
Also, look at xyz_from_ra_dec(). """
""" Transforms between Cartesian and spherical coordinates
@param [in] xyz is a numpy array of points in 3-D space. Each row is a different point.
@param [out] returns longitude and latitude
All angles are in radians
Also, look at ra_dec_from_xyz(). """ raise RuntimeError("You need to pass a numpy array to sphericalFromCartesian")
else:
""" Utility to convert RA,dec positions in x,y,z space.
Parameters ---------- ra : float or array RA in degrees dec : float or array Dec in degrees
Returns ------- x,y,z : floats or arrays The position of the given points on the unit sphere. """ return _xyz_from_ra_dec(np.radians(ra), np.radians(dec))
""" Utility to convert RA,dec positions in x,y,z space.
Parameters ---------- ra : float or array RA in radians dec : float or array Dec in radians
Returns ------- x,y,z : floats or arrays The position of the given points on the unit sphere. """ # It is ok to mix floats and numpy arrays.
""" Utility to convert x,y,z Cartesian coordinates to RA, dec positions in space.
Parameters ---------- x : float or array The position on the x-axis of the given points on the unit sphere y : float or array The position on the y-axis of the given points on the unit sphere z : float or array The position on the z-axis of the given points on the unit sphere
Returns ------- ra, dec : floats or arrays Ra and dec coordinates in radians. """
""" Utility to convert x,y,z Cartesian coordinates to RA, dec positions in space.
Parameters ---------- x : float or array The position on the x-axis of the given points on the unit sphere y : float or array The position on the y-axis of the given points on the unit sphere z : float or array The position on the z-axis of the given points on the unit sphere
Returns ------- ra, dec : floats or arrays Ra and dec coordinates in degrees. """
return np.degrees(_ra_dec_from_xyz(x, y, z))
""" Convert an angular radius into a physical radius for a kdtree search.
Parameters ---------- radius : float Radius in degrees.
Returns ------- radius : float """
""" Convert an angular radius into a physical radius for a kdtree search.
Parameters ---------- radius : float Radius in radians.
Returns ------- radius : float """
[ss, cc, 0.0], [0.0, 0.0, 1.0]])
""" Rotate a Cartesian vector an angle theta about the z axis. Theta is in radians. Positive theta rotates +x towards +y. """
[0.0, 1.0, 0.0], [-ss, 0.0, cc]])
""" Rotate a Cartesian vector an angle theta about the y axis. Theta is in radians. Positive theta rotates +x towards -z. """
[0.0, cc, -ss], [0.0, ss, cc]])
""" Rotate a Cartesian vector an angle theta about the x axis. Theta is in radians. Positive theta rotates +y towards +z. """
''' Given two vectors v1,v2 calculate the rotation matrix for v1->v2 using the axis-angle approach
@param [in] v1, v2 are two Cartesian unit vectors (in three dimensions)
@param [out] rot is the rotation matrix that rotates from one to the other
'''
# Calculate the axis of rotation by the cross product of v1 and v2
# calculate the angle of rotation via dot product
# calculate the corresponding rotation matrix # http://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_and_angle (1 - cosDot) * cross[0] * cross[1], cross[1] * sinDot + (1 - cosDot) * cross[0] * cross[2]], [cross[2] * sinDot + (1 - cosDot) * cross[0] * cross[1], cosDot + (1 - cosDot) * cross[1] * cross[1], -cross[0] * sinDot + (1 - cosDot) * cross[1] * cross[2]], [-cross[1] * sinDot + (1 - cosDot) * cross[0] * cross[2], cross[0] * sinDot + (1 - cosDot) * cross[1] * cross[2], cosDot + (1 - cosDot) * (cross[2] * cross[2])]]
""" The equation of equinoxes. See http://aa.usno.navy.mil/faq/docs/GAST.php
@param [in] d is either a numpy array or a number that is Terrestrial Time expressed as an MJD
@param [out] the equation of equinoxes in radians. """
else:
""" Compute Greenwich mean sidereal time and Greenwich apparent sidereal time see: From http://aa.usno.navy.mil/faq/docs/GAST.php
@param [in] mjd is the universal time (UT1) expressed as an MJD
@param [out] gmst Greenwich mean sidereal time in hours
@param [out] gast Greenwich apparent sidereal time in hours """
else:
""" Angular separation between two points in radians
Parameters ---------- long1 is the first longitudinal coordinate in radians
lat1 is the first latitudinal coordinate in radians
long2 is the second longitudinal coordinate in radians
lat2 is the second latitudinal coordinate in radians
Returns ------- The angular separation between the two points in radians
Calculated based on the haversine formula From http://en.wikipedia.org/wiki/Haversine_formula """ ['long1', 'lat1'], 'angularSeparation')
['long2', 'lat2'], 'angularSeparation')
# The code below is necessary because the call to np.radians() in # angularSeparation() will automatically convert floats # into length 1 numpy arrays, confusing validate_inputs()
"as arguments to angularSeparation()")
else:
""" Angular separation between two points in degrees
Parameters ---------- long1 is the first longitudinal coordinate in degrees
lat1 is the first latitudinal coordinate in degrees
long2 is the second longitudinal coordinate in degrees
lat2 is the second latitudinal coordinate in degrees
Returns ------- The angular separation between the two points in degrees """ np.radians(lat1), np.radians(long2), np.radians(lat2)))
""" DEPRECATED; use angularSeparation() instead
Return the angular distance between two points in radians
@param [in] long1 is the longitude of point 1 in radians
@param [in] lat1 is the latitude of point 1 in radians
@param [in] long2 is the longitude of point 2 in radians
@param [in] lat2 is the latitude of point 2 in radians
@param [out] the angular separation between points 1 and 2 in radians """
""" Convert an angle in radians to arcseconds
Note: if you input None, you will get None back """
""" Convert an angle in arcseconds to radians
Note: if you input None, you will get None back """ return None
""" Convert an angle in degrees to arcseconds
Note: if you input None, you will get None back """ return None
""" Convert an angle in arcseconds to degrees
Note: if you input None, you will get None back """ return None
|