Search in sources :

Example 6 with OrekitExceptionWrapper

use of org.orekit.errors.OrekitExceptionWrapper in project Orekit by CS-SI.

the class JacobianPropagatorConverter method getModel.

/**
 * {@inheritDoc}
 */
protected MultivariateJacobianFunction getModel() {
    return new MultivariateJacobianFunction() {

        /**
         * {@inheritDoc}
         */
        public Pair<RealVector, RealMatrix> value(final RealVector point) throws IllegalArgumentException, OrekitExceptionWrapper {
            try {
                final RealVector value = new ArrayRealVector(getTargetSize());
                final RealMatrix jacobian = MatrixUtils.createRealMatrix(getTargetSize(), point.getDimension());
                final NumericalPropagator prop = builder.buildPropagator(point.toArray());
                final int stateSize = isOnlyPosition() ? 3 : 6;
                final ParameterDriversList orbitalParameters = builder.getOrbitalParametersDrivers();
                final PartialDerivativesEquations pde = new PartialDerivativesEquations("pde", prop);
                final ParameterDriversList propagationParameters = pde.getSelectedParameters();
                prop.setInitialState(pde.setInitialJacobians(prop.getInitialState()));
                final JacobiansMapper mapper = pde.getMapper();
                final List<SpacecraftState> sample = getSample();
                for (int i = 0; i < sample.size(); ++i) {
                    final int row = i * stateSize;
                    if (prop.getInitialState().getDate().equals(sample.get(i).getDate())) {
                        // use initial state and Jacobians
                        fillRows(value, jacobian, row, prop.getInitialState(), stateSize, orbitalParameters, propagationParameters, mapper);
                    } else {
                        // use a date detector to pick up state and Jacobians
                        prop.addEventDetector(new DateDetector(sample.get(i).getDate()).withHandler(new EventHandler<DateDetector>() {

                            /**
                             * {@inheritDoc}
                             */
                            @Override
                            public Action eventOccurred(final SpacecraftState state, final DateDetector detector, final boolean increasing) throws OrekitException {
                                fillRows(value, jacobian, row, state, stateSize, orbitalParameters, propagationParameters, mapper);
                                return row + stateSize >= getTargetSize() ? Action.STOP : Action.CONTINUE;
                            }
                        }));
                    }
                }
                prop.propagate(sample.get(sample.size() - 1).getDate().shiftedBy(10.0));
                return new Pair<RealVector, RealMatrix>(value, jacobian);
            } catch (OrekitException ex) {
                throw new OrekitExceptionWrapper(ex);
            }
        }
    };
}
Also used : DateDetector(org.orekit.propagation.events.DateDetector) OrekitExceptionWrapper(org.orekit.errors.OrekitExceptionWrapper) ArrayRealVector(org.hipparchus.linear.ArrayRealVector) EventHandler(org.orekit.propagation.events.handlers.EventHandler) MultivariateJacobianFunction(org.hipparchus.optim.nonlinear.vector.leastsquares.MultivariateJacobianFunction) SpacecraftState(org.orekit.propagation.SpacecraftState) RealMatrix(org.hipparchus.linear.RealMatrix) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) ParameterDriversList(org.orekit.utils.ParameterDriversList) PartialDerivativesEquations(org.orekit.propagation.numerical.PartialDerivativesEquations) ArrayRealVector(org.hipparchus.linear.ArrayRealVector) RealVector(org.hipparchus.linear.RealVector) OrekitException(org.orekit.errors.OrekitException) JacobiansMapper(org.orekit.propagation.numerical.JacobiansMapper) Pair(org.hipparchus.util.Pair)

Example 7 with OrekitExceptionWrapper

use of org.orekit.errors.OrekitExceptionWrapper in project Orekit by CS-SI.

the class FieldIntegratedEphemeris method basicPropagate.

/**
 * {@inheritDoc}
 */
@Override
protected FieldSpacecraftState<T> basicPropagate(final FieldAbsoluteDate<T> date) throws OrekitException {
    try {
        final FieldODEStateAndDerivative<T> os = getInterpolatedState(date);
        FieldSpacecraftState<T> state = mapper.mapArrayToState(mapper.mapDoubleToDate(os.getTime(), date), os.getPrimaryState(), os.getPrimaryDerivative(), meanFieldOrbit);
        for (Map.Entry<String, T[]> initial : unmanaged.entrySet()) {
            state = state.addAdditionalState(initial.getKey(), initial.getValue());
        }
        return state;
    } catch (OrekitExceptionWrapper oew) {
        throw new OrekitException(oew.getException());
    }
}
Also used : OrekitExceptionWrapper(org.orekit.errors.OrekitExceptionWrapper) OrekitException(org.orekit.errors.OrekitException) Map(java.util.Map)

Example 8 with OrekitExceptionWrapper

use of org.orekit.errors.OrekitExceptionWrapper in project Orekit by CS-SI.

the class IntegratedEphemeris method basicPropagate.

/**
 * {@inheritDoc}
 */
@Override
protected SpacecraftState basicPropagate(final AbsoluteDate date) throws OrekitException {
    try {
        final ODEStateAndDerivative os = getInterpolatedState(date);
        SpacecraftState state = mapper.mapArrayToState(mapper.mapDoubleToDate(os.getTime(), date), os.getPrimaryState(), os.getPrimaryDerivative(), meanOrbit);
        for (Map.Entry<String, double[]> initial : unmanaged.entrySet()) {
            state = state.addAdditionalState(initial.getKey(), initial.getValue());
        }
        return state;
    } catch (OrekitExceptionWrapper oew) {
        throw oew.getException();
    }
}
Also used : SpacecraftState(org.orekit.propagation.SpacecraftState) OrekitExceptionWrapper(org.orekit.errors.OrekitExceptionWrapper) HashMap(java.util.HashMap) Map(java.util.Map) ODEStateAndDerivative(org.hipparchus.ode.ODEStateAndDerivative)

