Search in sources :

Example 21 with Frame

use of org.orekit.frames.Frame in project Orekit by CS-SI.

the class StreamingOemWriterTest method testWriteOemStepHandler.

/**
 * Check reading and writing an OEM both with and without using the step handler
 * methods.
 *
 * @throws Exception on error.
 */
@Test
public void testWriteOemStepHandler() throws Exception {
    // setup
    TimeScale utc = TimeScalesFactory.getUTC();
    List<String> files = Arrays.asList("/ccsds/OEMExample5.txt", "/ccsds/OEMExample4.txt");
    for (String ex : files) {
        InputStream inEntry = getClass().getResourceAsStream(ex);
        OEMParser parser = new OEMParser().withMu(CelestialBodyFactory.getEarth().getGM()).withConventions(IERSConventions.IERS_2010);
        OEMFile oemFile = parser.parse(inEntry, "OEMExample.txt");
        OemSatelliteEphemeris satellite = oemFile.getSatellites().values().iterator().next();
        EphemeridesBlock ephemerisBlock = satellite.getSegments().get(0);
        Frame frame = ephemerisBlock.getFrame();
        double step = ephemerisBlock.getStopTime().durationFrom(ephemerisBlock.getStartTime()) / (ephemerisBlock.getCoordinates().size() - 1);
        String originator = oemFile.getOriginator();
        EphemeridesBlock block = oemFile.getEphemeridesBlocks().get(0);
        String objectName = block.getMetaData().getObjectName();
        String objectID = block.getMetaData().getObjectID();
        Map<Keyword, String> metadata = new LinkedHashMap<>();
        metadata.put(Keyword.ORIGINATOR, originator);
        metadata.put(Keyword.OBJECT_NAME, "will be overwritten");
        metadata.put(Keyword.OBJECT_ID, objectID);
        Map<Keyword, String> segmentData = new LinkedHashMap<>();
        segmentData.put(Keyword.OBJECT_NAME, objectName);
        // check using the Propagator / StepHandler interface
        StringBuilder buffer = new StringBuilder();
        StreamingOemWriter writer = new StreamingOemWriter(buffer, utc, metadata);
        writer.writeHeader();
        Segment segment = writer.newSegment(frame, segmentData);
        BoundedPropagator propagator = satellite.getPropagator();
        propagator.setMasterMode(step, segment);
        propagator.propagate(propagator.getMinDate(), propagator.getMaxDate());
        // verify
        BufferedReader reader = new BufferedReader(new StringReader(buffer.toString()));
        OEMFile generatedOemFile = parser.parse(reader, "buffer");
        compareOemFiles(oemFile, generatedOemFile, 1e-7, 1e-7);
        // check calling the methods directly
        buffer = new StringBuilder();
        writer = new StreamingOemWriter(buffer, utc, metadata);
        writer.writeHeader();
        // set start and stop date manually
        segmentData.put(Keyword.START_TIME, StreamingOemWriter.dateToString(block.getStart().getComponents(utc)));
        segmentData.put(Keyword.STOP_TIME, StreamingOemWriter.dateToString(block.getStop().getComponents(utc)));
        segment = writer.newSegment(frame, segmentData);
        segment.writeMetadata();
        for (TimeStampedPVCoordinates coordinate : block.getCoordinates()) {
            segment.writeEphemerisLine(coordinate);
        }
        // verify
        reader = new BufferedReader(new StringReader(buffer.toString()));
        generatedOemFile = parser.parse(reader, "buffer");
        compareOemFiles(oemFile, generatedOemFile, 1e-7, 1e-7);
    }
}
Also used : Frame(org.orekit.frames.Frame) InputStream(java.io.InputStream) EphemeridesBlock(org.orekit.files.ccsds.OEMFile.EphemeridesBlock) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) TimeScale(org.orekit.time.TimeScale) Segment(org.orekit.files.ccsds.StreamingOemWriter.Segment) LinkedHashMap(java.util.LinkedHashMap) BufferedReader(java.io.BufferedReader) StringReader(java.io.StringReader) OemSatelliteEphemeris(org.orekit.files.ccsds.OEMFile.OemSatelliteEphemeris) BoundedPropagator(org.orekit.propagation.BoundedPropagator) Test(org.junit.Test)

Example 22 with Frame

use of org.orekit.frames.Frame 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 23 with Frame

use of org.orekit.frames.Frame in project Orekit by CS-SI.

the class SP3ParserTest method testWrongNumberOfEpochs.

@Test
public void testWrongNumberOfEpochs() throws IOException {
    try {
        final String ex = "/sp3/wrong-number-of-epochs.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);
        parser.parse(inEntry);
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertEquals(OrekitMessages.SP3_NUMBER_OF_EPOCH_MISMATCH, oe.getSpecifier());
        Assert.assertEquals(2, ((Integer) oe.getParts()[0]).intValue());
        Assert.assertEquals(192, ((Integer) oe.getParts()[2]).intValue());
    }
}
Also used : Frame(org.orekit.frames.Frame) FactoryManagedFrame(org.orekit.frames.FactoryManagedFrame) InputStream(java.io.InputStream) OrekitException(org.orekit.errors.OrekitException) Test(org.junit.Test)

Example 24 with Frame

use of org.orekit.frames.Frame in project Orekit by CS-SI.

the class SP3ParserTest method testTruncatedLine.

@Test
public void testTruncatedLine() throws IOException {
    try {
        final String ex = "/sp3/truncated-line.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);
        parser.parse(inEntry);
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertEquals(OrekitMessages.UNABLE_TO_PARSE_LINE_IN_FILE, oe.getSpecifier());
        Assert.assertEquals(27, ((Integer) oe.getParts()[0]).intValue());
    }
}
Also used : Frame(org.orekit.frames.Frame) FactoryManagedFrame(org.orekit.frames.FactoryManagedFrame) InputStream(java.io.InputStream) OrekitException(org.orekit.errors.OrekitException) Test(org.junit.Test)

Example 25 with Frame

use of org.orekit.frames.Frame in project Orekit by CS-SI.

the class SP3ParserTest method testMissingEOF.

@Test
public void testMissingEOF() throws IOException {
    try {
        final String ex = "/sp3/missing-eof.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);
        parser.parse(inEntry);
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertEquals(OrekitMessages.SP3_UNEXPECTED_END_OF_FILE, oe.getSpecifier());
        Assert.assertEquals(24, ((Integer) oe.getParts()[0]).intValue());
    }
}
Also used : Frame(org.orekit.frames.Frame) FactoryManagedFrame(org.orekit.frames.FactoryManagedFrame) InputStream(java.io.InputStream) OrekitException(org.orekit.errors.OrekitException) Test(org.junit.Test)

Aggregations

Frame (org.orekit.frames.Frame)257 Test (org.junit.Test)169 AbsoluteDate (org.orekit.time.AbsoluteDate)153 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)117 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)99 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)79 SpacecraftState (org.orekit.propagation.SpacecraftState)79 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)70 OrekitException (org.orekit.errors.OrekitException)60 PVCoordinates (org.orekit.utils.PVCoordinates)58 Orbit (org.orekit.orbits.Orbit)51 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)50 TimeScale (org.orekit.time.TimeScale)46 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)46 GeodeticPoint (org.orekit.bodies.GeodeticPoint)41 TopocentricFrame (org.orekit.frames.TopocentricFrame)38 Transform (org.orekit.frames.Transform)38 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)35 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)33 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)31