use of org.orekit.propagation.analytical.KeplerianPropagator in project Orekit by CS-SI.
the class EventDetectorTest method testWrappedException.
@Test
public void testWrappedException() throws OrekitException {
final Throwable dummyCause = new RuntimeException();
try {
// initial conditions
Frame eme2000 = FramesFactory.getEME2000();
TimeScale utc = TimeScalesFactory.getUTC();
final AbsoluteDate initialDate = new AbsoluteDate(2011, 5, 11, utc);
final AbsoluteDate exceptionDate = initialDate.shiftedBy(3600.0);
KeplerianPropagator k = 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));
k.addEventDetector(new DateDetector(initialDate.shiftedBy(Constants.JULIAN_DAY)) {
private static final long serialVersionUID = 1L;
@Override
public double g(final SpacecraftState s) throws OrekitException {
final double dt = s.getDate().durationFrom(exceptionDate);
if (FastMath.abs(dt) < 1.0) {
throw new OrekitException(dummyCause, LocalizedCoreFormats.SIMPLE_MESSAGE, "dummy");
}
return dt;
}
});
k.propagate(initialDate.shiftedBy(Constants.JULIAN_YEAR));
Assert.fail("an exception should have been thrown");
} catch (OrekitException oe) {
Assert.assertSame(dummyCause, oe.getCause());
}
}
use of org.orekit.propagation.analytical.KeplerianPropagator in project Orekit by CS-SI.
the class EventDetectorTest method testBasicScheduling.
@Test
public void testBasicScheduling() 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);
Propagator propagator = new KeplerianPropagator(orbit);
double stepSize = 60.0;
OutOfOrderChecker checker = new OutOfOrderChecker(stepSize);
propagator.addEventDetector(new DateDetector(date.shiftedBy(5.25 * stepSize)).withHandler(checker));
propagator.setMasterMode(stepSize, checker);
propagator.propagate(date.shiftedBy(10 * stepSize));
Assert.assertTrue(checker.outOfOrderCallDetected());
}
use of org.orekit.propagation.analytical.KeplerianPropagator in project Orekit by CS-SI.
the class FieldOfViewDetectorTest method testDihedralFielOfView.
@Test
public void testDihedralFielOfView() throws OrekitException {
// Definition of initial conditions with position and velocity
// ------------------------------------------------------------
// Extrapolator definition
KeplerianPropagator propagator = new KeplerianPropagator(initialOrbit, earthCenterAttitudeLaw);
// Event definition : square field of view, along X axis, aperture 56°
final double maxCheck = 1.;
final PVCoordinatesProvider sunPV = CelestialBodyFactory.getSun();
final Vector3D center = Vector3D.MINUS_J;
final Vector3D axis1 = Vector3D.PLUS_K;
final Vector3D axis2 = Vector3D.PLUS_I;
final double aperture1 = FastMath.toRadians(28);
final double aperture2 = FastMath.toRadians(28);
final EventDetector sunVisi = new FieldOfViewDetector(sunPV, new FieldOfView(center, axis1, aperture1, axis2, aperture2, 0.0)).withMaxCheck(maxCheck).withHandler(new DihedralSunVisiHandler());
Assert.assertSame(sunPV, ((FieldOfViewDetector) sunVisi).getPVTarget());
Assert.assertEquals(0, ((FieldOfViewDetector) sunVisi).getFieldOfView().getMargin(), 1.0e-15);
double eta = FastMath.acos(FastMath.sin(aperture1) * FastMath.sin(aperture2));
double theoreticalArea = MathUtils.TWO_PI - 4 * eta;
Assert.assertEquals(theoreticalArea, ((FieldOfViewDetector) sunVisi).getFieldOfView().getZone().getSize(), 1.0e-15);
// Add event to be detected
propagator.addEventDetector(sunVisi);
// Extrapolate from the initial to the final date
propagator.propagate(initDate.shiftedBy(6000.));
}
use of org.orekit.propagation.analytical.KeplerianPropagator in project Orekit by CS-SI.
the class FieldOfViewTest method testRollPitchYawHexagonalFootprint.
@Test
public void testRollPitchYawHexagonalFootprint() throws OrekitException {
Utils.setDataRoot("regular-data");
FieldOfView fov = new FieldOfView(Vector3D.PLUS_K, Vector3D.PLUS_I, FastMath.toRadians(3.0), 6, 0.0);
OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
KeplerianOrbit orbit = new KeplerianOrbit(new PVCoordinates(new Vector3D(7.0e6, 1.0e6, 4.0e6), new Vector3D(-500.0, 8000.0, 1000.0)), FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, Constants.EIGEN5C_EARTH_MU);
Propagator propagator = new KeplerianPropagator(orbit);
propagator.setAttitudeProvider(new LofOffset(orbit.getFrame(), LOFType.VVLH, RotationOrder.XYZ, FastMath.toRadians(10), FastMath.toRadians(20), FastMath.toRadians(5)));
SpacecraftState state = propagator.propagate(orbit.getDate().shiftedBy(1000.0));
Transform inertToBody = state.getFrame().getTransformTo(earth.getBodyFrame(), state.getDate());
Transform fovToBody = new Transform(state.getDate(), state.toTransform().getInverse(), inertToBody);
List<List<GeodeticPoint>> footprint = fov.getFootprint(fovToBody, earth, FastMath.toRadians(0.1));
Vector3D subSat = earth.projectToGround(state.getPVCoordinates(earth.getBodyFrame()).getPosition(), state.getDate(), earth.getBodyFrame());
Assert.assertEquals(1, footprint.size());
List<GeodeticPoint> loop = footprint.get(0);
Assert.assertEquals(210, loop.size());
double minEl = Double.POSITIVE_INFINITY;
double maxEl = 0;
double minDist = Double.POSITIVE_INFINITY;
double maxDist = 0;
for (int i = 0; i < loop.size(); ++i) {
Assert.assertEquals(0.0, loop.get(i).getAltitude(), 1.0e-15);
TopocentricFrame topo = new TopocentricFrame(earth, loop.get(i), "atLimb");
final double elevation = topo.getElevation(state.getPVCoordinates().getPosition(), state.getFrame(), state.getDate());
minEl = FastMath.min(minEl, elevation);
maxEl = FastMath.max(maxEl, elevation);
final double dist = Vector3D.distance(subSat, earth.transform(loop.get(i)));
minDist = FastMath.min(minDist, dist);
maxDist = FastMath.max(maxDist, dist);
}
Assert.assertEquals(48.0026, FastMath.toDegrees(minEl), 0.001);
Assert.assertEquals(60.1975, FastMath.toDegrees(maxEl), 0.001);
Assert.assertEquals(1221543.6, minDist, 1.0);
Assert.assertEquals(1804921.6, maxDist, 1.0);
}
use of org.orekit.propagation.analytical.KeplerianPropagator in project Orekit by CS-SI.
the class FieldOfViewTest method testFOVPartiallyTruncatedAtLimb.
@Test
public void testFOVPartiallyTruncatedAtLimb() throws OrekitException {
Utils.setDataRoot("regular-data");
FieldOfView fov = new FieldOfView(Vector3D.PLUS_K, Vector3D.PLUS_I, FastMath.toRadians(40.0), 6, 0.0);
OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, FramesFactory.getITRF(IERSConventions.IERS_2010, true));
KeplerianOrbit orbit = new KeplerianOrbit(new PVCoordinates(new Vector3D(7.0e6, 1.0e6, 4.0e6), new Vector3D(-500.0, 8000.0, 1000.0)), FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, Constants.EIGEN5C_EARTH_MU);
Propagator propagator = new KeplerianPropagator(orbit);
propagator.setAttitudeProvider(new NadirPointing(orbit.getFrame(), earth));
SpacecraftState state = propagator.propagate(orbit.getDate().shiftedBy(1000.0));
Transform inertToBody = state.getFrame().getTransformTo(earth.getBodyFrame(), state.getDate());
Transform fovToBody = new Transform(state.getDate(), state.toTransform().getInverse(), inertToBody);
List<List<GeodeticPoint>> footprint = fov.getFootprint(fovToBody, earth, FastMath.toRadians(1.0));
Vector3D subSat = earth.projectToGround(state.getPVCoordinates(earth.getBodyFrame()).getPosition(), state.getDate(), earth.getBodyFrame());
Assert.assertEquals(1, footprint.size());
List<GeodeticPoint> loop = footprint.get(0);
Assert.assertEquals(246, loop.size());
double minEl = Double.POSITIVE_INFINITY;
double maxEl = 0;
double minDist = Double.POSITIVE_INFINITY;
double maxDist = 0;
for (int i = 0; i < loop.size(); ++i) {
Assert.assertEquals(0.0, loop.get(i).getAltitude(), 3.0e-7);
TopocentricFrame topo = new TopocentricFrame(earth, loop.get(i), "atLimb");
final double elevation = topo.getElevation(state.getPVCoordinates().getPosition(), state.getFrame(), state.getDate());
minEl = FastMath.min(minEl, elevation);
maxEl = FastMath.max(maxEl, elevation);
final double dist = Vector3D.distance(subSat, earth.transform(loop.get(i)));
minDist = FastMath.min(minDist, dist);
maxDist = FastMath.max(maxDist, dist);
}
Assert.assertEquals(0.0, FastMath.toDegrees(minEl), 2.0e-12);
Assert.assertEquals(7.8897, FastMath.toDegrees(maxEl), 0.001);
Assert.assertEquals(4584829.6, minDist, 1.0);
Assert.assertEquals(5347029.8, maxDist, 1.0);
}
Aggregations