Search in sources :

Example 6 with LoggedEvent

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

the class LongitudeCrossingDetectorTest method testRegularCrossing.

@Test
public void testRegularCrossing() throws OrekitException {
    final OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
    LongitudeCrossingDetector d = new LongitudeCrossingDetector(earth, FastMath.toRadians(10.0)).withMaxCheck(60).withThreshold(1.e-6).withHandler(new ContinueOnEvent<LongitudeCrossingDetector>());
    Assert.assertEquals(60.0, d.getMaxCheckInterval(), 1.0e-15);
    Assert.assertEquals(1.0e-6, d.getThreshold(), 1.0e-15);
    Assert.assertEquals(10.0, FastMath.toDegrees(d.getLongitude()), 1.0e-14);
    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));
    AbsoluteDate previous = null;
    for (LoggedEvent e : logger.getLoggedEvents()) {
        SpacecraftState state = e.getState();
        double longitude = earth.transform(state.getPVCoordinates(earth.getBodyFrame()).getPosition(), earth.getBodyFrame(), null).getLongitude();
        Assert.assertEquals(10.0, FastMath.toDegrees(longitude), 1.6e-7);
        if (previous != null) {
            // same time interval regardless of increasing/decreasing,
            // as increasing/decreasing flag is irrelevant for this detector
            Assert.assertEquals(4954.70, state.getDate().durationFrom(previous), 1e10);
        }
        previous = state.getDate();
    }
    Assert.assertEquals(16, logger.getLoggedEvents().size());
}
Also used : OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) Orbit(org.orekit.orbits.Orbit) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) LoggedEvent(org.orekit.propagation.events.EventsLogger.LoggedEvent) PVCoordinates(org.orekit.utils.PVCoordinates) TimeScale(org.orekit.time.TimeScale) AbsoluteDate(org.orekit.time.AbsoluteDate) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) Test(org.junit.Test)

Example 7 with LoggedEvent

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

the class PositionAngleDetectorTest method doTest.

private void doTest(final OrbitType orbitType, final PositionAngle positionAngle, final double angle, final int expectedCrossings) throws OrekitException {
    PositionAngleDetector d = new PositionAngleDetector(orbitType, positionAngle, angle).withMaxCheck(60).withThreshold(1.e-10).withHandler(new ContinueOnEvent<PositionAngleDetector>());
    Assert.assertEquals(60.0, d.getMaxCheckInterval(), 1.0e-15);
    Assert.assertEquals(1.0e-10, d.getThreshold(), 1.0e-15);
    Assert.assertEquals(orbitType, d.getOrbitType());
    Assert.assertEquals(positionAngle, d.getPositionAngle());
    Assert.assertEquals(angle, d.getAngle(), 1.0e-14);
    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(506.0, 943.0, 7450);
    final AbsoluteDate date = new AbsoluteDate(2003, 9, 16, utc);
    final Orbit orbit = new CartesianOrbit(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));
    double[] array = new double[6];
    for (LoggedEvent e : logger.getLoggedEvents()) {
        SpacecraftState state = e.getState();
        orbitType.mapOrbitToArray(state.getOrbit(), positionAngle, array, null);
        Assert.assertEquals(angle, MathUtils.normalizeAngle(array[5], angle), 1.0e-10);
    }
    Assert.assertEquals(15, logger.getLoggedEvents().size());
}
Also used : CartesianOrbit(org.orekit.orbits.CartesianOrbit) Orbit(org.orekit.orbits.Orbit) CartesianOrbit(org.orekit.orbits.CartesianOrbit) LoggedEvent(org.orekit.propagation.events.EventsLogger.LoggedEvent) PVCoordinates(org.orekit.utils.PVCoordinates) TimeScale(org.orekit.time.TimeScale) AbsoluteDate(org.orekit.time.AbsoluteDate) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) SpacecraftState(org.orekit.propagation.SpacecraftState) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) Propagator(org.orekit.propagation.Propagator)

