Search in sources :

Example 96 with TimeScale

use of org.orekit.time.TimeScale in project Orekit by CS-SI.

the class FieldApsideDetectorTest method doTestSimple.

private <T extends RealFieldElement<T>> void doTestSimple(Field<T> field) throws OrekitException {
    final T zero = field.getZero();
    final TimeScale utc = TimeScalesFactory.getUTC();
    final FieldVector3D<T> position = new FieldVector3D<>(zero.add(-6142438.668), zero.add(3492467.56), zero.add(-25767.257));
    final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(506.0), zero.add(943.0), zero.add(7450));
    final FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, 2003, 9, 16, utc);
    final FieldOrbit<T> orbit = new FieldCartesianOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), date, Constants.EIGEN5C_EARTH_MU);
    FieldEcksteinHechlerPropagator<T> propagator = new FieldEcksteinHechlerPropagator<>(orbit, Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS, Constants.EIGEN5C_EARTH_MU, Constants.EIGEN5C_EARTH_C20, Constants.EIGEN5C_EARTH_C30, Constants.EIGEN5C_EARTH_C40, Constants.EIGEN5C_EARTH_C50, Constants.EIGEN5C_EARTH_C60);
    FieldEventDetector<T> detector = new FieldApsideDetector<>(propagator.getInitialState().getOrbit()).withMaxCheck(zero.add(600.0)).withThreshold(zero.add(1.0e-12)).withHandler(new FieldContinueOnEvent<FieldApsideDetector<T>, T>());
    Assert.assertEquals(600.0, detector.getMaxCheckInterval().getReal(), 1.0e-15);
    Assert.assertEquals(1.0e-12, detector.getThreshold().getReal(), 1.0e-15);
    Assert.assertEquals(AbstractDetector.DEFAULT_MAX_ITER, detector.getMaxIterationCount());
    FieldEventsLogger<T> logger = new FieldEventsLogger<>();
    propagator.addEventDetector(logger.monitorDetector(detector));
    propagator.propagate(propagator.getInitialState().getOrbit().getDate().shiftedBy(Constants.JULIAN_DAY));
    Assert.assertEquals(30, logger.getLoggedEvents().size());
    for (FieldLoggedEvent<T> e : logger.getLoggedEvents()) {
        FieldKeplerianOrbit<T> o = (FieldKeplerianOrbit<T>) OrbitType.KEPLERIAN.convertType(e.getState().getOrbit());
        double expected = e.isIncreasing() ? 0.0 : FastMath.PI;
        Assert.assertEquals(expected, MathUtils.normalizeAngle(o.getMeanAnomaly().getReal(), expected), 4.0e-14);
    }
}
Also used : TimeScale(org.orekit.time.TimeScale) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldCartesianOrbit(org.orekit.orbits.FieldCartesianOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) FieldEcksteinHechlerPropagator(org.orekit.propagation.analytical.FieldEcksteinHechlerPropagator) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Example 97 with TimeScale

use of org.orekit.time.TimeScale in project Orekit by CS-SI.

the class SolarBodyTest method testNaif.

@Test
public void testNaif() throws OrekitException, UnsupportedEncodingException, IOException {
    Utils.setDataRoot("regular-data");
    final Frame refFrame = FramesFactory.getICRF();
    final TimeScale tdb = TimeScalesFactory.getTDB();
    final InputStream inEntry = getClass().getResourceAsStream("/naif/DE431-ephemeris-NAIF.txt");
    BufferedReader reader = new BufferedReader(new InputStreamReader(inEntry, "UTF-8"));
    for (String line = reader.readLine(); line != null; line = reader.readLine()) {
        line = line.trim();
        if (!line.isEmpty() && !line.startsWith("#")) {
            // extract reference data from Naif
            String[] fields = line.split("\\s+");
            final AbsoluteDate date1 = new AbsoluteDate(fields[0], tdb);
            final AbsoluteDate date2 = new AbsoluteDate(AbsoluteDate.J2000_EPOCH, Double.parseDouble(fields[1]), tdb);
            String name = fields[2];
            final String barycenter = fields[3];
            final Vector3D pRef = new Vector3D(Double.parseDouble(fields[4]) * 1000.0, Double.parseDouble(fields[5]) * 1000.0, Double.parseDouble(fields[6]) * 1000.0);
            final Vector3D vRef = new Vector3D(Double.parseDouble(fields[7]) * 1000.0, Double.parseDouble(fields[8]) * 1000.0, Double.parseDouble(fields[9]) * 1000.0);
            // check position-velocity
            Assert.assertEquals("BARYCENTER", barycenter);
            if (name.equals("EARTH")) {
                name = "EARTH-MOON BARYCENTER";
            }
            Assert.assertEquals(0.0, date2.durationFrom(date1), 8.0e-5);
            final PVCoordinates pv = CelestialBodyFactory.getBody(name).getPVCoordinates(date2, refFrame);
            Assert.assertEquals(0.0, Vector3D.distance(pRef, pv.getPosition()), 15.0);
            Assert.assertEquals(0.0, Vector3D.distance(vRef, pv.getVelocity()), 1.0e-5);
        }
    }
}
Also used : Frame(org.orekit.frames.Frame) InputStreamReader(java.io.InputStreamReader) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) InputStream(java.io.InputStream) BufferedReader(java.io.BufferedReader) PVCoordinates(org.orekit.utils.PVCoordinates) TimeScale(org.orekit.time.TimeScale) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 98 with TimeScale

