Main Page
Most Used Mice APIs

Mice APIs for accessing SPICE kernel data

Mice APIs for computing derived geometry

Mice APIs for checking geometric conditions

Mice APIs for finding times of geometric events

Mice APIs for coordinate conversions

Mice APIs for operations with 3D vectors and matrices

Miscellaneous Mice APIs


Top

Loading and Unloading SPICE Kernels

APIs:

  • cspice_furnsh - loads an individual kernel or a collection of kernels.
  • cspice_unload - unloads an individual kernel or a collection of kernels.

Brief Example:

   Generic LSK and PCK files listed in a meta-kernel named
   "mykernels.furnsh" and containing

      \begindata
         KERNELS_TO_LOAD = (
                            '/kernels/gen/lsk/naif0008.tls'
                            '/kernels/gen/pck/pck00008.tps'
                           )
      \begintext

   are loaded with a single call to cspice_furnsh:

      cspice_furnsh( 'mykernels.furnsh' );

Reference documents:

  • kernel.req - reference on loading/unloading kernels and text kernel format

Top

Converting between UTC and Ephemeris Time (LSK)

APIs:

  • cspice_furnsh - loads an individual kernel or a collection of kernels.
  • cspice_str2et - converts a time string to ET seconds past J2000.
  • cspice_timout - converts ET seconds past J2000 to a time string.

Brief Example:

   The following example loads an LSK file, converts a UTC string to ET
   seconds, adds 1 day and converts TDB seconds back to a UTC string in
   ISO DOY format:

      %
      % load LSK file
      %
      cspice_furnsh( 'naif0008.tls' );

      %
      % convert UTC to ET
      %
      et = cspice_str2et( '2005 DEC 31 12:00' );

      %
      % add 1 day to ET and convert it back to UTC
      %
      utc = cspice_timout( et+cspice_spd, ...
                           'YYYY-DOYTHR:MN:SC.### ::RND' );

Reference documents:

  • time.req - reference on time systems and conversions supported in SPICE
  • kernel.req - reference on loading/unloading kernels and text kernel format

Top

Converting between Ephemeris Time and Spacecraft Clock (SCLK)

APIs:

  • cspice_furnsh - loads individual kernels and collections of kernels.
  • cspice_scs2e - converts an SCLK string to ET seconds past J2000.
  • cspice_sce2s - converts ET seconds past J2000 to SCLK string.
  • cspice_sct2e - converts an encoded SCLK to ET seconds past J2000.
  • cspice_sce2c - converts ET seconds past J2000 to encoded SCLK.
  • cspice_scencd - converts an SCLK string to encoded SCLK.
  • cspice_scdecd - converts an encoded SCLK to SCLK string.

Brief Example:

   The following example loads an LSK file and an MGS SCLK file, then
   converts an MGS SCLK string to ET and encoded SCLK:

      scid = -94;

      %
      % load LSK and SCLK files
      %
      cspice_furnsh( 'naif0008.tls'           );
      cspice_furnsh( 'mgs_sclkscet_00061.tsc' );

      %
      % convert string SCLK to ET and to encoded SCLK
      %
      sclk = '820584056:121';
      et = cspice_scs2e( scid, sclk );
      sclkdp = cspice_scencd( scid, sclk );

Reference documents:

  • sclk.req - reference on on-board clock (SCLK) implementation in SPICE
  • kernel.req - reference on loading/unloading kernels and text kernel format

Top

Constants and Orientation for Natural Bodies (PCK)

APIs:

  • cspice_furnsh - loads individual kernels and collections of kernels.
  • cspice_bodfnd - determines whether values exist for some item for a body in the kernel pool.
  • cspice_bodvrd - retrieves from the kernel pool the values of an item associated with a body.
  • cspice_pxform - returns the 3x3 matrix rotating a position vector one frame to another.
  • cspice_sxform - returns the 6x6 matrix rotating a state vector from one frame to another.
  • cspice_pckfrm - finds the set of reference frame class ID codes of all frames in a binary PCK file.
  • cspice_pckcov - finds the coverage window for a reference frame in a binary PCK file.

Brief Example:

   The following example retrieves radii for Mars and computes
   orientation of the Mars body-fixed frame:

      %
      % load LSK and PCK files
      %
      cspice_furnsh( 'naif0008.tls' );
      cspice_furnsh( 'pck00008.tpc' );

      %
      % retrieve Mars radii
      %
      radii = cspice_bodvrd( 'MARS', 'RADII', 3 );

      %
      % convert UTC to ET
      %
      et = cspice_str2et( '2005-DEC-28 12:00' );

      %
      % compute Mars orientation relative to the J2000 frame
      %
      mat = cspice_pxform( 'J2000', 'IAU_MARS', et );

Reference documents:

  • pck.req - reference on Planetary Constants Kernel (PCK) subsystem of SPICE
  • kernel.req - reference on loading/unloading kernels and text kernel format

Top

Computing Transformations Between Frames (FK)

APIs:

  • cspice_furnsh - loads individual kernels and collections of kernels.
  • cspice_pxform - returns the 3x3 matrix rotating a position vector one frame to another.
  • cspice_sxform - returns the 6x6 matrix rotating a state vector from one frame to another.
  • cspice_pxfrm2 - returns the 3x3 matrix rotating a position vector from one frame at a specified epoch to another frame at a different epoch.

Brief Example:

   The following example computes orientation of the CASSINI ISS WAC
   camera relative to the Saturn body-fixed frame:

      %
      % load kernels: LSK, PCK, CASSINI SCLK, FK and CK
      %
      cspice_furnsh( 'naif0008.tls'     );
      cspice_furnsh( 'pck00008.tpc'     );
      cspice_furnsh( 'cas00101.tsc'     );
      cspice_furnsh( 'cas_v39.tf'       );
      cspice_furnsh( '05362_06002ra.bc' );

      %
      % convert UTC to ET
      %
      et = cspice_str2et( '2005-DEC-28 12:00' );

      %
      % compute orientation of CASSINI relative to J2000 frame
      %
      mat = cspice_pxform( 'IAU_SATURN', 'CASSINI_ISS_WAC', et );

Reference documents:

  • frames.req - reference on Frames Kernel (FK) and Frames subsystem of SPICE
  • kernel.req - reference on loading/unloading kernels and text kernel format

