Search in sources :

Example 46 with AbsoluteDate

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

the class OEMParserTest method testParseOEM2.

@Test
public void testParseOEM2() throws OrekitException, URISyntaxException {
    final String name = getClass().getResource("/ccsds/OEMExample2.txt").toURI().getPath();
    OEMParser parser = new OEMParser().withConventions(IERSConventions.IERS_2010).withSimpleEOP(true).withMu(CelestialBodyFactory.getMars().getGM()).withInternationalDesignator(1996, 2, "A").withMissionReferenceDate(new AbsoluteDate("1996-12-17T00:00:00.000", TimeScalesFactory.getUTC()));
    final OEMFile file = parser.parse(name);
    final List<String> headerComment = new ArrayList<String>();
    headerComment.add("comment");
    Assert.assertEquals(headerComment, file.getHeaderComment());
    final List<String> metadataComment = new ArrayList<String>();
    metadataComment.add("comment 1");
    metadataComment.add("comment 2");
    Assert.assertEquals(metadataComment, file.getEphemeridesBlocks().get(0).getMetaData().getComment());
    Assert.assertEquals("TOD", file.getEphemeridesBlocks().get(0).getFrameString());
    Assert.assertEquals("EME2000", file.getEphemeridesBlocks().get(1).getFrameString());
    List<EphemeridesBlock> blocks = file.getEphemeridesBlocks();
    Assert.assertEquals(2, blocks.size());
    Assert.assertTrue(blocks.get(0).getHasRefFrameEpoch());
    Assert.assertEquals(129600.331, blocks.get(0).getStartTime().durationFrom(file.getMissionReferenceDate()), 1.0e-15);
    Assert.assertEquals(941347.267, blocks.get(1).getStartTime().durationFrom(file.getMissionReferenceDate()), 1.0e-15);
}
Also used : ArrayList(java.util.ArrayList) EphemeridesBlock(org.orekit.files.ccsds.OEMFile.EphemeridesBlock) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 47 with AbsoluteDate

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

the class OMMParserTest method testParseOMM1.

