use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class BoxAndSolarArraySpacecraftTest method testNormalSunAlignedDS.
@Test
public void testNormalSunAlignedDS() throws OrekitException {
BoxAndSolarArraySpacecraft s = new BoxAndSolarArraySpacecraft(0, 0, 0, (date, frame) -> new TimeStampedPVCoordinates(date, new Vector3D(0, 1e6, 0), Vector3D.ZERO), 20.0, Vector3D.PLUS_J, 0.0, 1.0, 0.0);
DSFactory factory = new DSFactory(1, 2);
FieldVector3D<DerivativeStructure> normal = s.getNormal(AbsoluteDate.J2000_EPOCH, FramesFactory.getEME2000(), FieldVector3D.getZero(factory.getDerivativeField()), FieldRotation.getIdentity(factory.getDerivativeField()));
Assert.assertEquals(0, FieldVector3D.dotProduct(normal, Vector3D.PLUS_J).getReal(), 1.0e-16);
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class DragForceTest method testIssue229.
@Test
public void testIssue229() throws OrekitException {
AbsoluteDate initialDate = new AbsoluteDate(2004, 1, 1, 0, 0, 0., TimeScalesFactory.getUTC());
Frame frame = FramesFactory.getEME2000();
double rpe = 160.e3 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS;
double rap = 2000.e3 + Constants.WGS84_EARTH_EQUATORIAL_RADIUS;
double inc = FastMath.toRadians(0.);
double aop = FastMath.toRadians(0.);
double raan = FastMath.toRadians(0.);
double mean = FastMath.toRadians(180.);
double mass = 100.;
KeplerianOrbit orbit = new KeplerianOrbit(0.5 * (rpe + rap), (rap - rpe) / (rpe + rap), inc, aop, raan, mean, PositionAngle.MEAN, frame, initialDate, Constants.EIGEN5C_EARTH_MU);
IsotropicDrag shape = new IsotropicDrag(10., 2.2);
Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
BodyShape earthShape = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, itrf);
Atmosphere atmosphere = new SimpleExponentialAtmosphere(earthShape, 2.6e-10, 200000, 26000);
double[][] tolerance = NumericalPropagator.tolerances(0.1, orbit, OrbitType.CARTESIAN);
AbstractIntegrator integrator = new DormandPrince853Integrator(1.0e-3, 300, tolerance[0], tolerance[1]);
NumericalPropagator propagator = new NumericalPropagator(integrator);
propagator.setOrbitType(OrbitType.CARTESIAN);
propagator.setMu(orbit.getMu());
propagator.addForceModel(new DragForce(atmosphere, shape));
PartialDerivativesEquations partials = new PartialDerivativesEquations("partials", propagator);
propagator.setInitialState(partials.setInitialJacobians(new SpacecraftState(orbit, mass)));
SpacecraftState state = propagator.propagate(new AbsoluteDate(2004, 1, 1, 1, 30, 0., TimeScalesFactory.getUTC()));
double delta = 0.1;
Orbit shifted = new CartesianOrbit(new TimeStampedPVCoordinates(orbit.getDate(), orbit.getPVCoordinates().getPosition().add(new Vector3D(delta, 0, 0)), orbit.getPVCoordinates().getVelocity()), orbit.getFrame(), orbit.getMu());
propagator.setInitialState(partials.setInitialJacobians(new SpacecraftState(shifted, mass)));
SpacecraftState newState = propagator.propagate(new AbsoluteDate(2004, 1, 1, 1, 30, 0., TimeScalesFactory.getUTC()));
double[] dPVdX = new double[] { (newState.getPVCoordinates().getPosition().getX() - state.getPVCoordinates().getPosition().getX()) / delta, (newState.getPVCoordinates().getPosition().getY() - state.getPVCoordinates().getPosition().getY()) / delta, (newState.getPVCoordinates().getPosition().getZ() - state.getPVCoordinates().getPosition().getZ()) / delta, (newState.getPVCoordinates().getVelocity().getX() - state.getPVCoordinates().getVelocity().getX()) / delta, (newState.getPVCoordinates().getVelocity().getY() - state.getPVCoordinates().getVelocity().getY()) / delta, (newState.getPVCoordinates().getVelocity().getZ() - state.getPVCoordinates().getVelocity().getZ()) / delta };
double[][] dYdY0 = new double[6][6];
partials.getMapper().getStateJacobian(state, dYdY0);
for (int i = 0; i < 6; ++i) {
Assert.assertEquals(dPVdX[i], dYdY0[i][0], 6.2e-6 * FastMath.abs(dPVdX[i]));
}
}
use of org.orekit.utils.TimeStampedPVCoordinates 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.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class EphemerisSegmentPropagatorTest method testPropagator.
/**
* Check {@link EphemerisSegmentPropagator} and {@link EphemerisSegment#getPropagator()}.
*
* @throws Exception on error.
*/
@Test
public void testPropagator() throws Exception {
// setup
AbsoluteDate start = AbsoluteDate.J2000_EPOCH, end = start.shiftedBy(60);
Frame frame = FramesFactory.getEME2000();
List<TimeStampedPVCoordinates> coordinates = Arrays.asList(new TimeStampedPVCoordinates(start, new Vector3D(6778137, 0, 0), new Vector3D(0, 7.5e3, 0)), new TimeStampedPVCoordinates(start.shiftedBy(30), new Vector3D(6778137 + 1, 0, 0), new Vector3D(0, 7.5e3, 0)), new TimeStampedPVCoordinates(end, new Vector3D(6778137 + 3, 0, 0), new Vector3D(0, 7.5e3, 0)));
EphemerisSegment ephemeris = new EphemerisSegment() {
@Override
public double getMu() {
return Constants.EGM96_EARTH_MU;
}
@Override
public String getFrameCenterString() {
return null;
}
@Override
public String getFrameString() {
return null;
}
@Override
public Frame getFrame() throws OrekitException {
return frame;
}
@Override
public String getTimeScaleString() {
return null;
}
@Override
public TimeScale getTimeScale() throws OrekitException {
return null;
}
@Override
public int getInterpolationSamples() {
return 2;
}
@Override
public CartesianDerivativesFilter getAvailableDerivatives() {
return CartesianDerivativesFilter.USE_P;
}
@Override
public List<TimeStampedPVCoordinates> getCoordinates() {
return coordinates;
}
@Override
public AbsoluteDate getStart() {
return start;
}
@Override
public AbsoluteDate getStop() {
return end;
}
};
// action
BoundedPropagator propagator = ephemeris.getPropagator();
// verify
Assert.assertThat(propagator.getMinDate(), CoreMatchers.is(start));
Assert.assertThat(propagator.getMaxDate(), CoreMatchers.is(end));
Assert.assertThat(propagator.getFrame(), CoreMatchers.is(frame));
int ulps = 0;
PVCoordinates expected = new PVCoordinates(new Vector3D(6778137, 0, 0), new Vector3D(1.0 / 30, 0, 0));
Assert.assertThat(propagator.propagate(start).getPVCoordinates(), OrekitMatchers.pvCloseTo(expected, ulps));
Assert.assertThat(propagator.getPVCoordinates(start, frame), OrekitMatchers.pvCloseTo(expected, ulps));
expected = new PVCoordinates(new Vector3D(6778137 + 2, 0, 0), new Vector3D(2 / 30.0, 0, 0));
Assert.assertThat(propagator.propagate(start.shiftedBy(45)).getPVCoordinates(), OrekitMatchers.pvCloseTo(expected, ulps));
Assert.assertThat(propagator.getPVCoordinates(start.shiftedBy(45), frame), OrekitMatchers.pvCloseTo(expected, ulps));
expected = new PVCoordinates(new Vector3D(6778137 + 3, 0, 0), new Vector3D(2 / 30.0, 0, 0));
Assert.assertThat(propagator.propagate(end).getPVCoordinates(), OrekitMatchers.pvCloseTo(expected, ulps));
Assert.assertThat(propagator.getPVCoordinates(end, frame), OrekitMatchers.pvCloseTo(expected, ulps));
// check reset state is prohibited
SpacecraftState ic = propagator.propagate(start);
try {
propagator.resetInitialState(ic);
Assert.fail("Expected Exception");
} catch (OrekitException e) {
// expected
}
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class OnBoardAntennaInterSatellitesRangeModifierTest method testEffect.
@Test
public void testEffect() throws OrekitException {
Context context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
final NumericalPropagatorBuilder propagatorBuilder = context.createBuilder(OrbitType.KEPLERIAN, PositionAngle.TRUE, true, 1.0e-6, 60.0, 0.001);
propagatorBuilder.setAttitudeProvider(new LofOffset(propagatorBuilder.getFrame(), LOFType.LVLH));
// create perfect inter-satellites range measurements without antenna offset
final TimeStampedPVCoordinates original = context.initialOrbit.getPVCoordinates();
final Orbit closeOrbit = new CartesianOrbit(new TimeStampedPVCoordinates(context.initialOrbit.getDate(), original.getPosition().add(new Vector3D(1000, 2000, 3000)), original.getVelocity().add(new Vector3D(-0.03, 0.01, 0.02))), context.initialOrbit.getFrame(), context.initialOrbit.getMu());
final Propagator closePropagator = EstimationTestUtils.createPropagator(closeOrbit, propagatorBuilder);
closePropagator.setEphemerisMode();
closePropagator.propagate(context.initialOrbit.getDate().shiftedBy(3.5 * closeOrbit.getKeplerianPeriod()));
final BoundedPropagator ephemeris = closePropagator.getGeneratedEphemeris();
final Propagator p1 = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
final List<ObservedMeasurement<?>> spacecraftCenteredMeasurements = EstimationTestUtils.createMeasurements(p1, new InterSatellitesRangeMeasurementCreator(ephemeris, Vector3D.ZERO, Vector3D.ZERO), 1.0, 3.0, 300.0);
// create perfect inter-satellites range measurements with antenna offset
final Vector3D apc1 = new Vector3D(-2.5, 0.0, 0);
final Vector3D apc2 = new Vector3D(0.0, 0.8, 0);
final Propagator p2 = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
final List<ObservedMeasurement<?>> antennaCenteredMeasurements = EstimationTestUtils.createMeasurements(p2, new InterSatellitesRangeMeasurementCreator(ephemeris, apc1, apc2), 1.0, 3.0, 300.0);
final Propagator p3 = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
OnBoardAntennaInterSatellitesRangeModifier modifier = new OnBoardAntennaInterSatellitesRangeModifier(apc1, apc2);
for (int i = 0; i < spacecraftCenteredMeasurements.size(); ++i) {
InterSatellitesRange sr = (InterSatellitesRange) spacecraftCenteredMeasurements.get(i);
sr.addModifier(modifier);
EstimatedMeasurement<InterSatellitesRange> estimated = sr.estimate(0, 0, new SpacecraftState[] { p3.propagate(sr.getDate()), ephemeris.propagate(sr.getDate()) });
InterSatellitesRange ar = (InterSatellitesRange) antennaCenteredMeasurements.get(i);
Assert.assertEquals(0.0, sr.getDate().durationFrom(ar.getDate()), 2.0e-8);
Assert.assertEquals(ar.getObservedValue()[0], estimated.getEstimatedValue()[0], 2.0e-5);
}
}
Aggregations