Search in sources :

Example 26 with Decimal64

use of org.hipparchus.util.Decimal64 in project Orekit by CS-SI.

the class PredefinedIAUPolesTest method testFieldConsistency.

@Test
public void testFieldConsistency() {
    for (IAUPole iaupole : PredefinedIAUPoles.values()) {
        for (double dt = 0; dt < Constants.JULIAN_YEAR; dt += 3600) {
            final AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(dt);
            final FieldAbsoluteDate<Decimal64> date64 = new FieldAbsoluteDate<>(Decimal64Field.getInstance(), date);
            Assert.assertEquals(0, Vector3D.angle(iaupole.getPole(date), iaupole.getPole(date64).toVector3D()), 2.0e-15);
            Assert.assertEquals(iaupole.getPrimeMeridianAngle(date), iaupole.getPrimeMeridianAngle(date64).getReal(), 1.0e-12);
        }
    }
}
Also used : OldIAUPole(org.orekit.bodies.IAUPoleFactory.OldIAUPole) Decimal64(org.hipparchus.util.Decimal64) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 27 with Decimal64

use of org.hipparchus.util.Decimal64 in project Orekit by CS-SI.

the class PoissonSeriesParserTest method testDerivativesFromFieldAPI.

@Test
public void testDerivativesFromFieldAPI() throws OrekitException {
    Utils.setDataRoot("regular-data");
    String directory = "/assets/org/orekit/IERS-conventions/";
    PoissonSeriesParser parser = new PoissonSeriesParser(17).withPolynomialPart('t', PolynomialParser.Unit.NO_UNITS).withFirstDelaunay(4).withFirstPlanetary(9).withSinCos(0, 2, 1.0, 3, 1.0);
    InputStream xStream = getClass().getResourceAsStream(directory + "2010/tab5.2a.txt");
    PoissonSeries xSeries = parser.parse(xStream, "2010/tab5.2a.txt");
    InputStream yStream = getClass().getResourceAsStream(directory + "2010/tab5.2b.txt");
    PoissonSeries ySeries = parser.parse(yStream, "2010/tab5.2b.txt");
    InputStream zStream = getClass().getResourceAsStream(directory + "2010/tab5.2d.txt");
    PoissonSeries zSeries = parser.parse(zStream, "2010/tab5.2d.txt");
    final PoissonSeries.CompiledSeries compiled = PoissonSeries.compile(xSeries, ySeries, zSeries);
    TimeScale ut1 = TimeScalesFactory.getUT1(FramesFactory.getEOPHistory(IERSConventions.IERS_2010, true));
    final FundamentalNutationArguments arguments = IERSConventions.IERS_2010.getNutationArguments(ut1);
    UnivariateDifferentiableVectorFunction finite = new FiniteDifferencesDifferentiator(4, 0.4).differentiate((double t) -> compiled.value(arguments.evaluateAll(AbsoluteDate.J2000_EPOCH.shiftedBy(t))));
    DSFactory factory = new DSFactory(1, 1);
    for (double t = 0; t < Constants.JULIAN_DAY; t += 120) {
        // computation of derivatives from API
        Decimal64[] dAPI = compiled.derivative(arguments.evaluateAll(FieldAbsoluteDate.getJ2000Epoch(Decimal64Field.getInstance()).shiftedBy(t)));
        // finite differences computation of derivatives
        DerivativeStructure[] d = finite.value(factory.variable(0, t));
        Assert.assertEquals(d.length, dAPI.length);
        for (int i = 0; i < d.length; ++i) {
            Assert.assertEquals(d[i].getPartialDerivative(1), dAPI[i].getReal(), FastMath.abs(2.0e-7 * d[i].getPartialDerivative(1)));
        }
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Decimal64(org.hipparchus.util.Decimal64) DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) TimeScale(org.orekit.time.TimeScale) UnivariateDifferentiableVectorFunction(org.hipparchus.analysis.differentiation.UnivariateDifferentiableVectorFunction) FiniteDifferencesDifferentiator(org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator) Test(org.junit.Test)

Example 28 with Decimal64

use of org.hipparchus.util.Decimal64 in project Orekit by CS-SI.

the class FramesFactoryTest method testFieldConsistency.

@Test
public void testFieldConsistency() throws OrekitException {
    for (final Predefined predefined : Predefined.values()) {
        final Frame frame = FramesFactory.getFrame(predefined);
        final Frame parent = frame.getParent();
        if (parent != null) {
            double maxPositionError = 0;
            double maxVelocityError = 0;
            double maxAccelerationError = 0;
            double maxRotationError = 0;
            double maxRotationRateError = 0;
            double maxRotationAccelerationError = 0;
            for (double dt = 0; dt < Constants.JULIAN_DAY; dt += 60.0) {
                final AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(dt);
                final Transform transformDouble = parent.getTransformTo(frame, date);
                final FieldTransform<Decimal64> transformD64 = parent.getTransformTo(frame, new FieldAbsoluteDate<>(Decimal64Field.getInstance(), date));
                maxPositionError = FastMath.max(maxPositionError, Vector3D.distance(transformDouble.getTranslation(), transformD64.getTranslation().toVector3D()));
                maxVelocityError = FastMath.max(maxVelocityError, Vector3D.distance(transformDouble.getVelocity(), transformD64.getVelocity().toVector3D()));
                maxAccelerationError = FastMath.max(maxAccelerationError, Vector3D.distance(transformDouble.getAcceleration(), transformD64.getAcceleration().toVector3D()));
                maxRotationError = FastMath.max(maxRotationError, Rotation.distance(transformDouble.getRotation(), transformD64.getRotation().toRotation()));
                maxRotationRateError = FastMath.max(maxRotationRateError, Vector3D.distance(transformDouble.getRotationRate(), transformD64.getRotationRate().toVector3D()));
                maxRotationAccelerationError = FastMath.max(maxRotationAccelerationError, Vector3D.distance(transformDouble.getRotationAcceleration(), transformD64.getRotationAcceleration().toVector3D()));
            }
            Assert.assertEquals(0, maxPositionError, 1.0e-100);
            Assert.assertEquals(0, maxVelocityError, 1.0e-100);
            Assert.assertEquals(0, maxAccelerationError, 1.0e-100);
            Assert.assertEquals(0, maxRotationError, 2.0e-14);
            Assert.assertEquals(0, maxRotationRateError, 2.0e-18);
            Assert.assertEquals(0, maxRotationAccelerationError, 8.0e-22);
        }
    }
}
Also used : Decimal64(org.hipparchus.util.Decimal64) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 29 with Decimal64

use of org.hipparchus.util.Decimal64 in project Orekit by CS-SI.

the class ITRFVersionTest method testAllConverters.

@Test
public void testAllConverters() throws OrekitException {
    // for this test, we arbitrarily assume FramesFactory provides an ITRF 2014
    Frame itrf2014 = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
    for (final ITRFVersion origin : ITRFVersion.values()) {
        for (final ITRFVersion destination : ITRFVersion.values()) {
            ITRFVersion.Converter converter = ITRFVersion.getConverter(origin, destination);
            Assert.assertEquals(origin, converter.getOrigin());
            Assert.assertEquals(destination, converter.getDestination());
            Frame originFrame = origin == ITRFVersion.ITRF_2014 ? itrf2014 : from2014(origin.getYear()).createTransformedITRF(itrf2014, origin.toString());
            Frame destinationFrame = destination == ITRFVersion.ITRF_2014 ? itrf2014 : from2014(destination.getYear()).createTransformedITRF(itrf2014, destination.toString());
            for (int year = 2000; year < 2007; ++year) {
                AbsoluteDate date = new AbsoluteDate(year, 4, 17, 12, 0, 0, TimeScalesFactory.getTT());
                Transform looped = new Transform(date, converter.getTransform(date), destinationFrame.getTransformTo(originFrame, date));
                if (origin == ITRFVersion.ITRF_2008 || destination == ITRFVersion.ITRF_2008) {
                    // if we use ITRF 2008, as internally the pivot frame is ITRF 2014
                    // on side of the transform is computed as f -> 2008 -> 2014, and on
                    // the other side as f -> 2014 and we get some inversion in between.
                    // the errors are not strictly zero (but they are very small) because
                    // Helmert transformations are a translation plus a rotation. If we do
                    // t1 -> r1 -> t2 -> r2, it is not the same as t1 -> t2 -> r1 -> r2
                    // which would correspond to simply add the offsets, velocities, rotations and rate,
                    // which is what is done in the reference documents.
                    // Anyway, the non-commutativity errors are well below models accuracy
                    Assert.assertEquals(0, looped.getTranslation().getNorm(), 6.0e-06);
                    Assert.assertEquals(0, looped.getVelocity().getNorm(), 2.0e-22);
                    Assert.assertEquals(0, looped.getRotation().getAngle(), 2.0e-12);
                    Assert.assertEquals(0, looped.getRotationRate().getNorm(), 2.0e-32);
                } else {
                    // if we always stay in the ITRF 2014 branch, we do the right conversions
                    // and errors are at numerical noise level
                    Assert.assertEquals(0, looped.getTranslation().getNorm(), 6.0e-17);
                    Assert.assertEquals(0, looped.getVelocity().getNorm(), 4.0e-26);
                    Assert.assertEquals(0, looped.getRotation().getAngle(), 1.0e-40);
                    Assert.assertEquals(0, looped.getRotationRate().getNorm(), 2.0e-32);
                }
                FieldAbsoluteDate<Decimal64> date64 = new FieldAbsoluteDate<>(Decimal64Field.getInstance(), date);
                FieldTransform<Decimal64> looped64 = new FieldTransform<>(date64, converter.getTransform(date64), destinationFrame.getTransformTo(originFrame, date64));
                if (origin == ITRFVersion.ITRF_2008 || destination == ITRFVersion.ITRF_2008) {
                    // if we use ITRF 2008, as internally the pivot frame is ITRF 2014
                    // on side of the transform is computed as f -> 2008 -> 2014, and on
                    // the other side as f -> 2014 and we get some inversion in between.
                    // the errors are not strictly zero (but they are very small) because
                    // Helmert transformations are a translation plus a rotation. If we do
                    // t1 -> r1 -> t2 -> r2, it is not the same as t1 -> t2 -> r1 -> r2
                    // which would correspond to simply add the offsets, velocities, rotations and rate,
                    // which is what is done in the reference documents.
                    // Anyway, the non-commutativity errors are well below models accuracy
                    Assert.assertEquals(0, looped64.getTranslation().getNorm().getReal(), 6.0e-06);
                    Assert.assertEquals(0, looped64.getVelocity().getNorm().getReal(), 2.0e-22);
                    Assert.assertEquals(0, looped64.getRotation().getAngle().getReal(), 2.0e-12);
                    Assert.assertEquals(0, looped64.getRotationRate().getNorm().getReal(), 2.0e-32);
                } else {
                    // if we always stay in the ITRF 2014 branch, we do the right conversions
                    // and errors are at numerical noise level
                    Assert.assertEquals(0, looped64.getTranslation().getNorm().getReal(), 6.0e-17);
                    Assert.assertEquals(0, looped64.getVelocity().getNorm().getReal(), 4.0e-26);
                    Assert.assertEquals(0, looped64.getRotation().getAngle().getReal(), 1.0e-40);
                    Assert.assertEquals(0, looped64.getRotationRate().getNorm().getReal(), 2.0e-32);
                }
            }
        }
    }
}
Also used : Decimal64(org.hipparchus.util.Decimal64) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 30 with Decimal64

use of org.hipparchus.util.Decimal64 in project Orekit by CS-SI.

the class VersionedITRFFrameTest method doTestBulletinA2018Jump.

private void doTestBulletinA2018Jump(AbsoluteDate date, double expectedDistance2008, double expectedDistance2014, double tolerance) throws OrekitException {
    Frame eme2000 = FramesFactory.getEME2000();
    Frame unspecifiedITRF = FramesFactory.getITRF(IERSConventions.IERS_2010, false);
    VersionedITRF itrf2008 = FramesFactory.getITRF(ITRFVersion.ITRF_2008, IERSConventions.IERS_2010, false);
    VersionedITRF itrf2014 = FramesFactory.getITRF(ITRFVersion.ITRF_2014, IERSConventions.IERS_2010, false);
    Assert.assertEquals(ITRFVersion.ITRF_2008, itrf2008.getITRFVersion());
    Assert.assertEquals(ITRFVersion.ITRF_2014, itrf2014.getITRFVersion());
    GeodeticPoint laPaz = new GeodeticPoint(FastMath.toRadians(-16.50), FastMath.toRadians(-68.15), 3640.0);
    OneAxisEllipsoid earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, unspecifiedITRF);
    Vector3D p = earth.transform(laPaz);
    // regular transform
    Vector3D pUnspecified = unspecifiedITRF.getTransformTo(eme2000, date).transformPosition(p);
    Vector3D p2008 = itrf2008.getTransformTo(eme2000, date).transformPosition(p);
    Vector3D p2014 = itrf2014.getTransformTo(eme2000, date).transformPosition(p);
    Assert.assertEquals(expectedDistance2008, Vector3D.distance(pUnspecified, p2008), tolerance);
    Assert.assertEquals(expectedDistance2014, Vector3D.distance(pUnspecified, p2014), tolerance);
    // non-interpolating transform
    Vector3D pUnspecifiedNI = FramesFactory.getNonInterpolatingTransform(unspecifiedITRF, eme2000, date).transformPosition(p);
    Vector3D p2008NI = FramesFactory.getNonInterpolatingTransform(itrf2008, eme2000, date).transformPosition(p);
    Vector3D p2014NI = FramesFactory.getNonInterpolatingTransform(itrf2014, eme2000, date).transformPosition(p);
    Assert.assertEquals(expectedDistance2008, Vector3D.distance(pUnspecifiedNI, p2008NI), tolerance);
    Assert.assertEquals(expectedDistance2014, Vector3D.distance(pUnspecifiedNI, p2014NI), tolerance);
    // field transform
    FieldAbsoluteDate<Decimal64> dateField = new FieldAbsoluteDate<>(Decimal64Field.getInstance(), date);
    FieldVector3D<Decimal64> pUnspecifiedField = unspecifiedITRF.getTransformTo(eme2000, dateField).transformPosition(p);
    FieldVector3D<Decimal64> p2008Field = itrf2008.getTransformTo(eme2000, dateField).transformPosition(p);
    FieldVector3D<Decimal64> p2014Field = itrf2014.getTransformTo(eme2000, dateField).transformPosition(p);
    Assert.assertEquals(expectedDistance2008, FieldVector3D.distance(pUnspecifiedField, p2008Field).getReal(), tolerance);
    Assert.assertEquals(expectedDistance2014, FieldVector3D.distance(pUnspecifiedField, p2014Field).getReal(), tolerance);
}
Also used : OneAxisEllipsoid(org.orekit.bodies.OneAxisEllipsoid) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Decimal64(org.hipparchus.util.Decimal64) GeodeticPoint(org.orekit.bodies.GeodeticPoint) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Aggregations

Decimal64 (org.hipparchus.util.Decimal64)41 Test (org.junit.Test)37 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)21 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)18 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)12 FieldDerivativeStructure (org.hipparchus.analysis.differentiation.FieldDerivativeStructure)10 AbsoluteDate (org.orekit.time.AbsoluteDate)9 RandomGenerator (org.hipparchus.random.RandomGenerator)5 Well19937a (org.hipparchus.random.Well19937a)5 GeodeticPoint (org.orekit.bodies.GeodeticPoint)4 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)4 Frame (org.orekit.frames.Frame)4 FieldCartesianOrbit (org.orekit.orbits.FieldCartesianOrbit)3 TimeScale (org.orekit.time.TimeScale)3 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)3 PVCoordinates (org.orekit.utils.PVCoordinates)3 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)3 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)2 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)2 CelestialBody (org.orekit.bodies.CelestialBody)2