@Test
public void testParseOMM1() throws OrekitException {
    // simple test for OMM file, contains p/v entries and other mandatory
    // data.
    final String ex = "/ccsds/OMMExample.txt";
    // initialize parser with purposely wrong international designator
    // (in order to check it is correctly overridden when parsing)
    final OMMParser parser = new OMMParser().withMu(398600e9).withInternationalDesignator(1998, 1, "a");
    final InputStream inEntry = getClass().getResourceAsStream(ex);
    final OMMFile file = parser.parse(inEntry);
    // Check Header Block;
    Assert.assertEquals(2.0, file.getFormatVersion(), 1.0e-10);
    Assert.assertEquals(new AbsoluteDate(2007, 03, 06, 16, 00, 00, TimeScalesFactory.getUTC()), file.getCreationDate());
    Assert.assertEquals("NOAA/USA", file.getOriginator());
    // Check Metadata Block;
    Assert.assertEquals("GOES 9", file.getMetaData().getObjectName());
    Assert.assertEquals("1995-025A", file.getMetaData().getObjectID());
    Assert.assertEquals("EARTH", file.getMetaData().getCenterName());
    Assert.assertTrue(file.getMetaData().getHasCreatableBody());
    Assert.assertEquals(file.getMetaData().getCenterBody(), CelestialBodyFactory.getEarth());
    Assert.assertEquals(file.getMetaData().getFrame(), FramesFactory.getTEME());
    Assert.assertEquals(file.getMetaData().getTimeSystem(), CcsdsTimeScale.UTC);
    Assert.assertEquals("SGP/SGP4", file.getMetaData().getMeanElementTheory());
    Assert.assertEquals("TEME", file.getMetaData().getFrame().toString());
    Assert.assertTrue(file.getTLERelatedParametersComment().isEmpty());
    // Check Mean Keplerian elements data block;
    Assert.assertEquals(new AbsoluteDate(2007, 03, 05, 10, 34, 41.4264, TimeScalesFactory.getUTC()), file.getEpoch());
    Assert.assertEquals(file.getMeanMotion(), 1.00273272 * FastMath.PI / 43200.0, 1e-10);
    Assert.assertEquals(file.getE(), 0.0005013, 1e-10);
    Assert.assertEquals(file.getI(), FastMath.toRadians(3.0539), 1e-10);
    Assert.assertEquals(file.getRaan(), FastMath.toRadians(81.7939), 1e-10);
    Assert.assertEquals(file.getPa(), FastMath.toRadians(249.2363), 1e-10);
    Assert.assertEquals(file.getAnomaly(), FastMath.toRadians(150.1602), 1e-10);
    Assert.assertEquals(file.getMuParsed(), 398600.8 * 1e9, 1e-10);
    Assert.assertEquals(file.getMuSet(), 398600e9, 1e-10);
    Assert.assertEquals(file.getMuCreated(), CelestialBodyFactory.getEarth().getGM(), 1e-10);
    // Check TLE Related Parameters data block;
    Assert.assertEquals(0, file.getEphemerisType());
    Assert.assertEquals('U', file.getClassificationType());
    int[] noradIDExpected = new int[23581];
    int[] noradIDActual = new int[file.getNoradID()];
    Assert.assertEquals(noradIDExpected[0], noradIDActual[0]);
    Assert.assertEquals("0925", file.getElementSetNumber());
    int[] revAtEpochExpected = new int[4316];
    int[] revAtEpochActual = new int[file.getRevAtEpoch()];
    Assert.assertEquals(1.00273272 * FastMath.PI / 43200.0, file.getMeanMotion(), 1e-10);
    Assert.assertEquals(revAtEpochExpected[0], revAtEpochActual[0]);
    Assert.assertEquals(file.getBStar(), 0.0001, 1e-10);
    Assert.assertEquals(file.getMeanMotionDot(), -0.00000113 * FastMath.PI / 1.86624e9, 1e-12);
    Assert.assertEquals(file.getMeanMotionDotDot(), 0.0 * FastMath.PI / 5.3747712e13, 1e-10);
    Assert.assertEquals(1995, file.getMetaData().getLaunchYear());
    Assert.assertEquals(25, file.getMetaData().getLaunchNumber());
    Assert.assertEquals("A", file.getMetaData().getLaunchPiece());
    file.generateCartesianOrbit();
    file.generateKeplerianOrbit();
    try {
        file.generateSpacecraftState();
    } catch (OrekitException orekitException) {
        Assert.assertEquals(OrekitMessages.CCSDS_UNKNOWN_SPACECRAFT_MASS, orekitException.getSpecifier());
    } finally {
    }
    file.generateTLE();
}
Also used : InputStream(java.io.InputStream) OrekitException(org.orekit.errors.OrekitException) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 48 with AbsoluteDate

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

the class OPMParserTest method testParseOPM1.

