@Test public void testZeroInclination() throws OrekitException { TLE tle = new TLE( "1 26451U 00043A 10130.13784012 -.00000276 00000-0 10000-3 0 3866", "2 26451 000.0000 266.1044 0001893 160.7642 152.5985 01.00271160 35865"); TLEPropagator propagator = TLEPropagator.selectExtrapolator(tle); PVCoordinates pv = propagator.propagate(tle.getDate().shiftedBy(100)).getPVCoordinates(); Assert.assertEquals(42171546.979560345, pv.getPosition().getNorm(), 1.0e-3); Assert.assertEquals(3074.1890089357994, pv.getVelocity().getNorm(), 1.0e-6); }
@Test public void testCartesian() throws OrekitException { // Propagation of the initial at t + dt final double dt = 3200; propagator.setOrbitType(OrbitType.CARTESIAN); final PVCoordinates finalState = propagator.propagate(initDate.shiftedBy(dt)).getPVCoordinates(); final Vector3D pFin = finalState.getPosition(); final Vector3D vFin = finalState.getVelocity(); // Check results final PVCoordinates reference = initialState.shiftedBy(dt).getPVCoordinates(); final Vector3D pRef = reference.getPosition(); final Vector3D vRef = reference.getVelocity(); Assert.assertEquals(0, pRef.subtract(pFin).getNorm(), 2e-4); Assert.assertEquals(0, vRef.subtract(vFin).getNorm(), 7e-8); try { propagator.getGeneratedEphemeris(); Assert.fail("an exception should have been thrown"); } catch (IllegalStateException ise) { // expected } }
/** * Compute the transform at some date. * * @param date date at which the transform is desired * @return computed transform at specified date */ public Transform getTransform(final AbsoluteDate date) { // compute parameters evolution since reference epoch final double dt = date.durationFrom(epoch); final Vector3D dR = new Vector3D(1, rotationVector, dt, rotationRate); // build translation part final Transform translationTransform = new Transform(date, cartesian.shiftedBy(dt)); // build rotation part final double angle = dR.getNorm(); final Transform rotationTransform = new Transform( date, (angle < Precision.SAFE_MIN) ? Rotation.IDENTITY : new Rotation(dR, angle), rotationRate); // combine both parts return new Transform(date, translationTransform, rotationTransform); }
@Test public void testSatCodeCompliance() throws IOException, OrekitException, ParseException { BufferedReader rEntry = null; BufferedReader rResults = null; InputStream inEntry = TLETest.class.getResourceAsStream("/tle/extrapolationTest-data/SatCode-entry"); rEntry = new BufferedReader(new InputStreamReader(inEntry)); try { InputStream inResults = TLETest.class.getResourceAsStream("/tle/extrapolationTest-data/SatCode-results"); rResults = new BufferedReader(new InputStreamReader(inResults)); try { double cumulated = 0; // sum of all differences between test cases and OREKIT results boolean stop = false; String rline = rResults.readLine(); while (!stop) { if (rline == null) break; String[] title = rline.split(" "); if (title[0].matches("r")) { String eline; int count = 0; String[] header = new String[4]; for (eline = rEntry.readLine(); (eline != null) && (eline.charAt(0) == '#'); eline = rEntry.readLine()) { header[count++] = eline; } String line1 = eline; String line2 = rEntry.readLine(); Assert.assertTrue(TLE.isFormatOK(line1, line2)); TLE tle = new TLE(line1, line2); int satNum = Integer.parseInt(title[1]); Assert.assertTrue(satNum == tle.getSatelliteNumber()); TLEPropagator ex = TLEPropagator.selectExtrapolator(tle); for (rline = rResults.readLine(); (rline != null) && (rline.charAt(0) != 'r'); rline = rResults.readLine()) { String[] data = rline.split(" "); double minFromStart = Double.parseDouble(data[0]); double pX = 1000 * Double.parseDouble(data[1]); double pY = 1000 * Double.parseDouble(data[2]); double pZ = 1000 * Double.parseDouble(data[3]); double vX = 1000 * Double.parseDouble(data[4]); double vY = 1000 * Double.parseDouble(data[5]); double vZ = 1000 * Double.parseDouble(data[6]); Vector3D testPos = new Vector3D(pX, pY, pZ); Vector3D testVel = new Vector3D(vX, vY, vZ); AbsoluteDate date = tle.getDate().shiftedBy(minFromStart * 60); PVCoordinates results = ex.getPVCoordinates(date); double normDifPos = testPos.subtract(results.getPosition()).getNorm(); double normDifVel = testVel.subtract(results.getVelocity()).getNorm(); cumulated += normDifPos; Assert.assertEquals(0, normDifPos, 2e-3); ; Assert.assertEquals(0, normDifVel, 1e-5); } } } Assert.assertEquals(0, cumulated, 0.026); } finally { if (rResults != null) { rResults.close(); } } } finally { if (rEntry != null) { rEntry.close(); } } }
@Test public void testIntersectionFromPoints() throws OrekitException { AbsoluteDate date = new AbsoluteDate( new DateComponents(2008, 03, 21), TimeComponents.H12, TimeScalesFactory.getUTC()); Frame frame = FramesFactory.getITRF(IERSConventions.IERS_2010, true); OneAxisEllipsoid earth = new OneAxisEllipsoid(6378136.460, 1 / 298.257222101, frame); // Satellite on polar position // *************************** final double mu = 3.9860047e14; CircularOrbit circ = new CircularOrbit( 7178000.0, 0.5e-4, 0., FastMath.toRadians(90.), FastMath.toRadians(60.), FastMath.toRadians(90.), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu); // Transform satellite position to position/velocity parameters in EME2000 and ITRF200B PVCoordinates pvSatEME2000 = circ.getPVCoordinates(); PVCoordinates pvSatItrf = frame.getTransformTo(FramesFactory.getEME2000(), date).transformPVCoordinates(pvSatEME2000); Vector3D pSatItrf = pvSatItrf.getPosition(); // Test first visible surface points GeodeticPoint geoPoint = new GeodeticPoint(FastMath.toRadians(70.), FastMath.toRadians(60.), 0.); Vector3D pointItrf = earth.transform(geoPoint); Line line = new Line(pSatItrf, pointItrf, 1.0e-10); GeodeticPoint geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date); Assert.assertEquals(geoPoint.getLongitude(), geoInter.getLongitude(), Utils.epsilonAngle); Assert.assertEquals(geoPoint.getLatitude(), geoInter.getLatitude(), Utils.epsilonAngle); // Test second visible surface points geoPoint = new GeodeticPoint(FastMath.toRadians(65.), FastMath.toRadians(-120.), 0.); pointItrf = earth.transform(geoPoint); line = new Line(pSatItrf, pointItrf, 1.0e-10); geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date); Assert.assertEquals(geoPoint.getLongitude(), geoInter.getLongitude(), Utils.epsilonAngle); Assert.assertEquals(geoPoint.getLatitude(), geoInter.getLatitude(), Utils.epsilonAngle); // Test non visible surface points geoPoint = new GeodeticPoint(FastMath.toRadians(30.), FastMath.toRadians(60.), 0.); pointItrf = earth.transform(geoPoint); line = new Line(pSatItrf, pointItrf, 1.0e-10); geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date); // For polar satellite position, intersection point is at the same longitude but different // latitude Assert.assertEquals(1.04437199, geoInter.getLongitude(), Utils.epsilonAngle); Assert.assertEquals(1.36198012, geoInter.getLatitude(), Utils.epsilonAngle); // Satellite on equatorial position // ******************************** circ = new CircularOrbit( 7178000.0, 0.5e-4, 0., FastMath.toRadians(1.e-4), FastMath.toRadians(0.), FastMath.toRadians(0.), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu); // Transform satellite position to position/velocity parameters in EME2000 and ITRF200B pvSatEME2000 = circ.getPVCoordinates(); pvSatItrf = frame.getTransformTo(FramesFactory.getEME2000(), date).transformPVCoordinates(pvSatEME2000); pSatItrf = pvSatItrf.getPosition(); // Test first visible surface points geoPoint = new GeodeticPoint(FastMath.toRadians(5.), FastMath.toRadians(0.), 0.); pointItrf = earth.transform(geoPoint); line = new Line(pSatItrf, pointItrf, 1.0e-10); Assert.assertTrue(line.toSubSpace(pSatItrf).getX() < 0); geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date); Assert.assertEquals(geoPoint.getLongitude(), geoInter.getLongitude(), Utils.epsilonAngle); Assert.assertEquals(geoPoint.getLatitude(), geoInter.getLatitude(), Utils.epsilonAngle); // With the point opposite to satellite point along the line GeodeticPoint geoInter2 = earth.getIntersectionPoint( line, line.toSpace(new Vector1D(-line.toSubSpace(pSatItrf).getX())), frame, date); Assert.assertTrue( FastMath.abs(geoInter.getLongitude() - geoInter2.getLongitude()) > FastMath.toRadians(0.1)); Assert.assertTrue( FastMath.abs(geoInter.getLatitude() - geoInter2.getLatitude()) > FastMath.toRadians(0.1)); // Test second visible surface points geoPoint = new GeodeticPoint(FastMath.toRadians(-5.), FastMath.toRadians(0.), 0.); pointItrf = earth.transform(geoPoint); line = new Line(pSatItrf, pointItrf, 1.0e-10); geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date); Assert.assertEquals(geoPoint.getLongitude(), geoInter.getLongitude(), Utils.epsilonAngle); Assert.assertEquals(geoPoint.getLatitude(), geoInter.getLatitude(), Utils.epsilonAngle); // Test non visible surface points geoPoint = new GeodeticPoint(FastMath.toRadians(40.), FastMath.toRadians(0.), 0.); pointItrf = earth.transform(geoPoint); line = new Line(pSatItrf, pointItrf, 1.0e-10); geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date); Assert.assertEquals(-0.00768481, geoInter.getLongitude(), Utils.epsilonAngle); Assert.assertEquals(0.32180410, geoInter.getLatitude(), Utils.epsilonAngle); // Satellite on any position // ************************* circ = new CircularOrbit( 7178000.0, 0.5e-4, 0., FastMath.toRadians(50.), FastMath.toRadians(0.), FastMath.toRadians(90.), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu); // Transform satellite position to position/velocity parameters in EME2000 and ITRF200B pvSatEME2000 = circ.getPVCoordinates(); pvSatItrf = frame.getTransformTo(FramesFactory.getEME2000(), date).transformPVCoordinates(pvSatEME2000); pSatItrf = pvSatItrf.getPosition(); // Test first visible surface points geoPoint = new GeodeticPoint(FastMath.toRadians(40.), FastMath.toRadians(90.), 0.); pointItrf = earth.transform(geoPoint); line = new Line(pSatItrf, pointItrf, 1.0e-10); geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date); Assert.assertEquals(geoPoint.getLongitude(), geoInter.getLongitude(), Utils.epsilonAngle); Assert.assertEquals(geoPoint.getLatitude(), geoInter.getLatitude(), Utils.epsilonAngle); // Test second visible surface points geoPoint = new GeodeticPoint(FastMath.toRadians(60.), FastMath.toRadians(90.), 0.); pointItrf = earth.transform(geoPoint); line = new Line(pSatItrf, pointItrf, 1.0e-10); geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date); Assert.assertEquals(geoPoint.getLongitude(), geoInter.getLongitude(), Utils.epsilonAngle); Assert.assertEquals(geoPoint.getLatitude(), geoInter.getLatitude(), Utils.epsilonAngle); // Test non visible surface points geoPoint = new GeodeticPoint(FastMath.toRadians(0.), FastMath.toRadians(90.), 0.); pointItrf = earth.transform(geoPoint); line = new Line(pSatItrf, pointItrf, 1.0e-10); geoInter = earth.getIntersectionPoint(line, pSatItrf, frame, date); Assert.assertEquals( FastMath.toRadians(89.5364061088196), geoInter.getLongitude(), Utils.epsilonAngle); Assert.assertEquals( FastMath.toRadians(35.555543683351125), geoInter.getLatitude(), Utils.epsilonAngle); }
@Test public void testPropagationTypesHyperbolic() throws OrekitException, ParseException, IOException { SpacecraftState state = new SpacecraftState( new KeplerianOrbit( -10000000.0, 2.5, 0.3, 0, 0, 0.0, PositionAngle.TRUE, FramesFactory.getEME2000(), initDate, mu)); ForceModel gravityField = new HolmesFeatherstoneAttractionModel( FramesFactory.getITRF(IERSConventions.IERS_2010, true), GravityFieldFactory.getNormalizedProvider(5, 5)); propagator.addForceModel(gravityField); // Propagation of the initial at t + dt final PVCoordinates pv = state.getPVCoordinates(); final double dP = 0.001; final double dV = state.getMu() * dP / (pv.getPosition().getNormSq() * pv.getVelocity().getNorm()); final PVCoordinates pvcM = propagateInType(state, dP, OrbitType.CARTESIAN, PositionAngle.MEAN); final PVCoordinates pvkM = propagateInType(state, dP, OrbitType.KEPLERIAN, PositionAngle.MEAN); final PVCoordinates pvcE = propagateInType(state, dP, OrbitType.CARTESIAN, PositionAngle.ECCENTRIC); final PVCoordinates pvkE = propagateInType(state, dP, OrbitType.KEPLERIAN, PositionAngle.ECCENTRIC); final PVCoordinates pvcT = propagateInType(state, dP, OrbitType.CARTESIAN, PositionAngle.TRUE); final PVCoordinates pvkT = propagateInType(state, dP, OrbitType.KEPLERIAN, PositionAngle.TRUE); Assert.assertEquals(0, pvcM.getPosition().subtract(pvkT.getPosition()).getNorm() / dP, 0.3); Assert.assertEquals(0, pvcM.getVelocity().subtract(pvkT.getVelocity()).getNorm() / dV, 0.4); Assert.assertEquals(0, pvkM.getPosition().subtract(pvkT.getPosition()).getNorm() / dP, 0.2); Assert.assertEquals(0, pvkM.getVelocity().subtract(pvkT.getVelocity()).getNorm() / dV, 0.3); Assert.assertEquals(0, pvcE.getPosition().subtract(pvkT.getPosition()).getNorm() / dP, 0.3); Assert.assertEquals(0, pvcE.getVelocity().subtract(pvkT.getVelocity()).getNorm() / dV, 0.4); Assert.assertEquals(0, pvkE.getPosition().subtract(pvkT.getPosition()).getNorm() / dP, 0.009); Assert.assertEquals(0, pvkE.getVelocity().subtract(pvkT.getVelocity()).getNorm() / dV, 0.006); Assert.assertEquals(0, pvcT.getPosition().subtract(pvkT.getPosition()).getNorm() / dP, 0.3); Assert.assertEquals(0, pvcT.getVelocity().subtract(pvkT.getVelocity()).getNorm() / dV, 0.4); }
@Test public void testPropagationTypesElliptical() throws OrekitException, ParseException, IOException { ForceModel gravityField = new HolmesFeatherstoneAttractionModel( FramesFactory.getITRF(IERSConventions.IERS_2010, true), GravityFieldFactory.getNormalizedProvider(5, 5)); propagator.addForceModel(gravityField); // Propagation of the initial at t + dt final PVCoordinates pv = initialState.getPVCoordinates(); final double dP = 0.001; final double dV = initialState.getMu() * dP / (pv.getPosition().getNormSq() * pv.getVelocity().getNorm()); final PVCoordinates pvcM = propagateInType(initialState, dP, OrbitType.CARTESIAN, PositionAngle.MEAN); final PVCoordinates pviM = propagateInType(initialState, dP, OrbitType.CIRCULAR, PositionAngle.MEAN); final PVCoordinates pveM = propagateInType(initialState, dP, OrbitType.EQUINOCTIAL, PositionAngle.MEAN); final PVCoordinates pvkM = propagateInType(initialState, dP, OrbitType.KEPLERIAN, PositionAngle.MEAN); final PVCoordinates pvcE = propagateInType(initialState, dP, OrbitType.CARTESIAN, PositionAngle.ECCENTRIC); final PVCoordinates pviE = propagateInType(initialState, dP, OrbitType.CIRCULAR, PositionAngle.ECCENTRIC); final PVCoordinates pveE = propagateInType(initialState, dP, OrbitType.EQUINOCTIAL, PositionAngle.ECCENTRIC); final PVCoordinates pvkE = propagateInType(initialState, dP, OrbitType.KEPLERIAN, PositionAngle.ECCENTRIC); final PVCoordinates pvcT = propagateInType(initialState, dP, OrbitType.CARTESIAN, PositionAngle.TRUE); final PVCoordinates pviT = propagateInType(initialState, dP, OrbitType.CIRCULAR, PositionAngle.TRUE); final PVCoordinates pveT = propagateInType(initialState, dP, OrbitType.EQUINOCTIAL, PositionAngle.TRUE); final PVCoordinates pvkT = propagateInType(initialState, dP, OrbitType.KEPLERIAN, PositionAngle.TRUE); Assert.assertEquals(0, pvcM.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 3.0); Assert.assertEquals(0, pvcM.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 2.0); Assert.assertEquals(0, pviM.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.6); Assert.assertEquals(0, pviM.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.4); Assert.assertEquals(0, pvkM.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.5); Assert.assertEquals(0, pvkM.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.3); Assert.assertEquals(0, pveM.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.2); Assert.assertEquals(0, pveM.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.2); Assert.assertEquals(0, pvcE.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 3.0); Assert.assertEquals(0, pvcE.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 2.0); Assert.assertEquals(0, pviE.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.03); Assert.assertEquals(0, pviE.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.04); Assert.assertEquals(0, pvkE.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.4); Assert.assertEquals(0, pvkE.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.3); Assert.assertEquals(0, pveE.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.2); Assert.assertEquals(0, pveE.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.07); Assert.assertEquals(0, pvcT.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 3.0); Assert.assertEquals(0, pvcT.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 2.0); Assert.assertEquals(0, pviT.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.3); Assert.assertEquals(0, pviT.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.2); Assert.assertEquals(0, pvkT.getPosition().subtract(pveT.getPosition()).getNorm() / dP, 0.4); Assert.assertEquals(0, pvkT.getVelocity().subtract(pveT.getVelocity()).getNorm() / dV, 0.2); }