Top

Computing Positions of Spacecraft and Natural Bodies (SPK)

APIs:

  • cspice_furnsh - loads individual kernels and collections of kernels.
  • cspice_spkezr - returns the state of a target body relative to an observing body.
  • cspice_spkpos - returns the position of a target body relative to an observing body.
  • cspice_spkcpo - returns the state of a target body relative to a constant-position observer location.
  • cspice_spkcpt - returns the state of a constant-position target location relative to an observing body.
  • cspice_spkcvo - returns the state of a target body relative to a constant-velocity observer location.
  • cspice_spkcvt - returns the state of a constant-velocity target location relative to an observing body.
  • cspice_spkobj - finds the set of ID codes for all objects in a specified SPK file.
  • cspice_spkcov - finds the coverage window for a specified object in a specified SPK file.

Brief Example:

   The following example computes the geometric state (position and
   velocity) of MGS relative to Mars in the J2000 reference frame:

      %
      % load kernels: LSK and MGS and DE SPKs
      %
      cspice_furnsh( 'naif0008.tls'  );
      cspice_furnsh( 'de405.bsp'     );
      cspice_furnsh( 'mgs_ext22.bsp' );

      %
      % convert UTC to ET
      %
      et = cspice_str2et( '2006 JAN 31 01:00' );

      %
      % compute geometric state of MGS relative to Mars
      %
      [ state, ltime ] = cspice_spkezr( 'MGS', et, 'J2000', ...
                                        'NONE', 'MARS' );

Reference documents:

  • spk.req - reference on Spacecraft and Planet Ephemeris (SPK) subsystem of SPICE
  • frames.req - reference on Frames Kernel (FK) and Frames subsystem of SPICE
  • kernel.req - reference on loading/unloading kernels and text kernel format

Top

Computing Orientation for Spacecraft and Instruments (CK)

APIs:

  • cspice_furnsh - loads individual kernels and collections of kernels.
  • cspice_pxform - returns the 3x3 matrix rotating a position vector one frame to another.
  • cspice_sxform - returns the 6x6 matrix rotating a state vector from one frame to another.
  • cspice_ckobj - finds the set of ID codes for all objects in a specified CK file.
  • cspice_ckcov - finds the coverage window for a specified object in a specified CK file.
  • cspice_ckgp - gets pointing for a specified CK ID at a specified SCLK time.
  • cspice_ckgpav - gets pointing and angular velocity for a specified CK ID at a specified SCLK time.

Brief Example:

   The following example computes orientation of the CASSINI spacecraft
   provided in CK files using the Frames subsystem routine
   cspice_pxform:

      %
      % load kernels: LSK, CASSINI SCLK, FK and CK
      %
      cspice_furnsh( 'naif0008.tls'     );
      cspice_furnsh( 'cas00101.tsc'     );
      cspice_furnsh( 'cas_v39.tf'       );
      cspice_furnsh( '05362_06002ra.bc' );

      %
      % convert UTC to ET
      %
      et = cspice_str2et( '2005-DEC-28 12:00' );

      %
      % compute orientation of CASSINI relative to J2000 frame
      %
      mat = cspice_pxform( 'J2000', 'CASSINI_SC_COORD', et );

Reference documents:

  • ck.req - reference on spacecraft orientation (CK) subsystem of SPICE
  • frames.req - reference on Frames Kernel (FK) and Frames subsystem of SPICE
  • kernel.req - reference on loading/unloading kernels and text kernel format

Top

Retrieving Instrument Parameters (IK)

APIs:

  • cspice_furnsh - loads individual kernels and collections of kernels.
  • cspice_getfvn - returns the field-of-view (FOV) configuration for an instrument specified by name.
  • cspice_getfov - returns the field-of-view (FOV) configuration for an instrument specified by ID.
  • cspice_gdpool - returns the double precision value of a kernel variable from the kernel pool.
  • cspice_gipool - returns the integer value of a kernel variable from the kernel pool.
  • cspice_gcpool - returns the character value of a kernel variable from the kernel pool.

Brief Example:

   The following example retrieves the M01 THEMIS IR camera focal
   length and FOV parameters:

      %
      % load M01 FK and THEMIS IK
      %
      cspice_furnsh( 'm01_v28.tf'        );
      cspice_furnsh( 'm01_themis_v32.ti' );

      %
      % retrieve M01 THEMIS IR pixel size
      %
      [ fl, found ] = cspice_gdpool( 'INS-53031_FOCAL_LENGTH', 0, 1 );

      %
      % retrieve M01 THEMIS IR FOV parameters
      %
      [ shape, frame, bsight, bounds ] = cspice_getfvn( 'M01_THEMIS_IR', 4 );

Reference documents:

  • kernel.req - reference on loading/unloading kernels and text kernel format

Top

Computing surface coordinates using digital shape (DSK)

APIs:

  • cspice_furnsh - loads individual kernels and collections of kernels.
  • cspice_latsrf - maps an array of planetocentric longitude/latitude coordinate pairs to surface points on a body, modeled as an ellipsoid or a digital shape (DSK).
  • cspice_srfnrm - maps an array of surface points on a body, modeled as an ellipsoid or a digital shape (DSK), to the corresponding outward surface normal vectors.
  • cspice_dskz02 - returns plate model size parameters (plate count and vertex count) for a type 2 DSK segment.
  • cspice_dskp02 - returns triangular plates from a type 2 DSK segment.
  • cspice_dskv02 - returns vertices from a type 2 DSK segment.
  • cspice_dskobj - returns the set of body ID codes of all objects for which data are provided in a DSK file.
  • cspice_dsksrf - returns the set of surface ID codes for all surfaces associated with a body in a DSK file.

