BistaticRange.java

  1. /* Copyright 2002-2022 Mark Rutten
  2.  * Licensed to CS GROUP (CS) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * Mark Rutten licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.orekit.estimation.measurements;

  18. import java.util.Arrays;
  19. import java.util.Collections;
  20. import java.util.HashMap;
  21. import java.util.Map;

  22. import org.hipparchus.analysis.differentiation.Gradient;
  23. import org.hipparchus.analysis.differentiation.GradientField;
  24. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  25. import org.orekit.frames.FieldTransform;
  26. import org.orekit.propagation.SpacecraftState;
  27. import org.orekit.time.AbsoluteDate;
  28. import org.orekit.time.FieldAbsoluteDate;
  29. import org.orekit.utils.Constants;
  30. import org.orekit.utils.ParameterDriver;
  31. import org.orekit.utils.TimeStampedFieldPVCoordinates;
  32. import org.orekit.utils.TimeStampedPVCoordinates;

  33. /**
  34.  * Class modeling a bistatic range measurement using
  35.  * an emitter ground station and a receiver ground station.
  36.  * <p>
  37.  * The measurement is considered to be a signal:
  38.  * <ul>
  39.  * <li>Emitted from the emitter ground station</li>
  40.  * <li>Reflected on the spacecraft</li>
  41.  * <li>Received on the receiver ground station</li>
  42.  * </ul>
  43.  * The date of the measurement corresponds to the reception on ground of the reflected signal.
  44.  * <p>
  45.  * The motion of the stations and the spacecraft during the signal flight time are taken into account.
  46.  * </p>
  47.  *
  48.  * @author Mark Rutten
  49.  * @since 11.2
  50.  */
  51. public class BistaticRange extends AbstractMeasurement<BistaticRange> {

  52.     /** Type of the measurement. */
  53.     public static final String MEASUREMENT_TYPE = "BistaticRange";

  54.     /**
  55.      * Ground station from which transmission is made.
  56.      */
  57.     private final GroundStation emitter;

  58.     /**
  59.      * Ground station from which measurement is performed.
  60.      */
  61.     private final GroundStation receiver;

  62.     /**
  63.      * Simple constructor.
  64.      *
  65.      * @param emitter     ground station from which transmission is performed
  66.      * @param receiver    ground station from which measurement is performed
  67.      * @param date        date of the measurement
  68.      * @param range       observed value
  69.      * @param sigma       theoretical standard deviation
  70.      * @param baseWeight  base weight
  71.      * @param satellite   satellite related to this measurement
  72.      * @since 11.2
  73.      */
  74.     public BistaticRange(final GroundStation emitter, final GroundStation receiver, final AbsoluteDate date,
  75.                          final double range, final double sigma, final double baseWeight,
  76.                          final ObservableSatellite satellite) {
  77.         super(date, range, sigma, baseWeight, Collections.singletonList(satellite));
  78.         addParameterDriver(emitter.getClockOffsetDriver());
  79.         addParameterDriver(emitter.getEastOffsetDriver());
  80.         addParameterDriver(emitter.getNorthOffsetDriver());
  81.         addParameterDriver(emitter.getZenithOffsetDriver());
  82.         addParameterDriver(emitter.getPrimeMeridianOffsetDriver());
  83.         addParameterDriver(emitter.getPrimeMeridianDriftDriver());
  84.         addParameterDriver(emitter.getPolarOffsetXDriver());
  85.         addParameterDriver(emitter.getPolarDriftXDriver());
  86.         addParameterDriver(emitter.getPolarOffsetYDriver());
  87.         addParameterDriver(emitter.getPolarDriftYDriver());

  88.         addParameterDriver(receiver.getClockOffsetDriver());
  89.         addParameterDriver(receiver.getEastOffsetDriver());
  90.         addParameterDriver(receiver.getNorthOffsetDriver());
  91.         addParameterDriver(receiver.getZenithOffsetDriver());
  92.         addParameterDriver(receiver.getPrimeMeridianOffsetDriver());
  93.         addParameterDriver(receiver.getPrimeMeridianDriftDriver());
  94.         addParameterDriver(receiver.getPolarOffsetXDriver());
  95.         addParameterDriver(receiver.getPolarDriftXDriver());
  96.         addParameterDriver(receiver.getPolarOffsetYDriver());
  97.         addParameterDriver(receiver.getPolarDriftYDriver());

  98.         this.emitter = emitter;
  99.         this.receiver = receiver;
  100.     }

  101.     public GroundStation getEmitterStation() {
  102.         return emitter;
  103.     }

  104.     public GroundStation getReceiverStation() {
  105.         return receiver;
  106.     }

  107.     /**
  108.      * {@inheritDoc}
  109.      */
  110.     @Override
  111.     protected EstimatedMeasurement<BistaticRange> theoreticalEvaluation(final int iteration,
  112.                                                                         final int evaluation,
  113.                                                                         final SpacecraftState[] states) {

  114.         final SpacecraftState state = states[0];

  115.         // Range derivatives are computed with respect to spacecraft state in inertial frame
  116.         // and station parameters
  117.         // ----------------------
  118.         //
  119.         // Parameters:
  120.         //  - 0..2 - Position of the spacecraft in inertial frame
  121.         //  - 3..5 - Velocity of the spacecraft in inertial frame
  122.         //  - 6..n - measurements parameters (clock offset, station offsets, pole, prime meridian, sat clock offset...)
  123.         int nbParams = 6;
  124.         final Map<String, Integer> indices = new HashMap<>();
  125.         for (ParameterDriver driver : getParametersDrivers()) {
  126.             if (driver.isSelected()) {
  127.                 indices.put(driver.getName(), nbParams++);
  128.             }
  129.         }
  130.         final FieldVector3D<Gradient> zero = FieldVector3D.getZero(GradientField.getField(nbParams));

  131.         // Coordinates of the spacecraft expressed as a gradient
  132.         final TimeStampedFieldPVCoordinates<Gradient> pvaDS = getCoordinates(state, 0, nbParams);

  133.         // transform between station and inertial frame, expressed as a gradient
  134.         // The components of station's position in offset frame are the 3 last derivative parameters
  135.         final FieldTransform<Gradient> offsetToInertialRx =
  136.                 receiver.getOffsetToInertial(state.getFrame(), getDate(), nbParams, indices);
  137.         final FieldAbsoluteDate<Gradient> downlinkDateDS = offsetToInertialRx.getFieldDate();

  138.         // Station position in inertial frame at end of the downlink leg
  139.         final TimeStampedFieldPVCoordinates<Gradient> stationReceiver =
  140.                 offsetToInertialRx.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(downlinkDateDS,
  141.                         zero, zero, zero));

  142.         // Compute propagation times
  143.         // (if state has already been set up to pre-compensate propagation delay,
  144.         //  we will have delta == tauD and transitState will be the same as state)

  145.         // Downlink delay
  146.         final Gradient tauD = signalTimeOfFlight(pvaDS, stationReceiver.getPosition(), downlinkDateDS);

  147.         // Transit state & Transit state (re)computed with gradients
  148.         final Gradient delta = downlinkDateDS.durationFrom(state.getDate());
  149.         final Gradient deltaMTauD = tauD.negate().add(delta);
  150.         final SpacecraftState transitState = state.shiftedBy(deltaMTauD.getValue());
  151.         final TimeStampedFieldPVCoordinates<Gradient> transitStateDS = pvaDS.shiftedBy(deltaMTauD);

  152.         // transform between secondary station topocentric frame (east-north-zenith) and inertial frame expressed as gradients
  153.         // The components of secondary station's position in offset frame are the 3 last derivative parameters
  154.         final FieldAbsoluteDate<Gradient> transitDate = downlinkDateDS.shiftedBy(tauD.negate());
  155.         final FieldTransform<Gradient> offsetToInertialTxApprox =
  156.                 emitter.getOffsetToInertial(state.getFrame(), transitDate, nbParams, indices);

  157.         // Secondary station PV in inertial frame at transit time
  158.         final TimeStampedFieldPVCoordinates<Gradient> transmitApprox =
  159.                 offsetToInertialTxApprox.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(transitDate,
  160.                         zero, zero, zero));

  161.         // Uplink time of flight from secondary station to transit state of leg2
  162.         final Gradient tauU = signalTimeOfFlight(transmitApprox, transitStateDS.getPosition(), transitStateDS.getDate());

  163.         // Total time of flight
  164.         final Gradient tauTotal = deltaMTauD.negate().add(tauU);

  165.         // Absolute date of transmission
  166.         final FieldAbsoluteDate<Gradient> transmitDateDS = downlinkDateDS.shiftedBy(tauTotal);
  167.         final FieldTransform<Gradient> transmitToInert =
  168.                 emitter.getOffsetToInertial(state.getFrame(), transmitDateDS, nbParams, indices);

  169.         // Secondary station PV in inertial frame at rebound date on secondary station
  170.         final TimeStampedFieldPVCoordinates<Gradient> stationTransmitter =
  171.                 transmitToInert.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(transmitDateDS,
  172.                         zero, zero, zero));

  173.         // Prepare the evaluation
  174.         final EstimatedMeasurement<BistaticRange> estimated = new EstimatedMeasurement<>(this,
  175.                 iteration, evaluation,
  176.                 new SpacecraftState[] {
  177.                     transitState
  178.                 },
  179.                 new TimeStampedPVCoordinates[] {
  180.                     stationReceiver.toTimeStampedPVCoordinates(),
  181.                     transitStateDS.toTimeStampedPVCoordinates(),
  182.                     stationTransmitter.toTimeStampedPVCoordinates()
  183.                 });

  184.         // Range value
  185.         final Gradient tau = tauD.add(tauU);
  186.         final Gradient range = tau.multiply(Constants.SPEED_OF_LIGHT);

  187.         estimated.setEstimatedValue(range.getValue());

  188.         // Range partial derivatives with respect to state
  189.         final double[] derivatives = range.getGradient();
  190.         estimated.setStateDerivatives(0, Arrays.copyOfRange(derivatives, 0, 6));

  191.         // set partial derivatives with respect to parameters
  192.         // (beware element at index 0 is the value, not a derivative)
  193.         for (final ParameterDriver driver : getParametersDrivers()) {
  194.             final Integer index = indices.get(driver.getName());
  195.             if (index != null) {
  196.                 estimated.setParameterDerivatives(driver, derivatives[index]);
  197.             }
  198.         }

  199.         return estimated;
  200.     }

  201. }