Search in sources :

Example 96 with FieldAbsoluteDate

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

the class FieldEventDetectorTest method doTestIssue108Analytical.

private <T extends RealFieldElement<T>> void doTestIssue108Analytical(Field<T> field) throws OrekitException {
    final T zero = field.getZero();
    final TimeScale utc = TimeScalesFactory.getUTC();
    final FieldVector3D<T> position = new FieldVector3D<>(zero.add(-6142438.668), zero.add(3492467.56), zero.add(-25767.257));
    final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(505.848), zero.add(942.781), zero.add(7435.922));
    final FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, 2003, 9, 16, utc);
    final FieldOrbit<T> orbit = new FieldCircularOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), date, mu);
    final T step = zero.add(60.0);
    final int n = 100;
    FieldKeplerianPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit);
    GCallsCounter<T> counter = new GCallsCounter<>(zero.add(100000.0), zero.add(1.0e-6), 20, new FieldStopOnEvent<GCallsCounter<T>, T>());
    propagator.addEventDetector(counter);
    propagator.setMasterMode(step, new FieldOrekitFixedStepHandler<T>() {

        public void handleStep(FieldSpacecraftState<T> currentState, boolean isLast) {
        }
    });
    propagator.propagate(date.shiftedBy(step.multiply(n)));
    Assert.assertEquals(n + 1, counter.getCount());
}
Also used : TimeScale(org.orekit.time.TimeScale) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldKeplerianPropagator(org.orekit.propagation.analytical.FieldKeplerianPropagator) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) FieldCircularOrbit(org.orekit.orbits.FieldCircularOrbit)

Example 97 with FieldAbsoluteDate

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

the class FieldEventDetectorTest method doTestBasicScheduling.

private <T extends RealFieldElement<T>> void doTestBasicScheduling(Field<T> field) throws OrekitException {
    final T zero = field.getZero();
    final TimeScale utc = TimeScalesFactory.getUTC();
    final FieldVector3D<T> position = new FieldVector3D<>(zero.add(-6142438.668), zero.add(3492467.56), zero.add(-25767.257));
    final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(505.848), zero.add(942.781), zero.add(7435.922));
    final FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, 2003, 9, 16, utc);
    final FieldOrbit<T> orbit = new FieldCircularOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), date, mu);
    FieldPropagator<T> propagator = new FieldKeplerianPropagator<>(orbit);
    T stepSize = zero.add(60.0);
    OutOfOrderChecker<T> checker = new OutOfOrderChecker<>(stepSize);
    propagator.addEventDetector(new FieldDateDetector<>(date.shiftedBy(stepSize.multiply(5.25))).withHandler(checker));
    propagator.setMasterMode(stepSize, checker);
    propagator.propagate(date.shiftedBy(stepSize.multiply(10)));
    Assert.assertTrue(checker.outOfOrderCallDetected());
}
Also used : TimeScale(org.orekit.time.TimeScale) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldKeplerianPropagator(org.orekit.propagation.analytical.FieldKeplerianPropagator) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) FieldCircularOrbit(org.orekit.orbits.FieldCircularOrbit)

Example 98 with FieldAbsoluteDate

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

the class FieldApsideDetectorTest method doTestSimple.