Brief Example:

   The following example computes surface points and normals for
   for a one-degree longitude/latitude grid on Phobos modeled by
   a DSK:

      %
      % Load generic PCK and Phobos DSK.
      %
      cspice_furnsh ( 'pck00010.tpc' );
      cspice_furnsh ( 'phobos512.bds' );

      %
      % Generate longitude/latitude pairs of the grid (without
      % poles).
      %
      n = 0;
      grid = eye( 2, 360 * 179 );
      for i = 1:360
	       for j = 1:179
	          n   = n + 1;
	          grid(1,n) = cspice_rpd() *   i;
	          grid(2,n) = cspice_rpd() * ( j - 90 );
	       end
      end

      %
      % Compute surface points based on DSK.
      %
      srfpts = cspice_latsrf ( 'DSK/UNPRIORITIZED', 'PHOBOS', 0.0, ...
                               'IAU_PHOBOS', grid );

      %
      % Compute surface normals based on DSK.
      %
      normls = cspice_srfnrm ( 'DSK/UNPRIORITIZED', 'PHOBOS', 0.0, ...
                               'IAU_PHOBOS', srfpts );

Reference documents:

  • dsk.req - reference on Digital Shape Kernels (DSK) subsystem of SPICE
  • kernel.req - reference on loading/unloading kernels and text kernel format

Top

Mapping Between Object Names and NAIF IDs

APIs:

  • cspice_furnsh - loads individual kernels and collections of kernels.
  • cspice_bodc2n - translates the NAIF integer code of a body into a common name for that body.
  • cspice_bodn2c - translates the name of a body or object to the corresponding NAIF integer ID code.

Brief Example:

   The following example uses cspice_bodn2c to get the NAIF ID for
   Phobos (built into the SPICE system) and for the M01 THEMIS IR
   camera (defined in the M01 FK file):

      %
      % load FK defining M01 name-ID mappings
      %
      cspice_furnsh( 'm01_v28.tf' );

      %
      % get NAIF ID for Phobos
      %
      [ phobos_id, found ] = cspice_bodn2c( 'PHOBOS' );

      %
      % get NAIF ID for THEMIS IR camera
      %
      [ themis_ir_id, found ] = cspice_bodn2c( 'M01_THEMIS_IR' );

Reference documents:

  • naif_ids.req - reference on object names and IDs supported in SPICE
  • kernel.req - reference on loading/unloading kernels and text kernel format

Top

Mapping objects to their preferred reference frames

APIs:

  • cspice_furnsh - loads individual kernels and collections of kernels.
  • cspice_cnmfrm - returns the preferred reference frame for an object specified by name.
  • cspice_cidfrm - returns the preferred reference frame for an object specified by ID.

Brief Example:

   The following example loads a text kernel that sets the preferred
   reference frame for the Earth to 'ITRF93' and calls cspice_cnmfrm to
   retrieve the name of this frame:

      %
      % load FK associating 'ITRF93' with the Earth
      %
      cspice_furnsh ( 'earth_assoc_itrf93.tf' );

      %
      % retrieve the name of the preferred frame for the Earth
      %
      [ frcode, frname, found ] = cspice_cnmfrm( 'EARTH' );

Reference documents:

  • frames.req - reference on Frames Kernel (FK) and Frames subsystem of SPICE
  • kernel.req - reference on loading/unloading kernels and text kernel format

Top

Mapping between surface names and NAIF IDs

APIs:

  • cspice_furnsh - loads individual kernels and collections of kernels.
  • cspice_srfcss - translates a surface ID code, together with a body name, to the corresponding surface name.
  • cspice_srfs2c - translates a surface string, together with a body name, to the corresponding surface ID code.
  • cspice_srfc2s - translates a surface ID code, together with a body ID code, to the corresponding surface name.
  • cspice_srfscc - translates a surface string, together with a body ID code, to the corresponding surface ID code.

Brief Example:

   The following example uses SRFS2C to get the surface ID for
   the 67P/Churyumov-Gerasimenko DSK surface named
   'ROS_CG_M001_OMSDLAM_N_V1':

      %
      % Load ROS FK defining surface name-ID mappings
      %
      cspice_furnsh ( 'ROS_V25.TF' );

      %
      % Get NAIF ID for the surface 'ROS_CG_M001_OMSDLAM_N_V1'
      %
      [ surfid, found ] = cspice_srfs2c ( 'ROS_CG_M001_OMSDLAM_N_V1', ...
                                          '67P/C-G' );

Reference documents:

  • dsk.req - reference on Digital Shape Kernels (DSK) subsystem of SPICE
  • naif_ids.req - reference on object names and IDs supported in SPICE
  • kernel.req - reference on loading/unloading kernels and text kernel format

Top

Computing Planetocentric, Planetodetic, and Planetographic Coordinates

APIs:

  • cspice_reclat - converts from rectangular to planetocentric coordinates.
  • cspice_latrec - converts from planetocentric to rectangular coordinates.
  • cspice_srfrec - converts from planetocentric lat/lon of a surface point on a body to rectangular coordinates.
  • cspice_recgeo - converts from rectangular to geodetic coordinates.
  • cspice_georec - converts from geodetic to rectangular coordinates.
  • cspice_recpgr - converts from rectangular to planetographic coordinates.
  • cspice_pgrrec - converts from planetographic to rectangular coordinates.

Brief Example:

   The following example computes the planetocentric, planetodetic and
   planetographic coordinates for a point given as a Cartesian vector
   with respect to Mars in the Mars body-fixed frame (IAU_MARS):

      %
      % load PCK file
      %
      cspice_furnsh( 'pck00008.tpc' );

      %
      % retrieve Mars radii
      %
      radii = cspice_bodvrd( 'MARS', 'RADII', 3 );
      f = (radii(1) - radii(3))/radii(1);

      %
      % package 3D vector
      %
      vec = [3373.850; -351.034; -117.267];

      %
      % compute planetocentric coordinates
      %
      [ pcr, pclon, pclat ] = cspice_reclat( vec );

      %
      % compute planetodetic coordinates
      %
      [ pdlon, pdlat, pdalt ] = cspice_recgeo( vec, radii(1), f );

      %
      % compute planetographic coordinates
      %
      [ pglon, pglat, pgalt ] = cspice_recpgr( 'MARS', vec, radii(1), f );

Reference documents:

  • pck.req - reference on Planetary Constants Kernel (PCK) subsystem of SPICE
.

Top

Computing azimuth and elevation

APIs:

  • cspice_azlcpo - returns azimuth and elevation a target body relative to a constant-position observer location.
  • cspice_azlrec - converts from azimuth and elevation to rectangular coordinates.
  • cspice_recazl - converts from rectangular coordinates to azimuth and elevation.

