@Test
  public void testCartesian() throws OrekitException {

    // Propagation of the initial at t + dt
    final double dt = 3200;
    propagator.setOrbitType(OrbitType.CARTESIAN);
    final PVCoordinates finalState =
        propagator.propagate(initDate.shiftedBy(dt)).getPVCoordinates();
    final Vector3D pFin = finalState.getPosition();
    final Vector3D vFin = finalState.getVelocity();

    // Check results
    final PVCoordinates reference = initialState.shiftedBy(dt).getPVCoordinates();
    final Vector3D pRef = reference.getPosition();
    final Vector3D vRef = reference.getVelocity();
    Assert.assertEquals(0, pRef.subtract(pFin).getNorm(), 2e-4);
    Assert.assertEquals(0, vRef.subtract(vFin).getNorm(), 7e-8);

    try {
      propagator.getGeneratedEphemeris();
      Assert.fail("an exception should have been thrown");
    } catch (IllegalStateException ise) {
      // expected
    }
  }
Example #2
0
 @Test
 public void testZeroInclination() throws OrekitException {
   TLE tle =
       new TLE(
           "1 26451U 00043A   10130.13784012 -.00000276  00000-0  10000-3 0  3866",
           "2 26451 000.0000 266.1044 0001893 160.7642 152.5985 01.00271160 35865");
   TLEPropagator propagator = TLEPropagator.selectExtrapolator(tle);
   PVCoordinates pv = propagator.propagate(tle.getDate().shiftedBy(100)).getPVCoordinates();
   Assert.assertEquals(42171546.979560345, pv.getPosition().getNorm(), 1.0e-3);
   Assert.assertEquals(3074.1890089357994, pv.getVelocity().getNorm(), 1.0e-6);
 }