private <T extends RealFieldElement<T>> void doTestSimple(Field<T> field) throws OrekitException {
    final T zero = field.getZero();
    final TimeScale utc = TimeScalesFactory.getUTC();
    final FieldVector3D<T> position = new FieldVector3D<>(zero.add(-6142438.668), zero.add(3492467.56), zero.add(-25767.257));
    final FieldVector3D<T> velocity = new FieldVector3D<>(zero.add(506.0), zero.add(943.0), zero.add(7450));
    final FieldAbsoluteDate<T> date = new FieldAbsoluteDate<>(field, 2003, 9, 16, utc);
    final FieldOrbit<T> orbit = new FieldCartesianOrbit<>(new FieldPVCoordinates<>(position, velocity), FramesFactory.getEME2000(), date, Constants.EIGEN5C_EARTH_MU);
    FieldEcksteinHechlerPropagator<T> propagator = new FieldEcksteinHechlerPropagator<>(orbit, Constants.EIGEN5C_EARTH_EQUATORIAL_RADIUS, Constants.EIGEN5C_EARTH_MU, Constants.EIGEN5C_EARTH_C20, Constants.EIGEN5C_EARTH_C30, Constants.EIGEN5C_EARTH_C40, Constants.EIGEN5C_EARTH_C50, Constants.EIGEN5C_EARTH_C60);
    FieldEventDetector<T> detector = new FieldApsideDetector<>(propagator.getInitialState().getOrbit()).withMaxCheck(zero.add(600.0)).withThreshold(zero.add(1.0e-12)).withHandler(new FieldContinueOnEvent<FieldApsideDetector<T>, T>());
    Assert.assertEquals(600.0, detector.getMaxCheckInterval().getReal(), 1.0e-15);
    Assert.assertEquals(1.0e-12, detector.getThreshold().getReal(), 1.0e-15);
    Assert.assertEquals(AbstractDetector.DEFAULT_MAX_ITER, detector.getMaxIterationCount());
    FieldEventsLogger<T> logger = new FieldEventsLogger<>();
    propagator.addEventDetector(logger.monitorDetector(detector));
    propagator.propagate(propagator.getInitialState().getOrbit().getDate().shiftedBy(Constants.JULIAN_DAY));
    Assert.assertEquals(30, logger.getLoggedEvents().size());
    for (FieldLoggedEvent<T> e : logger.getLoggedEvents()) {
        FieldKeplerianOrbit<T> o = (FieldKeplerianOrbit<T>) OrbitType.KEPLERIAN.convertType(e.getState().getOrbit());
        double expected = e.isIncreasing() ? 0.0 : FastMath.PI;
        Assert.assertEquals(expected, MathUtils.normalizeAngle(o.getMeanAnomaly().getReal(), expected), 4.0e-14);
    }
}
Also used : TimeScale(org.orekit.time.TimeScale) FieldVector3D(org.hipparchus.geometry.euclidean.threed.FieldVector3D) FieldCartesianOrbit(org.orekit.orbits.FieldCartesianOrbit) FieldKeplerianOrbit(org.orekit.orbits.FieldKeplerianOrbit) FieldEcksteinHechlerPropagator(org.orekit.propagation.analytical.FieldEcksteinHechlerPropagator) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Example 99 with FieldAbsoluteDate

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

the class AngularRaDec method theoreticalEvaluation.

/**
 * {@inheritDoc}
 */