Brief Example:

   The following example computes the azimuth/elevation coordinates
   of the Sun as seen from a location on Mars specified by its
   planetocentric coordinates:

      %
      % load kernels: LSK, PCK, and satellite ephemeris SPK
      %
      cspice_furnsh( 'naif0012.tls' );
      cspice_furnsh( 'pck00010.tpc' );
      cspice_furnsh( 'mar097s.bsp'  );

      %
      % convert planetocentric coordinates of the observer
      % to rectangular coordinates.
      %
      r   = 3390.42;
      lon =  175.30;
      lat =  -14.59;

      obspos = cspice_latrec( r, lon * cspice_rpd, lat * cspice_rpd );

      %
      % convert UTC to ET
      %
      et = cspice_str2et( '2022 JAN 31 01:00' );

      %
      % compute azimuth/elevation coordinates with the azimuth
      % increasing clockwise about and the elevation positive
      % towards +Z axis of the local topocentric reference frame.
      %
      [azlsta, ltim] = cspice_azlcpo( 'ELLIPSOID', 'SUN', et, ...
                                      'CN+S', false, true, ...
                                      obspos, 'MARS', 'IAU_MARS' );

Top

Computing Surface Intercept Point

APIs:

  • cspice_sincpt - computes the surface intercept point of the ray on a body, modeled as an ellipsoid or a digital shape (DSK), at a specified epoch.
  • cspice_dskxv - computes ray-surface intercepts for a set of rays, using data provided by multiple loaded DSK segments.
  • cspice_dskxsi - computes a ray-surface intercept using data provided by multiple loaded DSK segments and returns information about the source of the data defining the surface on which the intercept was found.

Brief Example:

   The following example computes the surface intercept point of the
   MGS MOC NA camera boresight with the surface of Mars modeled as
   an ellipsoid:

      %
      % load kernels: LSK, PCK, MGS SCLK, planet/satellite
      % ephemeris SPK, MGS spacecraft SPK, MGS spacecraft
      % CK, MGS FK, and MOC IK
      %
      cspice_furnsh( 'naif0008.tls'           );
      cspice_furnsh( 'mars_iau2000_v0.tpc'    );
      cspice_furnsh( 'mgs_sclkscet_00061.tsc' );
      cspice_furnsh( 'mar063.bsp'             );
      cspice_furnsh( 'mgs_ext22.bsp'          );
      cspice_furnsh( 'mgs_sc_ext22.bc'        );
      cspice_furnsh( 'mgs_v10.tf'             );
      cspice_furnsh( 'mgs_moc_v20.ti'         );

      %
      % retrieve MOC NA camera boresight direction
      %
      [ shape, frame, bsight, bounds ] = cspice_getfvn( 'MGS_MOC_NA', 4 );

      %
      % convert UTC to ET
      %
      et = cspice_str2et( '2006 JAN 31 01:00' );

      %
      % compute surface intercept point
      %
      [ spoint, trgepc, srfvec, found ] = ...
         cspice_sincpt( 'Ellipsoid', 'MARS', et, 'IAU_MARS', ...
                        'CN+S', 'MGS', frame, bsight );

Top

Computing point on a ray nearest to the body's surface

APIs:

  • cspice_tangpt - computes the "tangent point", the point on a ray nearest to the target's surface, modeled as an ellipsoid, at a specified epoch.

Brief Example:

   The following example computes the tangent point on the MAVEN
   IUVS instrument boresight nearest to the surface of Mars modeled
   as an ellipsoid:

      %
      % load kernels: LSK, PCK, MAVEN SCLK, planet/satellite
      % ephemeris SPK, MAVEN spacecraft SPK, MAVEN FK, IUVS
      % IK, and MAVEN spacecraft, IPP, and IUVS CKs.
      %
      cspice_furnsh( 'naif0012.tls'                       );
      cspice_furnsh( 'pck00010.tpc'                       );
      cspice_furnsh( 'mvn_sclkscet_00086.tsc'             );
      cspice_furnsh( 'mar097s.bsp'                        );
      cspice_furnsh( 'maven_orb_rec_201001_210101_v1.bsp' );
      cspice_furnsh( 'maven_v09.tf'                       );
      cspice_furnsh( 'maven_iuvs_v11.ti'                  );
      cspice_furnsh( 'mvn_sc_rel_201005_201011_v01.bc'    );
      cspice_furnsh( 'mvn_app_rel_201005_201011_v01.bc'   );
      cspice_furnsh( 'mvn_iuvs_rem_201001_201231_v01.bc'  );

      %
      % retrieve IUVS boresight direction
      %
      [ shape, frame, bsight, bounds ] = cspice_getfvn( 'MAVEN_IUVS', 12 );

      %
      % convert UTC to ET
      %
      et = cspice_str2et( '2020-10-11 16:01:43' );

      %
      % compute tangent point
      %
      [tanpt, alt, range, srfpt, trgepc, srfvec] = ...
         cspice_tangpt( 'ELLIPSOID',  'MARS', et, 'IAU_MARS', 'CN+S', ...
                        'TANGENT POINT', 'MAVEN', frame, bsight );

Top

Computing Sub-observer and Sub-solar Points

APIs:

  • cspice_subpnt - computes the sub-observer point on a body, modeled as an ellipsoid or a digital shape (DSK), at a particular epoch.
  • cspice_subslr - computes the sub-solar point on a body, modeled as an ellipsoid or a digital shape (DSK), as seen by an observer at a particular epoch.

Brief Example:

   The following example computes the sub-spacecraft and sub-solar
   points on Mars, modeled as an ellipsoid, for MGS:

      %
      % load kernels: LSK, PCK, planet/satellite SPK
      % and MGS spacecraft SPK
      %
      cspice_furnsh( 'naif0008.tls'        );
      cspice_furnsh( 'mars_iau2000_v0.tpc' );
      cspice_furnsh( 'mar063.bsp'          );
      cspice_furnsh( 'mgs_ext22.bsp'       );

      %
      % convert UTC to ET
      %
      et = cspice_str2et( '2006 JAN 31 01:00' );

      %
      % compute sub-spacecraft point
      %
      [ scraft, trgepc, srfvec ] = ...
         cspice_subpnt( 'Near point: ellipsoid', 'MARS', ...
                        et, 'IAU_MARS', 'LT+S', 'MGS' );

      %
      % compute sub-solar point
      %
      [ ssolar, trgepc, srfvec ] = ...
         cspice_subslr( 'Near point: ellipsoid', 'MARS', ...
                        et, 'IAU_MARS', 'LT+S', 'MGS' );

