Main Page
Most Used Icy APIs

Icy APIs for accessing SPICE kernel data

Icy APIs for computing derived geometry

Icy APIs for checking geometric conditions

Icy APIs for finding times of geometric events

Icy APIs for coordinate conversions

Icy APIs for operations with 3D vectors and matrices

Miscellaneous Icy 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
      ;;
      cspice_str2et, '2005 DEC 31 12:00', et 

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

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'
      cspice_scs2e, scid, sclk, et 
      cspice_scencd, scid, sclk, sclkdp 

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.

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
      ;;
      cspice_bodvrd, 'MARS', 'RADII', 3, radii 

      ;;
      ;; convert UTC to ET
      ;;
      cspice_str2et, '2005-DEC-28 12:00', et 

      ;;
      ;; compute Mars orientation relative to the J2000 frame
      ;;
      cspice_pxform, 'J2000', 'IAU_MARS', et, mat 

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
      ;;
      cspice_str2et, '2005-DEC-28 12:00', et 

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

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
      ;;
      cspice_str2et, '2006 JAN 31 01:00', et 

      ;;
      ;; compute geometric state of MGS relative to Mars
      ;;
      cspice_spkezr, 'MGS', et, 'J2000', 'NONE', 'MARS', state, $
                     ltime

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
      ;;
      cspice_str2et, '2005-DEC-28 12:00', et 

      ;;
      ;; compute orientation of CASSINI relative to J2000 frame
      ;;
      cspice_pxform, 'J2000', 'CASSINI_SC_COORD', et, mat 

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_getfov - returns the field-of-view (FOV) configuration for a specified instrument.
  • 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 THEMIS IK
      ;;
      cspice_furnsh, 'm01_themis_v31.ti' 

      ;;
      ;; retrieve M01 THEMIS IR pixel size
      ;;
      cspice_gdpool, 'INS-53031_FOCAL_LENGTH', 0, 1, fl, found 

      ;;
      ;; retrieve M01 THEMIS IR FOV parameters
      ;;
      cspice_getfov, -53031, 4, shape, frame, bsight, bounds 

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 = 0L
      grid = dblarr( 2,  360 * 179 )
      for i=1, 360 do begin
	 for j=1, 179 do begin
            grid[0,n] = cspice_rpd() *   i
            grid[1,n] = cspice_rpd() * ( j - 90 )
	    n   = n + 1L;
	 end
      end

      ;;
      ;; Compute surface points based on DSK.
      ;;
      cspice_latsrf, 'DSK/UNPRIORITIZED', 'PHOBOS', 0.0d, $
                     'IAU_PHOBOS', grid, srfpts

      ;;
      ;; Compute surface normals based on DSK.
      ;;
      cspice_srfnrm, 'DSK/UNPRIORITIZED', 'PHOBOS', 0.0d, $
                     'IAU_PHOBOS', srfpts, normls

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
      ;;
      cspice_bodn2c, 'PHOBOS', phobos_id, found 

      ;;
      ;; get NAIF ID for THEMIS IR camera
      ;;
      cspice_bodn2c, 'M01_THEMIS_IR', themis_ir_id, found 

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 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'
      ;;
      cspice_srfs2c, 'ROS_CG_M001_OMSDLAM_N_V1', '67P/C-G', surfid, found

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
      ;;
      cspice_bodvrd, 'MARS', 'RADII', 3, radii 

      ;;
      ;; package 3D vector
      ;;
      cspice_vpack, 3373.850d, -351.034d, -117.267d, vec 

      ;;
      ;; compute planetocentric coordinates
      ;;
      cspice_reclat, vec, pcr, pclon, pclat 

      ;;
      ;; compute planetodetic coordinates
      ;;
      cspice_recgeo, vec, radii[0], f, pdlon, pdlat, pdalt 

      ;;
      ;; compute planetographic coordinates
      ;;
      cspice_recpgr, 'MARS', vec, radii[0], f, pglon, pglat, pgalt 

