Package astLib :: Module astCoords
[hide private]
[frames] | no frames]

Module astCoords

source code

module for coordinate manipulation (conversions, calculations etc.)

(c) 2007-2012 Matt Hilton

(c) 2013-2014 Matt Hilton & Steven Boada

http://astlib.sourceforge.net

Functions [hide private]
float
hms2decimal(RAString, delimiter)
Converts a delimited string of Hours:Minutes:Seconds format into decimal degrees.
source code
float
dms2decimal(decString, delimiter)
Converts a delimited string of Degrees:Minutes:Seconds format into decimal degrees.
source code
string
decimal2hms(RADeg, delimiter)
Converts decimal degrees to string in Hours:Minutes:Seconds format with user specified delimiter.
source code
string
decimal2dms(decDeg, delimiter)
Converts decimal degrees to string in Degrees:Minutes:Seconds format with user specified delimiter.
source code
tuple
eq2cart(RA, DEC, r)
Convert Equatorial coordinates to Cartesian coordinates.
source code
tuple
cart2eq(x, y, z)
Convert Cartesian coordinates to Equatorial coordinates.
source code
float or numpy array, depending upon type of RADeg2, decDeg2
calcAngSepDeg(RADeg1, decDeg1, RADeg2, decDeg2)
Calculates the angular separation of two positions on the sky (specified in decimal degrees) in decimal degrees, assuming a tangent plane projection (so separation has to be <90 deg).
source code
float [newRA, newDec]
shiftRADec(ra1, dec1, deltaRA, deltaDec)
Computes new right ascension and declination shifted from the original by some delta RA and delta DEC.
source code
list
convertCoords(inputSystem, outputSystem, coordX, coordY, epoch)
Converts specified coordinates (given in decimal degrees) between J2000, B1950, and Galactic.
source code
 
calcSkyArea(RA1, RA2, DEC1, DEC2, units=True)
Calculates the area of the quadrangle on the sky given by the intersection of a right ascension lune and declination zone.
source code
list
calcRADecSearchBox(RADeg, decDeg, radiusSkyDeg)
Calculates minimum and maximum RA, dec coords needed to define a box enclosing a circle of radius radiusSkyDeg around the given RADeg, decDeg coordinates.
source code
 
aitoff(lon, lat)
Make Aitoff map projection.
source code
Function Details [hide private]

hms2decimal(RAString, delimiter)

source code 

Converts a delimited string of Hours:Minutes:Seconds format into decimal degrees.

Parameters:
  • RAString (string) - coordinate string in H:M:S format
  • delimiter (string) - delimiter character in RAString
Returns: float
coordinate in decimal degrees

dms2decimal(decString, delimiter)

source code 

Converts a delimited string of Degrees:Minutes:Seconds format into decimal degrees.

Parameters:
  • decString (string) - coordinate string in D:M:S format
  • delimiter (string) - delimiter character in decString
Returns: float
coordinate in decimal degrees

decimal2hms(RADeg, delimiter)

source code 

Converts decimal degrees to string in Hours:Minutes:Seconds format with user specified delimiter.

Parameters:
  • RADeg (float) - coordinate in decimal degrees
  • delimiter (string) - delimiter character in returned string
Returns: string
coordinate string in H:M:S format

decimal2dms(decDeg, delimiter)

source code 

Converts decimal degrees to string in Degrees:Minutes:Seconds format with user specified delimiter.

Parameters:
  • decDeg (float) - coordinate in decimal degrees
  • delimiter (string) - delimiter character in returned string
Returns: string
coordinate string in D:M:S format

eq2cart(RA, DEC, r)

source code 

Convert Equatorial coordinates to Cartesian coordinates. Return a tuple (x, y, z) in the same unit of the input distance. This is the inverse of cart2eq.

Parameters:
  • RA (float) - Right Ascension in decimal degrees
  • DEC (float) - Declination in decimal degrees
  • r (float) - Distance to the object.
Returns: tuple
Tuple of (x, y, z) in same unit as the input distance.

cart2eq(x, y, z)

source code 

Convert Cartesian coordinates to Equatorial coordinates. Returns a tuple of (RA, DEC, r), with RA and DEC given in decimal degrees and r in the same unit as the input.