Example 8 with LoggedEvent

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

the class OrekitEphemerisFileTest method testWritingToOEM.

@Test
public void testWritingToOEM() throws OrekitException, IOException {
    final double muTolerance = 1e-12;
    final double positionTolerance = 1e-8;
    final double velocityTolerance = 1e-8;
    final String satId = "SATELLITE1";
    final double sma = 10000000;
    final double inc = Math.toRadians(45.0);
    final double ecc = 0.001;
    final double raan = 0.0;
    final double pa = 0.0;
    final double ta = 0.0;
    final AbsoluteDate date = new AbsoluteDate();
    final Frame frame = FramesFactory.getGCRF();
    final CelestialBody body = CelestialBodyFactory.getEarth();
    final double mu = body.getGM();
    KeplerianOrbit initialOrbit = new KeplerianOrbit(sma, ecc, inc, pa, raan, ta, PositionAngle.TRUE, frame, date, mu);
    KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit);
    final double propagationDurationSeconds = 86400.0;
    final double stepSizeSeconds = 60.0;
    List<SpacecraftState> states = new ArrayList<SpacecraftState>();
    for (double dt = 0.0; dt < propagationDurationSeconds; dt += stepSizeSeconds) {
        states.add(propagator.propagate(date.shiftedBy(dt)));
    }
    OrekitEphemerisFile ephemerisFile = new OrekitEphemerisFile();
    OrekitSatelliteEphemeris satellite = ephemerisFile.addSatellite(satId);
    satellite.addNewSegment(states);
    String tempOemFile = Files.createTempFile("OrekitEphemerisFileTest", ".oem").toString();
    new OEMWriter().write(tempOemFile, ephemerisFile);
    EphemerisFile ephemerisFromFile = new OEMParser().parse(tempOemFile);
    Files.delete(Paths.get(tempOemFile));
    EphemerisSegment segment = ephemerisFromFile.getSatellites().get(satId).getSegments().get(0);
    assertEquals(states.get(0).getDate(), segment.getStart());
    assertEquals(states.get(states.size() - 1).getDate(), segment.getStop());
    assertEquals(states.size(), segment.getCoordinates().size());
    assertEquals(frame, segment.getFrame());
    assertEquals(body.getName().toUpperCase(), segment.getFrameCenterString());
    assertEquals(body.getGM(), segment.getMu(), muTolerance);
    for (int i = 0; i < states.size(); i++) {
        TimeStampedPVCoordinates expected = states.get(i).getPVCoordinates();
        TimeStampedPVCoordinates actual = segment.getCoordinates().get(i);
        assertEquals(expected.getDate(), actual.getDate());
        assertEquals(0.0, Vector3D.distance(expected.getPosition(), actual.getPosition()), positionTolerance);
        assertEquals(0.0, Vector3D.distance(expected.getVelocity(), actual.getVelocity()), velocityTolerance);
    }
    // test ingested ephemeris generates access intervals
    final OneAxisEllipsoid parentShape = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
    final double latitude = 0.0;
    final double longitude = 0.0;
    final double altitude = 0.0;
    final GeodeticPoint point = new GeodeticPoint(latitude, longitude, altitude);
    final TopocentricFrame topo = new TopocentricFrame(parentShape, point, "testPoint1");
    final ElevationDetector elevationDetector = new ElevationDetector(topo);
    final EphemerisSegmentPropagator ephemerisSegmentPropagator = new EphemerisSegmentPropagator(segment);
    final EventsLogger lookupLogger = new EventsLogger();
    ephemerisSegmentPropagator.addEventDetector(lookupLogger.monitorDetector(elevationDetector));
    final EventsLogger referenceLogger = new EventsLogger();
    propagator.clearEventsDetectors();
    propagator.addEventDetector(referenceLogger.monitorDetector(elevationDetector));
    propagator.propagate(segment.getStart(), segment.getStop());
    ephemerisSegmentPropagator.propagate(segment.getStart(), segment.getStop());
    final double dateEpsilon = 1.0e-9;
    assertTrue(referenceLogger.getLoggedEvents().size() > 0);
    assertEquals(referenceLogger.getLoggedEvents().size(), lookupLogger.getLoggedEvents().size());
    for (int i = 0; i < referenceLogger.getLoggedEvents().size(); i++) {
        LoggedEvent reference = referenceLogger.getLoggedEvents().get(i);
        LoggedEvent actual = lookupLogger.getLoggedEvents().get(i);
        assertEquals(0.0, FastMath.abs(reference.getState().getDate().durationFrom(actual.getState().getDate())), dateEpsilon);
    }
    final Propagator embeddedPropagator = segment.getPropagator();
    final EventsLogger embeddedPropLogger = new EventsLogger();
    embeddedPropagator.addEventDetector(embeddedPropLogger.monitorDetector(elevationDetector));
    embeddedPropagator.propagate(segment.getStart(), segment.getStop());
    assertEquals(referenceLogger.getLoggedEvents().size(), embeddedPropLogger.getLoggedEvents().size());
    for (int i = 0; i < referenceLogger.getLoggedEvents().size(); i++) {
        LoggedEvent reference = referenceLogger.getLoggedEvents().get(i);
        LoggedEvent actual = embeddedPropLogger.getLoggedEvents().get(i);
        assertEquals(0.0, FastMath.abs(reference.getState().getDate().durationFrom(actual.getState().getDate())), dateEpsilon);
    }
    final List<SpacecraftState> readInStates = new ArrayList<SpacecraftState>();
    segment.getCoordinates().forEach(c -> {
        try {
            readInStates.add(new SpacecraftState(new CartesianOrbit(c, frame, mu)));
        } catch (IllegalArgumentException | OrekitException e) {
            fail(e.getLocalizedMessage());
        }
    });
    final int interpolationPoints = 5;
    Ephemeris directEphemProp = new Ephemeris(readInStates, interpolationPoints);
    final EventsLogger directEphemPropLogger = new EventsLogger();
    directEphemProp.addEventDetector(directEphemPropLogger.monitorDetector(elevationDetector));
    directEphemProp.propagate(segment.getStart(), segment.getStop());
    assertEquals(referenceLogger.getLoggedEvents().size(), directEphemPropLogger.getLoggedEvents().size());
    for (int i = 0; i < referenceLogger.getLoggedEvents().size(); i++) {
        LoggedEvent reference = referenceLogger.getLoggedEvents().get(i);
        LoggedEvent actual = directEphemPropLogger.getLoggedEvents().get(i);
        assertEquals(0.0, FastMath.abs(reference.getState().getDate().durationFrom(actual.getState().getDate())), dateEpsilon);
    }
}
Also used : Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) CartesianOrbit(org.orekit.orbits.CartesianOrbit) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) LoggedEvent(org.orekit.propagation.events.EventsLogger.LoggedEvent) ElevationDetector(org.orekit.propagation.events.ElevationDetector) ArrayList(java.util.ArrayList) TopocentricFrame(org.orekit.frames.TopocentricFrame) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) OrekitSatelliteEphemeris(org.orekit.files.general.OrekitEphemerisFile.OrekitSatelliteEphemeris) EphemerisSegment(org.orekit.files.general.EphemerisFile.EphemerisSegment) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) CelestialBody(org.orekit.bodies.CelestialBody) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) OrekitException(org.orekit.errors.OrekitException) GeodeticPoint(org.orekit.bodies.GeodeticPoint) OEMParser(org.orekit.files.ccsds.OEMParser) GeodeticPoint(org.orekit.bodies.GeodeticPoint) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) OEMWriter(org.orekit.files.ccsds.OEMWriter) EventsLogger(org.orekit.propagation.events.EventsLogger) OrekitSatelliteEphemeris(org.orekit.files.general.OrekitEphemerisFile.OrekitSatelliteEphemeris) Ephemeris(org.orekit.propagation.analytical.Ephemeris) Test(org.junit.Test)