Reference documents:

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

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
      ;;
      cspice_getfov, -94031, 4, shape, frame, bsight, bounds 

      ;;
      ;; convert UTC to ET
      ;;
      cspice_str2et, '2006 JAN 31 01:00', et 

      ;;
      ;; compute surface intercept point
      ;;
      cspice_sincpt, 'Ellipsoid', 'MARS', et, 'IAU_MARS', $
                     'CN+S', 'MGS', frame, bsight, $ 
                     spoint, trgepc, srfvec, found

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
      ;;
      cspice_str2et, '2006 JAN 31 01:00', et 

      ;;
      ;; compute sub-spacecraft point
      ;;
      cspice_subpnt, 'Near point: ellipsoid', 'MARS', $
                     et, 'IAU_MARS', 'LT+S', 'MGS', $
                     scraft, trgepc, srfvec

      ;;
      ;; compute sub-solar point
      ;;
      cspice_subslr, 'Near point: ellipsoid', 'MARS', $
                     et, 'IAU_MARS', 'LT+S', 'MGS', $
                     ssolar, trgepc, srfvec

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.42d
      lon =  175.30d
      lat =  -14.59d

      ;;
      ;; 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
      ;;
      cspice_latrec, r, lon * cspice_rpd(), lat * cspice_rpd(), $
                     point 

      ;;
      ;; convert UTC to ET
      ;;
      cspice_str2et, '2006 JAN 31 01:00', et 

      ;;
      ;; compute illumination angles modeling Mars as
      ;; an ellipsoid
      ;;
      cspice_ilumin, 'Ellipsoid', 'MARS', et, 'IAU_MARS', $
                     'LT+S', 'MGS', point, $
                     trgepc, srfvec, phase, solar, emissn

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.0d, 0.0d, 1.0d ]

      ;;
      ;; 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 
      ;;
      cspice_str2et, '2008 AUG 11 00:00:00', et

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

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.

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
      ;;
      cspice_bodvrd, 'MARS', 'GM', 1, gm 

      ;;
      ;; convert UTC to ET
      ;;
      cspice_str2et, '2005 SEP 02 04:50:45', et 

      ;;
      ;; compute state of MEX at given UTC
      ;;
      cspice_spkezr, 'MEX', et, 'MARSIAU', 'NONE', 'MARS', $
                     state, lt 

      ;;
      ;; compute orbital elements
      ;;
      cspice_oscelt, state, et, gm, elts 

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.
      ;;
      cspice_str2et, '2004-06-11 18:00', et
 
      ;;
      ;; Check for in-FOV condition.
      ;;
      cspice_fovtrg , 'CASSINI_ISS_NAC', 'PHOEBE',        $
                      'ELLIPSOID', 'IAU_PHOEBE', 'CN+S',  $
                      'CASSINI', et, visibl

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.
      ;;
      cspice_str2et, '2005-05-03 06:00', et

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

      if   ocltid GT 0   then begin
         print, 'CASSINI IS IN SATURN SHADOW.'
      endif

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.
      ;;
      cspice_str2et, [ '2007 JAN 01', '2007 APR 01'], et

      cnfine = cspice_celld( 2 )
      cspice_wninsd, et[0], et[1], cnfine

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

      step    = cspice_spd()
      refval  = 4.D5
      adjust  = 0.D

      target  = 'MOON'
      abcorr  = 'NONE'
      obsrvr  = 'EARTH'
      relate  = '>'
      nintvls = MAXWIN 

      result  = cspice_celld( MAXWIN*2)

      ;;
      ;; Perform search.
      ;;
      cspice_gfdist, target, abcorr, obsrvr, $
                     relate, refval, adjust, $
                     step,   nintvls,        $
                     cnfine, result

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.
      ;;
      cspice_str2et, [ '2004 JUN 11 09:00', $
                       '2004 JUN 11 11:15'], et

      cnfine = cspice_celld( 2 )
      cspice_wninsd, et[0], et[1], cnfine

      ;;
      ;; 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.D

      result = cspice_celld( MAXWIN*2)

      ;;
      ;; Perform search.
      ;;
      cspice_gftfov, inst,  target, tshape, tframe, abcorr, $
                     obsrvr, step, cnfine, result

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.
      ;;
      cspice_str2et, [ '2001 DEC 01', '2002 JAN 01'], et
   
      cnfine = cspice_celld( 2 )
      cspice_wninsd, et[0], et[1], cnfine

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

      step    = 180.D
      
      occtyp  = 'any'
      front   = 'moon'
      fshape  = 'ellipsoid'
      fframe  = 'iau_moon'
      back    = 'sun'
      bshape  = 'ellipsoid'
      bframe  = 'iau_sun'
      obsrvr  = 'earth'  
      abcorr  = 'lt'

      ;;
      ;; Perform search.
      ;;
      cspice_gfoclt, occtyp, front, fshape, fframe, $
                     back, bshape, bframe,          $
                     abcorr, obsrvr, step, cnfine, result

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_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.
  • 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
      ;;
      cspice_bodvrd, 'MARS', 'RADII', 3, radii 

      ;;
      ;; pack 3D vector
      ;;
      cspice_vpack, 3373.850d, -351.034d, -117.267d, vec 

      ;;
      ;; compute planetocentric coordinates
      ;;
      cspice_reclat, vec, pcr, pclon, pclat 

      ;;
      ;; compute planetodetic coordinates
      ;;
      cspice_recgeo, vec, radii[0], f, pdlon, pdlat, pdalt 

      ;;
      ;; compute planetographic coordinates
      ;;
      cspice_recpgr, 'MARS', vec, radii[0], f, pglon, pglat, $
                     pgalt 

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:

      cspice_vpack, 1.0d, 1.0d, 1.0d, vec 

      cspice_recsph, vec, r, colat, lon 

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:

      cspice_vpack, 1.0d, 1.0d, 1.0d, vec 

      cspice_reccyl, vec, r, lon, z 

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.42d
      lon =  175.30d
      lat =  -14.59d

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

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.0d
      dec = -30.0d

      cspice_radrec, 1.0d, ra * cspice_rpd(), dec * cspice_rpd(), vec 

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' 

      cspice_bodvrd, 'MARS', 'RADII', 3, radii 

      lon =  175.30d * cspice_rpd()
      lat =  -14.59d * cspice_rpd()
      alt =   -1.91d

      f = (radii[0]-radii[2])/radii[0]

      cspice_georec, lon, lat, alt, radii[0], f, vec 

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[0] = 1000.0d
      istate[1] = 2000.0d
      istate[2] = 3000.0d
      istate[3] =   20.0d
      istate[4] =  -40.0d
      istate[6] =  -60.0d

      cspice_xfmsta, istate, 'RECTANGULAR',      $
                     'LATITUDINAL', ' ', ostate

      print, 'R     (KM)    = ', ostate[0]
      print, 'LONG  (RAD)   = ', ostate[1]
      print, 'LAT   (RAD)   = ', ostate[2]
      print, 'DR    (KM/S)  = ', ostate[3]
      print, 'DLONG (RAD/S) = ', ostate[4]
      print, 'DLAT  (RAD/S) = ', ostate[5]

