Using a SPICE Ephemeris

Top  Previous  Next

FreeFlyer also allows the user to propagate a Spacecraft using a SPICE Ephemeris. SPICE Ephemerides are set up differently than the other supported ephemeris formats discussed on the Setting up an Ephemeris page.

 

SPICE files are ephemerides created and maintained by the Navigation and Ancillary Information Facility (NAIF) Node of the Planetary Data System. SPICE ephemerides can be used to define the motion of Spacecraft or Celestial Objects in FreeFlyer. For more information on SPICE files, including instructions on how to obtain them, see the SPICE Files page of the Ephemerides and AHF section of the Appendix.

 

For information about using SPICE ephemerides with CelestialObject objects, see the Celestial Objects page of the Interplanetary Analysis Guide.

 

The following Sample Mission Plans (included with your FreeFlyer installation) demonstrate the use of SPICE ephemerides in FreeFlyer:

 

Interplanetary Samples

Celestial Object

Mars Flybys

 

Spacecraft Propagation Samples

Ephemeris Generation

Propagate Spacecraft from SPICE Ephemeris

 

 

Configuring a Spacecraft to use a SPICE Ephemeris


The SpiceEphemeris object is only available via FreeFlyer script. From script, you can either create a Spacecraft using a SpiceEphemeris or override an existing Spacecraft's propagator with a new SpiceEphemeris propagator.

 

To create a new Spacecraft that uses a SpiceEphemeris Propagator, use the following syntax:

 

SpiceEphemeris SpiceEphem;

Spacecraft Cassini(SpiceEphem);

 

To override an existing Spacecraft's propagator with a new SpiceEphemeris Propagator, use the SetPropagatorType() method:

 

Spacecraft Cassini;

Cassini.SetPropagatorType(TypeOf(SpiceEphemeris));

 

Once you've changed the propagator to be a SpiceEphemeris, access the properties of the SpiceEphemeris Propagator object using the following syntax:

 

(Cassini.Propagator AsType SpiceEphemeris)

 

To learn more about related topics, see the Object Constructors and Type Casting references in the Working with Objects Guide.

 

 

Setting the Observer and Target


When using a SpiceEphemeris as the Propagator for a Spacecraft, you must set the observer and target to use from the SPICE file. The observer corresponds to the desired Central Body for the Spacecraft, and the Target corresponds to the Spacecraft itself.

 

There are two ways to set the observer and target:

 

Via the object names

 

Alias spiceEph = (Cassini.Propagator AsType SpiceEphemeris); // This alias is used to shorten the script examples below

 

// Specify source and target objects

spiceEph.Observer = "SATURN";

spiceEph.Target = "CASSINI";

 

Via the NAIF ID's

 

// Specify source and target objects

spiceEph.ObserverNAIFID = 699;

spiceEph.TargetNAIFID = -82;

 

Once the observer and target have been set, ensure that the Spacecraft's Central Body matches the observer:

 

// Spacecraft central body must match the SpiceEphemeris Observer:

Cassini.SetCentralBody(Saturn);

 

Note: SPK ID numbers for asteroids are equal to 20000000 + JPL asteroid number. For example, the asteroid number for Bennu is 101955, and the NAIF ID is 20101955.

 

 

Setting the SPICE Ephemeris File(s)


When working with SPICE Ephemerides, you may need to specify more than one input file. You must provide all SPICE Ephemerides necessary to calculate the position of your desired target with respect to the observer. For example, you may have a SPICE file that contains the position of a satellite with respect to Io, and another that contains the position of Io with respect to Jupiter. Both files must be included in the SpiceEphemeris.SpiceFiles[] array if you want to use the satellite as the target and Jupiter as the observer. If more than one specified SPICE file contains information for a given object at the same time, data from the most recently loaded file takes precedence over the previously loaded data.

 

The input files may also include any additional leap second files pertinent to your analysis.

 

Use the following syntax to add a SPICE file to a SpiceEphemeris:

 

spiceEph.NumberOfSpiceFiles = 1;