@Override
protected EstimatedMeasurement<AngularRaDec> theoreticalEvaluation(final int iteration, final int evaluation, final SpacecraftState[] states) throws OrekitException {
    final SpacecraftState state = states[getPropagatorsIndices().get(0)];
    // Right Ascension/elevation (in reference frame )derivatives are computed with respect to spacecraft state in inertial frame
    // and station parameters
    // ----------------------
    // 
    // Parameters:
    // - 0..2 - Position of the spacecraft in inertial frame
    // - 3..5 - Velocity of the spacecraft in inertial frame
    // - 6..n - station parameters (station offsets, pole, prime meridian...)
    // Get the number of parameters used for derivation
    // Place the selected drivers into a map
    int nbParams = 6;
    final Map<String, Integer> indices = new HashMap<>();
    for (ParameterDriver driver : getParametersDrivers()) {
        if (driver.isSelected()) {
            indices.put(driver.getName(), nbParams++);
        }
    }
    final DSFactory factory = new DSFactory(nbParams, 1);
    final Field<DerivativeStructure> field = factory.getDerivativeField();
    final FieldVector3D<DerivativeStructure> zero = FieldVector3D.getZero(field);
    // Coordinates of the spacecraft expressed as a derivative structure
    final TimeStampedFieldPVCoordinates<DerivativeStructure> pvaDS = getCoordinates(state, 0, factory);
    // Transform between station and inertial frame, expressed as a derivative structure
    // The components of station's position in offset frame are the 3 last derivative parameters
    final AbsoluteDate downlinkDate = getDate();
    final FieldAbsoluteDate<DerivativeStructure> downlinkDateDS = new FieldAbsoluteDate<>(field, downlinkDate);
    final FieldTransform<DerivativeStructure> offsetToInertialDownlink = station.getOffsetToInertial(state.getFrame(), downlinkDateDS, factory, indices);
    // Station position/velocity in inertial frame at end of the downlink leg
    final TimeStampedFieldPVCoordinates<DerivativeStructure> stationDownlink = offsetToInertialDownlink.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(downlinkDateDS, zero, zero, zero));
    // Compute propagation times
    // (if state has already been set up to pre-compensate propagation delay,
    // we will have delta == tauD and transitState will be the same as state)
    // Downlink delay
    final DerivativeStructure tauD = signalTimeOfFlight(pvaDS, stationDownlink.getPosition(), downlinkDateDS);
    // Transit state
    final double delta = downlinkDate.durationFrom(state.getDate());
    final DerivativeStructure deltaMTauD = tauD.negate().add(delta);
    final SpacecraftState transitState = state.shiftedBy(deltaMTauD.getValue());
    // Transit state (re)computed with derivative structures
    final TimeStampedFieldPVCoordinates<DerivativeStructure> transitStateDS = pvaDS.shiftedBy(deltaMTauD);
    // Station-satellite vector expressed in inertial frame
    final FieldVector3D<DerivativeStructure> staSatInertial = transitStateDS.getPosition().subtract(stationDownlink.getPosition());
    // Field transform from inertial to reference frame at station's reception date
    final FieldTransform<DerivativeStructure> inertialToReferenceDownlink = state.getFrame().getTransformTo(referenceFrame, downlinkDateDS);
    // Station-satellite vector in reference frame
    final FieldVector3D<DerivativeStructure> staSatReference = inertialToReferenceDownlink.transformPosition(staSatInertial);
    // Compute right ascension and declination
    final DerivativeStructure baseRightAscension = staSatReference.getAlpha();
    final double twoPiWrap = MathUtils.normalizeAngle(baseRightAscension.getReal(), getObservedValue()[0]) - baseRightAscension.getReal();
    final DerivativeStructure rightAscension = baseRightAscension.add(twoPiWrap);
    final DerivativeStructure declination = staSatReference.getDelta();
    // Prepare the estimation
    final EstimatedMeasurement<AngularRaDec> estimated = new EstimatedMeasurement<>(this, iteration, evaluation, new SpacecraftState[] { transitState }, new TimeStampedPVCoordinates[] { transitStateDS.toTimeStampedPVCoordinates(), stationDownlink.toTimeStampedPVCoordinates() });
    // azimuth - elevation values
    estimated.setEstimatedValue(rightAscension.getValue(), declination.getValue());
    // Partial derivatives of right ascension/declination in reference frame with respect to state
    // (beware element at index 0 is the value, not a derivative)
    final double[] raDerivatives = rightAscension.getAllDerivatives();
    final double[] decDerivatives = declination.getAllDerivatives();
    estimated.setStateDerivatives(0, Arrays.copyOfRange(raDerivatives, 1, 7), Arrays.copyOfRange(decDerivatives, 1, 7));
    // (beware element at index 0 is the value, not a derivative)
    for (final ParameterDriver driver : getParametersDrivers()) {
        final Integer index = indices.get(driver.getName());
        if (index != null) {
            estimated.setParameterDerivatives(driver, raDerivatives[index + 1], decDerivatives[index + 1]);
        }
    }
    return estimated;
}
Also used : HashMap(java.util.HashMap) DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) ParameterDriver(org.orekit.utils.ParameterDriver) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Example 100 with FieldAbsoluteDate

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

the class RangeRate method theoreticalEvaluation.

/**
 * {@inheritDoc}
 */