@Test
public void testParseOPM1() throws OrekitException {
    // simple test for OPM file, contains p/v entries and other mandatory
    // data.
    final String ex = "/ccsds/OPMExample.txt";
    final OPMParser parser = new OPMParser().withMu(398600e9).withConventions(IERSConventions.IERS_2010).withSimpleEOP(true);
    final InputStream inEntry = getClass().getResourceAsStream(ex);
    final OPMFile file = parser.parse(inEntry, "OPMExample.txt");
    Assert.assertEquals(IERSConventions.IERS_2010, file.getConventions());
    // Check Header Block;
    Assert.assertEquals(2.0, file.getFormatVersion(), 1.0e-10);
    Assert.assertEquals(new AbsoluteDate(1998, 11, 06, 9, 23, 57, TimeScalesFactory.getUTC()), file.getCreationDate());
    Assert.assertEquals("JAXA", file.getOriginator());
    // Check Metadata Block;
    Assert.assertEquals("GODZILLA 5", file.getMetaData().getObjectName());
    Assert.assertEquals("1998-057A", file.getMetaData().getObjectID());
    Assert.assertEquals(1998, file.getMetaData().getLaunchYear());
    Assert.assertEquals(57, file.getMetaData().getLaunchNumber());
    Assert.assertEquals("A", file.getMetaData().getLaunchPiece());
    Assert.assertEquals("EARTH", file.getMetaData().getCenterName());
    Assert.assertTrue(file.getMetaData().getHasCreatableBody());
    Assert.assertEquals(CelestialBodyFactory.getEarth(), file.getMetaData().getCenterBody());
    Assert.assertEquals(CCSDSFrame.ITRF97.toString(), file.getMetaData().getFrame().getName());
    Assert.assertEquals(CcsdsTimeScale.TAI, file.getMetaData().getTimeSystem());
    Assert.assertFalse(file.hasCovarianceMatrix());
    // Check State Vector data Block;
    Assert.assertEquals(new AbsoluteDate(1998, 12, 18, 14, 28, 15.1172, TimeScalesFactory.getTAI()), file.getEpoch());
    checkPVEntry(new PVCoordinates(new Vector3D(6503514.000, 1239647.000, -717490.000), new Vector3D(-873.160, 8740.420, -4191.076)), file.getPVCoordinates());
    try {
        file.generateCartesianOrbit();
        Assert.fail("an exception should have been thrown");
    } catch (OrekitIllegalArgumentException oiae) {
        Assert.assertEquals(OrekitMessages.NON_PSEUDO_INERTIAL_FRAME, oiae.getSpecifier());
        Assert.assertEquals("ITRF97", oiae.getParts()[0]);
    }
    try {
        file.generateKeplerianOrbit();
        Assert.fail("an exception should have been thrown");
    } catch (OrekitIllegalArgumentException oiae) {
        Assert.assertEquals(OrekitMessages.NON_PSEUDO_INERTIAL_FRAME, oiae.getSpecifier());
        Assert.assertEquals("ITRF97", oiae.getParts()[0]);
    }
    try {
        file.generateSpacecraftState();
        Assert.fail("an exception should have been thrown");
    } catch (OrekitIllegalArgumentException oiae) {
        Assert.assertEquals(OrekitMessages.NON_PSEUDO_INERTIAL_FRAME, oiae.getSpecifier());
        Assert.assertEquals("ITRF97", oiae.getParts()[0]);
    }
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) InputStream(java.io.InputStream) PVCoordinates(org.orekit.utils.PVCoordinates) AbsoluteDate(org.orekit.time.AbsoluteDate) OrekitIllegalArgumentException(org.orekit.errors.OrekitIllegalArgumentException) Test(org.junit.Test)

Example 49 with AbsoluteDate

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

the class OPMParserTest method testParseOPM4.

@Test
public void testParseOPM4() throws OrekitException {
    // 
    final String ex = "/ccsds/OPMExample4.txt";
    OPMParser parser = new OPMParser().withMissionReferenceDate(new AbsoluteDate()).withConventions(IERSConventions.IERS_2010);
    final InputStream inEntry = getClass().getResourceAsStream(ex);
    final OPMFile file = parser.parse(inEntry, "OPMExample4.txt");
    file.getMetaData().getFrame().toString();
    file.getMetaData().getObjectID();
    file.getEpoch();
    file.getPVCoordinates();
    file.getMetaData().getFrame();
}
Also used : InputStream(java.io.InputStream) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Example 50 with AbsoluteDate

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

the class OPMParserTest method testParseOPM2.