Example 9 with OrekitExceptionWrapper

use of org.orekit.errors.OrekitExceptionWrapper in project Orekit by CS-SI.

the class Model method value.

/**
 * {@inheritDoc}
 */
@Override
public Pair<RealVector, RealMatrix> value(final RealVector point) throws OrekitExceptionWrapper {
    try {
        // Set up the propagators parallelizer
        final NumericalPropagator[] propagators = createPropagators(point);
        final Orbit[] orbits = new Orbit[propagators.length];
        for (int i = 0; i < propagators.length; ++i) {
            mappers[i] = configureDerivatives(propagators[i]);
            orbits[i] = propagators[i].getInitialState().getOrbit();
        }
        final PropagatorsParallelizer parallelizer = new PropagatorsParallelizer(Arrays.asList(propagators), configureMeasurements(point));
        // Reset value and Jacobian
        evaluations.clear();
        value.set(0.0);
        for (int i = 0; i < jacobian.getRowDimension(); ++i) {
            for (int j = 0; j < jacobian.getColumnDimension(); ++j) {
                jacobian.setEntry(i, j, 0.0);
            }
        }
        // Run the propagation, gathering residuals on the fly
        if (forwardPropagation) {
            // Propagate forward from firstDate
            parallelizer.propagate(firstDate.shiftedBy(-1.0), lastDate.shiftedBy(+1.0));
        } else {
            // Propagate backward from lastDate
            parallelizer.propagate(lastDate.shiftedBy(+1.0), firstDate.shiftedBy(-1.0));
        }
        observer.modelCalled(orbits, evaluations);
        return new Pair<RealVector, RealMatrix>(value, jacobian);
    } catch (OrekitException oe) {
        throw new OrekitExceptionWrapper(oe);
    }
}
Also used : OrekitExceptionWrapper(org.orekit.errors.OrekitExceptionWrapper) Orbit(org.orekit.orbits.Orbit) NumericalPropagator(org.orekit.propagation.numerical.NumericalPropagator) PropagatorsParallelizer(org.orekit.propagation.PropagatorsParallelizer) OrekitException(org.orekit.errors.OrekitException) Pair(org.hipparchus.util.Pair)

Example 10 with OrekitExceptionWrapper

use of org.orekit.errors.OrekitExceptionWrapper in project Orekit by CS-SI.

the class Model method getInnovation.

/**
 * {@inheritDoc}
 */
@Override
public RealVector getInnovation(final MeasurementDecorator measurement, final NonLinearEvolution evolution, final RealMatrix innovationCovarianceMatrix) throws OrekitExceptionWrapper {
    try {
        // Apply the dynamic outlier filter, if it exists
        applyDynamicOutlierFilter(predictedMeasurement, innovationCovarianceMatrix);
        if (predictedMeasurement.getStatus() == EstimatedMeasurement.Status.REJECTED) {
            // set innovation to null to notify filter measurement is rejected
            return null;
        } else {
            // Normalized innovation of the measurement (Nx1)
            final double[] observed = predictedMeasurement.getObservedMeasurement().getObservedValue();
            final double[] estimated = predictedMeasurement.getEstimatedValue();
            final double[] sigma = predictedMeasurement.getObservedMeasurement().getTheoreticalStandardDeviation();
            final double[] residuals = new double[observed.length];
            for (int i = 0; i < observed.length; i++) {
                residuals[i] = (observed[i] - estimated[i]) / sigma[i];
            }
            return MatrixUtils.createRealVector(residuals);
        }
    } catch (OrekitException oe) {
        throw new OrekitExceptionWrapper(oe);
    }
}
Also used : OrekitExceptionWrapper(org.orekit.errors.OrekitExceptionWrapper) OrekitException(org.orekit.errors.OrekitException)

Aggregations

OrekitExceptionWrapper (org.orekit.errors.OrekitExceptionWrapper)27 OrekitException (org.orekit.errors.OrekitException)25 UnivariateFunction (org.hipparchus.analysis.UnivariateFunction)10 BracketingNthOrderBrentSolver (org.hipparchus.analysis.solvers.BracketingNthOrderBrentSolver)9 SpacecraftState (org.orekit.propagation.SpacecraftState)9 AbsoluteDate (org.orekit.time.AbsoluteDate)8 Map (java.util.Map)7 UnivariateSolver (org.hipparchus.analysis.solvers.UnivariateSolver)7 MathRuntimeException (org.hipparchus.exception.MathRuntimeException)6 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)6 Frame (org.orekit.frames.Frame)5 Transform (org.orekit.frames.Transform)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)3 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)3 FiniteDifferencesDifferentiator (org.hipparchus.analysis.differentiation.FiniteDifferencesDifferentiator)3 NumericalPropagator (org.orekit.propagation.numerical.NumericalPropagator)3 UnivariateVectorFunction (org.hipparchus.analysis.UnivariateVectorFunction)2 UnivariateDifferentiableVectorFunction (org.hipparchus.analysis.differentiation.UnivariateDifferentiableVectorFunction)2 BracketedUnivariateSolver (org.hipparchus.analysis.solvers.BracketedUnivariateSolver)2