use of org.orekit.propagation.Propagator 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);
}
use of org.orekit.propagation.Propagator in project Orekit by CS-SI.
the class FieldOfViewTest method testFOVAwayFromEarth.
@Test
public void testFOVAwayFromEarth() throws OrekitException {
Utils.setDataRoot("regular-data");
FieldOfView fov = new FieldOfView(Vector3D.MINUS_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 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));
Assert.assertEquals(0, footprint.size());
}
use of org.orekit.propagation.Propagator in project Orekit by CS-SI.
the class TLEConverterTest method checkFit.
protected void checkFit(final TLE tle, final double duration, final double stepSize, final double threshold, final boolean positionOnly, final boolean withBStar, final double expectedRMS) throws OrekitException {
Propagator p = TLEPropagator.selectExtrapolator(tle);
List<SpacecraftState> sample = new ArrayList<SpacecraftState>();
for (double dt = 0; dt < duration; dt += stepSize) {
sample.add(p.propagate(tle.getDate().shiftedBy(dt)));
}
TLEPropagatorBuilder builder = new TLEPropagatorBuilder(tle, PositionAngle.TRUE, 1.0);
List<DelegatingDriver> drivers = builder.getPropagationParametersDrivers().getDrivers();
// there should *not* be any drivers for central attraction coefficient (see issue #313)
Assert.assertEquals(1, drivers.size());
Assert.assertEquals("BSTAR", drivers.get(0).getName());
FiniteDifferencePropagatorConverter fitter = new FiniteDifferencePropagatorConverter(builder, threshold, 1000);
if (withBStar) {
fitter.convert(sample, positionOnly, TLEPropagatorBuilder.B_STAR);
} else {
fitter.convert(sample, positionOnly);
}
TLEPropagator prop = (TLEPropagator) fitter.getAdaptedPropagator();
TLE fitted = prop.getTLE();
Assert.assertEquals(expectedRMS, fitter.getRMS(), 0.001 * expectedRMS);
Assert.assertEquals(tle.getSatelliteNumber(), fitted.getSatelliteNumber());
Assert.assertEquals(tle.getClassification(), fitted.getClassification());
Assert.assertEquals(tle.getLaunchYear(), fitted.getLaunchYear());
Assert.assertEquals(tle.getLaunchNumber(), fitted.getLaunchNumber());
Assert.assertEquals(tle.getLaunchPiece(), fitted.getLaunchPiece());
Assert.assertEquals(tle.getElementNumber(), fitted.getElementNumber());
Assert.assertEquals(tle.getRevolutionNumberAtEpoch(), fitted.getRevolutionNumberAtEpoch());
final double eps = 1.0e-5;
Assert.assertEquals(tle.getMeanMotion(), fitted.getMeanMotion(), eps * tle.getMeanMotion());
Assert.assertEquals(tle.getE(), fitted.getE(), eps * tle.getE());
Assert.assertEquals(tle.getI(), fitted.getI(), eps * tle.getI());
Assert.assertEquals(tle.getPerigeeArgument(), fitted.getPerigeeArgument(), eps * tle.getPerigeeArgument());
Assert.assertEquals(tle.getRaan(), fitted.getRaan(), eps * tle.getRaan());
Assert.assertEquals(tle.getMeanAnomaly(), fitted.getMeanAnomaly(), eps * tle.getMeanAnomaly());
if (withBStar) {
Assert.assertEquals(tle.getBStar(), fitted.getBStar(), eps * tle.getBStar());
}
}
use of org.orekit.propagation.Propagator 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.Propagator 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