Search in sources :

Example 6 with TimeScale

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

the class TDMParserTest method validateTDMExampleAllKeywords.

/**
 * Validation function for example displaying all keywords.
 * @param file Parsed TDMFile to validate
 * @throws OrekitException if UTC time scale cannot be retrieved
 */
public static void validateTDMExampleAllKeywords(TDMFile file) throws OrekitException {
    final TimeScale utc = TimeScalesFactory.getUTC();
    // Header
    Assert.assertEquals(1.0, file.getFormatVersion(), 0.0);
    Assert.assertEquals(new AbsoluteDate("2017-06-14T10:53:00.000", utc).durationFrom(file.getCreationDate()), 0.0, 0.0);
    Assert.assertEquals("CSSI", file.getOriginator());
    final List<String> headerComment = new ArrayList<String>();
    headerComment.add("TDM example created by CSSI");
    headerComment.add("Testing all TDM known meta-data and data keywords");
    Assert.assertEquals(headerComment, file.getHeaderComment());
    // Meta-Data
    final TDMFile.TDMMetaData metaData = file.getObservationsBlocks().get(0).getMetaData();
    Assert.assertEquals(CcsdsTimeScale.UTC, metaData.getTimeSystem());
    Assert.assertEquals(new AbsoluteDate("2017-06-14T10:53:00.000", utc).durationFrom(metaData.getStartTime()), 0.0, 0.0);
    Assert.assertEquals("2017-06-14T10:53:00.000", metaData.getStartTimeString());
    Assert.assertEquals(new AbsoluteDate("2017-06-15T10:53:00.000", utc).durationFrom(metaData.getStopTime()), 0.0, 0.0);
    Assert.assertEquals("2017-06-15T10:53:00.000", metaData.getStopTimeString());
    Assert.assertEquals("DSS-25", metaData.getParticipants().get(1));
    Assert.assertEquals("YYYY-NNNA", metaData.getParticipants().get(2));
    Assert.assertEquals("P3", metaData.getParticipants().get(3));
    Assert.assertEquals("P4", metaData.getParticipants().get(4));
    Assert.assertEquals("P5", metaData.getParticipants().get(5));
    Assert.assertEquals("SEQUENTIAL", metaData.getMode());
    Assert.assertEquals("2,1", metaData.getPath());
    Assert.assertEquals("4,5", metaData.getPath1());
    Assert.assertEquals("3,2", metaData.getPath2());
    Assert.assertEquals("S", metaData.getTransmitBand());
    Assert.assertEquals("L", metaData.getReceiveBand());
    Assert.assertEquals(240, metaData.getTurnaroundNumerator(), 0);
    Assert.assertEquals(221, metaData.getTurnaroundDenominator(), 0);
    Assert.assertEquals("TRANSMIT", metaData.getTimetagRef());
    Assert.assertEquals(1.0, metaData.getIntegrationInterval(), 0.0);
    Assert.assertEquals("MIDDLE", metaData.getIntegrationRef());
    Assert.assertEquals(32021035200.0, metaData.getFreqOffset(), 0.0);
    Assert.assertEquals("COHERENT", metaData.getRangeMode());
    Assert.assertEquals(32768.0, metaData.getRangeModulus(), 0.0);
    Assert.assertEquals("RU", metaData.getRangeUnits());
    Assert.assertEquals("RADEC", metaData.getAngleType());
    Assert.assertEquals("EME2000", metaData.getReferenceFrameString());
    Assert.assertEquals(true, FramesFactory.getEME2000().equals(metaData.getReferenceFrame()));
    Assert.assertEquals(0.000077, metaData.getTransmitDelays().get(1), 0.0);
    Assert.assertEquals(0.000077, metaData.getTransmitDelays().get(2), 0.0);
    Assert.assertEquals(0.000077, metaData.getTransmitDelays().get(3), 0.0);
    Assert.assertEquals(0.000077, metaData.getTransmitDelays().get(4), 0.0);
    Assert.assertEquals(0.000077, metaData.getTransmitDelays().get(5), 0.0);
    Assert.assertEquals(0.000077, metaData.getReceiveDelays().get(1), 0.0);
    Assert.assertEquals(0.000077, metaData.getReceiveDelays().get(2), 0.0);
    Assert.assertEquals(0.000077, metaData.getReceiveDelays().get(3), 0.0);
    Assert.assertEquals(0.000077, metaData.getReceiveDelays().get(4), 0.0);
    Assert.assertEquals(0.000077, metaData.getReceiveDelays().get(5), 0.0);
    Assert.assertEquals("RAW", metaData.getDataQuality());
    Assert.assertEquals(1.0, metaData.getCorrectionAngle1(), 0.0);
    Assert.assertEquals(2.0, metaData.getCorrectionAngle2(), 0.0);
    Assert.assertEquals(3.0, metaData.getCorrectionDoppler(), 0.0);
    Assert.assertEquals(4.0, metaData.getCorrectionRange(), 0.0);
    Assert.assertEquals(5.0, metaData.getCorrectionReceive(), 0.0);
    Assert.assertEquals(6.0, metaData.getCorrectionTransmit(), 0.0);
    Assert.assertEquals("YES", metaData.getCorrectionsApplied());
    final List<String> metaDataComment = new ArrayList<String>();
    metaDataComment.add("All known meta-data keywords displayed");
    Assert.assertEquals(metaDataComment, metaData.getComment());
    // Data
    final List<TDMFile.Observation> observations = file.getObservationsBlocks().get(0).getObservations();
    // Reference data
    final String[] keywords = { "CARRIER_POWER", "DOPPLER_INSTANTANEOUS", "DOPPLER_INTEGRATED", "PC_N0", "PR_N0", "RANGE", "RECEIVE_FREQ_1", "RECEIVE_FREQ_2", "RECEIVE_FREQ_3", "RECEIVE_FREQ_4", "RECEIVE_FREQ_5", "RECEIVE_FREQ", "TRANSMIT_FREQ_1", "TRANSMIT_FREQ_2", "TRANSMIT_FREQ_3", "TRANSMIT_FREQ_4", "TRANSMIT_FREQ_5", "TRANSMIT_FREQ_RATE_1", "TRANSMIT_FREQ_RATE_2", "TRANSMIT_FREQ_RATE_3", "TRANSMIT_FREQ_RATE_4", "TRANSMIT_FREQ_RATE_5", "DOR", "VLBI_DELAY", "ANGLE_1", "ANGLE_2", "CLOCK_BIAS", "CLOCK_DRIFT", "STEC", "TROPO_DRY", "TROPO_WET", "PRESSURE", "RHUMIDITY", "TEMPERATURE" };
    final AbsoluteDate epoch = new AbsoluteDate("2017-06-14T10:53:00.000", utc);
    // Check consistency
    for (int i = 0; i < keywords.length; i++) {
        Assert.assertEquals(keywords[i], observations.get(i).getKeyword());
        Assert.assertEquals(epoch.shiftedBy((double) (i + 1)).durationFrom(observations.get(i).getEpoch()), 0.0, 0.0);
        Assert.assertEquals((double) (i + 1), observations.get(i).getMeasurement(), 0.0);
    }
    // Comment
    final List<String> dataComment = new ArrayList<String>();
    dataComment.add("Signal related Keywords");
    dataComment.add("VLBI/Delta-DOR Related Keywords");
    dataComment.add("Angle Related Keywords");
    dataComment.add("Time Related Keywords");
    dataComment.add("Media Related Keywords");
    dataComment.add("Meteorological Related Keywords");
    Assert.assertEquals(dataComment, file.getObservationsBlocks().get(0).getObservationsComment());
}
Also used : ArrayList(java.util.ArrayList) TimeScale(org.orekit.time.TimeScale) AbsoluteDate(org.orekit.time.AbsoluteDate)