use of org.orekit.time.TimeScale in project Orekit by CS-SI.

the class PredefinedIAUPolesTest method testNaif.

@Test
public void testNaif() throws OrekitException, UnsupportedEncodingException, IOException {
    final TimeScale tdb = TimeScalesFactory.getTDB();
    final InputStream inEntry = getClass().getResourceAsStream("/naif/IAU-pole-NAIF.txt");
    BufferedReader reader = new BufferedReader(new InputStreamReader(inEntry, "UTF-8"));
    for (String line = reader.readLine(); line != null; line = reader.readLine()) {
        line = line.trim();
        if (!line.isEmpty() && !line.startsWith("#")) {
            // extract reference data from Naif
            String[] fields = line.split("\\s+");
            final AbsoluteDate date1 = new AbsoluteDate(fields[0], tdb);
            final AbsoluteDate date2 = new AbsoluteDate(AbsoluteDate.J2000_EPOCH, Double.parseDouble(fields[1]), tdb);
            final EphemerisType type = EphemerisType.valueOf(fields[2]);
            final double alphaRef = Double.parseDouble(fields[3]);
            final double deltaRef = Double.parseDouble(fields[4]);
            final double wRef = Double.parseDouble(fields[5]);
            final double[][] m = new double[3][3];
            int index = 6;
            for (int i = 0; i < 3; ++i) {
                for (int j = 0; j < 3; ++j) {
                    // we transpose the matrix to get the transform
                    // from ICRF to body frame
                    m[j][i] = Double.parseDouble(fields[index++]);
                }
            }
            Rotation rRef = new Rotation(m, 1.0e-10);
            // check pole
            IAUPole iauPole = PredefinedIAUPoles.getIAUPole(type);
            Vector3D pole = iauPole.getPole(date2);
            double w = iauPole.getPrimeMeridianAngle(date2);
            Assert.assertEquals(0.0, date2.durationFrom(date1), 8.0e-5);
            Assert.assertEquals(alphaRef, MathUtils.normalizeAngle(pole.getAlpha(), alphaRef), 1.8e-15);
            Assert.assertEquals(deltaRef, pole.getDelta(), 2.4e-13);
            Assert.assertEquals(wRef, MathUtils.normalizeAngle(w, wRef), 2.5e-12);
            // check matrix
            Vector3D qNode = Vector3D.crossProduct(Vector3D.PLUS_K, pole);
            if (qNode.getNormSq() < Precision.SAFE_MIN) {
                qNode = Vector3D.PLUS_I;
            }
            final Rotation rotation = new Rotation(Vector3D.PLUS_K, wRef, RotationConvention.FRAME_TRANSFORM).applyTo(new Rotation(pole, qNode, Vector3D.PLUS_K, Vector3D.PLUS_I));
            Assert.assertEquals(0.0, Rotation.distance(rRef, rotation), 1.9e-15);
        }
    }
}
Also used : EphemerisType(org.orekit.bodies.JPLEphemeridesLoader.EphemerisType) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) TimeScale(org.orekit.time.TimeScale) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) OldIAUPole(org.orekit.bodies.IAUPoleFactory.OldIAUPole) Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) BufferedReader(java.io.BufferedReader) Test(org.junit.Test)

Example 99 with TimeScale

use of org.orekit.time.TimeScale 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 100 with TimeScale

use of org.orekit.time.TimeScale in project Orekit by CS-SI.

the class ITRFEquinoxProviderTest method testSofaCookbook.

