use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class CircularOrbitTest method testPositionAngleDerivatives.
@Test
public void testPositionAngleDerivatives() throws OrekitException {
final AbsoluteDate date = new AbsoluteDate("2003-05-01T00:00:20.000", TimeScalesFactory.getUTC());
final Vector3D position = new Vector3D(6896874.444705, 1956581.072644, -147476.245054);
final Vector3D velocity = new Vector3D(166.816407662, -1106.783301861, -7372.745712770);
final Vector3D acceleration = new Vector3D(-7.466182457944, -2.118153357345, 0.160004048437);
final TimeStampedPVCoordinates pv = new TimeStampedPVCoordinates(date, position, velocity, acceleration);
final Frame frame = FramesFactory.getEME2000();
final double mu = Constants.EIGEN5C_EARTH_MU;
final CircularOrbit orbit = new CircularOrbit(pv, frame, mu);
for (PositionAngle type : PositionAngle.values()) {
final CircularOrbit rebuilt = new CircularOrbit(orbit.getA(), orbit.getCircularEx(), orbit.getCircularEy(), orbit.getI(), orbit.getRightAscensionOfAscendingNode(), orbit.getAlpha(type), orbit.getADot(), orbit.getCircularExDot(), orbit.getCircularEyDot(), orbit.getIDot(), orbit.getRightAscensionOfAscendingNodeDot(), orbit.getAlphaDot(type), type, orbit.getFrame(), orbit.getDate(), orbit.getMu());
Assert.assertThat(rebuilt.getA(), relativelyCloseTo(orbit.getA(), 1));
Assert.assertThat(rebuilt.getCircularEx(), relativelyCloseTo(orbit.getCircularEx(), 1));
Assert.assertThat(rebuilt.getCircularEy(), relativelyCloseTo(orbit.getCircularEy(), 1));
Assert.assertThat(rebuilt.getE(), relativelyCloseTo(orbit.getE(), 1));
Assert.assertThat(rebuilt.getI(), relativelyCloseTo(orbit.getI(), 1));
Assert.assertThat(rebuilt.getRightAscensionOfAscendingNode(), relativelyCloseTo(orbit.getRightAscensionOfAscendingNode(), 1));
Assert.assertThat(rebuilt.getADot(), relativelyCloseTo(orbit.getADot(), 1));
Assert.assertThat(rebuilt.getCircularExDot(), relativelyCloseTo(orbit.getCircularExDot(), 1));
Assert.assertThat(rebuilt.getCircularEyDot(), relativelyCloseTo(orbit.getCircularEyDot(), 1));
Assert.assertThat(rebuilt.getEDot(), relativelyCloseTo(orbit.getEDot(), 1));
Assert.assertThat(rebuilt.getIDot(), relativelyCloseTo(orbit.getIDot(), 1));
Assert.assertThat(rebuilt.getRightAscensionOfAscendingNodeDot(), relativelyCloseTo(orbit.getRightAscensionOfAscendingNodeDot(), 1));
for (PositionAngle type2 : PositionAngle.values()) {
Assert.assertThat(rebuilt.getAlpha(type2), relativelyCloseTo(orbit.getAlpha(type2), 1));
Assert.assertThat(rebuilt.getAlphaDot(type2), relativelyCloseTo(orbit.getAlphaDot(type2), 1));
}
}
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class TransformTest method testAcceleration.
@Test
public void testAcceleration() {
PVCoordinates initPV = new PVCoordinates(new Vector3D(9, 8, 7), new Vector3D(6, 5, 4), new Vector3D(3, 2, 1));
for (double dt = 0; dt < 1; dt += 0.01) {
PVCoordinates basePV = initPV.shiftedBy(dt);
PVCoordinates transformedPV = evolvingTransform(AbsoluteDate.J2000_EPOCH, dt).transformPVCoordinates(basePV);
// rebuild transformed acceleration, relying only on transformed position and velocity
List<TimeStampedPVCoordinates> sample = new ArrayList<TimeStampedPVCoordinates>();
double h = 1.0e-2;
for (int i = -3; i < 4; ++i) {
Transform t = evolvingTransform(AbsoluteDate.J2000_EPOCH, dt + i * h);
PVCoordinates pv = t.transformPVCoordinates(initPV.shiftedBy(dt + i * h));
sample.add(new TimeStampedPVCoordinates(t.getDate(), pv.getPosition(), pv.getVelocity(), Vector3D.ZERO));
}
PVCoordinates rebuiltPV = TimeStampedPVCoordinates.interpolate(AbsoluteDate.J2000_EPOCH.shiftedBy(dt), CartesianDerivativesFilter.USE_PV, sample);
checkVector(rebuiltPV.getPosition(), transformedPV.getPosition(), 4.0e-16);
checkVector(rebuiltPV.getVelocity(), transformedPV.getVelocity(), 2.0e-16);
checkVector(rebuiltPV.getAcceleration(), transformedPV.getAcceleration(), 9.0e-11);
}
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class TidalDisplacementTest method doTestDehant.
private void doTestDehant(final IERSConventions conventions, final boolean removePermanentDeformation, final boolean replaceModels, final double expectedDx, final double expectedDy, final double expectedDz, final double tolerance) throws OrekitException {
Frame itrf = FramesFactory.getITRF(conventions, false);
TimeScale ut1 = TimeScalesFactory.getUT1(conventions, false);
final double re;
final double sunEarthSystemMassRatio;
final double earthMoonMassRatio;
if (replaceModels) {
// constants consistent with DEHANTTIDEINEL.F reference program
// available at <ftp://tai.bipm.org/iers/conv2010/chapter7/dehanttideinel/>
// and Copyright (C) 2008 IERS Conventions Center
re = 6378136.6;
final double massRatioSun = 332946.0482;
final double massRatioMoon = 0.0123000371;
sunEarthSystemMassRatio = massRatioSun * (1.0 / (1.0 + massRatioMoon));
earthMoonMassRatio = 1.0 / massRatioMoon;
} else {
// constants consistent with IERS and JPL
re = Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS;
sunEarthSystemMassRatio = Constants.JPL_SSD_SUN_EARTH_PLUS_MOON_MASS_RATIO;
earthMoonMassRatio = Constants.JPL_SSD_EARTH_MOON_MASS_RATIO;
}
// fake providers generating only the positions from the reference program test
PVCoordinatesProvider fakeSun = (date, frame) -> new TimeStampedPVCoordinates(date, new Vector3D(137859926952.015, 54228127881.435, 23509422341.6960), Vector3D.ZERO, Vector3D.ZERO);
PVCoordinatesProvider fakeMoon = (date, frame) -> new TimeStampedPVCoordinates(date, new Vector3D(-179996231.920342, -312468450.131567, -169288918.592160), Vector3D.ZERO, Vector3D.ZERO);
TidalDisplacement td = new TidalDisplacement(re, sunEarthSystemMassRatio, earthMoonMassRatio, fakeSun, fakeMoon, conventions, removePermanentDeformation);
FundamentalNutationArguments arguments = null;
if (replaceModels) {
try {
// we override the official IERS conventions 2010 arguments with fake arguments matching DEHANTTIDEINEL.F code
String regularArguments = "/assets/org/orekit/IERS-conventions/2010/nutation-arguments.txt";
arguments = new FundamentalNutationArguments(conventions, ut1, IERSConventions.class.getResourceAsStream(regularArguments), regularArguments) {
private static final long serialVersionUID = 20170913L;
@Override
public BodiesElements evaluateAll(final AbsoluteDate date) {
BodiesElements base = super.evaluateAll(date);
double fhr = date.getComponents(ut1).getTime().getSecondsInUTCDay() / 3600.0;
double t = base.getTC();
// Doodson fundamental arguments as per DEHANTTIDEINEL.F code
double s = 218.31664563 + (481267.88194 + (-0.0014663889 + (0.00000185139) * t) * t) * t;
double tau = fhr * 15 + 280.4606184 + (36000.7700536 + (0.00038793 + (-0.0000000258) * t) * t) * t - s;
double pr = (1.396971278 + (0.000308889 + (0.000000021 + (0.000000007) * t) * t) * t) * t;
double h = 280.46645 + (36000.7697489 + (0.00030322222 + (0.000000020 + (-0.00000000654) * t) * t) * t) * t;
double p = 83.35324312 + (4069.01363525 + (-0.01032172222 + (-0.0000124991 + (0.00000005263) * t) * t) * t) * t;
double zns = 234.95544499 + (1934.13626197 + (-0.00207561111 + (-0.00000213944 + (0.00000001650) * t) * t) * t) * t;
double ps = 282.93734098 + (1.71945766667 + (0.00045688889 + (-0.00000001778 + (-0.00000000334) * t) * t) * t) * t;
s += pr;
// rebuild Delaunay arguments from Doodson arguments, ignoring derivatives
return new BodiesElements(date, base.getTC(), FastMath.toRadians(s + tau), 0.0, FastMath.toRadians(s - p), 0.0, FastMath.toRadians(h - ps), 0.0, FastMath.toRadians(s + zns), 0.0, FastMath.toRadians(s - h), 0.0, FastMath.toRadians(-zns), 0.0, base.getLMe(), 0.0, base.getLVe(), 0.0, base.getLE(), 0.0, base.getLMa(), 0.0, base.getLJu(), 0.0, base.getLSa(), 0.0, base.getLUr(), 0.0, base.getLNe(), 0.0, base.getPa(), 0.0);
}
};
// we override the official IERS conventions 2010 tides displacements with tides displacements matching DEHANTTIDEINEL.F code
String table73a = "/tides/tab7.3a-Dehant.txt";
Field diurnalCorrectionField = td.getClass().getDeclaredField("frequencyCorrectionDiurnal");
diurnalCorrectionField.setAccessible(true);
Method diurnalCorrectionGetter = IERSConventions.class.getDeclaredMethod("getTidalDisplacementFrequencyCorrectionDiurnal", String.class, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE);
diurnalCorrectionGetter.setAccessible(true);
diurnalCorrectionField.set(td, diurnalCorrectionGetter.invoke(null, table73a, 18, 15, 16, 17, 18));
} catch (SecurityException | NoSuchMethodException | NoSuchFieldException | InvocationTargetException | IllegalArgumentException | IllegalAccessException e) {
Assert.fail(e.getLocalizedMessage());
}
} else {
arguments = conventions.getNutationArguments(ut1);
}
Vector3D fundamentalStationWettzell = new Vector3D(4075578.385, 931852.890, 4801570.154);
AbsoluteDate date = new AbsoluteDate(2009, 4, 13, 0, 0, 0.0, ut1);
Vector3D displacement = td.displacement(arguments.evaluateAll(date), itrf, fundamentalStationWettzell);
Assert.assertEquals(expectedDx, displacement.getX(), tolerance);
Assert.assertEquals(expectedDy, displacement.getY(), tolerance);
Assert.assertEquals(expectedDz, displacement.getZ(), tolerance);
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class OnBoardAntennaInterSatellitesRangeModifier method modifyTwoWay.
/**
* Apply a modifier to an estimated measurement in the two-way case.
* @param estimated estimated measurement to modify
*/
private void modifyTwoWay(final EstimatedMeasurement<InterSatellitesRange> estimated) {
// the participants are satellite 1 at emission, satellite 2 at transit, satellite 1 at reception
final TimeStampedPVCoordinates[] participants = estimated.getParticipants();
final AbsoluteDate emissionDate = participants[0].getDate();
final AbsoluteDate transitDate = participants[1].getDate();
final AbsoluteDate receptionDate = participants[2].getDate();
// transforms from spacecraft to inertial frame at emission/reception dates
final SpacecraftState refState1 = estimated.getStates()[0];
final SpacecraftState receptionState = refState1.shiftedBy(receptionDate.durationFrom(refState1.getDate()));
final Transform receptionSpacecraftToInert = receptionState.toTransform().getInverse();
final SpacecraftState refState2 = estimated.getStates()[1];
final SpacecraftState transitState = refState2.shiftedBy(transitDate.durationFrom(refState2.getDate()));
final Transform transitSpacecraftToInert = transitState.toTransform().getInverse();
final SpacecraftState emissionState = refState1.shiftedBy(emissionDate.durationFrom(refState1.getDate()));
final Transform emissionSpacecraftToInert = emissionState.toTransform().getInverse();
// compute the geometrical value of the inter-satellites range directly from participants positions.
// Note that this may be different from the value returned by estimated.getEstimatedValue(),
// because other modifiers may already have been taken into account
final Vector3D pSpacecraftReception = receptionSpacecraftToInert.transformPosition(Vector3D.ZERO);
final Vector3D pSpacecraftTransit = transitSpacecraftToInert.transformPosition(Vector3D.ZERO);
final Vector3D pSpacecraftEmission = emissionSpacecraftToInert.transformPosition(Vector3D.ZERO);
final double interSatellitesRangeUsingSpacecraftCenter = 0.5 * (Vector3D.distance(pSpacecraftEmission, pSpacecraftTransit) + Vector3D.distance(pSpacecraftTransit, pSpacecraftReception));
// compute the geometrical value of the range replacing
// the spacecraft positions with antenna phase center positions
final Vector3D pAPCReception = receptionSpacecraftToInert.transformPosition(antennaPhaseCenter1);
final Vector3D pAPCTransit = transitSpacecraftToInert.transformPosition(antennaPhaseCenter2);
final Vector3D pAPCEmission = emissionSpacecraftToInert.transformPosition(antennaPhaseCenter1);
final double interSatellitesRangeUsingAntennaPhaseCenter = 0.5 * (Vector3D.distance(pAPCEmission, pAPCTransit) + Vector3D.distance(pAPCTransit, pAPCReception));
// get the estimated value before this modifier is applied
final double[] value = estimated.getEstimatedValue();
// modify the value
value[0] += interSatellitesRangeUsingAntennaPhaseCenter - interSatellitesRangeUsingSpacecraftCenter;
estimated.setEstimatedValue(value);
}
use of org.orekit.utils.TimeStampedPVCoordinates in project Orekit by CS-SI.
the class InterSatellitesRange method theoreticalEvaluation.
/**
* {@inheritDoc}
*/
@Override
protected EstimatedMeasurement<InterSatellitesRange> theoreticalEvaluation(final int iteration, final int evaluation, final SpacecraftState[] states) throws OrekitException {
// Range derivatives are computed with respect to spacecrafts states in inertial frame
// ----------------------
//
// Parameters:
// - 0..2 - Position of the satellite 1 in inertial frame
// - 3..5 - Velocity of the satellite 1 in inertial frame
// - 6..8 - Position of the satellite 2 in inertial frame
// - 9..11 - Velocity of the satellite 2 in inertial frame
final int nbParams = 12;
final DSFactory factory = new DSFactory(nbParams, 1);
final Field<DerivativeStructure> field = factory.getDerivativeField();
// coordinates of both satellites
final SpacecraftState state1 = states[getPropagatorsIndices().get(0)];
final TimeStampedFieldPVCoordinates<DerivativeStructure> pva1 = getCoordinates(state1, 0, factory);
final SpacecraftState state2 = states[getPropagatorsIndices().get(1)];
final TimeStampedFieldPVCoordinates<DerivativeStructure> pva2 = getCoordinates(state2, 6, factory);
// compute propagation times
// (if state has already been set up to pre-compensate propagation delay,
// we will have delta == tauD and transitState will be the same as state)
// downlink delay
final FieldAbsoluteDate<DerivativeStructure> arrivalDate = new FieldAbsoluteDate<>(field, getDate());
final TimeStampedFieldPVCoordinates<DerivativeStructure> s1Downlink = pva1.shiftedBy(arrivalDate.durationFrom(pva1.getDate()));
final DerivativeStructure tauD = signalTimeOfFlight(pva2, s1Downlink.getPosition(), arrivalDate);
// Transit state
final double delta = getDate().durationFrom(state2.getDate());
final DerivativeStructure deltaMTauD = tauD.negate().add(delta);
// prepare the evaluation
final EstimatedMeasurement<InterSatellitesRange> estimated;
final DerivativeStructure range;
if (twoway) {
// Transit state (re)computed with derivative structures
final TimeStampedFieldPVCoordinates<DerivativeStructure> transitStateDS = pva2.shiftedBy(deltaMTauD);
// uplink delay
final DerivativeStructure tauU = signalTimeOfFlight(pva1, transitStateDS.getPosition(), transitStateDS.getDate());
estimated = new EstimatedMeasurement<>(this, iteration, evaluation, new SpacecraftState[] { state1.shiftedBy(deltaMTauD.getValue()), state2.shiftedBy(deltaMTauD.getValue()) }, new TimeStampedPVCoordinates[] { state1.shiftedBy(delta - tauD.getValue() - tauU.getValue()).getPVCoordinates(), state2.shiftedBy(delta - tauD.getValue()).getPVCoordinates(), state1.shiftedBy(delta).getPVCoordinates() });
// Range value
range = tauD.add(tauU).multiply(0.5 * Constants.SPEED_OF_LIGHT);
} else {
estimated = new EstimatedMeasurement<>(this, iteration, evaluation, new SpacecraftState[] { state1.shiftedBy(deltaMTauD.getValue()), state2.shiftedBy(deltaMTauD.getValue()) }, new TimeStampedPVCoordinates[] { state2.shiftedBy(delta - tauD.getValue()).getPVCoordinates(), state1.shiftedBy(delta).getPVCoordinates() });
// Range value
range = tauD.multiply(Constants.SPEED_OF_LIGHT);
}
estimated.setEstimatedValue(range.getValue());
// Range partial derivatives with respect to states
final double[] derivatives = range.getAllDerivatives();
estimated.setStateDerivatives(0, Arrays.copyOfRange(derivatives, 1, 7));
estimated.setStateDerivatives(1, Arrays.copyOfRange(derivatives, 7, 13));
return estimated;
}
Aggregations