Parameters:
  • x (float) - x coordinate
  • y (float) - x coordinate
  • z (float) - x coordinate
Returns: tuple
Tuple of (RA, DEC, r)

calcAngSepDeg(RADeg1, decDeg1, RADeg2, decDeg2)

source code 

Calculates the angular separation of two positions on the sky (specified in decimal degrees) in decimal degrees, assuming a tangent plane projection (so separation has to be <90 deg). Note that RADeg2, decDeg2 can be numpy arrays.

Parameters:
  • RADeg1 (float) - R.A. in decimal degrees for position 1
  • decDeg1 (float) - dec. in decimal degrees for position 1
  • RADeg2 (float or numpy array) - R.A. in decimal degrees for position 2
  • decDeg2 (float or numpy array) - dec. in decimal degrees for position 2
Returns: float or numpy array, depending upon type of RADeg2, decDeg2
angular separation in decimal degrees

shiftRADec(ra1, dec1, deltaRA, deltaDec)

source code 

Computes new right ascension and declination shifted from the original by some delta RA and delta DEC. Input position is decimal degrees. Shifts (deltaRA, deltaDec) are arcseconds, and output is decimal degrees. Based on an IDL routine of the same name.

Parameters:
  • ra1 (R.A. in decimal degrees) - float
  • dec1 (dec. in decimal degrees) - float
  • deltaRA (shift in R.A. in arcseconds) - float
  • deltaDec (shift in dec. in arcseconds) - float
Returns: float [newRA, newDec]
shifted R.A. and dec.

convertCoords(inputSystem, outputSystem, coordX, coordY, epoch)

source code 

Converts specified coordinates (given in decimal degrees) between J2000, B1950, and Galactic.

Parameters:
  • inputSystem (string) - system of the input coordinates (either "J2000", "B1950" or "GALACTIC")
  • outputSystem (string) - system of the returned coordinates (either "J2000", "B1950" or "GALACTIC")
  • coordX (float) - longitude coordinate in decimal degrees, e.g. R. A.
  • coordY (float) - latitude coordinate in decimal degrees, e.g. dec.
  • epoch (float) - epoch of the input coordinates
Returns: list
coordinates in decimal degrees in requested output system

calcSkyArea(RA1, RA2, DEC1, DEC2, units=True)

source code 

Calculates the area of the quadrangle on the sky given by the intersection of a right ascension lune and declination zone. By default, the area is returned in square degrees.

Parameters:
  • RA1 (float) - Right ascension in decimal degrees
  • RA2 (float) - Right ascension in decimal degrees
  • DEC1 (float) - Declination in decimal degrees
  • DEC2 (float) - Declination in decimal degrees
  • units (bool) - True: Area is given in square degrees. False: Area is given as a fraction of the total sky.

calcRADecSearchBox(RADeg, decDeg, radiusSkyDeg)

source code 

Calculates minimum and maximum RA, dec coords needed to define a box enclosing a circle of radius radiusSkyDeg around the given RADeg, decDeg coordinates. Useful for freeform queries of e.g. SDSS, UKIDSS etc.. Uses calcAngSepDeg, so has the same limitations.

Parameters:
  • RADeg (float) - RA coordinate of centre of search region
  • decDeg (float) - dec coordinate of centre of search region
  • radiusSkyDeg (float) - radius in degrees on the sky used to define search region
Returns: list
[RAMin, RAMax, decMin, decMax] - coordinates in decimal degrees defining search box

aitoff(lon, lat)

source code 

Make Aitoff map projection.

Take traditional longitude and latitude in radians and return a tuple (x, y).

Notice that traditionally longitude is in [-pi:pi] from the meridian, and latitude is in [-pi/2:pi/2] from the equator. So, for example, if you would like to make a galactic map projection centered on the galactic center, before passing galactic longitude l to the function you should first do: l = l if l <= numpy.pi else l - 2 * numpy.pi

Keyword arguments: lon -- Traditional longitude in radians, in range [-pi:pi] lat -- Traditional latitude in radians, in range [-pi/2:pi/2]