@Test
public void testSofaCookbook() throws OrekitException {
    // SOFA cookbook test case:
    // date       2007 April 05, 12h00m00s.0 UTC
    // xp         +0′′.0349282
    // yp         +0′′.4833163
    // UT1 − UTC  -0s.072073685
    // dψ 1980    -0′′.0550655
    // dε 1980    -0′′.0063580
    // dX 2000    +0′′.0001725
    // dY 2000    -0′′.0002650
    // dX 2006    +0′′.0001750
    // dY 2006    -0′′.0002259
    Utils.setLoaders(IERSConventions.IERS_1996, Utils.buildEOPList(IERSConventions.IERS_1996, ITRFVersion.ITRF_2008, new double[][] { { 54192, -0.072073685, 1.4020, 0.0349282, 0.4833163, -0.0550666, -0.0063580, Double.NaN, Double.NaN }, { 54193, -0.072073685, 1.4020, 0.0349282, 0.4833163, -0.0550666, -0.0063580, Double.NaN, Double.NaN }, { 54194, -0.072073685, 1.4020, 0.0349282, 0.4833163, -0.0550666, -0.0063580, Double.NaN, Double.NaN }, { 54195, -0.072073685, 1.4020, 0.0349282, 0.4833163, -0.0550666, -0.0063580, Double.NaN, Double.NaN }, { 54196, -0.072073685, 1.4020, 0.0349282, 0.4833163, -0.0550666, -0.0063580, Double.NaN, Double.NaN }, { 54197, -0.072073685, 1.4020, 0.0349282, 0.4833163, -0.0550666, -0.0063580, Double.NaN, Double.NaN }, { 54198, -0.072073685, 1.4020, 0.0349282, 0.4833163, -0.0550666, -0.0063580, Double.NaN, Double.NaN }, { 54199, -0.072073685, 1.4020, 0.0349282, 0.4833163, -0.0550666, -0.0063580, Double.NaN, Double.NaN } }));
    EOPHistory eopHistory = FramesFactory.getEOPHistory(IERSConventions.IERS_1996, true);
    TimeScale utc = TimeScalesFactory.getUTC();
    TTScale tt = TimeScalesFactory.getTT();
    UT1Scale ut1 = TimeScalesFactory.getUT1(eopHistory);
    Frame gcrf = FramesFactory.getGCRF();
    Frame itrf = FramesFactory.getITRFEquinox(IERSConventions.IERS_1996, true);
    Frame gtod = itrf.getParent();
    Frame tod = gtod.getParent();
    // time scales checks
    AbsoluteDate date = new AbsoluteDate(new DateComponents(2007, 4, 5), TimeComponents.H12, utc);
    Assert.assertEquals(0.50075444444444, date.getComponents(tt).getTime().getSecondsInUTCDay() / Constants.JULIAN_DAY, 5.0e-15);
    Assert.assertEquals(0.499999165813831, date.getComponents(ut1).getTime().getSecondsInUTCDay() / Constants.JULIAN_DAY, 1.0e-15);
    // sidereal time check
    double gast = IERSConventions.IERS_1996.getGASTFunction(ut1, eopHistory).value(date);
    Assert.assertEquals(13.412402380740 * 3600 * 1.0e6, radToMicroAS(MathUtils.normalizeAngle(gast, 0)), 25);
    // nutation/precession/bias matrix check
    Rotation refNPB = new Rotation(new double[][] { { +0.999998403176203, -0.001639032970562, -0.000712190961847 }, { +0.001639000942243, +0.999998655799521, -0.000045552846624 }, { +0.000712264667137, +0.000044385492226, +0.999999745354454 } }, 1.0e-13);
    Rotation npb = gcrf.getTransformTo(tod, date).getRotation();
    Assert.assertEquals(0.0, radToMicroAS(Rotation.distance(refNPB, npb)), 27.0);
    // celestial to terrestrial frames matrix, without polar motion
    Rotation refWithoutPolarMotion = new Rotation(new double[][] { { +0.973104317592265, +0.230363826166883, -0.000703332813776 }, { -0.230363798723533, +0.973104570754697, +0.000120888299841 }, { +0.000712264667137, +0.000044385492226, +0.999999745354454 } }, 1.0e-13);
    Rotation withoutPM = gcrf.getTransformTo(gtod, date).getRotation();
    Assert.assertEquals(0.0, radToMicroAS(Rotation.distance(refWithoutPolarMotion, withoutPM)), 9);
    // celestial to terrestrial frames matrix, with polar motion
    Rotation refWithPolarMotion = new Rotation(new double[][] { { +0.973104317712772, +0.230363826174782, -0.000703163477127 }, { -0.230363800391868, +0.973104570648022, +0.000118545116892 }, { +0.000711560100206, +0.000046626645796, +0.999999745754058 } }, 1.0e-13);
    Rotation withPM = gcrf.getTransformTo(itrf, date).getRotation();
    Assert.assertEquals(0.0, radToMicroAS(Rotation.distance(refWithPolarMotion, withPM)), 10);
}
Also used : UT1Scale(org.orekit.time.UT1Scale) TTScale(org.orekit.time.TTScale) DateComponents(org.orekit.time.DateComponents) TimeScale(org.orekit.time.TimeScale) Rotation(org.hipparchus.geometry.euclidean.threed.Rotation) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Aggregations

TimeScale (org.orekit.time.TimeScale)116 AbsoluteDate (org.orekit.time.AbsoluteDate)89 Test (org.junit.Test)75 Frame (org.orekit.frames.Frame)44 Orbit (org.orekit.orbits.Orbit)38 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)38 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)35 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)32 SpacecraftState (org.orekit.propagation.SpacecraftState)30 PVCoordinates (org.orekit.utils.PVCoordinates)28 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)25 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)17 OrekitException (org.orekit.errors.OrekitException)17 Propagator (org.orekit.propagation.Propagator)17 EcksteinHechlerPropagator (org.orekit.propagation.analytical.EcksteinHechlerPropagator)15 BodiesElements (org.orekit.data.BodiesElements)14 FundamentalNutationArguments (org.orekit.data.FundamentalNutationArguments)14 CartesianOrbit (org.orekit.orbits.CartesianOrbit)14 FieldCartesianOrbit (org.orekit.orbits.FieldCartesianOrbit)14 KeplerianPropagator (org.orekit.propagation.analytical.KeplerianPropagator)13