Exemple #1
0
  @Test
  public void testTLEFormat() throws OrekitException {

    String line1 = "1 27421U 02021A   02124.48976499 -.00021470  00000-0 -89879-2 0    20";
    String line2 = "2 27421  98.7490 199.5121 0001333 133.9522 226.1918 14.26113993    62";

    Assert.assertTrue(TLE.isFormatOK(line1, line2));

    TLE tle = new TLE(line1, line2);
    Assert.assertEquals(27421, tle.getSatelliteNumber(), 0);
    Assert.assertEquals(2002, tle.getLaunchYear());
    Assert.assertEquals(21, tle.getLaunchNumber());
    Assert.assertEquals("A", tle.getLaunchPiece());
    Assert.assertEquals(-0.0089879, tle.getBStar(), 0);
    Assert.assertEquals(0, tle.getEphemerisType());
    Assert.assertEquals(98.749, FastMath.toDegrees(tle.getI()), 1e-10);
    Assert.assertEquals(199.5121, FastMath.toDegrees(tle.getRaan()), 1e-10);
    Assert.assertEquals(0.0001333, tle.getE(), 1e-10);
    Assert.assertEquals(133.9522, FastMath.toDegrees(tle.getPerigeeArgument()), 1e-10);
    Assert.assertEquals(226.1918, FastMath.toDegrees(tle.getMeanAnomaly()), 1e-10);
    Assert.assertEquals(
        14.26113993, tle.getMeanMotion() * Constants.JULIAN_DAY / (2 * FastMath.PI), 0);
    Assert.assertEquals(tle.getRevolutionNumberAtEpoch(), 6, 0);
    Assert.assertEquals(tle.getElementNumber(), 2, 0);

    line1 = "1 27421U 02021A   02124.48976499 -.00021470  00000-0 -89879-2 0    20";
    line2 = "2 27421  98.7490 199.5121 0001333 133.9522 226.1918 14*26113993    62";
    Assert.assertFalse(TLE.isFormatOK(line1, line2));

    line1 = "1 27421 02021A   02124.48976499 -.00021470  00000-0 -89879-2 0    20";
    line2 = "2 27421  98.7490 199.5121 0001333 133.9522 226.1918 14.26113993    62";
    Assert.assertFalse(TLE.isFormatOK(line1, line2));

    line1 = "1 27421U 02021A   02124.48976499 -.00021470  00000-0 -89879-2 0    20";
    line2 = "2 27421  98.7490 199.5121 0001333 133.9522 226.1918 10006113993    62";
    Assert.assertFalse(TLE.isFormatOK(line1, line2));

    line1 = "1 27421U 02021A   02124.48976499 -.00021470  00000-0 -89879 2 0    20";
    line2 = "2 27421  98.7490 199.5121 0001333 133.9522 226.1918 14.26113993    62";
    Assert.assertFalse(TLE.isFormatOK(line1, line2));
  }
  private void run(final File input, final File output, final String separator)
      throws IOException, IllegalArgumentException, OrekitException {

    // read input parameters
    KeyValueFileParser<ParameterKey> parser =
        new KeyValueFileParser<ParameterKey>(ParameterKey.class);
    parser.parseInput(input.getAbsolutePath(), new FileInputStream(input));

    double minElevation = parser.getAngle(ParameterKey.MIN_ELEVATION);
    double radius =
        Constants.WGS84_EARTH_EQUATORIAL_RADIUS
            + parser.getDouble(ParameterKey.SPACECRAFT_ALTITUDE);
    int points = parser.getInt(ParameterKey.POINTS_NUMBER);

    // station properties
    double latitude = parser.getAngle(ParameterKey.STATION_LATITUDE);
    double longitude = parser.getAngle(ParameterKey.STATION_LONGITUDE);
    double altitude = parser.getDouble(ParameterKey.STATION_ALTITUDE);
    String name = parser.getString(ParameterKey.STATION_NAME);

    // compute visibility circle
    List<GeodeticPoint> circle =
        computeCircle(latitude, longitude, altitude, name, minElevation, radius, points);

    // create a 2 columns csv file representing the visibility circle
    // in the user home directory, with latitude in column 1 and longitude in column 2
    DecimalFormat format = new DecimalFormat("#00.00000", new DecimalFormatSymbols(Locale.US));
    PrintStream csvFile = new PrintStream(output);
    for (GeodeticPoint p : circle) {
      csvFile.println(
          format.format(FastMath.toDegrees(p.getLatitude()))
              + ","
              + format.format(FastMath.toDegrees(p.getLongitude())));
    }
    csvFile.close();
  }
  @Test
  public void testFrance() throws OrekitException {

    final BodyShape earth =
        new OneAxisEllipsoid(
            Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
            Constants.WGS84_EARTH_FLATTENING,
            FramesFactory.getITRF(IERSConventions.IERS_2010, true));

    GeographicZoneDetector d =
        new GeographicZoneDetector(20.0, 1.e-3, earth, buildFrance(), FastMath.toRadians(0.5))
            .withHandler(new ContinueOnEvent<GeographicZoneDetector>());

    Assert.assertEquals(20.0, d.getMaxCheckInterval(), 1.0e-15);
    Assert.assertEquals(1.0e-3, d.getThreshold(), 1.0e-15);
    Assert.assertEquals(0.5, FastMath.toDegrees(d.getMargin()), 1.0e-15);
    Assert.assertEquals(AbstractDetector.DEFAULT_MAX_ITER, d.getMaxIterationCount());

    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);
    final Orbit orbit =
        new EquinoctialOrbit(
            new PVCoordinates(position, velocity),
            FramesFactory.getEME2000(),
            date,
            Constants.EIGEN5C_EARTH_MU);

    Propagator propagator =
        new EcksteinHechlerPropagator(
            orbit,
            Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS,
            Constants.EIGEN5C_EARTH_MU,
            Constants.EIGEN5C_EARTH_C20,
            Constants.EIGEN5C_EARTH_C30,
            Constants.EIGEN5C_EARTH_C40,
            Constants.EIGEN5C_EARTH_C50,
            Constants.EIGEN5C_EARTH_C60);

    EventsLogger logger = new EventsLogger();
    propagator.addEventDetector(logger.monitorDetector(d));

    propagator.propagate(date.shiftedBy(10 * Constants.JULIAN_DAY));
    Assert.assertEquals(26, logger.getLoggedEvents().size());
  }
  @Test
  public void testSerialization()
      throws IOException, ClassNotFoundException, NoSuchFieldException, IllegalAccessException,
          OrekitException {

    final double r = Constants.WGS84_EARTH_EQUATORIAL_RADIUS;
    final BodyShape earth =
        new OneAxisEllipsoid(
            r,
            Constants.WGS84_EARTH_FLATTENING,
            FramesFactory.getITRF(IERSConventions.IERS_2010, true));

    GeographicZoneDetector d =
        new GeographicZoneDetector(20.0, 1.e-3, earth, buildFrance(), FastMath.toRadians(0.5))
            .withMargin(FastMath.toRadians(0.75))
            .withHandler(new ContinueOnEvent<GeographicZoneDetector>());

    Assert.assertEquals(r, ((OneAxisEllipsoid) d.getBody()).getEquatorialRadius(), 1.0e-12);
    Assert.assertEquals(0.75, FastMath.toDegrees(d.getMargin()), 1.0e-12);
    Assert.assertEquals(5.6807e11, d.getZone().getSize() * r * r, 1.0e9);
    Assert.assertEquals(4.0289e6, d.getZone().getBoundarySize() * r, 1.0e3);

    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bos);
    oos.writeObject(d);

    Assert.assertTrue(bos.size() > 2100);
    Assert.assertTrue(bos.size() < 2200);

    ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
    ObjectInputStream ois = new ObjectInputStream(bis);
    GeographicZoneDetector deserialized = (GeographicZoneDetector) ois.readObject();

    Assert.assertEquals(d.getZone().getSize(), deserialized.getZone().getSize(), 1.0e-3);
    Assert.assertEquals(
        d.getZone().getBoundarySize(), deserialized.getZone().getBoundarySize(), 1.0e-3);
    Assert.assertEquals(d.getZone().getTolerance(), deserialized.getZone().getTolerance(), 1.0e-15);
    Assert.assertEquals(d.getMaxCheckInterval(), deserialized.getMaxCheckInterval(), 1.0e-15);
    Assert.assertEquals(d.getThreshold(), deserialized.getThreshold(), 1.0e-15);
    Assert.assertEquals(d.getMaxIterationCount(), deserialized.getMaxIterationCount());

    Assert.assertTrue(
        new RegionFactory<Sphere2D>().difference(d.getZone(), deserialized.getZone()).isEmpty());
  }