Top

Performing simple operations on 3D vectors

APIs:

Brief Example:

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

      cspice_vpack, 1.0d, 0.0d, 0.0d, a 
      cspice_vpack, 1.0d, 1.0d, 0.0d, b 

      print, 'angular separation, deg = ', $
             cspice_vsep(a,b) * cspice_dpr() 

Top

Projecting, Combining and Rotating 3D vectors

APIs:

  • 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.
  • cspice_vrotv - rotates a 3D vector about a specified axis 3D vector by a specified angle.
  • cspice_rotvec - transform a 3D vector to a new coordinate system rotated by an angle about X, Y, or Z.
  • cspice_vlcom - computes the vector linear combination a*v1 + b*v2 of two 3D vectors.
  • cspice_vlcom3 - computes the vector linear combination a*v1 + b*v2 + c*v3 of three 3D vectors.

Brief Example:

   The following example finds the projection of one 3D vector onto
   another 3D vector:

      cspice_vproj, a, b, c 

Top

Performing Simple Operations on 3x3 Matrices

APIs:

  • cspice_mxm - multiplies two 3x3 matrices.
  • cspice_mxmt - multiplies a 3x3 matrix and the transpose of another 3x3 matrix.
  • cspice_mxv - multiplies a 3x3 matrix with a 3D vector.
  • cspice_mtxm - multiplies the transpose of a 3x3 matrix and a 3x3 matrix.
  • cspice_mtxv - multiplies the transpose of a 3x3 matrix on the left with a 3D vector on the right.
  • cspice_vtmv - multiplies the transpose of a 3D vector, a 3x3 matrix, and a 3D vector.
  • cspice_xpose - transposes a 3x3 matrix.
  • cspice_mequ - sets one 3x3 matrix equal to another.
  • cspice_det - computes the determinant of a 3x3 matrix.
  • cspice_trace - returns the trace of a 3x3 matrix.

Brief Example:

   The following example multiples two matrices and converts the
   resulting matrix to a SPICE-style quaternion:

      cspice_mxm, mat1, mat2, mat3 
      cspice_m2q, mat3, q 

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.0d
      dec   =   20.0d
      twist = -135.0d

      ra    = ra    * cspice_rpd()
      dec   = dec   * cspice_rpd()
      twist = twist * cspice_rpd()

      cspice_eul2m, twist, cspice_halfpi() - dec, ra, $
                    3, 2, 3, mat 

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()

      print, 'angle, deg = ', angle * cspice_dpr()