Top

Computing Illumination Angles

APIs:

  • cspice_ilumin - computes the illumination angles at a specified surface point of a target body, modeled as an ellipsoid or a digital shape (DSK), as seen from an observer body, illuminated by the Sun.
  • cspice_illumg - computes the illumination angles at a specified surface point of a target body, modeled as an ellipsoid or a digital shape (DSK), as seen from an observer body, illuminated by a user specified body.
  • cspice_illumf - computes the illumination angles at a specified surface point of a target body, modeled as an ellipsoid or a digital shape (DSK), as seen from an observer body, illuminated by a user specified body, with flags indicating whether the point is visible from the observer and whether it is illuminated.
  • cspice_phaseq - computes the apparent phase angle between the centers of target, observer, and illuminator ephemeris objects.

Brief Example:

   The following example computes the illumination angles for a point
   specified using planetocentric coordinates, observed by MGS:

      r   = 3390.42;
      lon =  175.30;
      lat =  -14.59;

      %
      % load kernels: LSK, PCK, planet/satellite SPK
      % and MGS spacecraft SPK
      %
      cspice_furnsh( 'naif0008.tls'        );
      cspice_furnsh( 'mars_iau2000_v0.tpc' );
      cspice_furnsh( 'mar063.bsp'          );
      cspice_furnsh( 'mgs_ext22.bsp'       );

      %
      % convert planetocentric r/lon/lat to Cartesian vector
      %
      point = cspice_latrec( r, lon * cspice_rpd, lat * cspice_rpd );

      %
      % convert UTC to ET
      %
      et = cspice_str2et( '2006 JAN 31 01:00' );

      %
      % compute illumination angles modeling Mars as
      % an ellipsoid
      %
      [ trgepc, srfvec, phase, solar, emissn ] = ...
         cspice_ilumin( 'Ellipsoid', 'MARS', et, 'IAU_MARS', ...
                        'LT+S', 'MGS', point );

Top

Computing limb and terminator

APIs:

  • cspice_limbpt - computes limb points on a body, modeled as an ellipsoid or a digital shape (DSK).
  • cspice_termpt - computes umbral or penumbral terminator points on a body, modeled as an ellipsoid or a digital shape (DSK).

Brief Example:

   The following example computes the apparent limb points on
   Phobos, modeled by a DSK, as seen from Mars:

      MAXN = 10000;
      z = [ 0.0, 0.0, 1.0 ]';

      %
      % Load kernels: LSK, PCK, planet/satellite SPK
      % and Phobos DSK
      %
      cspice_furnsh ( 'naif0011.tls'  );
      cspice_furnsh ( 'pck00010.tpc'  );
      cspice_furnsh ( 'de430.bsp'     );
      cspice_furnsh ( 'mar097.bsp'    );
      cspice_furnsh ( 'phobos512.bds' );

      %
      % Convert UTC to ET
      %
      et = cspice_str2et ( '2008 AUG 11 00:00:00' );

      %
      % Compute limb points in 360 cutting half-planes
      % spaced 1 degree apart about the Mars-Phobos
      % direction.
      %
      [npts, points, trgeps, tangts] = cspice_limbpt ...
                ( 'TANGENT/DSK/UNPRIORITIZED', 'PHOBOS', ET, ...
                  'IAU_PHOBOS', 'CN+S', 'CENTER', 'MARS', z, ...
                  1./cspice_dpr(), 360, 1.e-4, 1.e-7, MAXN );

Top

Computing angular separation between two bodies

APIs:

  • cspice_trgsep - Computes the angular separation between two spherical or point bodies at a specified epoch.

Brief Example:

   The following example computes the apparent angular separation
   of the Sun and Moon modeled as spheres as observed from the Earth:

      %
      % Load kernels: LSK, PCK, and planetary ephemeris SPK
      %
      cspice_furnsh ( 'naif0012.tls' );
      cspice_furnsh ( 'pck00010.tpc' );
      cspice_furnsh ( 'de421.bsp'    );

      %
      % Convert UTC to ET
      %
      et = cspice_str2et ( '2021-12-04T07:33:00' );

      %
      % Compute angular separation
      %
      angle = cspice_trgsep( et, ...
                            'SUN',   'SPHERE', 'IAU_SUN', ...
                            'MOON',  'SPHERE', 'IAU_MOON', ...
                            'EARTH', 'CN+S'    );

Top

Computing and Propagating Orbital Elements

APIs:

  • cspice_conics - determines the state of an orbiting body from a set orbital elements.
  • cspice_oscelt - determines the set of orbital elements corresponding to the state of a body.
  • cspice_getelm - parses the "lines" of a two-line element set, returning the elements in units suitable for use in SPICE APIs.
  • cspice_evsgp4 - evaluates NORAD two-line elements for earth orbiting spacecraft using algorithms by D. Vallado.

Brief Example:

   The following example computes the set of orbital elements for the
   state of the Mars Express spacecraft at a given time:

      %
      % load kernels: LSK, MEX trajectory SPK, and gravity PCK
      %
      cspice_furnsh( 'naif0008.tls'                 );
      cspice_furnsh( 'ORMM__050901000000_00165.BSP' );
      cspice_furnsh( 'DE403-MASSES.TPC'             );

      %
      % retrieve GM for Mars
      %
      gm = cspice_bodvrd( 'MARS', 'GM', 1 );

      %
      % convert UTC to ET
      %
      et = cspice_str2et( '2005 SEP 02 04:50:45' );

      %
      % compute state of MEX at given UTC
      %
      [ state, lt ] = cspice_spkezr( 'MEX', et, ...
                                     'MARSIAU', 'NONE', 'MARS' );

      %
      % compute orbital elements
      %
      elts = cspice_oscelt( state, et, gm );

Top

Checking for in Field-Of-View (FOV) conditions