@Test
public void testParseOPM2() throws OrekitException {
    // simple test for OPM file, contains all mandatory information plus
    // Keplerian elements, Spacecraft parameters and 2 maneuvers.
    final String ex = "/ccsds/OPMExample2.txt";
    final OPMParser parser = new OPMParser();
    final InputStream inEntry = getClass().getResourceAsStream(ex);
    final OPMFile file = parser.parse(inEntry, "OPMExample2.txt");
    try {
        file.getConventions();
        Assert.fail("an exception should have been thrown");
    } catch (OrekitException oe) {
        Assert.assertEquals(OrekitMessages.CCSDS_UNKNOWN_CONVENTIONS, oe.getSpecifier());
    }
    // Check Header Block;
    Assert.assertEquals(2.0, file.getFormatVersion(), 1.0e-10);
    ArrayList<String> headerComment = new ArrayList<String>();
    headerComment.add("Generated by GSOC, R. Kiehling");
    headerComment.add("Current intermediate orbit IO2 and maneuver planning data");
    Assert.assertEquals(headerComment, file.getHeaderComment());
    Assert.assertEquals(new AbsoluteDate(2000, 06, 03, 05, 33, 00, TimeScalesFactory.getUTC()), file.getCreationDate());
    Assert.assertEquals(file.getOriginator(), "GSOC");
    // Check Metadata Block;
    Assert.assertEquals("EUTELSAT W4", file.getMetaData().getObjectName());
    Assert.assertEquals("2000-028A", file.getMetaData().getObjectID());
    Assert.assertEquals("EARTH", file.getMetaData().getCenterName());
    Assert.assertTrue(file.getMetaData().getHasCreatableBody());
    Assert.assertEquals(CelestialBodyFactory.getEarth(), file.getMetaData().getCenterBody());
    Assert.assertEquals(FramesFactory.getGCRF(), file.getMetaData().getFrame());
    Assert.assertEquals(CcsdsTimeScale.GPS, file.getMetaData().getTimeSystem());
    Assert.assertEquals(0, file.getMetaDataComment().size());
    // Check Data State Vector block
    ArrayList<String> epochComment = new ArrayList<String>();
    epochComment.add("State Vector");
    Assert.assertEquals(epochComment, file.getEpochComment());
    Assert.assertEquals(new AbsoluteDate(2006, 06, 03, 00, 00, 00, TimeScalesFactory.getGPS()), file.getEpoch());
    checkPVEntry(new PVCoordinates(new Vector3D(6655994.2, -40218575.1, -82917.7), new Vector3D(3115.48208, 470.42605, -1.01495)), file.getPVCoordinates());
    // Check Data Keplerian Elements block
    Assert.assertTrue(file.hasKeplerianElements());
    ArrayList<String> keplerianElementsComment = new ArrayList<String>();
    keplerianElementsComment.add("Keplerian elements");
    Assert.assertEquals(keplerianElementsComment, file.getKeplerianElementsComment());
    Assert.assertEquals(41399512.3, file.getA(), 1e-6);
    Assert.assertEquals(0.020842611, file.getE(), 1e-10);
    Assert.assertEquals(FastMath.toRadians(0.117746), file.getI(), 1e-10);
    Assert.assertEquals(FastMath.toRadians(17.604721), file.getRaan(), 1e-10);
    Assert.assertEquals(FastMath.toRadians(218.242943), file.getPa(), 1e-10);
    Assert.assertEquals(PositionAngle.TRUE, file.getAnomalyType());
    Assert.assertEquals(FastMath.toRadians(41.922339), file.getAnomaly(), 1e-10);
    Assert.assertEquals(398600.4415 * 1e9, file.getMuParsed(), 1e-10);
    // Check Data Spacecraft block
    ArrayList<String> spacecraftComment = new ArrayList<String>();
    spacecraftComment.add("Spacecraft parameters");
    Assert.assertEquals(spacecraftComment, file.getSpacecraftComment());
    Assert.assertEquals(1913.000, file.getMass(), 1e-10);
    Assert.assertEquals(10.000, file.getSolarRadArea(), 1e-10);
    Assert.assertEquals(1.300, file.getSolarRadCoeff(), 1e-10);
    Assert.assertEquals(10.000, file.getDragArea(), 1e-10);
    Assert.assertEquals(2.300, file.getDragCoeff(), 1e-10);
    // Check Data Maneuvers block
    Assert.assertTrue(file.getHasManeuver());
    Assert.assertEquals(3, file.getNbManeuvers());
    ArrayList<String> stateManeuverComment0 = new ArrayList<String>();
    stateManeuverComment0.add("2 planned maneuvers");
    stateManeuverComment0.add("First maneuver: AMF-3");
    stateManeuverComment0.add("Non-impulsive, thrust direction fixed in inertial frame");
    Assert.assertEquals(stateManeuverComment0, file.getManeuver(0).getComment());
    Assert.assertEquals(new AbsoluteDate(2000, 06, 03, 9, 00, 34.1, TimeScalesFactory.getGPS()), file.getManeuvers().get(0).getEpochIgnition());
    Assert.assertEquals(132.6, file.getManeuver(0).getDuration(), 1e-10);
    Assert.assertEquals(-18.418, file.getManeuver(0).getDeltaMass(), 1e-10);
    Assert.assertNull(file.getManeuver(0).getRefLofType());
    Assert.assertEquals(FramesFactory.getEME2000(), file.getManeuver(0).getRefFrame());
    Assert.assertEquals(0.0, new Vector3D(-23.25700, 16.83160, -8.93444).distance(file.getManeuver(0).getDV()), 1.0e-10);
    ArrayList<String> stateManeuverComment1 = new ArrayList<String>();
    stateManeuverComment1.add("Second maneuver: first station acquisition maneuver");
    stateManeuverComment1.add("impulsive, thrust direction fixed in RTN frame");
    Assert.assertEquals(stateManeuverComment1, file.getManeuver(1).getComment());
    Assert.assertEquals(new AbsoluteDate(2000, 06, 05, 18, 59, 21, TimeScalesFactory.getGPS()), file.getManeuvers().get(1).getEpochIgnition());
    Assert.assertEquals(0.0, file.getManeuver(1).getDuration(), 1e-10);
    Assert.assertEquals(-1.469, file.getManeuver(1).getDeltaMass(), 1e-10);
    Assert.assertEquals(LOFType.QSW, file.getManeuver(1).getRefLofType());
    Assert.assertNull(file.getManeuver(1).getRefFrame());
    Assert.assertEquals(0.0, new Vector3D(1.015, -1.873, 0.0).distance(file.getManeuver(1).getDV()), 1.0e-10);
    Assert.assertTrue(file.getManeuver(2).getComment().isEmpty());
    Assert.assertEquals(new AbsoluteDate(2000, 06, 05, 18, 59, 51, TimeScalesFactory.getGPS()), file.getManeuvers().get(2).getEpochIgnition());
    Assert.assertEquals(0.0, file.getManeuver(2).getDuration(), 1e-10);
    Assert.assertEquals(-1.469, file.getManeuver(2).getDeltaMass(), 1e-10);
    Assert.assertEquals(LOFType.QSW, file.getManeuver(2).getRefLofType());
    Assert.assertNull(file.getManeuver(2).getRefFrame());
    Assert.assertEquals(0.0, new Vector3D(1.015, -1.873, 0.0).distance(file.getManeuver(2).getDV()), 1.0e-10);
    file.generateCartesianOrbit();
    file.generateKeplerianOrbit();
    file.generateSpacecraftState();
}
Also used : Vector3D(org.hipparchus.geometry.euclidean.threed.Vector3D) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) PVCoordinates(org.orekit.utils.PVCoordinates) OrekitException(org.orekit.errors.OrekitException) AbsoluteDate(org.orekit.time.AbsoluteDate) Test(org.junit.Test)

Aggregations

AbsoluteDate (org.orekit.time.AbsoluteDate)840 Test (org.junit.Test)632 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)321 FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)283 SpacecraftState (org.orekit.propagation.SpacecraftState)279 KeplerianOrbit (org.orekit.orbits.KeplerianOrbit)204 PVCoordinates (org.orekit.utils.PVCoordinates)193 Orbit (org.orekit.orbits.Orbit)157 Frame (org.orekit.frames.Frame)152 OrekitException (org.orekit.errors.OrekitException)141 DateComponents (org.orekit.time.DateComponents)134 TimeStampedPVCoordinates (org.orekit.utils.TimeStampedPVCoordinates)106 CartesianOrbit (org.orekit.orbits.CartesianOrbit)104 EquinoctialOrbit (org.orekit.orbits.EquinoctialOrbit)97 ArrayList (java.util.ArrayList)96 Propagator (org.orekit.propagation.Propagator)90 TimeScale (org.orekit.time.TimeScale)90 OneAxisEllipsoid (org.orekit.bodies.OneAxisEllipsoid)88 TimeComponents (org.orekit.time.TimeComponents)88 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)87