Example 7 with TimeScale

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

the class SP3ParserTest method testSP3Propagator.

@Test
public void testSP3Propagator() throws Exception {
    // setup
    final String ex = "/sp3/example-a-2.sp3";
    final Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2003, true);
    final SP3Parser parser = new SP3Parser(Constants.EIGEN5C_EARTH_MU, 3, s -> frame);
    final InputStream inEntry = getClass().getResourceAsStream(ex);
    TimeScale gps = TimeScalesFactory.getGPS();
    // action
    final SP3File file = parser.parse(inEntry);
    // verify
    SP3Ephemeris ephemeris = file.getSatellites().get("1");
    BoundedPropagator propagator = ephemeris.getPropagator();
    Assert.assertEquals(propagator.getMinDate(), new AbsoluteDate(1994, 12, 17, gps));
    Assert.assertEquals(propagator.getMaxDate(), new AbsoluteDate(1994, 12, 17, 23, 45, 0, gps));
    SP3Coordinate expected = ephemeris.getCoordinates().get(0);
    checkPVEntry(propagator.getPVCoordinates(propagator.getMinDate(), frame), expected);
    expected = ephemeris.getCoordinates().get(1);
    checkPVEntry(propagator.getPVCoordinates(expected.getDate(), frame), expected);
    expected = ephemeris.getCoordinates().get(2);
    checkPVEntry(propagator.getPVCoordinates(propagator.getMaxDate(), frame), expected);
    ephemeris = file.getSatellites().get("31");
    propagator = ephemeris.getPropagator();
    Assert.assertEquals(propagator.getMinDate(), new AbsoluteDate(1994, 12, 17, gps));
    Assert.assertEquals(propagator.getMaxDate(), new AbsoluteDate(1994, 12, 17, 23, 45, 0, gps));
    expected = ephemeris.getCoordinates().get(0);
    checkPVEntry(propagator.propagate(propagator.getMinDate()).getPVCoordinates(frame), expected);
    expected = ephemeris.getCoordinates().get(1);
    checkPVEntry(propagator.propagate(expected.getDate()).getPVCoordinates(frame), expected);
    expected = ephemeris.getCoordinates().get(2);
    checkPVEntry(propagator.propagate(propagator.getMaxDate()).getPVCoordinates(frame), expected);
}
Also used : Frame(org.orekit.frames.Frame) FactoryManagedFrame(org.orekit.frames.FactoryManagedFrame) SP3Coordinate(org.orekit.files.sp3.SP3File.SP3Coordinate) InputStream(java.io.InputStream) TimeScale(org.orekit.time.TimeScale) BoundedPropagator(org.orekit.propagation.BoundedPropagator) SP3Ephemeris(org.orekit.files.sp3.SP3File.SP3Ephemeris) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 8 with TimeScale

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