APIs:

  • cspice_fovray - determines if a specified ray is within the FOV of a specified instrument at a given time.
  • cspice_fovtrg - determines if a specified ephemeris object is within the FOV of a specified instrument at a given time.

Brief Example:

   The following example determines if Phoebe is in the CASSINI
   ISS NAC FOV on 2004-06-11 18:00 UTC:

      %
      % Load kernels.
      %
      cspice_furnsh( 'cas_2004_v17.tm' );

      %
      % Convert UTC to ET.
      %
      et = cspice_str2et( '2004-06-11 18:00' );

      %
      % Check for in-FOV condition.
      %
      visibl = cspice_fovtrg( 'CASSINI_ISS_NAC', 'PHOEBE',       ...
                              'ELLIPSOID', 'IAU_PHOEBE', 'CN+S', ...
                              'CASSINI', et );

Top

Checking for occultation conditions

APIs:

  • cspice_occult - determines the occultation condition (not occulted, partially, etc.) of one target relative to another target as seen by an observer at a given time, with targets modeled as points, ellipsoids, or digital shapes (DSK).

Brief Example:

   The following example determines if the Sun is occulted by Saturn as
   seen from CASSINI on 2005-05-03 06:00 UTC, with both Sun and Saturn
   modeled as ellipsoids:

      %
      % Load kernels.
      %
      cspice_furnsh( 'cas_2005_v17.tm' );

      %
      % Convert UTC to ET.
      %
      et = cspice_str2et( '2005-05-03 06:00' );

      %
      % Check for in-FOV condition.
      %
      ocltid = cspice_occult( 'SATURN', 'ELLIPSOID', 'IAU_SATURN', ...
                              'SUN',    'ELLIPSOID', 'IAU_SUN',    ...
                              'CN',     'CASSINI',   et );

      if ( ocltid > 0 )
         disp( 'CASSINI IS IN SATURN SHADOW.' );
      end

Top

Finding times of events satisfying numerical constraints

APIs:

  • cspice_gfdist - determines time intervals when a specified constraint on observer-target distance is met.
  • cspice_gfilum - determines time intervals when a specified constraint on the observed phase, solar incidence, or emission angle at a surface point is met.
  • cspice_gfpa - determines time intervals when a specified constraint on the phase angle between the illuminator, target, and observer body centers is met.
  • cspice_gfposc - determines time intervals when a coordinate of an observer-target position vector satisfies a numerical constraint.
  • cspice_gfrr - determines time intervals when a specified constraint on the observer-target range rate is met.
  • cspice_gfsep - determines time intervals when the angular separation between the position vectors of two target bodies relative to an observer satisfies a numerical relationship.
  • cspice_gfsntc - determines time intervals when a coordinate of a ray-surface intercept position vector satisfies a numerical constraint.
  • cspice_gfsubc - determines time intervals when a coordinate of a sub-observer point position vector satisfies a numerical constraint.

Brief Example:

   The following example determines time intervals between Jan 1 and
   and April 1, 2007 when the distance between the Moon and the Earth
   was greater than 400,000 km.

      %
      % Load kernels.
      %
      cspice_furnsh( 'naif0008.tls' );
      cspice_furnsh( 'de421.bsp'    );

      %
      % Store the time bounds in the confinement window.
      %
      et = cspice_str2et( { '2007 JAN 01', '2007 APR 01'} );
      cnfine = cspice_wninsd( et(1), et(2) );

      %
      % Set search parameters. Use a step size of 1 day (in units of
      % seconds).
      %
      MAXWIN  = 1000;

      target  = 'MOON';
      abcorr  = 'NONE';
      obsrvr  = 'EARTH';
      relate  = '>';
      refval  = 4.e5;
      adjust  = 0.;

      step    = 1.*cspice_spd;

      %
      % Perform search.
      %
      result = cspice_gfdist( target, abcorr, obsrvr, ...
			      relate, refval, adjust, ...
			      step,   MAXWIN,        ...
			      cnfine);

Reference documents:

  • gf.req - reference on the Geometry Finder (GF) subsystem of SPICE

Top

Finding times of events satisfying FOV constraints

APIs:

  • cspice_gfrfov - determines time intervals when a specified ray intersects the space bounded by the field-of-view (FOV) of a specified instrument.
  • cspice_gftfov - determines time intervals when a specified ephemeris object intersects the space bounded by the field-of-view (FOV) of a specified instrument.

Brief Example:

   The following example determines time intervals between 09:00 and
   11:15 UTC on Jun 11, 2004 when Saturn's satellite Phoebe was within
   the FOV of the Cassini narrow angle camera (CASSINI_ISS_NAC).

      %
      % Load kernels.
      %
      cspice_furnsh( 'naif0009.tls'              );
      cspice_furnsh( 'cpck05Mar2004.tpc'         );
      cspice_furnsh( '981005_PLTEPH-DE405S.bsp'  );
      cspice_furnsh( '020514_SE_SAT105.bsp'      );
      cspice_furnsh( '030201AP_SK_SM546_T45.bsp' );
      cspice_furnsh( 'cas_v37.tf'                );
      cspice_furnsh( '04135_04171pc_psiv2.bc'    );
      cspice_furnsh( 'cas00084.tsc'              );
      cspice_furnsh( 'cas_iss_v09.ti'            );

      %
      % Store the time bounds in the confinement window.
      %
      et = cspice_str2et( { '2004 JUN 11 09:00', ...
			    '2004 JUN 11 11:15' } );
      cnfine = cspice_wninsd( et(1), et(2) );

      %
      % Set search parameters. Use a step size of 10 seconds.
      %
      MAXWIN = 1000;

      inst   = 'CASSINI_ISS_NAC';
      target = 'PHOEBE';
      tshape = 'ELLIPSOID';
      tframe = 'IAU_PHOEBE';
      abcorr = 'LT+S';
      obsrvr = 'CASSINI';

      step   = 10.;

      %
      % Perform search.
      %
      result = cspice_gftfov( inst,  target, tshape, tframe, ...
			      abcorr, obsrvr, step, cnfine, MAXWIN);

Reference documents:

  • gf.req - reference on the Geometry Finder (GF) subsystem of SPICE

Top

Finding times of occultations

APIs:

  • cspice_gfoclt - determines time intervals when an observer sees one target occulted by another, with targets modeled as points, ellipsoids, or digital shapes (DSK).

