CSPICE_BODS2C translates a string containing a body name or ID code to the
corresponding SPICE integer code.
For important details concerning this module's function, please refer to
the CSPICE routine bods2c_c.
name the scalar string containing the name or ID code of a body or
object, such as a planet, satellite, comet, asteroid, barycenter,
DSN station, spacecraft, or instrument.
If `name' contains the name of a body or object, that name must be
"known" to the SPICE system, whether through hard-coded
registration or run-time registration in the SPICE kernel pool.
Case and leading and trailing blanks in `name' are not significant.
However when a name is made up of more than one word, they must be
separated by at least one blank. That is, all of the following
strings are equivalent names:
'JUPITER BARYCENTER '
' JUPITER BARYCENTER'
However, 'JUPITERBARYCENTER' is not equivalent to the names above.
If NAME is a string representation of an integer, for example
the string will be translated to the equivalent integer datum. The
input integer need not be one recognized by the SPICE system: the
integer need not be a built-in NAIF ID code, nor need it be
associated with a name via run-time registration.
cspice_bods2c, name, code, found
code the scalar integer returning the code(s) for 'name' if 'name'
contains the name(s) of a body or object as determined by the
SPICE name-code mapping subsystem. If the input argument 'name'
represents an integer, the same integer is returned in 'code'.
'code' is assigned a value only if 'found' returns
as true; otherwise it is returned unchanged.
found a scalar boolean with value TRUE if 'name' has a translation.
Otherwise, 'found' is FALSE.
Any numerical results shown for this example may differ between
platforms as the results depend on the SPICE kernels used as input
and the machine specific arithmetic implementation.
;; Define an array of strings. Attempt to
;; convert each to a corresponding integer
;; ID value.
name = [ 'Cassini', '399', $
'Planet Bob', 'MARS', $
for i=0, (n_elements(name) - 1) do begin
;; Loop over each element in 'name'.
cspice_bods2c, name[i], code, found
;; Respond depending on the value of 'found'.
if ( found ) then begin
print, 'Name and corresponding code: ', name[i], code
endif else begin
print, 'No code corresponding to : ', name[i]
Name and corresponding code: Cassini -82
Name and corresponding code: 399 399
No code corresponding to : Planet Bob
Name and corresponding code: MARS 499
Name and corresponding code: -123456 -123456
Name and corresponding code: 987654 987654
cspice_bods2c is one of five related subroutines,
cspice_bods2c Body string to code
cspice_bodc2s Body code to string
cspice_bodn2c Body name to code
cspice_bodc2n Body code to name
cspice_boddef Body name/code definition
cspice_bods2c, cspice_bodc2s, cspice_bodn2c, and cspice_bodc2n
perform translations between body names and their corresponding
integer ID codes which are used in SPICE files and routines.
cspice_bods2c is a slightly more general version of cspice_bodn2c:
support for strings containing ID codes in string format enables a caller
to identify a body using a string, even when no name is associated with
cspice_bodc2s is a general version of cspice_bodc2n; the routine returns
either the name assigned in the body ID to name mapping or a string
representation of the 'code' value if no mapping exists.
cspice_boddef assigns a body name to ID mapping. The mapping has
priority in name-to-ID and ID-to-name translations.
Refer to NAIF_IDS.REQ for the list of name/code associations built
into SPICE, and for details concerning adding new name/code
associations at run time by loading text kernels.
-Icy Version 1.0.2, 29-APR-2011, EDW (JPL)
Edits to I/O section so as to parallel Mice version.
-Icy Version 1.0.1, 16-MAY-2009, EDW (JPL)
Edit to Particulars section to document the cspice_bodc2s routine.
Extended argument descriptions in the I/O section.
-Icy Version 1.0.0, 22-SEP-2004, EDW (JPL)
body name to code