@Test
  public void testOnlyPre1972Data() throws OrekitException {

    Utils.setDataRoot("USNO");
    TimeScalesFactory.addUTCTAIOffsetsLoader(
        new TAIUTCDatFilesLoader("tai-utc-only-pre-1972-data.dat"));

    // linear models between 1961 and 1972
    checkOffset(1961, 1, 2, -(1.422818 + 1 * 0.001296)); // MJD 37300 +   1
    checkOffset(1961, 8, 2, -(1.372818 + 213 * 0.001296)); // MJD 37300 + 213
    checkOffset(1962, 1, 2, -(1.845858 + 1 * 0.0011232)); // MJD 37665 +   1
    checkOffset(1963, 11, 2, -(1.945858 + 670 * 0.0011232)); // MJD 37665 + 670
    checkOffset(1964, 1, 2, -(3.240130 - 365 * 0.001296)); // MJD 38761 - 365
    checkOffset(1964, 4, 2, -(3.340130 - 274 * 0.001296)); // MJD 38761 - 274
    checkOffset(1964, 9, 2, -(3.440130 - 121 * 0.001296)); // MJD 38761 - 121
    checkOffset(1965, 1, 2, -(3.540130 + 1 * 0.001296)); // MJD 38761 +   1
    checkOffset(1965, 3, 2, -(3.640130 + 60 * 0.001296)); // MJD 38761 +  60
    checkOffset(1965, 7, 2, -(3.740130 + 182 * 0.001296)); // MJD 38761 + 182
    checkOffset(1965, 9, 2, -(3.840130 + 244 * 0.001296)); // MJD 38761 + 244
    checkOffset(1966, 1, 2, -(4.313170 + 1 * 0.002592)); // MJD 39126 +   1
    checkOffset(1968, 2, 2, -(4.213170 + 762 * 0.002592)); // MJD 39126 + 762

    // last linear drift is not stopped as we miss the first constant offset in 1972
    checkOffset(1972, 3, 5, -(4.213170 + 2255 * 0.002592)); // MJD 39126 +  2255
    checkOffset(1972, 7, 14, -(4.213170 + 2386 * 0.002592)); // MJD 39126 +  2386
    checkOffset(1979, 12, 31, -(4.213170 + 5112 * 0.002592)); // MJD 39126 +  5112
    checkOffset(1980, 1, 22, -(4.213170 + 5134 * 0.002592)); // MJD 39126 +  5134
    checkOffset(2006, 7, 7, -(4.213170 + 14797 * 0.002592)); // MJD 39126 + 14797
    checkOffset(2010, 7, 7, -(4.213170 + 16258 * 0.002592)); // MJD 39126 + 16258
    checkOffset(2012, 7, 7, -(4.213170 + 16989 * 0.002592)); // MJD 39126 + 16989
    checkOffset(2015, 7, 7, -(4.213170 + 18084 * 0.002592)); // MJD 39126 + 18084
  }
  @Test
  public void testModifiedLinearData() throws OrekitException {

    Utils.setDataRoot("USNO");
    TimeScalesFactory.addUTCTAIOffsetsLoader(
        new TAIUTCDatFilesLoader("tai-utc-modified-linear.dat"));

    // linear models between 1961 and 1972
    checkOffset(1961, 1, 2, -(1.4000000 + 1 * 0.001000)); // MJD 37300 +   1
    checkOffset(1961, 8, 2, -(1.5000000 + 213 * 0.001100)); // MJD 37300 + 213
    checkOffset(1962, 1, 2, -(1.6000000 + 1 * 0.001200)); // MJD 37665 +   1
    checkOffset(1963, 11, 2, -(1.7000000 + 670 * 0.001300)); // MJD 37665 + 670
    checkOffset(1964, 1, 2, -(1.8000000 - 365 * 0.001400)); // MJD 38761 - 365
    checkOffset(1964, 4, 2, -(1.9000000 - 274 * 0.001500)); // MJD 38761 - 274
    checkOffset(1964, 9, 2, -(2.0000000 - 121 * 0.001600)); // MJD 38761 - 121
    checkOffset(1965, 1, 2, -(2.1000000 + 1 * 0.001700)); // MJD 38761 +   1
    checkOffset(1965, 3, 2, -(2.2000000 + 60 * 0.001800)); // MJD 38761 +  60
    checkOffset(1965, 7, 2, -(2.3000000 + 182 * 0.001900)); // MJD 38761 + 182
    checkOffset(1965, 9, 2, -(2.4000000 + 244 * 0.002000)); // MJD 38761 + 244
    checkOffset(1966, 1, 2, -(2.5000000 + 1 * 0.002100)); // MJD 39126 +   1
    checkOffset(1968, 2, 2, -(2.6000000 + 762 * 0.002200)); // MJD 39126 + 762

    // last linear drift is not stopped as we miss the first constant offset in 1972
    checkOffset(1972, 3, 5, -(2.6000000 + 2255 * 0.002200)); // MJD 39126 +  2255
    checkOffset(1972, 7, 14, -(2.6000000 + 2386 * 0.002200)); // MJD 39126 +  2386
    checkOffset(1979, 12, 31, -(2.6000000 + 5112 * 0.002200)); // MJD 39126 +  5112
    checkOffset(1980, 1, 22, -(2.6000000 + 5134 * 0.002200)); // MJD 39126 +  5134
    checkOffset(2006, 7, 7, -(2.6000000 + 14797 * 0.002200)); // MJD 39126 + 14797
    checkOffset(2010, 7, 7, -(2.6000000 + 16258 * 0.002200)); // MJD 39126 + 16258
    checkOffset(2012, 7, 7, -(2.6000000 + 16989 * 0.002200)); // MJD 39126 + 16989
    checkOffset(2015, 7, 7, -(2.6000000 + 18084 * 0.002200)); // MJD 39126 + 18084
  }
 /**
  * load orekit data and gravity field.
  *
  * @throws Exception on error.
  */
 @BeforeClass
 public static void setUpBefore() throws Exception {
   Utils.setDataRoot("earth:geoid:regular-data");
   GravityFieldFactory.clearPotentialCoefficientsReaders();
   GravityFieldFactory.addPotentialCoefficientsReader(new EGMFormatReader("egm96", false));
   potential = GravityFieldFactory.getConstantNormalizedProvider(maxDegree, maxOrder);
 }
  @Test
  public void testRegularFile() throws OrekitException {

    Utils.setDataRoot("USNO");

    // we arbitrary put UTC == TAI before 1961-01-01
    checkOffset(1950, 1, 1, 0);

    // linear models between 1961 and 1972
    checkOffset(1961, 1, 2, -(1.422818 + 1 * 0.001296)); // MJD 37300 +   1
    checkOffset(1961, 8, 2, -(1.372818 + 213 * 0.001296)); // MJD 37300 + 213
    checkOffset(1962, 1, 2, -(1.845858 + 1 * 0.0011232)); // MJD 37665 +   1
    checkOffset(1963, 11, 2, -(1.945858 + 670 * 0.0011232)); // MJD 37665 + 670
    checkOffset(1964, 1, 2, -(3.240130 - 365 * 0.001296)); // MJD 38761 - 365
    checkOffset(1964, 4, 2, -(3.340130 - 274 * 0.001296)); // MJD 38761 - 274
    checkOffset(1964, 9, 2, -(3.440130 - 121 * 0.001296)); // MJD 38761 - 121
    checkOffset(1965, 1, 2, -(3.540130 + 1 * 0.001296)); // MJD 38761 +   1
    checkOffset(1965, 3, 2, -(3.640130 + 60 * 0.001296)); // MJD 38761 +  60
    checkOffset(1965, 7, 2, -(3.740130 + 182 * 0.001296)); // MJD 38761 + 182
    checkOffset(1965, 9, 2, -(3.840130 + 244 * 0.001296)); // MJD 38761 + 244
    checkOffset(1966, 1, 2, -(4.313170 + 1 * 0.002592)); // MJD 39126 +   1
    checkOffset(1968, 2, 2, -(4.213170 + 762 * 0.002592)); // MJD 39126 + 762

    // since 1972-01-01, offsets are only whole seconds
    checkOffset(1972, 3, 5, -10);
    checkOffset(1972, 7, 14, -11);
    checkOffset(1979, 12, 31, -18);
    checkOffset(1980, 1, 22, -19);
    checkOffset(2006, 7, 7, -33);
    checkOffset(2010, 7, 7, -34);
    checkOffset(2012, 7, 7, -35);
    checkOffset(2015, 7, 7, -36);
  }
  @Deprecated
  @Test
  public void testDeprecatedAPI() throws OrekitException {

    Utils.setDataRoot("USNO");
    TimeScalesFactory.addUTCTAILoader(
        new UTCTAILoader() {

          @Override
          public boolean stillAcceptsData() {
            return false;
          }

          @Override
          public void loadData(InputStream input, String name) {}

          @Override
          public SortedMap<DateComponents, Integer> loadTimeSteps() {
            SortedMap<DateComponents, Integer> map = new TreeMap<DateComponents, Integer>();
            map.put(new DateComponents(1972, 1, 1), 10);
            map.put(new DateComponents(1972, 7, 1), 11);
            return map;
          }

          @Override
          public String getSupportedNames() {
            return "non-existant-name";
          }
        });

    checkOffset(1972, 1, 2, -10.0);
    checkOffset(1972, 6, 30, -10.0);
    checkOffset(1972, 7, 2, -11.0);
    checkOffset(3000, 1, 1, -11.0);
  }
 private void checkException(String name, OrekitMessages message) {
   Utils.setDataRoot("USNO");
   TimeScalesFactory.addUTCTAIOffsetsLoader(new TAIUTCDatFilesLoader(name));
   try {
     TimeScalesFactory.getUTC();
     Assert.fail("an exception should have been thrown");
   } catch (OrekitException oe) {
     Assert.assertEquals(message, oe.getSpecifier());
   }
 }
 @Before
 public void setUp() throws OrekitException {
   Utils.setDataRoot("regular-data");
   geoTLE =
       new TLE(
           "1 27508U 02040A   12021.25695307 -.00000113  00000-0  10000-3 0  7326",
           "2 27508   0.0571 356.7800 0005033 344.4621 218.7816  1.00271798 34501");
   leoTLE =
       new TLE(
           "1 31135U 07013A   11003.00000000  .00000816  00000+0  47577-4 0    11",
           "2 31135   2.4656 183.9084 0021119 236.4164  60.4567 15.10546832    15");
 }
 @Before
 public void setUp() throws OrekitException {
   Utils.setDataRoot("regular-data:potential/shm-format");
   GravityFieldFactory.addPotentialCoefficientsReader(
       new SHMFormatReader("^eigen_cg03c_coef$", false));
   mu = GravityFieldFactory.getUnnormalizedProvider(0, 0).getMu();
   final Vector3D position = new Vector3D(7.0e6, 1.0e6, 4.0e6);
   final Vector3D velocity = new Vector3D(-500.0, 8000.0, 1000.0);
   initDate = AbsoluteDate.J2000_EPOCH;
   final Orbit orbit =
       new EquinoctialOrbit(
           new PVCoordinates(position, velocity), FramesFactory.getEME2000(), initDate, mu);
   initialState = new SpacecraftState(orbit);
   double[][] tolerance = NumericalPropagator.tolerances(0.001, orbit, OrbitType.EQUINOCTIAL);
   AdaptiveStepsizeIntegrator integrator =
       new DormandPrince853Integrator(0.001, 200, tolerance[0], tolerance[1]);
   integrator.setInitialStepSize(60);
   propagator = new NumericalPropagator(integrator);
   propagator.setInitialState(initialState);
 }
  @Before
  public void setUp() throws OrekitException {

    Utils.setDataRoot("regular-data");
    earth =
        new OneAxisEllipsoid(
            Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
            Constants.WGS84_EARTH_FLATTENING,
            FramesFactory.getITRF(IERSConventions.IERS_2010, true));

    gp = new GeodeticPoint(FastMath.toRadians(51.0), FastMath.toRadians(66.6), 300.0);
    final TimeScale utc = TimeScalesFactory.getUTC();
    final Vector3D position = new Vector3D(-6142438.668, 3492467.56, -25767.257);
    final Vector3D velocity = new Vector3D(505.848, 942.781, 7435.922);
    final AbsoluteDate date = new AbsoluteDate(2003, 9, 16, utc);
    orbit =
        new EquinoctialOrbit(
            new PVCoordinates(position, velocity),
            FramesFactory.getEME2000(),
            date,
            Constants.EIGEN5C_EARTH_MU);
  }
  @Before
  public void setUp() {
    try {

      Utils.setDataRoot("regular-data");

      // Computation date
      date =
          new AbsoluteDate(
              new DateComponents(2008, 04, 07), TimeComponents.H00, TimeScalesFactory.getUTC());

      // Body mu
      mu = 3.9860047e14;

      // Reference frame = ITRF
      frameItrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);

      // Elliptic earth shape
      earthSpheric = new OneAxisEllipsoid(6378136.460, 0., frameItrf);

    } catch (OrekitException oe) {
      Assert.fail(oe.getMessage());
    }
  }
 @Before
 public void setUp() {
   Utils.setDataRoot("regular-data");
 }
 /** set Orekit data for useful debugging messages from dates. */
 @BeforeClass
 public static void setUpBefore() {
   Utils.setDataRoot("regular-data");
 }
 @Before
 public void setUp() throws OrekitException {
   Utils.setDataRoot("regular-data:potential/shm-format");
   GravityFieldFactory.addPotentialCoefficientsReader(
       new SHMFormatReader("^eigen_cg03c_coef$", false));
 }