/** * Program entry point. * * @param args program arguments */ public static void main(String[] args) { try { // configure Orekit Autoconfiguration.configureOrekit(); // input/out File input = new File(VisibilityCircle.class.getResource("/visibility-circle.in").toURI().getPath()); File output = new File(input.getParentFile(), "visibility-circle.csv"); new VisibilityCircle().run(input, output, ","); System.out.println("visibility circle saved as file " + output); } catch (URISyntaxException use) { System.err.println(use.getLocalizedMessage()); System.exit(1); } catch (IOException ioe) { System.err.println(ioe.getLocalizedMessage()); System.exit(1); } catch (IllegalArgumentException iae) { System.err.println(iae.getLocalizedMessage()); System.exit(1); } catch (OrekitException oe) { System.err.println(oe.getLocalizedMessage()); System.exit(1); } }
@Test public void testUnsupportedParameter() throws OrekitException { Orbit initialOrbit = new KeplerianOrbit( 8000000.0, 0.01, 0.1, 0.7, 0, 1.2, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, Constants.EIGEN5C_EARTH_MU); double dP = 0.001; NumericalPropagator propagator = setUpPropagator( initialOrbit, dP, OrbitType.EQUINOCTIAL, PositionAngle.TRUE, new ThirdBodyAttraction(CelestialBodyFactory.getSun()), new ThirdBodyAttraction(CelestialBodyFactory.getMoon())); PartialDerivativesEquations partials = new PartialDerivativesEquations("partials", propagator); partials.selectParamAndStep("non-existent", 1.0); try { partials.computeDerivatives(new SpacecraftState(initialOrbit), new double[6]); Assert.fail("an exception should have been thrown"); } catch (OrekitException oe) { Assert.assertEquals(OrekitMessages.UNSUPPORTED_PARAMETER_NAME, oe.getSpecifier()); } }
@Test public void testMiss() throws OrekitException { final CircularOrbit circ = new CircularOrbit( 7178000.0, 0.5e-4, -0.5e-4, FastMath.toRadians(0.), FastMath.toRadians(270.), FastMath.toRadians(5.300), PositionAngle.MEAN, FramesFactory.getEME2000(), date, mu); final LofOffset upsideDown = new LofOffset(circ.getFrame(), LOFType.VVLH, RotationOrder.XYX, FastMath.PI, 0, 0); final LofOffsetPointing pointing = new LofOffsetPointing(earthSpheric, upsideDown, Vector3D.PLUS_K); try { pointing.getTargetPV(circ, date, circ.getFrame()); Assert.fail("an exception should have been thrown"); } catch (OrekitException oe) { Assert.assertEquals( OrekitMessages.ATTITUDE_POINTING_LAW_DOES_NOT_POINT_TO_GROUND, oe.getSpecifier()); } }
/** {@inheritDoc} */ @Override public void handleStep(final StepInterpolator interpolator, final boolean isLast) { // Reset the short periodics coefficients in order to ensure that interpolation // will be based on current step only mapper.resetShortPeriodicsCoefficients(); // Get the grid points to compute final double[] interpolationPoints = grid.getGridPoints(interpolator.getPreviousTime(), interpolator.getCurrentTime()); for (final double time : interpolationPoints) { // Move the interpolator to the grid point interpolator.setInterpolatedTime(time); // Build the corresponding state final SpacecraftState state; try { state = mapper.mapArrayToState(time, interpolator.getInterpolatedState(), true); // Launch the computation of short periodic coefficients for this date mapper.computeShortPeriodicsCoefficients(state); } catch (MaxCountExceededException e) { e.printStackTrace(); } catch (OrekitException e) { e.printStackTrace(); } } }
private void checkException(String name, OrekitMessages message) { Utils.setDataRoot("USNO"); TimeScalesFactory.addUTCTAIOffsetsLoader(new TAIUTCDatFilesLoader(name)); try { TimeScalesFactory.getUTC(); Assert.fail("an exception should have been thrown"); } catch (OrekitException oe) { Assert.assertEquals(message, oe.getSpecifier()); } }
@Test(expected = OrekitException.class) public void ioException() throws OrekitException { try { new NetworkCrawler(url("regular-data/UTC-TAI.history")) .feed(Pattern.compile(".*"), new IOExceptionLoader()); } catch (OrekitException oe) { // expected behavior Assert.assertNotNull(oe.getCause()); Assert.assertEquals(IOException.class, oe.getCause().getClass()); Assert.assertEquals("dummy error", oe.getMessage()); throw oe; } }
/** * Ensure the defining frame is a pseudo-inertial frame. * * @param frame frame to check * @exception IllegalArgumentException if frame is not a {@link Frame#isPseudoInertial * pseudo-inertial frame} */ private static void ensurePseudoInertialFrame(final Frame frame) throws IllegalArgumentException { if (!frame.isPseudoInertial()) { throw OrekitException.createIllegalArgumentException( OrekitMessages.NON_PSEUDO_INERTIAL_FRAME_NOT_SUITABLE_FOR_DEFINING_ORBITS, frame.getName()); } }
/** * Replace the deserialized data transfer object with a {@link GTODProvider}. * * @return replacement {@link GTODProvider} */ private Object readResolve() { try { // retrieve a managed frame return new GTODProvider(conventions, eopHistory); } catch (OrekitException oe) { throw OrekitException.createInternalError(oe); } }
/* (non-Javadoc) * @see org.orekit.propagation.sampling.OrekitFixedStepHandler#handleStep(org.orekit.propagation.SpacecraftState, boolean) */ public void handleStep(SpacecraftState currentState, boolean isLast) throws PropagationException { /** Create position vector. */ D3Vector position = new D3Vector( "", "Position", "Position", "The orbital position of the satellite at the given time.", currentState.getOrbit().getPVCoordinates().getPosition().getX(), currentState.getOrbit().getPVCoordinates().getPosition().getY(), currentState.getOrbit().getPVCoordinates().getPosition().getZ()); /** Create velocity vector. */ D3Vector velocity = new D3Vector( "", "Velocity", "Velocity", "The orbital velocity of the satellite at the given time", currentState.getOrbit().getPVCoordinates().getVelocity().getX(), currentState.getOrbit().getPVCoordinates().getVelocity().getY(), currentState.getOrbit().getPVCoordinates().getVelocity().getZ()); try { /** Create orbital state. */ OrbitalState state = new OrbitalState( predictor.name, orbitalStateName, orbitalStateDescription, currentState.getDate().toDate(TimeScalesFactory.getUTC()).getTime(), datasetidentifier, satellite, position, velocity); /** Send the orbital state on the response stream. */ predictor.addResult(state); } catch (OrekitException e) { e.printStackTrace(); } }
@Before public void setUp() { try { Utils.setDataRoot("regular-data"); // Computation date date = new AbsoluteDate( new DateComponents(2008, 04, 07), TimeComponents.H00, TimeScalesFactory.getUTC()); // Body mu mu = 3.9860047e14; // Reference frame = ITRF frameItrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true); // Elliptic earth shape earthSpheric = new OneAxisEllipsoid(6378136.460, 0., frameItrf); } catch (OrekitException oe) { Assert.fail(oe.getMessage()); } }
@Test public void testWrongParametersDimension() throws OrekitException { Orbit initialOrbit = new KeplerianOrbit( 8000000.0, 0.01, 0.1, 0.7, 0, 1.2, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, Constants.EIGEN5C_EARTH_MU); double dP = 0.001; NumericalPropagator propagator = setUpPropagator( initialOrbit, dP, OrbitType.EQUINOCTIAL, PositionAngle.TRUE, new ThirdBodyAttraction(CelestialBodyFactory.getSun()), new ThirdBodyAttraction(CelestialBodyFactory.getMoon())); PartialDerivativesEquations partials = new PartialDerivativesEquations("partials", propagator); partials.setInitialJacobians( new SpacecraftState(initialOrbit), new double[6][6], new double[6][3]); partials.selectParameters("Sun attraction coefficient"); try { partials.computeDerivatives(new SpacecraftState(initialOrbit), new double[6]); Assert.fail("an exception should have been thrown"); } catch (OrekitException oe) { Assert.assertEquals( OrekitMessages.INITIAL_MATRIX_AND_PARAMETERS_NUMBER_MISMATCH, oe.getSpecifier()); } }
/** * Compute the Jacobian of the Cartesian parameters with respect to the orbital parameters. * * <p>Element {@code jacobian[i][j]} is the derivative of Cartesian coordinate i of the orbit with * respect to orbital parameter j. This means each row corresponds to one Cartesian coordinate x, * y, z, xdot, ydot, zdot whereas columns 0 to 5 correspond to the orbital parameters. * * @param type type of the position angle to use * @param jacobian placeholder 6x6 (or larger) matrix to be filled with the Jacobian, if matrix is * larger than 6x6, only the 6x6 upper left corner will be modified */ public void getJacobianWrtParameters(final PositionAngle type, final double[][] jacobian) { final double[][] cachedJacobian; synchronized (this) { switch (type) { case MEAN: if (jacobianWrtParametersMean == null) { // first call, we need to compute the jacobian and cache it jacobianWrtParametersMean = createInverseJacobian(type); } cachedJacobian = jacobianWrtParametersMean; break; case ECCENTRIC: if (jacobianWrtParametersEccentric == null) { // first call, we need to compute the jacobian and cache it jacobianWrtParametersEccentric = createInverseJacobian(type); } cachedJacobian = jacobianWrtParametersEccentric; break; case TRUE: if (jacobianWrtParametersTrue == null) { // first call, we need to compute the jacobian and cache it jacobianWrtParametersTrue = createInverseJacobian(type); } cachedJacobian = jacobianWrtParametersTrue; break; default: throw OrekitException.createInternalError(null); } } // fill the user-provided array for (int i = 0; i < cachedJacobian.length; ++i) { System.arraycopy(cachedJacobian[i], 0, jacobian[i], 0, cachedJacobian[i].length); } }
@Test public void testEphemerisAdditionalState() throws OrekitException, IOException { // Propagation of the initial at t + dt final double dt = -3200; final double rate = 2.0; propagator.addAdditionalStateProvider( new AdditionalStateProvider() { public String getName() { return "squaredA"; } public double[] getAdditionalState(SpacecraftState state) { return new double[] {state.getA() * state.getA()}; } }); propagator.addAdditionalEquations( new AdditionalEquations() { public String getName() { return "extra"; } public double[] computeDerivatives(SpacecraftState s, double[] pDot) { pDot[0] = rate; return null; } }); propagator.setInitialState(propagator.getInitialState().addAdditionalState("extra", 1.5)); propagator.setOrbitType(OrbitType.CARTESIAN); propagator.setEphemerisMode(); propagator.propagate(initDate.shiftedBy(dt)); final BoundedPropagator ephemeris1 = propagator.getGeneratedEphemeris(); Assert.assertEquals(initDate.shiftedBy(dt), ephemeris1.getMinDate()); Assert.assertEquals(initDate, ephemeris1.getMaxDate()); try { ephemeris1.propagate(ephemeris1.getMinDate().shiftedBy(-10.0)); Assert.fail("an exception should have been thrown"); } catch (PropagationException pe) { Assert.assertEquals(OrekitMessages.OUT_OF_RANGE_EPHEMERIDES_DATE, pe.getSpecifier()); } try { ephemeris1.propagate(ephemeris1.getMaxDate().shiftedBy(+10.0)); Assert.fail("an exception should have been thrown"); } catch (PropagationException pe) { Assert.assertEquals(OrekitMessages.OUT_OF_RANGE_EPHEMERIDES_DATE, pe.getSpecifier()); } double shift = -60; SpacecraftState s = ephemeris1.propagate(initDate.shiftedBy(shift)); Assert.assertEquals(2, s.getAdditionalStates().size()); Assert.assertTrue(s.hasAdditionalState("squaredA")); Assert.assertTrue(s.hasAdditionalState("extra")); Assert.assertEquals(s.getA() * s.getA(), s.getAdditionalState("squaredA")[0], 1.0e-10); Assert.assertEquals(1.5 + shift * rate, s.getAdditionalState("extra")[0], 1.0e-10); try { ephemeris1.resetInitialState(s); Assert.fail("an exception should have been thrown"); } catch (OrekitException oe) { Assert.assertEquals(OrekitMessages.NON_RESETABLE_STATE, oe.getSpecifier()); } }
@Test public void testAdditionalStateEvent() throws OrekitException { propagator.addAdditionalEquations( new AdditionalEquations() { public String getName() { return "linear"; } public double[] computeDerivatives(SpacecraftState s, double[] pDot) { pDot[0] = 1.0; return new double[7]; } }); try { propagator.addAdditionalEquations( new AdditionalEquations() { public String getName() { return "linear"; } public double[] computeDerivatives(SpacecraftState s, double[] pDot) { pDot[0] = 1.0; return new double[7]; } }); Assert.fail("an exception should have been thrown"); } catch (OrekitException oe) { Assert.assertEquals(oe.getSpecifier(), OrekitMessages.ADDITIONAL_STATE_NAME_ALREADY_IN_USE); } try { propagator.addAdditionalStateProvider( new AdditionalStateProvider() { public String getName() { return "linear"; } public double[] getAdditionalState(SpacecraftState state) { return null; } }); Assert.fail("an exception should have been thrown"); } catch (OrekitException oe) { Assert.assertEquals(oe.getSpecifier(), OrekitMessages.ADDITIONAL_STATE_NAME_ALREADY_IN_USE); } propagator.addAdditionalStateProvider( new AdditionalStateProvider() { public String getName() { return "constant"; } public double[] getAdditionalState(SpacecraftState state) { return new double[] {1.0}; } }); Assert.assertTrue(propagator.isAdditionalStateManaged("linear")); Assert.assertTrue(propagator.isAdditionalStateManaged("constant")); Assert.assertFalse(propagator.isAdditionalStateManaged("non-managed")); Assert.assertEquals(2, propagator.getManagedAdditionalStates().length); propagator.setInitialState(propagator.getInitialState().addAdditionalState("linear", 1.5)); CheckingHandler<AdditionalStateLinearDetector> checking = new CheckingHandler<AdditionalStateLinearDetector>(Action.STOP); propagator.addEventDetector( new AdditionalStateLinearDetector(10.0, 1.0e-8).withHandler(checking)); final double dt = 3200; checking.assertEvent(false); final SpacecraftState finalState = propagator.propagate(initDate.shiftedBy(dt)); checking.assertEvent(true); Assert.assertEquals(3.0, finalState.getAdditionalState("linear")[0], 1.0e-8); Assert.assertEquals(1.5, finalState.getDate().durationFrom(initDate), 1.0e-8); }