Brief Example:

   The following example determines time intervals in December, 2001
   when the Sun is occulted by the Moon (solar eclipses) as seen from
   the center of the Earth, with both Sun and Moon modeled as
   ellipsoids:

      %
      % Load kernels.
      %
      cspice_furnsh( 'naif0008.tls' );
      cspice_furnsh( 'de421.bsp'    );
      cspice_furnsh( 'pck00008.tpc' );

      %
      % Store the time bounds the confinement window.
      %
      et = cspice_str2et( { '2001 DEC 01', '2002 JAN 01'} );
      cnfine = cspice_wninsd( et(1), et(2) );

      %
      % Set search parameters. Select a 3-minute step.
      %
      MAXWIN  = 1000;

      occtyp  = 'ANY';
      front   = 'MOON';
      fshape  = 'ELLIPSOID';
      fframe  = 'IAU_MOON';
      back    = 'SUN';
      bshape  = 'ELLIPSOID';
      bframe  = 'IAU_SUN';
      obsrvr  = 'EARTH';
      abcorr  = 'LT';

      step    = 180.;

      %
      % Perform search.
      %
      result = cspice_gfoclt( occtyp, front, fshape, fframe, ...
			      back, bshape, bframe,          ...
			      abcorr, obsrvr, step, cnfine,  ...
			      MAXWIN);

Reference documents:

  • gf.req - reference on the Geometry Finder (GF) subsystem of SPICE

Top

Converting from and to rectangular coordinates

APIs:

  • cspice_reclat - converts from rectangular to latitudinal coordinates.
  • cspice_latrec - converts from latitudinal to rectangular coordinates.
  • cspice_recgeo - converts from rectangular to geodetic coordinates.
  • cspice_georec - converts from geodetic to rectangular coordinates.
  • cspice_recpgr - converts from rectangular to planetographic coordinates.
  • cspice_pgrrec - converts from planetographic to rectangular coordinates.
  • cspice_recrad - converts from rectangular coordinates to range, right ascension, and declination.
  • cspice_radrec - converts from range, right ascension, and declination to rectangular coordinates.
  • cspice_recsph - converts from rectangular to spherical coordinates.
  • cspice_sphrec - converts from spherical to rectangular coordinates.
  • cspice_reccyl - converts from rectangular to cylindrical coordinates.
  • cspice_cylrec - converts from cylindrical to rectangular coordinates.

Brief Example:

   The following example computes the planetocentric, planetodetic and
   planetographic coordinates for a point given as a Cartesian vector
   with respect to Mars in the Mars body-fixed frame (IAU_MARS):

      %
      % load PCK file
      %
      cspice_furnsh( 'pck00008.tpc' );

      %
      % retrieve Mars radii
      %
      radii = cspice_bodvrd( 'MARS', 'RADII', 3 );
      f = (radii(1) - radii(3))/radii(1);

      %
      % package 3D vector
      %
      vec = [3373.850; -351.034; -117.267];

      %
      % compute planetocentric coordinates
      %
      [ pcr, pclon, pclat ] = cspice_reclat( vec );

      %
      % compute planetodetic coordinates
      %
      [ pdlon, pdlat, pdalt ] = cspice_recgeo( vec, radii(1), f );

      %
      % compute planetographic coordinates
      %
      [ pglon, pglat, pgalt ] = cspice_recpgr( 'MARS', vec, radii(1), f );

Top

Converting from and to Spherical Coordinates

APIs:

  • cspice_sphrec - converts from spherical to rectangular coordinates.
  • cspice_recsph - converts from rectangular to spherical coordinates.
  • cspice_sphcyl - converts from spherical to cylindrical coordinates.
  • cspice_cylsph - converts from cylindrical to spherical coordinates.
  • cspice_sphlat - converts from spherical to latitudinal coordinates.
  • cspice_latsph - converts from latitudinal to spherical coordinates.

Brief Example:

   The following example computes the spherical coordinates of a point
   specified as a Cartesian vector:

      vec = [ 1.0; 1.0; 1.0 ];

      [ r, colat, lon ] = cspice_recsph( vec );

Top

Converting from and to cylindrical coordinates

APIs:

  • cspice_cylrec - converts from cylindrical to rectangular coordinates.
  • cspice_reccyl - converts from rectangular to cylindrical coordinates.
  • cspice_cylsph - converts from cylindrical to spherical coordinates.
  • cspice_sphcyl - converts from spherical to cylindrical coordinates.
  • cspice_cyllat - converts from cylindrical to latitudinal coordinates.
  • cspice_latcyl - converts from latitudinal to cylindrical coordinates.

Brief Example:

   The following example computes the cylindrical coordinates of a
   point specified as a Cartesian vector:

      vec = [ 1.0; 1.0; 1.0 ];

      [ r, lon, z ] = cspice_reccyl( vec );

Top

Converting from and to Latitudinal Coordinates

APIs:

  • cspice_latrec - converts from latitudinal to rectangular coordinates.
  • cspice_reclat - converts from rectangular to latitudinal coordinates.
  • cspice_latsph - converts from latitudinal to spherical coordinates.
  • cspice_sphlat - converts from spherical to latitudinal coordinates.
  • cspice_latcyl - converts from latitudinal to cylindrical coordinates.
  • cspice_cyllat - converts from cylindrical to latitudinal coordinates.

Brief Example:

   The following example converts the planetocentric coordinates of a
   point to a Cartesian vector:

      r   = 3390.42;
      lon =  175.30;
      lat =  -14.59;

      vec = cspice_latrec( r, lon * cspice_rpd, lat * cspice_rpd );

Top

Converting from and to R, RA, and DEC

APIs:

  • cspice_radrec - converts from range, right ascension, and declination to rectangular coordinates.
  • cspice_recrad - converts from rectangular coordinates to range, right ascension, and declination.

Brief Example:

   The following example computes the unit vector corresponding to an
   RA and DEC given in degrees:

      ra  = 120.0;
      dec = -30.0;

      vec = cspice_radrec( 1.0, ra * cspice_rpd, dec * cspice_rpd );

Top

Converting from and to Geodetic Coordinates

APIs:

  • cspice_georec - converts from geodetic to rectangular coordinates.
  • cspice_recgeo - converts from rectangular to geodetic coordinates.

