use of org.orekit.propagation.events.EventsLogger.LoggedEvent in project Orekit by CS-SI.
the class ElevationDetectorTest method testIssue136.
@Test
public void testIssue136() throws OrekitException {
// Initial state definition : date, orbit
AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC());
// inertial frame for orbit definition
Frame inertialFrame = FramesFactory.getEME2000();
Orbit initialOrbit = new KeplerianOrbit(6828137.005, 7.322641382145889e-10, 1.6967079057368113, 0.0, 1.658054062748353, 0.0001223149429077902, PositionAngle.MEAN, inertialFrame, initialDate, Constants.EIGEN5C_EARTH_MU);
// Propagator : consider a simple Keplerian motion (could be more elaborate)
Propagator kepler = new EcksteinHechlerPropagator(initialOrbit, Constants.EGM96_EARTH_EQUATORIAL_RADIUS, Constants.EGM96_EARTH_MU, Constants.EGM96_EARTH_C20, 0.0, 0.0, 0.0, 0.0);
// Earth and frame
// equatorial radius in meter
double ae = 6378137.0;
// flattening
double f = 1.0 / 298.257223563;
// terrestrial frame at an arbitrary date
Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
BodyShape earth = new OneAxisEllipsoid(ae, f, itrf);
// Station
final double longitude = FastMath.toRadians(-147.5);
final double latitude = FastMath.toRadians(64);
final double altitude = 160;
final GeodeticPoint station1 = new GeodeticPoint(latitude, longitude, altitude);
final TopocentricFrame sta1Frame = new TopocentricFrame(earth, station1, "station1");
// Event definition
final double maxcheck = 120.0;
final double elevation = FastMath.toRadians(5.);
final double threshold = 10.0;
final EventDetector rawEvent = new ElevationDetector(maxcheck, threshold, sta1Frame).withConstantElevation(elevation).withHandler(new ContinueOnEvent<ElevationDetector>());
final EventsLogger logger = new EventsLogger();
kepler.addEventDetector(logger.monitorDetector(rawEvent));
// Propagate from the initial date to the first raising or for the fixed duration
kepler.propagate(initialDate.shiftedBy(60 * 60 * 24.0 * 40));
int countIncreasing = 0;
int countDecreasing = 0;
for (LoggedEvent le : logger.getLoggedEvents()) {
if (le.isIncreasing()) {
++countIncreasing;
} else {
++countDecreasing;
}
}
Assert.assertEquals(314, countIncreasing);
Assert.assertEquals(314, countDecreasing);
}
use of org.orekit.propagation.events.EventsLogger.LoggedEvent in project Orekit by CS-SI.
the class FootprintOverlapDetectorTest method testRightForwardView.
@Test
public void testRightForwardView() throws OrekitException, IOException {
propagator.setAttitudeProvider(new LofOffset(initialOrbit.getFrame(), LOFType.VVLH, RotationOrder.XYZ, FastMath.toRadians(-20.0), FastMath.toRadians(+20.0), 0.0));
// observe continental France plus Corsica
final SphericalPolygonsSet france = buildFrance();
// square field of view along Z axis (which is pointing sideways), aperture 5°, 0° margin
final FieldOfView fov = new FieldOfView(Vector3D.PLUS_K, Vector3D.PLUS_I, FastMath.toRadians(2.5), 4, 0.0);
final FootprintOverlapDetector detector = new FootprintOverlapDetector(fov, earth, france, 50000.0).withMaxCheck(1.0).withThreshold(1.0e-6).withHandler(new ContinueOnEvent<FootprintOverlapDetector>());
final EventsLogger logger = new EventsLogger();
propagator.addEventDetector(logger.monitorDetector(detector));
// Extrapolate from the initial to the final date
propagator.propagate(initialOrbit.getDate().shiftedBy(635000), initialOrbit.getDate().shiftedBy(735000));
List<LoggedEvent> events = logger.getLoggedEvents();
Assert.assertEquals(8, events.size());
// the first two consecutive close events occur during the same ascending orbit
// we first see Corsica, then lose visibility over the see, then see continental France
// above Mediterranean see, between Illes Balears and Sardigna,
// pointing to Corsica towards North-East
checkEventPair(events.get(0), events.get(1), 639010.0775, 33.9434, 39.2168, 6.5980, 42.0671, 9.0543);
// above Saint-Chamond (Loire), pointing near Saint-Dié-des-Vosges (Vosges) towards North-East
checkEventPair(events.get(2), events.get(3), 639111.1399, 40.8032, 45.4637, 4.5075, 48.3487, 7.1733);
// event is on a descending orbit, so the pointing direction,
// taking roll and pitch offsets, is towards South-West with respect to spacecraft
// above English Channel, pointing near Hanvec (Finistère) towards South-West
checkEventPair(events.get(4), events.get(5), 687772.4531, 27.0852, 50.2693, 0.0493, 48.3243, -4.1510);
// event on an ascending orbit
// above Atlantic ocean, pointing near to île d'Oléron (Charente-Maritime) towards North-East
checkEventPair(events.get(6), events.get(7), 727696.1033, 113.8829, 42.9785, -4.0426, 45.8492, -1.4656);
}
use of org.orekit.propagation.events.EventsLogger.LoggedEvent in project Orekit by CS-SI.
the class ApsideDetectorTest method testSimple.
@Test
public void testSimple() throws OrekitException {
EventDetector detector = new ApsideDetector(propagator.getInitialState().getOrbit()).withMaxCheck(600.0).withThreshold(1.0e-12).withHandler(new ContinueOnEvent<ApsideDetector>());
Assert.assertEquals(600.0, detector.getMaxCheckInterval(), 1.0e-15);
Assert.assertEquals(1.0e-12, detector.getThreshold(), 1.0e-15);
Assert.assertEquals(AbstractDetector.DEFAULT_MAX_ITER, detector.getMaxIterationCount());
EventsLogger logger = new EventsLogger();
propagator.addEventDetector(logger.monitorDetector(detector));
propagator.propagate(propagator.getInitialState().getOrbit().getDate().shiftedBy(Constants.JULIAN_DAY));
Assert.assertEquals(30, logger.getLoggedEvents().size());
for (LoggedEvent e : logger.getLoggedEvents()) {
KeplerianOrbit o = (KeplerianOrbit) OrbitType.KEPLERIAN.convertType(e.getState().getOrbit());
double expected = e.isIncreasing() ? 0.0 : FastMath.PI;
Assert.assertEquals(expected, MathUtils.normalizeAngle(o.getMeanAnomaly(), expected), 4.0e-14);
}
}
use of org.orekit.propagation.events.EventsLogger.LoggedEvent in project Orekit by CS-SI.
the class EventEnablingPredicateFilterTest method testExceedHistoryBackward.
@Test
public void testExceedHistoryBackward() throws OrekitException, IOException {
final double period = 900.0;
// the raw detector should trigger one event at each 900s period
final DateDetector raw = new DateDetector(orbit.getDate().shiftedBy(+0.5 * period)).withMaxCheck(period / 3).withHandler(new ContinueOnEvent<DateDetector>());
for (int i = 0; i < 300; ++i) {
raw.addEventDate(orbit.getDate().shiftedBy(-(i + 0.5) * period));
}
// in fact, we will filter out half of these events, so we get only one event every 2 periods
final EventEnablingPredicateFilter<DateDetector> filtered = new EventEnablingPredicateFilter<DateDetector>(raw, new EnablingPredicate<DateDetector>() {
public boolean eventIsEnabled(SpacecraftState state, DateDetector eventDetector, double g) {
double nbPeriod = orbit.getDate().durationFrom(state.getDate()) / period;
return ((int) FastMath.floor(nbPeriod)) % 2 == 1;
}
});
Propagator propagator = new KeplerianPropagator(orbit);
EventsLogger logger = new EventsLogger();
propagator.addEventDetector(logger.monitorDetector(filtered));
propagator.propagate(orbit.getDate().shiftedBy(-301 * period));
List<LoggedEvent> events = logger.getLoggedEvents();
// 300 periods, 150 events as half of them are filtered out
Assert.assertEquals(150, events.size());
// as we have encountered a lot of enabling status changes, we exceeded the internal history
// if we try to display again the filtered g function for dates far in the future,
// we will not see the zero crossings anymore, they have been lost
propagator.clearEventsDetectors();
for (double dt = -5000.0; dt > -10000.0; dt -= 3.0) {
double filteredG = filtered.g(propagator.propagate(orbit.getDate().shiftedBy(dt)));
Assert.assertTrue(filteredG < 0.0);
}
// that are still inside the history, we still see the zero crossings
for (double dt = -195400.0; dt > -196200.0; dt -= 3.0) {
double filteredG = filtered.g(propagator.propagate(orbit.getDate().shiftedBy(dt)));
if (dt < -195750) {
Assert.assertTrue(filteredG < 0.0);
} else {
Assert.assertTrue(filteredG > 0.0);
}
}
}
use of org.orekit.propagation.events.EventsLogger.LoggedEvent in project Orekit by CS-SI.
the class LatitudeExtremumDetectorTest method testLEO.
@Test
public void testLEO() throws OrekitException {
final OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
LatitudeExtremumDetector d = new LatitudeExtremumDetector(earth).withMaxCheck(60).withThreshold(1.e-6).withHandler(new ContinueOnEvent<LatitudeExtremumDetector>());
Assert.assertEquals(60.0, d.getMaxCheckInterval(), 1.0e-15);
Assert.assertEquals(1.0e-6, d.getThreshold(), 1.0e-15);
Assert.assertEquals(AbstractDetector.DEFAULT_MAX_ITER, d.getMaxIterationCount());
Assert.assertSame(earth, d.getBody());
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(Constants.JULIAN_DAY));
for (LoggedEvent e : logger.getLoggedEvents()) {
SpacecraftState state = e.getState();
double latitude = earth.transform(state.getPVCoordinates(earth.getBodyFrame()).getPosition(), earth.getBodyFrame(), null).getLatitude();
if (e.isIncreasing()) {
Assert.assertEquals(-81.863, FastMath.toDegrees(latitude), 0.001);
} else {
Assert.assertEquals(+81.863, FastMath.toDegrees(latitude), 0.001);
}
}
Assert.assertEquals(29, logger.getLoggedEvents().size());
}
Aggregations