use of org.orekit.propagation.analytical.KeplerianPropagator 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);
}
}
use of org.orekit.propagation.analytical.KeplerianPropagator in project Orekit by CS-SI.
the class IntegratedEphemerisTest method testNormalKeplerIntegration.
@Test
public void testNormalKeplerIntegration() throws OrekitException {
// Keplerian propagator definition
KeplerianPropagator keplerEx = new KeplerianPropagator(initialOrbit);
// Integrated ephemeris
// Propagation
AbsoluteDate finalDate = initialOrbit.getDate().shiftedBy(Constants.JULIAN_DAY);
numericalPropagator.setEphemerisMode();
numericalPropagator.setInitialState(new SpacecraftState(initialOrbit));
numericalPropagator.propagate(finalDate);
Assert.assertTrue(numericalPropagator.getCalls() < 3200);
BoundedPropagator ephemeris = numericalPropagator.getGeneratedEphemeris();
// tests
for (int i = 1; i <= Constants.JULIAN_DAY; i++) {
AbsoluteDate intermediateDate = initialOrbit.getDate().shiftedBy(i);
SpacecraftState keplerIntermediateOrbit = keplerEx.propagate(intermediateDate);
SpacecraftState numericIntermediateOrbit = ephemeris.propagate(intermediateDate);
Vector3D kepPosition = keplerIntermediateOrbit.getPVCoordinates().getPosition();
Vector3D numPosition = numericIntermediateOrbit.getPVCoordinates().getPosition();
Assert.assertEquals(0, kepPosition.subtract(numPosition).getNorm(), 0.06);
}
// test inv
AbsoluteDate intermediateDate = initialOrbit.getDate().shiftedBy(41589);
SpacecraftState keplerIntermediateOrbit = keplerEx.propagate(intermediateDate);
SpacecraftState state = keplerEx.propagate(finalDate);
numericalPropagator.setInitialState(state);
numericalPropagator.setEphemerisMode();
numericalPropagator.propagate(initialOrbit.getDate());
BoundedPropagator invEphemeris = numericalPropagator.getGeneratedEphemeris();
SpacecraftState numericIntermediateOrbit = invEphemeris.propagate(intermediateDate);
Vector3D kepPosition = keplerIntermediateOrbit.getPVCoordinates().getPosition();
Vector3D numPosition = numericIntermediateOrbit.getPVCoordinates().getPosition();
Assert.assertEquals(0, kepPosition.subtract(numPosition).getNorm(), 10e-2);
}
use of org.orekit.propagation.analytical.KeplerianPropagator in project Orekit by CS-SI.
the class EventDetectorTest method testIssue108Analytical.
@Test
public void testIssue108Analytical() throws OrekitException {
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 CircularOrbit(new PVCoordinates(position, velocity), FramesFactory.getEME2000(), date, mu);
final double step = 60.0;
final int n = 100;
KeplerianPropagator propagator = new KeplerianPropagator(orbit);
GCallsCounter counter = new GCallsCounter(100000.0, 1.0e-6, 20, new StopOnEvent<GCallsCounter>());
propagator.addEventDetector(counter);
propagator.setMasterMode(step, new OrekitFixedStepHandler() {
public void handleStep(SpacecraftState currentState, boolean isLast) {
}
});
propagator.propagate(date.shiftedBy(n * step));
Assert.assertEquals(n + 1, counter.getCount());
}
use of org.orekit.propagation.analytical.KeplerianPropagator in project Orekit by CS-SI.
the class EventDetectorTest method testNoisyGFunction.
@Test
public void testNoisyGFunction() throws OrekitException {
// initial conditions
Frame eme2000 = FramesFactory.getEME2000();
TimeScale utc = TimeScalesFactory.getUTC();
AbsoluteDate initialDate = new AbsoluteDate(2011, 5, 11, utc);
AbsoluteDate startDate = new AbsoluteDate(2032, 10, 17, utc);
AbsoluteDate interruptDate = new AbsoluteDate(2032, 10, 18, utc);
AbsoluteDate targetDate = new AbsoluteDate(2211, 5, 11, utc);
KeplerianPropagator k1 = new KeplerianPropagator(new EquinoctialOrbit(new PVCoordinates(new Vector3D(4008462.4706055815, -3155502.5373837613, -5044275.9880020910), new Vector3D(-5012.9298276860990, 1920.3567095973078, -5172.7403501801580)), eme2000, initialDate, Constants.WGS84_EARTH_MU));
KeplerianPropagator k2 = new KeplerianPropagator(new EquinoctialOrbit(new PVCoordinates(new Vector3D(4008912.4039522274, -3155453.3125615157, -5044297.6484738905), new Vector3D(-5012.5883854112530, 1920.6332221785074, -5172.2177085540500)), eme2000, initialDate, Constants.WGS84_EARTH_MU));
k2.addEventDetector(new CloseApproachDetector(2015.243454166727, 0.0001, 100, new ContinueOnEvent<CloseApproachDetector>(), k1));
k2.addEventDetector(new DateDetector(Constants.JULIAN_DAY, 1.0e-6, interruptDate));
SpacecraftState s = k2.propagate(startDate, targetDate);
Assert.assertEquals(0.0, interruptDate.durationFrom(s.getDate()), 1.1e-6);
}
use of org.orekit.propagation.analytical.KeplerianPropagator 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());
}
Aggregations