spiceEph.SpiceFiles[0] = "090421BP_SCPSE_09109_09130.bsp";

 

Additional input files can be specified using array indices: [1], [2], etc. A common example of using multiple SPICE files is when the ephemeris for the target object uses the solar system barycenter as the observer. Since the solar system barycenter cannot be a Spacecraft's CentralBody, and the Spacecraft CentralBody must match the SpiceEphemeris target, an additional SPICE file which contains system barycenter data must be included. A database of Development Ephemeris (DE) files in the binary SPICE format (.bsp) is maintained here: ftp://ssd.jpl.nasa.gov/pub/eph/planets/bsp/, and can be used to make the necessary connections between built-in CelestialObjects and the solar system barycenter. In the example below, the asteroid Apophis is being modeled with a SpiceEphemeris based on the solar system barycenter, and the SPICE format DE file is used to allow the SpiceEphemeris to treat the target and CentralBody as the Sun.

 

spiceEph.NumberOfSpiceFiles = 2;

spiceEph.SpiceFiles[0] = "apophis.bsp"// retrieved from JPL Horizons system

spiceEph.SpiceFiles[1] = "de430t.bsp";  // retrieved from ftp://ssd.jpl.nasa.gov/pub/eph/planets/bsp/

 

spiceEph.ObserverNAIFID = 10;    // Sun

spiceEph.TargetNAIFID = 2099942; // Apophis

 

Apophis.CentralBody = "Sun";

 

 

Setting the Step Size


A SPICE file represents the position of celestial objects and spacecraft using polynomials instead of discrete vectors, so there is no option to "Step to Ephemeris Points" when working with SPICE ephemerides. To set the Ephemeris Step Size, simply set the step size via FreeFlyer script using this syntax:

 

spiceEph.StepSize = TIMESPAN(120 seconds);

 

Note: As of FreeFlyer 7.3, the default timing precision mode is nanosecond precision mode. For older Mission Plans that have not yet been converted from millisecond precision mode, the syntax for working with times such as step sizes is different. A sample is shown below; see the timing precision mode page for more information.

 

spiceEph.StepSize = 120;

 

 

Creating SPICE Ephemeris Files


In addition to using existing SPICE ephemerides to define the motion of Spacecraft or Celestial Objects, FreeFlyer can export ephemeris files in the SPICE (.bsp) format.

 

To generate a SPICE ephemeris, start by configuring the Ephemeris object, including the SPICE-specific properties available through the SPKProperties child object. This includes specifying the observer and target names and NAIF IDs:

 

Ephemeris Ephemeris1;

 

// Set Central Body

Ephemeris1.CentralBody = "Earth";

 

// Set SPKProperties

Ephemeris1.SPKProperties.MetadataComments = "AQUA SPK Ephemeris";

Ephemeris1.SPKProperties.ObserverName = "EARTH";

Ephemeris1.SPKProperties.ObserverNAIFID = 399;

Ephemeris1.SPKProperties.TargetName = "AQUA";

Ephemeris1.SPKProperties.TargetNAIFID = -154;

Ephemeris1.SPKProperties.PolynomialDegree = 7;

Ephemeris1.SPKProperties.SPKType = 9;

 

Note: When generating a SPICE ephemeris, both the name and NAIF ID for the observer and target must be specified. This is different from importing a SPICE ephemeris to use for Spacecraft propagation, where either the names or the NAIF IDs can be specified, but it is not required to use both.

 

Add data to the ephemeris using the Put command:

 

// Put Spacecraft state to ephemeris

Put mySpacecraft to Ephemeris1;

 

Spacecraft state data can also be added to an Ephemeris object using the Ephemeris.AddVectorData() or Ephemeris.SetVectorData() methods. See the Accessing Data in an Ephemeris page for more information.

 

Finally, export the Ephemeris object to a SPICE ephemeris file:

 

Put Ephemeris1 to SPKephem "SCEphem.bsp";

 

 

See Also


SpiceEphemeris Properties and Methods

SPKProperties Object

Spacecraft, GroundStation, PointGroup, and Region Central Body