Search in sources :

Example 31 with FieldAbsoluteDate

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);
    }
}
Also used : RealFieldElement(org.hipparchus.RealFieldElement) PolynomialNutation(org.orekit.data.PolynomialNutation) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 32 with FieldAbsoluteDate

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);
    }
}
Also used : RealFieldElement(org.hipparchus.RealFieldElement) PolynomialNutation(org.orekit.data.PolynomialNutation) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 33 with FieldAbsoluteDate

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());
    }
}
Also used : IERSConventions(org.orekit.utils.IERSConventions) Method(java.lang.reflect.Method) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Field(java.lang.reflect.Field) TimeScalarFunction(org.orekit.time.TimeScalarFunction)

Example 34 with FieldAbsoluteDate

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);
        }
    }
}
Also used : Decimal64(org.hipparchus.util.Decimal64) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) Test(org.junit.Test)

Example 35 with FieldAbsoluteDate

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);
}
Also used : RealFieldElement(org.hipparchus.RealFieldElement) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) PVCoordinates(org.orekit.utils.PVCoordinates) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Aggregations

FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)138 Frame (org.orekit.frames.Frame)57 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)53 AbsoluteDate (org.orekit.time.AbsoluteDate)52 Test (org.junit.Test)51 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)40 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)37 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)37 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)29 OrekitException (org.orekit.errors.OrekitException)28 SpacecraftState (org.orekit.propagation.SpacecraftState)28 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)27 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)25 TimeStampedFieldPVCoordinates (org.orekit.utils.TimeStampedFieldPVCoordinates)24 PVCoordinates (org.orekit.utils.PVCoordinates)20 Decimal64 (org.hipparchus.util.Decimal64)18 RealFieldElement (org.hipparchus.RealFieldElement)17 OrbitType (org.orekit.orbits.OrbitType)17 DateComponents (org.orekit.time.DateComponents)17 FieldNumericalPropagator (org.orekit.propagation.numerical.FieldNumericalPropagator)14