NAME:
     ephem
 PURPOSE: (one line)
     Ephemeris generator for solar system objects.
 DESCRIPTION:
     This program pipes the input data to an external FORTRAN program
     written by Larry Wasserman.  The external program looks up the orbital
     elements of each object and computes the positions requested by the
     output code.  The output code options are:

        Code  Meaning
        -----------------------------------------------------------------------
         0    Topocentric RA, Dec, of date of object.
         1    Topocentric RA, Dec,  B1950  of object.
         2    Topocentric RA, Dec,  J2000  of object.
         3    Topocentric x, y, z, of date of object.
         4    Topocentric x, y, z,  B1950  of object.
         5    Topocentric x, y, z,  J2000  of object.
         6    Topocentric x, y, z, of date of Sun.
         7    Topocentric x, y, z,  B1950  of Sun.
         8    Topocentric x, y, z,  J2000  of Sun.
         9    B1950 x, y, z, of object with respect to solar system barycenter.
        10    J2000 x, y, z, of object with respect to solar system barycenter.
        11    J2000 osculating orbital elements for the object
                0 - mean anomaly (M)
                1 - argument of perihelion
                2 - longitude of the asending node
                3 - inclination (i)
                4 - eccentricity (e)
                5 - semi-major axis (a)
                6 - perihelion distance (q)
                7 - aphelion distance (Q)
                8 - Orbital period
                9 - epoch of elements
               10 - line of variations (delta RA)
               11 - line of variations (delta Dec)
               12 - semi-major axis of error ellipse
               13 - semi-minor axis of error ellipse
               14 - Julian Date of last astrometric measurement
               15 - Arc length of astrometry
               16 - Number of astrometric observations

                 VRA, VDec, line of variations for +1 deg change in M (radians)
                 JDlast - date of last astrometric measurement (nearest day)
                 arc - Arc length of astrometric observations (days)
                 nobs - Number of observations used to generate orbit.
        12    Errors on osculating orbital elements for the object
                 M, arg peri, node, i, e, a, q, Q, Period,
                 (9 values)

        20    Code 0 and Code 3 and Code 6 information.
        21    Code 1 and Code 4 and Code 7 information.
        22    Code 2 and Code 5 and Code 8 information.
        23    Code 2, 5, 8, and 11 information.

           all of the following include errors for all quantities, the
             errors are all together and follow the main quantities.
        31    Barycentric ecliptic x,y,z and velocities, no light time, of date.
        32    Barycentric ecliptic x,y,z and velocities, no light time, B1950.
        33    Barycentric ecliptic x,y,z and velocities, no light time, J2000.
        34    Heliocentric ecliptic x,y,z and velocities, no light time, of date.
        35    Heliocentric ecliptic x,y,z and velocities, no light time, B1950.
        36    Heliocentric ecliptic x,y,z and velocities, no light time, J2000.
        37    Barycentric equatorial x,y,z and velocities, no light time, of date.
        38    Barycentric equatorial x,y,z and velocities, no light time, B1950.
        39    Barycentric equatorial x,y,z and velocities, no light time, J2000.
        40    Heliocentric equatorial x,y,z and velocities, no light time, of date.
        41    Heliocentric equatorial x,y,z and velocities, no light time, B1950.
        42    Heliocentric equatorial x,y,z and velocities, no light time, J2000.
        43    Invariable plane x,y,z and velocities, no light time, of date.
        44    Invariable plane x,y,z and velocities, no light time, B1950.
        45    Invariable plane x,y,z and velocities, no light time, J2000.
        46    Same as 36, plus covariance matrix (48 values total).

     The object code depends on the type of object requested.
     All asteroids are preceeded by A, comets by C, planets and satellites
     by P, and topocentric locations by T.  For asteroids, either the number
     of the asteroid or its provisional designation will work.  Comets
     are recognized by either provisional or final designations, not names.
     Planets and satellites use the NAIF coding scheme for objects.  For
     example, the Pluto-Charon barycenter is 9, Charon is 901 and the
     center of Pluto is 999.  Topocentric locations use the same code as
     for the observatory codes, for example, Anderson Mesa would be T688.
     None of the names allow spaces.  If the object isn't recognized or
     supported by the external databases, RA and Dec values (if requested)
     are returned as -99 and the x,y,z values are returned as 0.  Elements
     will return as zero for invalid input.

 CATEGORY:
  Astronomy
 CALLING SEQUENCE:
     ephem,jd,obs,code,object,ephemeris
 INPUTS:
     jd     - Julian Date (UT) of position to calculate (scalar or vector).
     obs    - Observatory code, Marsden's IAUC codes (scalar).
     code   - Output format code (see description) (scalar).
     object - Object code (see description) (string or string array).

 OPTIONAL INPUT PARAMETERS:
 KEYWORD PARAMETERS:
     CACHE  - Flag, if set, indicates that the ephemeris calculations should
                 be saved in a file for possible later use.  The file name
                 used will be code+'.eph'.  The file will be written
                 to the current directory.  If the cache file exists in
                 the current directory and its length matches the length
                 of the input ephemeris generation request, then the file
                 will be read instead of making the call to the external
                 program, geteph.  If there is no file or if the file isn't
                 the right length, the ephemeris generation will proceed
                 normally.
     FNCACHE - If you need to provide a better (or more unique) file name
                 than the default algorithm, set this keyword to a string
                 to be used as the file name for the cached data.
     PIPE    - If you pass in a valid lun for the geteph pipe, then
                 ephem will use this pipe rather than open up a new one.
                 This can dramatically decrease execution time for numerous
                 "short" calls to ephem.  In this case, the calling program\
                 must open and close the pipe itself.
 OUTPUTS:
     ephemeris - 2-D double precision array of values requested by code.
                         array is NxM where M is equal to the number of
                         times in the input jd array.  N varies depending
                         on the output code (ie., for code=2, N=2)

 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 PROCEDURE:
 MODIFICATION HISTORY:
     3/24/93 - IDL interface written by Marc W. Buie, Lowell Observatory.
     99/07/25, MWB, added CACHE and FNCACHE keyword
     01/04/06, DBT, added PIPE keyword
     01/04/03, MWB, changed to support two error numbers in information
     02/06/28, MWB, added support for codes 31-45
     02/07/01, MWB, added support for code 12
     2002/09/09, MWB, added support for string obscode values
     2002/10/31, MWB, added support for code 46
     2003/04/25, MWB, changed test for bad return on code 12
     2013/03/06, MWB, changed to allow one input time and multiple objects
     2015/03/17, MWB, added support for non-standard observatories