@Override
protected EstimatedMeasurement<RangeRate> theoreticalEvaluation(final int iteration, final int evaluation, final SpacecraftState[] states) throws OrekitException {
    final SpacecraftState state = states[getPropagatorsIndices().get(0)];
    // Range-rate derivatives are computed with respect to spacecraft state in inertial frame
    // and station position in station's offset frame
    // -------
    // 
    // Parameters:
    // - 0..2 - Position of the spacecraft in inertial frame
    // - 3..5 - Velocity of the spacecraft in inertial frame
    // - 6..n - station parameters (station offsets, pole, prime meridian...)
    int nbParams = 6;
    final Map<String, Integer> indices = new HashMap<>();
    for (ParameterDriver driver : getParametersDrivers()) {
        if (driver.isSelected()) {
            indices.put(driver.getName(), nbParams++);
        }
    }
    final DSFactory factory = new DSFactory(nbParams, 1);
    final Field<DerivativeStructure> field = factory.getDerivativeField();
    final FieldVector3D<DerivativeStructure> zero = FieldVector3D.getZero(field);
    // Coordinates of the spacecraft expressed as a derivative structure
    final TimeStampedFieldPVCoordinates<DerivativeStructure> pvaDS = getCoordinates(state, 0, factory);
    // transform between station and inertial frame, expressed as a derivative structure
    // The components of station's position in offset frame are the 3 last derivative parameters
    final AbsoluteDate downlinkDate = getDate();
    final FieldAbsoluteDate<DerivativeStructure> downlinkDateDS = new FieldAbsoluteDate<>(field, downlinkDate);
    final FieldTransform<DerivativeStructure> offsetToInertialDownlink = station.getOffsetToInertial(state.getFrame(), downlinkDateDS, factory, indices);
    // Station position in inertial frame at end of the downlink leg
    final TimeStampedFieldPVCoordinates<DerivativeStructure> stationDownlink = offsetToInertialDownlink.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(downlinkDateDS, zero, zero, zero));
    // Compute propagation times
    // (if state has already been set up to pre-compensate propagation delay,
    // we will have delta == tauD and transitState will be the same as state)
    // Downlink delay
    final DerivativeStructure tauD = signalTimeOfFlight(pvaDS, stationDownlink.getPosition(), downlinkDateDS);
    // Transit state
    final double delta = downlinkDate.durationFrom(state.getDate());
    final DerivativeStructure deltaMTauD = tauD.negate().add(delta);
    final SpacecraftState transitState = state.shiftedBy(deltaMTauD.getValue());
    // Transit state (re)computed with derivative structures
    final TimeStampedFieldPVCoordinates<DerivativeStructure> transitPV = pvaDS.shiftedBy(deltaMTauD);
    // one-way (downlink) range-rate
    final EstimatedMeasurement<RangeRate> evalOneWay1 = oneWayTheoreticalEvaluation(iteration, evaluation, true, stationDownlink, transitPV, transitState, indices);
    final EstimatedMeasurement<RangeRate> estimated;
    if (twoway) {
        // one-way (uplink) light time correction
        final AbsoluteDate approxUplinkDate = downlinkDate.shiftedBy(-2 * tauD.getValue());
        final FieldAbsoluteDate<DerivativeStructure> approxUplinkDateDS = new FieldAbsoluteDate<>(field, approxUplinkDate);
        final FieldTransform<DerivativeStructure> offsetToInertialApproxUplink = station.getOffsetToInertial(state.getFrame(), approxUplinkDateDS, factory, indices);
        final TimeStampedFieldPVCoordinates<DerivativeStructure> stationApproxUplink = offsetToInertialApproxUplink.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(approxUplinkDateDS, zero, zero, zero));
        final DerivativeStructure tauU = signalTimeOfFlight(stationApproxUplink, transitPV.getPosition(), transitPV.getDate());
        final TimeStampedFieldPVCoordinates<DerivativeStructure> stationUplink = stationApproxUplink.shiftedBy(transitPV.getDate().durationFrom(approxUplinkDateDS).subtract(tauU));
        final EstimatedMeasurement<RangeRate> evalOneWay2 = oneWayTheoreticalEvaluation(iteration, evaluation, false, stationUplink, transitPV, transitState, indices);
        // combine uplink and downlink values
        estimated = new EstimatedMeasurement<>(this, iteration, evaluation, evalOneWay1.getStates(), new TimeStampedPVCoordinates[] { evalOneWay2.getParticipants()[0], evalOneWay1.getParticipants()[0], evalOneWay1.getParticipants()[1] });
        estimated.setEstimatedValue(0.5 * (evalOneWay1.getEstimatedValue()[0] + evalOneWay2.getEstimatedValue()[0]));
        // combine uplink and downlink partial derivatives with respect to state
        final double[][] sd1 = evalOneWay1.getStateDerivatives(0);
        final double[][] sd2 = evalOneWay2.getStateDerivatives(0);
        final double[][] sd = new double[sd1.length][sd1[0].length];
        for (int i = 0; i < sd.length; ++i) {
            for (int j = 0; j < sd[0].length; ++j) {
                sd[i][j] = 0.5 * (sd1[i][j] + sd2[i][j]);
            }
        }
        estimated.setStateDerivatives(0, sd);
        // combine uplink and downlink partial derivatives with respect to parameters
        evalOneWay1.getDerivativesDrivers().forEach(driver -> {
            final double[] pd1 = evalOneWay1.getParameterDerivatives(driver);
            final double[] pd2 = evalOneWay2.getParameterDerivatives(driver);
            final double[] pd = new double[pd1.length];
            for (int i = 0; i < pd.length; ++i) {
                pd[i] = 0.5 * (pd1[i] + pd2[i]);
            }
            estimated.setParameterDerivatives(driver, pd);
        });
    } else {
        estimated = evalOneWay1;
    }
    return estimated;
}
Also used : HashMap(java.util.HashMap) DerivativeStructure(org.hipparchus.analysis.differentiation.DerivativeStructure) DSFactory(org.hipparchus.analysis.differentiation.DSFactory) ParameterDriver(org.orekit.utils.ParameterDriver) TimeStampedPVCoordinates(org.orekit.utils.TimeStampedPVCoordinates) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate) AbsoluteDate(org.orekit.time.AbsoluteDate) SpacecraftState(org.orekit.propagation.SpacecraftState) FieldAbsoluteDate(org.orekit.time.FieldAbsoluteDate)

