Search in sources :

Example 16 with LoggedEvent

use of org.orekit.propagation.events.EventsLogger.LoggedEvent in project Orekit by CS-SI.

the class EventEnablingPredicateFilterTest method doElevationTest.

private void doElevationTest(final double minElevation, final AbsoluteDate start, final AbsoluteDate end, final int expectedEvents, final boolean sameSign) throws OrekitException {
    final ElevationExtremumDetector raw = new ElevationExtremumDetector(0.001, 1.e-6, new TopocentricFrame(earth, gp, "test")).withHandler(new ContinueOnEvent<ElevationExtremumDetector>());
    final EventEnablingPredicateFilter<ElevationExtremumDetector> aboveGroundElevationDetector = new EventEnablingPredicateFilter<ElevationExtremumDetector>(raw, new EnablingPredicate<ElevationExtremumDetector>() {

        public boolean eventIsEnabled(final SpacecraftState state, final ElevationExtremumDetector eventDetector, final double g) throws OrekitException {
            return eventDetector.getElevation(state) > minElevation;
        }
    }).withMaxCheck(60.0);
    Assert.assertEquals(0.001, raw.getMaxCheckInterval(), 1.0e-15);
    Assert.assertEquals(60.0, aboveGroundElevationDetector.getMaxCheckInterval(), 1.0e-15);
    Assert.assertEquals(1.0e-6, aboveGroundElevationDetector.getThreshold(), 1.0e-15);
    Assert.assertEquals(AbstractDetector.DEFAULT_MAX_ITER, aboveGroundElevationDetector.getMaxIterationCount());
    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(aboveGroundElevationDetector));
    propagator.propagate(start, end);
    for (LoggedEvent e : logger.getLoggedEvents()) {
        final double eMinus = raw.getElevation(e.getState().shiftedBy(-10.0));
        final double e0 = raw.getElevation(e.getState());
        final double ePlus = raw.getElevation(e.getState().shiftedBy(+10.0));
        Assert.assertTrue(e0 > eMinus);
        Assert.assertTrue(e0 > ePlus);
        Assert.assertTrue(e0 > minElevation);
    }
    Assert.assertEquals(expectedEvents, logger.getLoggedEvents().size());
    propagator.clearEventsDetectors();
    double g1Raw = raw.g(propagator.propagate(orbit.getDate().shiftedBy(18540.0)));
    double g2Raw = raw.g(propagator.propagate(orbit.getDate().shiftedBy(18624.0)));
    double g1 = aboveGroundElevationDetector.g(propagator.propagate(orbit.getDate().shiftedBy(18540.0)));
    double g2 = aboveGroundElevationDetector.g(propagator.propagate(orbit.getDate().shiftedBy(18624.0)));
    Assert.assertTrue(g1Raw > 0);
    Assert.assertTrue(g2Raw < 0);
    if (sameSign) {
        Assert.assertTrue(g1 > 0);
        Assert.assertTrue(g2 < 0);
    } else {
        Assert.assertTrue(g1 < 0);
        Assert.assertTrue(g2 > 0);
    }
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) LoggedEvent(org.orekit.propagation.events.EventsLogger.LoggedEvent) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) TopocentricFrame(org.orekit.frames.TopocentricFrame)

Aggregations

LoggedEvent (org.orekit.propagation.events.EventsLogger.LoggedEvent)16 Test (org.junit.Test)14 Propagator (org.orekit.propagation.Propagator)14 EcksteinHechlerPropagator (org.orekit.propagation.analytical.EcksteinHechlerPropagator)11 AbsoluteDate (org.orekit.time.AbsoluteDate)11 SpacecraftState (org.orekit.propagation.SpacecraftState)10 KeplerianPropagator (org.orekit.propagation.analytical.KeplerianPropagator)10 GeodeticPoint (org.orekit.bodies.GeodeticPoint)9 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)9 TopocentricFrame (org.orekit.frames.TopocentricFrame)7 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)7 Orbit (org.orekit.orbits.Orbit)7 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)6 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)5 Frame (org.orekit.frames.Frame)5 TimeScale (org.orekit.time.TimeScale)5 PVCoordinates (org.orekit.utils.PVCoordinates)5 BodyShape (org.orekit.bodies.BodyShape)4 ArrayList (java.util.ArrayList)2 CartesianOrbit (org.orekit.orbits.CartesianOrbit)2