the class PoissonSeriesParserTest method testDerivativesFromDoubleAPI.

@Test
public void testDerivativesFromDoubleAPI() 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
        double[] dAPI = compiled.derivative(arguments.evaluateAll(AbsoluteDate.J2000_EPOCH.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], FastMath.abs(2.0e-7 * d[i].getPartialDerivative(1)));
        }
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) 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 9 with TimeScale

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

the class PoissonSeriesParserTest method testCompile.

@Test
public void testCompile() throws OrekitException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
    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 sSeries = parser.parse(zStream, "2010/tab5.2d.txt");
    PoissonSeries.CompiledSeries xysSeries = PoissonSeries.compile(xSeries, ySeries, sSeries);
    Method m = IERSConventions.class.getDeclaredMethod("getNutationArguments", TimeScale.class);
    m.setAccessible(true);
    FundamentalNutationArguments arguments = (FundamentalNutationArguments) m.invoke(IERSConventions.IERS_2010, (TimeScale) null);
    for (double dt = 0; dt < Constants.JULIAN_YEAR; dt += Constants.JULIAN_DAY) {
        AbsoluteDate date = AbsoluteDate.J2000_EPOCH.shiftedBy(dt);
        BodiesElements elements = arguments.evaluateAll(date);
        double x = xSeries.value(elements);
        double y = ySeries.value(elements);
        double s = sSeries.value(elements);
        double[] xys = xysSeries.value(elements);
        Assert.assertEquals(x, xys[0], 1.0e-15 * FastMath.abs(x));
        Assert.assertEquals(y, xys[1], 1.0e-15 * FastMath.abs(y));
        Assert.assertEquals(s, xys[2], 1.0e-15 * FastMath.abs(s));
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Method(java.lang.reflect.Method) TimeScale(org.orekit.time.TimeScale) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 10 with TimeScale

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

the class PoissonSeriesParserTest method testDerivativesAsField.

@Test
public void testDerivativesAsField() 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);
    PoissonSeries xSeries = parser.parse(getClass().getResourceAsStream(directory + "2010/tab5.2a.txt"), "2010/tab5.2a.txt");
    PoissonSeries ySeries = parser.parse(getClass().getResourceAsStream(directory + "2010/tab5.2b.txt"), "2010/tab5.2b.txt");
    PoissonSeries zSeries = parser.parse(getClass().getResourceAsStream(directory + "2010/tab5.2d.txt"), "2010/tab5.2d.txt");
    TimeScale ut1 = TimeScalesFactory.getUT1(FramesFactory.getEOPHistory(IERSConventions.IERS_2010, true));
    FundamentalNutationArguments arguments = IERSConventions.IERS_2010.getNutationArguments(ut1);
    Coordinate xCoordinate = new Coordinate(xSeries, arguments);
    Coordinate yCoordinate = new Coordinate(ySeries, arguments);
    Coordinate zCoordinate = new Coordinate(zSeries, arguments);
    UnivariateDifferentiableFunction dx = new FiniteDifferencesDifferentiator(4, 0.4).differentiate(xCoordinate);
    UnivariateDifferentiableFunction dy = new FiniteDifferencesDifferentiator(4, 0.4).differentiate(yCoordinate);
    UnivariateDifferentiableFunction dz = new FiniteDifferencesDifferentiator(4, 0.4).differentiate(zCoordinate);
    DSFactory factory = new DSFactory(1, 1);
    FieldAbsoluteDate<DerivativeStructure> ds2000 = FieldAbsoluteDate.getJ2000Epoch(factory.getDerivativeField());
    for (double t = 0; t < Constants.JULIAN_DAY; t += 120) {
        final FieldAbsoluteDate<DerivativeStructure> date = ds2000.shiftedBy(factory.variable(0, t));
        // direct computation of derivatives
        FieldBodiesElements<DerivativeStructure> elements = arguments.evaluateAll(date);
        Assert.assertEquals(0.0, elements.getDate().durationFrom(date).getValue(), 1.0e-15);
        DerivativeStructure xDirect = xSeries.value(elements);
        DerivativeStructure yDirect = ySeries.value(elements);
        DerivativeStructure zDirect = zSeries.value(elements);
        // finite differences computation of derivatives
        DerivativeStructure zero = factory.variable(0, 0.0);
        xCoordinate.setDate(date.toAbsoluteDate());
        DerivativeStructure xFinite = dx.value(zero);
        yCoordinate.setDate(date.toAbsoluteDate());
        DerivativeStructure yFinite = dy.value(zero);
        zCoordinate.setDate(date.toAbsoluteDate());
        DerivativeStructure zFinite = dz.value(zero);
        Assert.assertEquals(xFinite.getValue(), xDirect.getValue(), FastMath.abs(7.0e-15 * xFinite.getValue()));
        Assert.assertEquals(xFinite.getPartialDerivative(1), xDirect.getPartialDerivative(1), FastMath.abs(2.0e-07 * xFinite.getPartialDerivative(1)));
        Assert.assertEquals(yFinite.getValue(), yDirect.getValue(), FastMath.abs(7.0e-15 * yFinite.getValue()));
        Assert.assertEquals(yFinite.getPartialDerivative(1), yDirect.getPartialDerivative(1), FastMath.abs(2.0e-07 * yFinite.getPartialDerivative(1)));
        Assert.assertEquals(zFinite.getValue(), zDirect.getValue(), FastMath.abs(7.0e-15 * zFinite.getValue()));
        Assert.assertEquals(zFinite.getPartialDerivative(1), zDirect.getPartialDerivative(1), FastMath.abs(2.0e-07 * zFinite.getPartialDerivative(1)));
    }
}
Also used : DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) TimeScale(org.orekit.time.TimeScale) UnivariateDifferentiableFunction(org.hipparchus.analysis.differentiation.UnivariateDifferentiableFunction) FiniteDifferencesDifferentiator(org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator) 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