| Earth Observation Mission CFI Software Usage Guide for Object Oriented Software |

# GENERATION OF EARTH OBSERVATION MISSION FILES

The Earth Observation CFI software contains a set of functions that generate the following orbit files:

- Orbit Scenario files
- Predicted Orbit files
- Restituted Orbit files (DORIS restituted and DORIS precise)
- DORIS Navigator files
- Orbit Event files

The calling sequence to generate those files is quite simple (see next figure):

- Initialise the time correlations (create TimeCorrelation object) and the ModelId if required. This step is not needed for the generation of orbit event files.

- Call one of the static methods for the file generation from the class OrbitFunc

- Optionally for the generation of OSFs: it is possible to add orbital changes within the OSF by calling one of these methods:
  - OrbitFunc::genOsfAppendOrbitChange
  - OrbitFunc::genOsfRepeatCycle
  - OrbitFunc::genOsfAddDriftCycle

## Example

Generation of an OSF and append one orbital change:

    // ------------------------------------------------------------------------
    //
    //                           JAVA Example Program.
    //                           ORBIT FILES GENERATION
    //
    // ------------------------------------------------------------------------

    import EECFI.*;

    import java.util.Vector;
    import java.lang.String;
    import java.lang.Long;

    // Main program
    public class Example
    {
      public static void main(String[] args)
      {

        //-------------------------------------------------
        // Put all the code inside try-catch statements
        //  so, if something fails, an exception is thrown
        //-------------------------------------------------
        try
        {
          ModelId  modelId = new ModelId();

          // Initializing Time Reference: Used for the first and second example
          double[] coorTime = new double[4];

          coorTime[0]   = -1100.1000000000000;   // TAI time [days]
          coorTime[1]   = -1100.0995949074074;   // UTC time [days] (= TAI + 35.0 s)
          coorTime[2]   = -1100.0995914351852;   // UT1 time [days] (= TAI + 35.3 s)
          coorTime[3]   = -1100.099780092;       // GPS time [days] (= TAI + 19.0 s)

          TimeCorrelation timeCorr = new TimeCorrelation(coorTime);

          // ------------------------------------------------------------------------
          // Create OSF file.
          //-------------------------------------------------------------------------
          String outputDir = new String("./");
          String osfFile   = new String("OSF_FILE.xml");
          String fileClass = new String("EXAMPLE");
          String fhSystem  = new String("CFI_example");
          SatId  satId     = new SatId(XOCFI_SAT_CRYOSAT);

          long   absOrbit      = 1;
          long   cycle         = 1;
          long   phase         = 1;
          long   versionNumber = 1;
          long   repeatCycle   = 369;
          long   cycleLength   = 5344;
          long   driftMode     = XOCFI_NOSUNSYNC_DRIFT;
          double mlstDrift     = -179.208556;
          double mlst          = 12.0;
          double anxLong       = 37.684960;

          double date          = 1643.395;

          double inclination;

          String outFile = new String(); // Name of the file created

          // With OrbitFunc class
          outFile = OrbitFunc.genOsf(satId,
            modelId,
            timeCorr,
            absOrbit,
            cycle,
            phase,
            repeatCycle,
            cycleLength,
            anxLong,
            driftMode,
            inclination,
            mlstDrift,
            mlst,
            date,
            outputDir,
            osfFile,
            fileClass,
            versionNumber,
            fhSystem);

          System.out.println( endl + "File " + outFile + " created " );

          // ------------------------------------------------------------------------
          // Append orbit change to OSF file.
          //-------------------------------------------------------------------------
          String outputFile     = "OSF_FILE_APPEND.xml";
          double oldNodalPeriod = 86400.0 * (1+mlstDrift/86400.0) *
          (double)repeatCycle/(double)cycleLength;

          long   phaseInc       = XOCFI_NO_PHASE_INCREMENT;

          versionNumber++;
          absOrbit    = 5345;
          repeatCycle = 369;
          cycleLength = 5344;

          // small change wrt to nominal to check tolerances
          anxLong = 37.68497;
          mlst = mlst + mlstDrift*(5345-1)*oldNodalPeriod/(3600.0*86400.0) + 24.0;

          outFile = OrbitFunc::genOsfAppendOrbitChange( satId,
            modelId,
            timeCorr,
            osfFile,
            absOrbit,
            repeatCycle,
            cycleLength,
            anxLong,
            driftMode,
            inclination,
            mlstDrift,
            mlst,
            phaseInc,
            outputDir,
            outputFile,
            fileClass,
            versionNumber,
            fhSystem );

          System.out.println( endl + "File " + outFile + " created " );

          // ------------------------------------------------------------------------
          // Change repeat cycle to OSF file.
          //-------------------------------------------------------------------------
          outputFile  = "OSF_FILE_CHANGE.xml";
          absOrbit    = 5000;
          phaseInc    = XOCFI_PHASE_INCREMENT;
          repeatCycle = 2;
          cycleLength = 29;
          anxLong     = 37.68497;
          driftMode   = XOCFI_NOSUNSYNC_INCLINATION;
          inclination = 92.0;

          versionNumber++;

          long searchDirection = XOCFI_SEARCH_FORWARD;

          outFile = OrbitFunc.genOsfChangeRepeatCycle( satId,
            modelId,
            timeCorr,
            osfFile,
            absOrbit,
            searchDirection,
            repeatCycle,
            cycleLength,
            anxLong,
            driftMode,
            inclination,
            mlstDrift,
            phaseInc,
            outputDir,
            outputFile,
            fileClass,
            versionNumber,
            fhSystem );
          System.out.println( endl + "File " + outFile + " created " );

        }//end try

        catch (CfiError cfiError)
        {
          //If an exception is thrown, there have been errors during execution
          Vector<String> errorMessages = new Vector<String>();

          // Get error messages
          errorMessages = cfiError.getMsg(errorMessages);

          // Pring Error messages
          for (int i = 0; i < errorMessages.size(); i++)
          {
            System.out.println( errorMessages.elementAt(i) );
          }
        }

      }

    }