Example #3
0
  @Test
  public void testSatCodeCompliance() throws IOException, OrekitException, ParseException {

    BufferedReader rEntry = null;
    BufferedReader rResults = null;

    InputStream inEntry =
        TLETest.class.getResourceAsStream("/tle/extrapolationTest-data/SatCode-entry");
    rEntry = new BufferedReader(new InputStreamReader(inEntry));

    try {
      InputStream inResults =
          TLETest.class.getResourceAsStream("/tle/extrapolationTest-data/SatCode-results");
      rResults = new BufferedReader(new InputStreamReader(inResults));

      try {
        double cumulated = 0; // sum of all differences between test cases and OREKIT results
        boolean stop = false;

        String rline = rResults.readLine();

        while (!stop) {
          if (rline == null) break;

          String[] title = rline.split(" ");

          if (title[0].matches("r")) {

            String eline;
            int count = 0;
            String[] header = new String[4];
            for (eline = rEntry.readLine();
                (eline != null) && (eline.charAt(0) == '#');
                eline = rEntry.readLine()) {
              header[count++] = eline;
            }
            String line1 = eline;
            String line2 = rEntry.readLine();
            Assert.assertTrue(TLE.isFormatOK(line1, line2));

            TLE tle = new TLE(line1, line2);

            int satNum = Integer.parseInt(title[1]);
            Assert.assertTrue(satNum == tle.getSatelliteNumber());
            TLEPropagator ex = TLEPropagator.selectExtrapolator(tle);

            for (rline = rResults.readLine();
                (rline != null) && (rline.charAt(0) != 'r');
                rline = rResults.readLine()) {

              String[] data = rline.split(" ");
              double minFromStart = Double.parseDouble(data[0]);
              double pX = 1000 * Double.parseDouble(data[1]);
              double pY = 1000 * Double.parseDouble(data[2]);
              double pZ = 1000 * Double.parseDouble(data[3]);
              double vX = 1000 * Double.parseDouble(data[4]);
              double vY = 1000 * Double.parseDouble(data[5]);
              double vZ = 1000 * Double.parseDouble(data[6]);
              Vector3D testPos = new Vector3D(pX, pY, pZ);
              Vector3D testVel = new Vector3D(vX, vY, vZ);

              AbsoluteDate date = tle.getDate().shiftedBy(minFromStart * 60);
              PVCoordinates results = ex.getPVCoordinates(date);
              double normDifPos = testPos.subtract(results.getPosition()).getNorm();
              double normDifVel = testVel.subtract(results.getVelocity()).getNorm();

              cumulated += normDifPos;
              Assert.assertEquals(0, normDifPos, 2e-3);
              ;
              Assert.assertEquals(0, normDifVel, 1e-5);
            }
          }
        }
        Assert.assertEquals(0, cumulated, 0.026);
      } finally {
        if (rResults != null) {
          rResults.close();
        }
      }
    } finally {
      if (rEntry != null) {
        rEntry.close();
      }
    }
  }
  @Test
  public void testPropagationTypesHyperbolic() throws OrekitException, ParseException, IOException {

    SpacecraftState state =
        new SpacecraftState(
            new KeplerianOrbit(
                -10000000.0,
                2.5,
                0.3,
                0,
                0,
                0.0,
                PositionAngle.TRUE,
                FramesFactory.getEME2000(),
                initDate,
                mu));

    ForceModel gravityField =
        new HolmesFeatherstoneAttractionModel(
            FramesFactory.getITRF(IERSConventions.IERS_2010, true),
            GravityFieldFactory.getNormalizedProvider(5, 5));
    propagator.addForceModel(gravityField);

    // Propagation of the initial at t + dt
    final PVCoordinates pv = state.getPVCoordinates();
    final double dP = 0.001;
    final double dV =
        state.getMu() * dP / (pv.getPosition().getNormSq() * pv.getVelocity().getNorm());

    final PVCoordinates pvcM = propagateInType(state, dP, OrbitType.CARTESIAN, PositionAngle.MEAN);
    final PVCoordinates pvkM = propagateInType(state, dP, OrbitType.KEPLERIAN, PositionAngle.MEAN);

    final PVCoordinates pvcE =
        propagateInType(state, dP, OrbitType.CARTESIAN, PositionAngle.ECCENTRIC);
    final PVCoordinates pvkE =
        propagateInType(state, dP, OrbitType.KEPLERIAN, PositionAngle.ECCENTRIC);

    final PVCoordinates pvcT = propagateInType(state, dP, OrbitType.CARTESIAN, PositionAngle.TRUE);
    final PVCoordinates pvkT = propagateInType(state, dP, OrbitType.KEPLERIAN, PositionAngle.TRUE);

    Assert.assertEquals(0, pvcM.getPosition().subtract(pvkT.getPosition()).getNorm() / dP, 0.3);
    Assert.assertEquals(0, pvcM.getVelocity().subtract(pvkT.getVelocity()).getNorm() / dV, 0.4);
    Assert.assertEquals(0, pvkM.getPosition().subtract(pvkT.getPosition()).getNorm() / dP, 0.2);
    Assert.assertEquals(0, pvkM.getVelocity().subtract(pvkT.getVelocity()).getNorm() / dV, 0.3);

    Assert.assertEquals(0, pvcE.getPosition().subtract(pvkT.getPosition()).getNorm() / dP, 0.3);
    Assert.assertEquals(0, pvcE.getVelocity().subtract(pvkT.getVelocity()).getNorm() / dV, 0.4);
    Assert.assertEquals(0, pvkE.getPosition().subtract(pvkT.getPosition()).getNorm() / dP, 0.009);
    Assert.assertEquals(0, pvkE.getVelocity().subtract(pvkT.getVelocity()).getNorm() / dV, 0.006);

    Assert.assertEquals(0, pvcT.getPosition().subtract(pvkT.getPosition()).getNorm() / dP, 0.3);
    Assert.assertEquals(0, pvcT.getVelocity().subtract(pvkT.getVelocity()).getNorm() / dV, 0.4);
  }
  @Test
  public void testPropagationTypesElliptical() throws OrekitException, ParseException, IOException {

    ForceModel gravityField =
        new HolmesFeatherstoneAttractionModel(
            FramesFactory.getITRF(IERSConventions.IERS_2010, true),
            GravityFieldFactory.getNormalizedProvider(5, 5));
    propagator.addForceModel(gravityField);

    // Propagation of the initial at t + dt
    final PVCoordinates pv = initialState.getPVCoordinates();
    final double dP = 0.001;
    final double dV =
        initialState.getMu() * dP / (pv.getPosition().getNormSq() * pv.getVelocity().getNorm());

    final PVCoordinates pvcM =
        propagateInType(initialState, dP, OrbitType.CARTESIAN, PositionAngle.MEAN);
    final PVCoordinates pviM =
        propagateInType(initialState, dP, OrbitType.CIRCULAR, PositionAngle.MEAN);
    final PVCoordinates pveM =
        propagateInType(initialState, dP, OrbitType.EQUINOCTIAL, PositionAngle.MEAN);
    final PVCoordinates pvkM =
        propagateInType(initialState, dP, OrbitType.KEPLERIAN, PositionAngle.MEAN);

    final PVCoordinates pvcE =
        propagateInType(initialState, dP, OrbitType.CARTESIAN, PositionAngle.ECCENTRIC);
    final PVCoordinates pviE =
        propagateInType(initialState, dP, OrbitType.CIRCULAR, PositionAngle.ECCENTRIC);
    final PVCoordinates pveE =
        propagateInType(initialState, dP, OrbitType.EQUINOCTIAL, PositionAngle.ECCENTRIC);
    final PVCoordinates pvkE =
        propagateInType(initialState, dP, OrbitType.KEPLERIAN, PositionAngle.ECCENTRIC);

    final PVCoordinates pvcT =
        propagateInType(initialState, dP, OrbitType.CARTESIAN, PositionAngle.TRUE);
    final PVCoordinates pviT =
        propagateInType(initialState, dP, OrbitType.CIRCULAR, PositionAngle.TRUE);
    final PVCoordinates pveT =
        propagateInType(initialState, dP, OrbitType.EQUINOCTIAL, PositionAngle.TRUE);
    final PVCoordinates pvkT =
        propagateInType(initialState, dP, OrbitType.KEPLERIAN, PositionAngle.TRUE);

    Assert.assertEquals(0, pvcM.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 3.0);
    Assert.assertEquals(0, pvcM.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 2.0);
    Assert.assertEquals(0, pviM.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.6);
    Assert.assertEquals(0, pviM.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.4);
    Assert.assertEquals(0, pvkM.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.5);
    Assert.assertEquals(0, pvkM.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.3);
    Assert.assertEquals(0, pveM.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.2);
    Assert.assertEquals(0, pveM.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.2);

    Assert.assertEquals(0, pvcE.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 3.0);
    Assert.assertEquals(0, pvcE.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 2.0);
    Assert.assertEquals(0, pviE.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.03);
    Assert.assertEquals(0, pviE.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.04);
    Assert.assertEquals(0, pvkE.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.4);
    Assert.assertEquals(0, pvkE.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.3);
    Assert.assertEquals(0, pveE.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.2);
    Assert.assertEquals(0, pveE.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.07);

    Assert.assertEquals(0, pvcT.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 3.0);
    Assert.assertEquals(0, pvcT.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 2.0);
    Assert.assertEquals(0, pviT.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.3);
    Assert.assertEquals(0, pviT.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.2);
    Assert.assertEquals(0, pvkT.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.4);
    Assert.assertEquals(0, pvkT.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.2);
  }