idlastro / Astronomical Utilities: PLANET_COORDS

[Source code]

NAME
PLANET_COORDS
PURPOSE
Find low or high precision RA and DEC for the planets given a date
EXPLANATION
For low precision this routine uses HELIO to get the heliocentric ecliptic
coordinates of the planets at the given date, then converts these to 
geocentric ecliptic coordinates ala "Astronomical Algorithms" by Jean 
Meeus (1991, p 209). These are then converted to RA and Dec using EULER.
The accuracy between the years 1800 and 2050 is better than 1 arcminute 
for  the terrestial planets, but reaches 10 arcminutes for Saturn.    
Before 1850 or after 2050 the accuracy can get much worse.   
For high precision use the /JPL option ito use the full JPL ephemeris.
CALLING SEQUENCE
PLANET_COORDS, DATE, RA, DEC, [ PLANET = , /JD, /JPL]
INPUTS
DATE - If /JD is not set, then date is a 3-6 element vector containing
       year,month (1-12), day, and optionally hour, minute, & second.
       If /JD is set then DATE is a Julian date.   An advantage of the
       /JD option is that it allows the use of vector dates.
OUTPUTS
RA - right ascension of planet(s), J2000 degrees, double precision
DEC - declination of   planet(s), J2000 degrees, double precision
OPTIONAL INPUT KEYWORD
PLANET - scalar string giving name of a planet, e.g. 'venus'. Default 
        is to compute coords for all of them (except Earth).
/JD - If set, then the date parameter should be supplied as Julian date
JPL - if /JPL set, then PLANET_COORDS will call the procedure 
      JPLEPHINTERP to compute positions using the full JPL ephemeris.   
      The JPL ephemeris FITS file JPLEPH.405 must exist in either the 
      current directory, or in the directory specified by the 
      environment variable ASTRO_DATA.   Alternatively, the JPL keyword
      can be set to the full path and name of the ephemeris file.
      A copy of the JPL ephemeris FITS file JPLEPH.405 is available in
          http://idlastro.gsfc.nasa.gov/ftp/data/         
EXAMPLES
(1)  Find the RA, Dec of Venus on 1992 Dec 20
      IDL> planet_coords, [1992,12,20], ra,dec    ;Compute for all planets
      IDL> print,adstring(ra[1],dec[1],1)         ;Venus is second planet
 ====> RA = 21 05  2.66  Dec = -18 51 45.7
This position is 37" from the full DE406 ephemeris position of
      RA = 21 05  5.24        -18 51 43.1
(2) Return the current RA and Dec of all 8 planets using JPL ephemeris
      IDL> get_juldate, jd                 ;Get current Julian Date
      IDL> planet_coords,jd,ra,dec,/jd,/jpl  ;Find positions of all planets
      IDL> forprint,adstring(ra,dec,0)     ;Display positions   
(3) Plot the declination of Mars for every day in the year 2001
      IDL> jdcnv,2001,1,1,0,jd      ;Get Julian date of midnight on Jan 1 
           Now get Mars RA,Dec for 365 consecutive days
      IDL> planet_coords,jd+indgen(365),ra,dec,/jd, planet = 'mars'     
      IDL> plot,indgen(365)+1,dec
NOTES
HELIO is based on the two-body problem and neglects interactions 
 between the planets.   This is why the worst results are for
 Saturn.   Use the /JPL option or the online ephemeris generator 
 http://ssd.jpl.nasa.gov/horizons.cgi for more accuracy. 
 The procedure returns astrometric coordinates, i.e. no correction
 for aberration.   A correction for light travel time is applied
 when /JPL is set, but not for the default low-precision calculation.
PROCEDURES USED
JULDATE 
EULER, HELIO  - if /JPL is not set
JPLEPHREAD, JPLEPHINTERP - if /JPL is set
REVISION HISTORY
Written P.Plait & W. Landsman     August 2000
Fixed Julian date conversion   W. Landsman August 2000
Added /JPL keyword  W. Landsman   July 2001
Allow vector Julian dates with JPL ephemeris W. Landsman December 2002
On_error,2
onvert input date to real JD
ake output arrays to include each planet
note that we need Earth to convert from heliocentric
ecliptic coordinates to geocentric and then to RA and DEC
ead ephemeris FITS file
Compute distance to planet(s) and adjust Julian date for light travel time
and recompute planet positions
Compute position of Earth at current time, but position of planet at time
light started traveling
extract Earth's info
et rectangular coords of planets
et geocentric longitude lambda and geo latitude, beta
onvert to Ra and Dec