Example 9 with LoggedEvent

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

the class ElevationDetectorTest method testIssue203.

@Test
public void testIssue203() throws OrekitException {
    // Initial state definition : date, orbit
    AbsoluteDate initialDate = new AbsoluteDate("2012-01-26T07:00:00.000", TimeScalesFactory.getUTC());
    // inertial frame for orbit definition
    Frame inertialFrame = FramesFactory.getEME2000();
    Orbit initialOrbit = new KeplerianOrbit(6828137.5, 7.322641060181212E-8, 1.7082667003713938, 0.0, 1.658054062748353, 1.2231496082116026E-4, PositionAngle.TRUE, inertialFrame, initialDate, Constants.WGS84_EARTH_MU);
    Propagator propagator = new EcksteinHechlerPropagator(initialOrbit, Constants.EGM96_EARTH_EQUATORIAL_RADIUS, Constants.EGM96_EARTH_MU, Constants.EGM96_EARTH_C20, Constants.EGM96_EARTH_C30, Constants.EGM96_EARTH_C40, Constants.EGM96_EARTH_C50, Constants.EGM96_EARTH_C60);
    // Earth and frame
    Frame earthFrame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, earthFrame);
    // Station
    final double longitude = FastMath.toRadians(21.0);
    final double latitude = FastMath.toRadians(67.9);
    final double altitude = 300.0;
    final GeodeticPoint station1 = new GeodeticPoint(latitude, longitude, altitude);
    final TopocentricFrame sta1Frame = new TopocentricFrame(earth, station1, "station1");
    double[][] maskValues = { { -0.017453292519943098, 0.006981317007977318 }, { 0.0, 0.006981317007977318 }, { 0.017453292519943295, 0.006981317007977318 }, { 0.03490658503988659, 0.010471975511965976 }, { 0.05235987755982989, 0.012217304763960306 }, { 0.06981317007977318, 0.010471975511965976 }, { 0.08726646259971647, 0.010471975511965976 }, { 0.10471975511965978, 0.012217304763960306 }, { 0.12217304763960307, 0.010471975511965976 }, { 0.13962634015954636, 0.008726646259971648 }, { 0.15707963267948966, 0.008726646259971648 }, { 0.17453292519943295, 0.006981317007977318 }, { 0.19198621771937624, 0.006981317007977318 }, { 0.20943951023931956, 0.006981317007977318 }, { 0.22689280275926285, 0.005235987755982988 }, { 0.24434609527920614, 0.005235987755982988 }, { 0.2617993877991494, 0.003490658503988659 }, { 0.2792526803190927, 0.003490658503988659 }, { 0.29670597283903605, 0.0017453292519943296 }, { 0.3141592653589793, 0.003490658503988659 }, { 0.33161255787892263, 0.0017453292519943296 }, { 0.3490658503988659, 0.0 }, { 0.3665191429188092, 0.012217304763960306 }, { 0.3839724354387525, 0.012217304763960306 }, { 0.4014257279586958, 0.0 }, { 0.4188790204786391, 0.010471975511965976 }, { 0.4363323129985824, 0.029670597283903602 }, { 0.4537856055185257, 0.029670597283903602 }, { 0.47123889803846897, 0.017453292519943295 }, { 0.4886921905584123, 0.0 }, { 0.5061454830783556, 0.029670597283903602 }, { 0.5235987755982988, 0.015707963267948967 }, { 0.5410520681182421, 0.005235987755982988 }, { 0.5585053606381855, 0.024434609527920613 }, { 0.5759586531581288, 0.041887902047863905 }, { 0.5934119456780721, 0.06283185307179587 }, { 0.6108652381980153, 0.05235987755982989 }, { 0.6283185307179586, 0.05759586531581287 }, { 0.6457718232379019, 0.061086523819801536 }, { 0.6632251157578453, 0.05759586531581287 }, { 0.6806784082777885, 0.04363323129985824 }, { 0.6981317007977318, 0.059341194567807204 }, { 0.7155849933176751, 0.07504915783575616 }, { 0.7330382858376184, 0.08726646259971647 }, { 0.7504915783575618, 0.08726646259971647 }, { 0.767944870877505, 0.07330382858376185 }, { 0.7853981633974483, 0.07853981633974483 }, { 0.8028514559173916, 0.09075712110370514 }, { 0.8203047484373349, 0.0942477796076938 }, { 0.8377580409572782, 0.11519173063162574 }, { 0.8552113334772214, 0.11519173063162574 }, { 0.8726646259971648, 0.12566370614359174 }, { 0.8901179185171081, 0.12566370614359174 }, { 0.9075712110370514, 0.10122909661567112 }, { 0.9250245035569946, 0.11868238913561441 }, { 0.9424777960769379, 0.11868238913561441 }, { 0.9599310885968813, 0.11868238913561441 }, { 0.9773843811168246, 0.10821041362364843 }, { 0.9948376736367679, 0.12217304763960307 }, { 1.0122909661567112, 0.12740903539558607 }, { 1.0297442586766545, 0.11344640137963143 }, { 1.0471975511965976, 0.11344640137963143 }, { 1.064650843716541, 0.06632251157578452 }, { 1.0821041362364843, 0.12391837689159739 }, { 1.0995574287564276, 0.12391837689159739 }, { 1.117010721276371, 0.10995574287564276 }, { 1.1344640137963142, 0.09250245035569947 }, { 1.1519173063162575, 0.12740903539558607 }, { 1.1693705988362009, 0.1308996938995747 }, { 1.1868238913561442, 0.1117010721276371 }, { 1.2042771838760873, 0.1117010721276371 }, { 1.2217304763960306, 0.0942477796076938 }, { 1.239183768915974, 0.10821041362364843 }, { 1.2566370614359172, 0.09599310885968812 }, { 1.2740903539558606, 0.09948376736367678 }, { 1.2915436464758039, 0.09773843811168245 }, { 1.3089969389957472, 0.08726646259971647 }, { 1.3264502315156905, 0.09250245035569947 }, { 1.3439035240356338, 0.10122909661567112 }, { 1.361356816555577, 0.09250245035569947 }, { 1.3788101090755203, 0.08552113334772216 }, { 1.3962634015954636, 0.08726646259971647 }, { 1.413716694115407, 0.08028514559173916 }, { 1.4311699866353502, 0.05759586531581287 }, { 1.4486232791552935, 0.054105206811824215 }, { 1.4660765716752369, 0.06632251157578452 }, { 1.4835298641951802, 0.08028514559173916 }, { 1.5009831567151235, 0.061086523819801536 }, { 1.5184364492350666, 0.048869219055841226 }, { 1.53588974175501, 0.0715584993317675 }, { 1.5533430342749532, 0.07504915783575616 }, { 1.5707963267948966, 0.05235987755982989 }, { 1.5882496193148399, 0.05235987755982989 }, { 1.6057029118347832, 0.06981317007977318 }, { 1.6231562043547265, 0.054105206811824215 }, { 1.6406094968746698, 0.0645771823237902 }, { 1.6580627893946132, 0.059341194567807204 }, { 1.6755160819145565, 0.029670597283903602 }, { 1.6929693744344996, 0.03316125578789226 }, { 1.710422666954443, 0.059341194567807204 }, { 1.7278759594743862, 0.0645771823237902 }, { 1.7453292519943295, 0.06283185307179587 }, { 1.7627825445142729, 0.061086523819801536 }, { 1.7802358370342162, 0.06806784082777885 }, { 1.7976891295541595, 0.06632251157578452 }, { 1.8151424220741028, 0.059341194567807204 }, { 1.8325957145940461, 0.05759586531581287 }, { 1.8500490071139892, 0.05759586531581287 }, { 1.8675022996339325, 0.0471238898038469 }, { 1.8849555921538759, 0.059341194567807204 }, { 1.9024088846738192, 0.05061454830783556 }, { 1.9198621771937625, 0.05061454830783556 }, { 1.9373154697137058, 0.024434609527920613 }, { 1.9547687622336491, 0.027925268031909273 }, { 1.9722220547535925, 0.041887902047863905 }, { 1.9896753472735358, 0.024434609527920613 }, { 2.007128639793479, 0.029670597283903602 }, { 2.0245819323134224, 0.03316125578789226 }, { 2.0420352248333655, 0.03665191429188092 }, { 2.059488517353309, 0.04537856055185257 }, { 2.076941809873252, 0.041887902047863905 }, { 2.0943951023931953, 0.05759586531581287 }, { 2.111848394913139, 0.06283185307179587 }, { 2.129301687433082, 0.06806784082777885 }, { 2.1467549799530254, 0.05759586531581287 }, { 2.1642082724729685, 0.059341194567807204 }, { 2.181661564992912, 0.06806784082777885 }, { 2.199114857512855, 0.06283185307179587 }, { 2.2165681500327987, 0.054105206811824215 }, { 2.234021442552742, 0.05235987755982989 }, { 2.251474735072685, 0.059341194567807204 }, { 2.2689280275926285, 0.07330382858376185 }, { 2.2863813201125716, 0.06283185307179587 }, { 2.303834612632515, 0.05235987755982989 }, { 2.321287905152458, 0.061086523819801536 }, { 2.3387411976724017, 0.048869219055841226 }, { 2.356194490192345, 0.06632251157578452 }, { 2.3736477827122884, 0.05061454830783556 }, { 2.3911010752322315, 0.07679448708775051 }, { 2.4085543677521746, 0.06283185307179587 }, { 2.426007660272118, 0.05585053606381855 }, { 2.443460952792061, 0.061086523819801536 }, { 2.4609142453120048, 0.06806784082777885 }, { 2.478367537831948, 0.0645771823237902 }, { 2.4958208303518914, 0.06283185307179587 }, { 2.5132741228718345, 0.06283185307179587 }, { 2.530727415391778, 0.0645771823237902 }, { 2.548180707911721, 0.07504915783575616 }, { 2.5656340004316642, 0.0715584993317675 }, { 2.5830872929516078, 0.0645771823237902 }, { 2.600540585471551, 0.059341194567807204 }, { 2.6179938779914944, 0.06283185307179587 }, { 2.6354471705114375, 0.06632251157578452 }, { 2.652900463031381, 0.06283185307179587 }, { 2.670353755551324, 0.06632251157578452 }, { 2.6878070480712677, 0.0645771823237902 } };
    ElevationMask mask = new ElevationMask(maskValues);
    final AbsoluteDate start = new AbsoluteDate("2012-02-10T22:00:00.000", TimeScalesFactory.getUTC());
    final AbsoluteDate end = initialDate.shiftedBy(1000 * Constants.JULIAN_DAY);
    // Event definition
    final double maxcheck = 60.0;
    // 0.001;
    final double threshold = 2.0;
    final EventDetector sta1Visi = new ElevationDetector(maxcheck, threshold, sta1Frame).withElevationMask(mask).withHandler(new EventHandler<ElevationDetector>() {

        private int count = 6;

        @Override
        public Action eventOccurred(SpacecraftState s, ElevationDetector detector, boolean increasing) {
            return (--count > 0) ? Action.CONTINUE : Action.STOP;
        }
    });
    // Add event to be detected
    EventsLogger logger = new EventsLogger();
    propagator.addEventDetector(logger.monitorDetector(sta1Visi));
    // Propagate until the sixth event
    propagator.propagate(start, end);
    List<LoggedEvent> events = logger.getLoggedEvents();
    Assert.assertEquals(6, events.size());
    // despite the events 2 and 3 are closer to each other than the convergence threshold
    // the second one is not merged into the first one
    AbsoluteDate d2 = events.get(2).getState().getDate();
    AbsoluteDate d3 = events.get(3).getState().getDate();
    Assert.assertEquals(1.529, d3.durationFrom(d2), 0.01);
}
Also used : Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) Orbit(org.orekit.orbits.Orbit) EquinoctialOrbit(org.orekit.orbits.EquinoctialOrbit) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) LoggedEvent(org.orekit.propagation.events.EventsLogger.LoggedEvent) TopocentricFrame(org.orekit.frames.TopocentricFrame) BodyShape(org.orekit.bodies.BodyShape) AbsoluteDate(org.orekit.time.AbsoluteDate) GeodeticPoint(org.orekit.bodies.GeodeticPoint) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) ElevationMask(org.orekit.utils.ElevationMask) SpacecraftState(org.orekit.propagation.SpacecraftState) EcksteinHechlerPropagator(org.orekit.propagation.analytical.EcksteinHechlerPropagator) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) GeodeticPoint(org.orekit.bodies.GeodeticPoint) Test(org.junit.Test)

