use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.
the class MODProviderTest method testEuler2000.
@Test
public void testEuler2000() throws OrekitException {
// this alternate representation of the transform
// is from equation 33 in IERS conventions 2003
TransformProvider eulerBasedProvider = new TransformProvider() {
private static final long serialVersionUID = 1L;
private final PolynomialNutation zetaA = new PolynomialNutation(2.5976176 * Constants.ARC_SECONDS_TO_RADIANS, 2306.0809506 * Constants.ARC_SECONDS_TO_RADIANS, 0.3019015 * Constants.ARC_SECONDS_TO_RADIANS, 0.0179663 * Constants.ARC_SECONDS_TO_RADIANS, -0.0000327 * Constants.ARC_SECONDS_TO_RADIANS, -0.0000002 * Constants.ARC_SECONDS_TO_RADIANS);
private final PolynomialNutation thetaA = new PolynomialNutation(0.0, 2004.1917476 * Constants.ARC_SECONDS_TO_RADIANS, -0.4269353 * Constants.ARC_SECONDS_TO_RADIANS, -0.0418251 * Constants.ARC_SECONDS_TO_RADIANS, -0.0000601 * Constants.ARC_SECONDS_TO_RADIANS, -0.0000001 * Constants.ARC_SECONDS_TO_RADIANS);
private final PolynomialNutation zA = new PolynomialNutation(-2.5976176 * Constants.ARC_SECONDS_TO_RADIANS, 2306.0803226 * Constants.ARC_SECONDS_TO_RADIANS, 1.0947790 * Constants.ARC_SECONDS_TO_RADIANS, 0.0182273 * Constants.ARC_SECONDS_TO_RADIANS, 0.0000470 * Constants.ARC_SECONDS_TO_RADIANS, -0.0000003 * Constants.ARC_SECONDS_TO_RADIANS);
public Transform getTransform(AbsoluteDate date) {
final double tc = IERSConventions.IERS_2003.evaluateTC(date);
final Rotation r1 = new Rotation(Vector3D.PLUS_K, zA.value(tc), RotationConvention.VECTOR_OPERATOR);
final Rotation r2 = new Rotation(Vector3D.PLUS_J, -thetaA.value(tc), RotationConvention.VECTOR_OPERATOR);
final Rotation r3 = new Rotation(Vector3D.PLUS_K, zetaA.value(tc), RotationConvention.VECTOR_OPERATOR);
return new Transform(date, r1.compose(r2.compose(r3, RotationConvention.VECTOR_OPERATOR), RotationConvention.VECTOR_OPERATOR));
}
public <T extends RealFieldElement<T>> FieldTransform<T> getTransform(final FieldAbsoluteDate<T> date) {
throw new UnsupportedOperationException("never called in this test");
}
};
MODProvider modProvider = new MODProvider(IERSConventions.IERS_2003);
for (double dt = -Constants.JULIAN_CENTURY; dt < Constants.JULIAN_CENTURY; dt += 50 * Constants.JULIAN_DAY) {
AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(dt);
Transform t = new Transform(date, modProvider.getTransform(date).getInverse(), eulerBasedProvider.getTransform(date));
Assert.assertEquals(0, t.getRotation().getAngle(), 6.6e-13);
}
}
use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.
the class MODProviderTest method testEuler1976.
@Test
public void testEuler1976() throws OrekitException {
TransformProvider eulerBasedProvider = new TransformProvider() {
private static final long serialVersionUID = 1L;
private final PolynomialNutation zetaA = new PolynomialNutation(0.0, 2306.2181 * Constants.ARC_SECONDS_TO_RADIANS, 0.30188 * Constants.ARC_SECONDS_TO_RADIANS, 0.017998 * Constants.ARC_SECONDS_TO_RADIANS);
private final PolynomialNutation thetaA = new PolynomialNutation(0.0, 2004.3109 * Constants.ARC_SECONDS_TO_RADIANS, -0.42665 * Constants.ARC_SECONDS_TO_RADIANS, -0.041833 * Constants.ARC_SECONDS_TO_RADIANS);
private final PolynomialNutation zA = new PolynomialNutation(0.0, 2306.2181 * Constants.ARC_SECONDS_TO_RADIANS, 1.09468 * Constants.ARC_SECONDS_TO_RADIANS, 0.018203 * Constants.ARC_SECONDS_TO_RADIANS);
public Transform getTransform(AbsoluteDate date) {
final double tc = IERSConventions.IERS_1996.evaluateTC(date);
final Rotation r1 = new Rotation(Vector3D.PLUS_K, zA.value(tc), RotationConvention.VECTOR_OPERATOR);
final Rotation r2 = new Rotation(Vector3D.PLUS_J, -thetaA.value(tc), RotationConvention.VECTOR_OPERATOR);
final Rotation r3 = new Rotation(Vector3D.PLUS_K, zetaA.value(tc), RotationConvention.VECTOR_OPERATOR);
return new Transform(date, r1.compose(r2.compose(r3, RotationConvention.VECTOR_OPERATOR), RotationConvention.VECTOR_OPERATOR));
}
public <T extends RealFieldElement<T>> FieldTransform<T> getTransform(final FieldAbsoluteDate<T> date) {
throw new UnsupportedOperationException("never called in this test");
}
};
MODProvider modProvider = new MODProvider(IERSConventions.IERS_1996);
for (double dt = -5 * Constants.JULIAN_YEAR; dt < 5 * Constants.JULIAN_YEAR; dt += 10 * Constants.JULIAN_DAY) {
AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(dt);
Transform t = new Transform(date, modProvider.getTransform(date).getInverse(), eulerBasedProvider.getTransform(date));
Assert.assertEquals(0, t.getRotation().getAngle(), 1.01e-11);
}
}
use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.
the class TideTest method patchEarthRotationModel.
/**
* Patch FundamentalNutationArguments to use a simplified Earth rotation angle.
* <p>
* The angle is simply computed such that Sun is at the anti-meridian at 00h00 UT1,
* and Earth rotates at 15°/hour between 00h00 UT1 and the current date.
* </p>
* @param fna FundamentalNutationArguments to patch
* @param ut1 UT1 time scale to use for computing date components
*/
public static void patchEarthRotationModel(FundamentalNutationArguments fna, final TimeScale ut1) {
try {
final Field conventionsField = FundamentalNutationArguments.class.getDeclaredField("conventions");
conventionsField.setAccessible(true);
final IERSConventions conventions = (IERSConventions) conventionsField.get(fna);
final Field fCoeffField = FundamentalNutationArguments.class.getDeclaredField("fCoefficients");
fCoeffField.setAccessible(true);
final double[] fCoefficients = (double[]) fCoeffField.get(fna);
final Field dCoeffField = FundamentalNutationArguments.class.getDeclaredField("dCoefficients");
dCoeffField.setAccessible(true);
final double[] dCoefficients = (double[]) dCoeffField.get(fna);
final Field oCoeffField = FundamentalNutationArguments.class.getDeclaredField("omegaCoefficients");
oCoeffField.setAccessible(true);
final double[] oCoefficients = (double[]) oCoeffField.get(fna);
final Method valueMethod = FundamentalNutationArguments.class.getDeclaredMethod("value", Double.TYPE, double[].class);
valueMethod.setAccessible(true);
final Field gmstFunctionField = FundamentalNutationArguments.class.getDeclaredField("gmstFunction");
gmstFunctionField.setAccessible(true);
final TimeScalarFunction old = (TimeScalarFunction) gmstFunctionField.get(fna);
gmstFunctionField.set(fna, new TimeScalarFunction() {
private double sunAngle(AbsoluteDate date) {
try {
double tc = conventions.evaluateTC(date);
return ((Double) valueMethod.invoke(fna, tc, fCoefficients)).doubleValue() + ((Double) valueMethod.invoke(fna, tc, oCoefficients)).doubleValue() - ((Double) valueMethod.invoke(fna, tc, dCoefficients)).doubleValue();
} catch (InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
return Double.NaN;
}
}
@Override
public double value(AbsoluteDate date) {
double dayFraction = date.getComponents(ut1).getTime().getSecondsInUTCDay() / Constants.JULIAN_DAY;
double v = 2 * FastMath.PI * dayFraction + sunAngle(date) + FastMath.PI;
// the patched value is about 24 arc seconds from the IERS value (almost independent on date)
double deltaArcSeconds = 3600.0 * FastMath.toDegrees(MathUtils.normalizeAngle(old.value(date) - v, 0.0));
Assert.assertEquals(0.0, deltaArcSeconds, 23.7);
return v;
}
@Override
public <T extends RealFieldElement<T>> T value(final FieldAbsoluteDate<T> date) {
return null;
}
});
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException | NoSuchMethodException | SecurityException e) {
Assert.fail(e.getLocalizedMessage());
}
}
use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.
the class EOPHistoryTest method testFieldOutOfRange.
@Test
public void testFieldOutOfRange() throws OrekitException {
EOPHistory history = FramesFactory.getEOPHistory(IERSConventions.IERS_2010, true);
FieldAbsoluteDate<Decimal64> endDate = new FieldAbsoluteDate<>(Decimal64Field.getInstance(), 2006, 3, 5, TimeScalesFactory.getUTC());
for (double t = -1000; t < 1000; t += 3) {
FieldAbsoluteDate<Decimal64> date = endDate.shiftedBy(t);
Decimal64 dt = history.getUT1MinusUTC(date);
if (t <= 0) {
Assert.assertTrue(dt.getReal() < 0.29236);
Assert.assertTrue(dt.getReal() > 0.29233);
} else {
// no more data after end date
Assert.assertEquals(0.0, dt.getReal(), 1.0e-10);
}
}
}
use of org.orekit.time.FieldAbsoluteDate in project Orekit by CS-SI.
the class FramesFactoryTest method testUnwrapInterpolatingTransformProvider.
@Test
public void testUnwrapInterpolatingTransformProvider() throws OrekitException {
TransformProvider raw = new TransformProvider() {
private static final long serialVersionUID = 1L;
public Transform getTransform(final AbsoluteDate date) {
double dt = date.durationFrom(AbsoluteDate.J2000_EPOCH);
double sin = FastMath.sin(dt * MathUtils.TWO_PI / Constants.JULIAN_DAY);
return new Transform(date, new PVCoordinates(new Vector3D(sin, Vector3D.PLUS_I), Vector3D.ZERO));
}
public <T extends RealFieldElement<T>> FieldTransform<T> getTransform(final FieldAbsoluteDate<T> date) {
throw new UnsupportedOperationException("never called in this test");
}
};
Frame parent = FramesFactory.getGCRF();
Frame frame = new Frame(parent, new InterpolatingTransformProvider(raw, CartesianDerivativesFilter.USE_P, AngularDerivativesFilter.USE_R, 4, Constants.JULIAN_DAY, 10, Constants.JULIAN_YEAR, 2 * Constants.JULIAN_DAY), "sine");
double maxErrorNonInterpolating = 0;
double maxErrorInterpolating = 0;
for (double dt = 0; dt < Constants.JULIAN_DAY; dt += 60.0) {
AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(dt);
Transform reference = raw.getTransform(date);
Transform nonInterpolating = FramesFactory.getNonInterpolatingTransform(parent, frame, date);
Transform interpolating = parent.getTransformTo(frame, date);
double errorNonInterpolating = Vector3D.distance(reference.getTranslation(), nonInterpolating.getTranslation());
maxErrorNonInterpolating = FastMath.max(maxErrorNonInterpolating, errorNonInterpolating);
double errorInterpolating = Vector3D.distance(reference.getTranslation(), interpolating.getTranslation());
maxErrorInterpolating = FastMath.max(maxErrorInterpolating, errorInterpolating);
}
Assert.assertEquals(0.0, maxErrorNonInterpolating, 1.0e-15);
Assert.assertEquals(1.0, maxErrorInterpolating, 1.0e-15);
}
Aggregations