Aggregations

FieldAbsoluteDate (org.orekit.time.FieldAbsoluteDate)138 Frame (org.orekit.frames.Frame)57 FieldVector3D (org.hipparchus.geometry.euclidean.threed.FieldVector3D)53 AbsoluteDate (org.orekit.time.AbsoluteDate)52 Test (org.junit.Test)51 FieldKeplerianOrbit (org.orekit.orbits.FieldKeplerianOrbit)40 DSFactory (org.hipparchus.analysis.differentiation.DSFactory)37 DerivativeStructure (org.hipparchus.analysis.differentiation.DerivativeStructure)37 FieldPVCoordinates (org.orekit.utils.FieldPVCoordinates)29 OrekitException (org.orekit.errors.OrekitException)28 SpacecraftState (org.orekit.propagation.SpacecraftState)28 Vector3D (org.hipparchus.geometry.euclidean.threed.Vector3D)27 FieldSpacecraftState (org.orekit.propagation.FieldSpacecraftState)25 TimeStampedFieldPVCoordinates (org.orekit.utils.TimeStampedFieldPVCoordinates)24 PVCoordinates (org.orekit.utils.PVCoordinates)20 Decimal64 (org.hipparchus.util.Decimal64)18 RealFieldElement (org.hipparchus.RealFieldElement)17 OrbitType (org.orekit.orbits.OrbitType)17 DateComponents (org.orekit.time.DateComponents)17 FieldNumericalPropagator (org.orekit.propagation.numerical.FieldNumericalPropagator)14