Example 10 with LoggedEvent

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

the class FieldOfViewDetectorTest method testStopOnExit.

/**
 * check the default behavior to stop propagation on FoV exit.
 */
@Test
public void testStopOnExit() throws OrekitException {
    // setup
    double pi = FastMath.PI;
    // arbitrary date
    AbsoluteDate date = AbsoluteDate.J2000_EPOCH;
    AbsoluteDate endDate = date.shiftedBy(Constants.JULIAN_DAY);
    Frame eci = FramesFactory.getGCRF();
    Frame ecef = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, ecef);
    GeodeticPoint gp = new GeodeticPoint(FastMath.toRadians(39), FastMath.toRadians(77), 0);
    TopocentricFrame topo = new TopocentricFrame(earth, gp, "topo");
    // iss like orbit
    KeplerianOrbit orbit = new KeplerianOrbit(6378137 + 400e3, 0, FastMath.toRadians(51.65), 0, 0, 0, PositionAngle.TRUE, eci, date, Constants.EGM96_EARTH_MU);
    AttitudeProvider attitude = new NadirPointing(eci, earth);
    // action
    FieldOfView fov = new FieldOfView(Vector3D.PLUS_K, Vector3D.PLUS_I, pi / 3, 16, 0);
    FieldOfViewDetector fovDetector = new FieldOfViewDetector(topo, fov).withMaxCheck(5.0);
    EventsLogger logger = new EventsLogger();
    Propagator prop = new KeplerianPropagator(orbit, attitude);
    prop.addEventDetector(logger.monitorDetector(fovDetector));
    prop.propagate(endDate);
    List<LoggedEvent> actual = logger.getLoggedEvents();
    // verify
    // check we have an entry and an exit event.
    Assert.assertEquals(2, actual.size());
}
Also used : NadirPointing(org.orekit.attitudes.NadirPointing) Frame(org.orekit.frames.Frame) TopocentricFrame(org.orekit.frames.TopocentricFrame) OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) LoggedEvent(org.orekit.propagation.events.EventsLogger.LoggedEvent) TopocentricFrame(org.orekit.frames.TopocentricFrame) BodyShape(org.orekit.bodies.BodyShape) AbsoluteDate(org.orekit.time.AbsoluteDate) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) Propagator(org.orekit.propagation.Propagator) KeplerianPropagator(org.orekit.propagation.analytical.KeplerianPropagator) KeplerianOrbit(org.orekit.orbits.KeplerianOrbit) GeodeticPoint(org.orekit.bodies.GeodeticPoint) AttitudeProvider(org.orekit.attitudes.AttitudeProvider) Test(org.junit.Test)

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