Brief Example:

   The following example converts the areodetic coordinates of a
   landing site (Lon = 175.3 deg, Lat = -14.59 deg, Alt = -1.91 km),
   given relative to the IAU 2000 Mars ellipsoid, to a Cartesian
   vector:

      cspice_furnsh( 'pck00008.tpc' );

      radii = cspice_bodvrd( 'MARS', 'RADII', 3 );

      lon =  175.30 * cspice_rpd;
      lat =  -14.59 * cspice_rpd;
      alt =   -1.91;

      f = (radii(1)-radii(3))/radii(1);

      vec = cspice_georec( lon, lat, alt, radii(1), f );

Top

Transforming states from one coordinate system to another

APIs:

  • cspice_xfmsta - transforms states between coordinate systems -- rectangular, cylindrical, latitudinal, spherical, geodetic, and planetographic.

Brief Example:

   The following example converts a state specified in the
   rectangular coordinate system (X, Y, Z, DX, DY, DZ) to
   the state specified in the latitudinal coordinate system
   (R, LONG, LAT, DR, DLONG, DLAT):

      istate(1) = 1000.0;
      istate(2) = 2000.0;
      istate(3) = 3000.0;
      istate(4) =   20.0;
      istate(5) =  -40.0;
      istate(6) =  -60.0;

      ostate = cspice_xfmsta( istate, 'RECTANGULAR', ...
                              'LATITUDINAL', ' ' );

      txt = sprintf( 'R     = %20.10f KM\n',    ostate(1) );
      disp( txt )
      txt = sprintf( 'LONG  = %20.10f RAD\n',   ostate(2) );
      disp( txt )
      txt = sprintf( 'LAT   = %20.10f RAD\n',   ostate(3) );
      disp( txt )
      txt = sprintf( 'DR    = %20.10f KM/S\n',  ostate(4) );
      disp( txt )
      txt = sprintf( 'DLONG = %20.10f RAD/S\n', ostate(5) );
      disp( txt )
      txt = sprintf( 'DLAT  = %20.10f RAD/S\n', ostate(6) );
      disp( txt )

Top

Performing simple operations on 3D vectors

APIs:

  • cspice_vsep - finds the separation angle between two 3D vectors.
  • cspice_vdist - returns the distance between two 3D vectors.
  • cspice_vhat - finds the unit vector along a 3D vector.
  • cspice_vrotv - rotates a 3D vector about a specified axis 3D vector by a specified angle.
  • cspice_vnorm - computes the magnitude of a 3D vector.
  • cspice_vupack - unpacks three scalar components from a vector.
  • cspice_unorm - normalizes a 3D vector and return its magnitude.

Brief Example:

   The following example computes the angular separation between two 3D
   vectors, in degrees:

      a = [ 1.0; 0.0; 0.0 ];
      b = [ 1.0; 1.0; 0.0 ];

      angle = cspice_vsep( a, b ) * cspice_dpr;

Top

Projecting, Combining and Rotating 3D vectors

APIs:

  • cspice_rotvec - transform a 3D vector to a new coordinate system rotated by an angle about X, Y, or Z.
  • cspice_vperp - finds the component of a 3D vector that is perpendicular to a second 3D vector.
  • cspice_vproj - finds the projection of one 3D vector onto another 3D vector.

Brief Example:

   The following example finds the component of a 3D vector that is
   perpendicular to a second 3D vector:

      p = cspice_vperp( a, b );

Top

Creating and Converting Transformation Matrices

APIs:

  • cspice_rotate - calculates the 3x3 matrix for a rotation of an angle about the X, Y or Z axis.
  • cspice_rotmat - applies a rotation of an angle about the X, Y, or Z axis to a matrix.
  • cspice_twovec - builds the transformation to a frame based on two vectors.
  • cspice_eul2m - constructs a rotation matrix from a set of Euler angles.
  • cspice_m2eul - factors a matrix as a product of three rotations about specified axes.
  • cspice_raxisa - computes the axis of the rotation given by a matrix and the angle about that axis.
  • cspice_axisar - construct a rotation matrix that rotates vectors by an angle about an axis.
  • cspice_m2q - finds a unit quaternion corresponding to a specified rotation matrix.
  • cspice_q2m - find the rotation matrix corresponding to a specified unit quaternion.

Brief Example:

   The following example creates a transformation matrix from right
   ascension, declination, and twist given in degrees:

      ra    =   10.0;
      dec   =   20.0;
      twist = -135.0;

      ra    = ra    * cspice_rpd;
      dec   = dec   * cspice_rpd;
      twist = twist * cspice_rpd;

      mat = cspice_eul2m( twist, cspice_halfpi - dec, ra, ...
                          3,     2,                   3       );

Reference documents:

  • rotation.req - reference on different representations of rotation transformations

Top

Accessing Physical and Mathematical Constants

APIs:

  • cspice_halfpi - returns half the value of pi.
  • cspice_pi - returns the value of pi.
  • cspice_twopi - returns twice the value of pi.
  • cspice_dpr - returns the number of degrees per radian.
  • cspice_rpd - returns the number of radians per degree.
  • cspice_spd - returns the number of seconds in a day.
  • cspice_jyear - returns the number of seconds per Julian year.
  • cspice_tyear - returns the number of seconds per tropical year.
  • cspice_clight - returns the speed of light in vacuo (km/sec)
  • cspice_b1900 - returns the Julian Date corresponding to Besselian date 1900.0.
  • cspice_b1950 - returns the Julian Date corresponding to Besselian date 1950.0.
  • cspice_j1900 - returns the Julian Date of 1899 DEC 31 12:00:00 (1900 JAN 0.5).
  • cspice_j1950 - returns the Julian Date of 1950 JAN 01 00:00:00 (1950 JAN 1.0).
  • cspice_j2000 - returns the Julian Date of 2000 JAN 01 12:00:00 (2000 JAN 1.5).
  • cspice_j2100 - returns the Julian Date of 2100 JAN 01 12:00:00 (2100 JAN 1.5).

Brief Example:

   The following example sets angle to pi/2 and prints it in degrees:

      angle = cspice_halfpi;

      angle_deg = angle * cspice_dpr;