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

# ON BOARD TIMES CALCULATION

The following classes allow to convert On Board Time to MJD2000 time and vice versa:

- AeolusOBT
- GoceOBT
- EnvisatOBT
- SmosOBT

The following example shows how to make this transformations in the case of Envisat OBT:

    // ------------------------------------------------------------------------
    //
    //                           JAVA Example Program.
    //                           OBT OPERATIONS
    //
    // ------------------------------------------------------------------------

    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
        {
          // ------------------------------------------------------------------------
          // OBT Time transformations
          // ------------------------------------------------------------------------

          // Envisat OBT to time
          double        time0   = 245.123456789000000;   // [days]
          long[] obt0 = new long[]{0x00001001, 0x00011111};
          long period0 = ((1/256.0)*1.0E12); // [picoseconds]

          EnvisatObt enviOBT = new EnvisatObt(time0, obt0, period0);

          enviOBT.obt[0]  = 0xFFFF0FFF;
          enviOBT.obt[1]  = 0x000FF000;

          Time timeFromOBT = enviOBT.getTime();

          System.out.println( "Input Time:"   );
          System.out.println( "   time0 = "   + enviOBT.time0   );
          System.out.println( "   obt0[0] = " + enviOBT.obt0[0] );
          System.out.println( "   obt0[1] = " + enviOBT.obt0[1] );
          System.out.println( "   period0 = " + enviOBT.period0 );
          System.out.println( "   obt[0] = "  + enviOBT.obt[0]  );
          System.out.println( "   obt[1] = "  + enviOBT.obt[1]  );

          System.out.println( "Output Time:"  );
          System.out.println( "   time = "    + timeFromOBT.time
          + "Ref = " + timeFromOBT.ref ) );

          // Time to Envisat OBT time

          timeFromOBT.time = 245.120493735624819;

          EnvisatObt newEnviOBT = new EnvisatObt(time0, obt0, period0);

          newEnviOBT.setObt(timeFromOBT);

          System.out.println( "Input Time:"   );
          System.out.println( "   time = "    + timeFromOBT.time
          + "Ref = " + timeFromOBT.ref );

          System.out.println( "Output Time:"  );
          System.out.println( "   time0 = "   + newEnviOBT.time0   );
          System.out.println( "   obt0[0] = " + newEnviOBT.obt0[0] );
          System.out.println( "   obt0[1] = " + newEnviOBT.obt0[1] );
          System.out.println( "   period0 = " + newEnviOBT.period0 );
          System.out.println( "   obt[0] = "  + newEnviOBT.obt[0]  );
          System.out.println( "   obt[1] = "  + newEnviOBT.obt[1]  ) );

        }//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) );
          }
        }

      }

    }