GroundReceiverMeasurement.java

  1. /* Copyright 2002-2025 CS GROUP
  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.  * CS 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.Collections;
  19. import java.util.HashMap;
  20. import java.util.Map;

  21. import org.hipparchus.analysis.differentiation.Gradient;
  22. import org.hipparchus.analysis.differentiation.GradientField;
  23. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  24. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  25. import org.orekit.frames.FieldTransform;
  26. import org.orekit.frames.Frame;
  27. import org.orekit.frames.Transform;
  28. import org.orekit.propagation.SpacecraftState;
  29. import org.orekit.time.AbsoluteDate;
  30. import org.orekit.time.FieldAbsoluteDate;
  31. import org.orekit.utils.PVCoordinates;
  32. import org.orekit.utils.ParameterDriver;
  33. import org.orekit.utils.TimeSpanMap.Span;
  34. import org.orekit.utils.TimeStampedFieldPVCoordinates;
  35. import org.orekit.utils.TimeStampedPVCoordinates;

  36. /** Base class modeling a measurement where receiver is a ground station.
  37.  * @author Thierry Ceolin
  38.  * @author Luc Maisonobe
  39.  * @author Maxime Journot
  40.  * @since 12.0
  41.  * @param <T> type of the measurement
  42.  */
  43. public abstract class GroundReceiverMeasurement<T extends GroundReceiverMeasurement<T>> extends AbstractMeasurement<T> {

  44.     /** Ground station from which measurement is performed. */
  45.     private final GroundStation station;

  46.     /** Flag indicating whether it is a two-way measurement. */
  47.     private final boolean twoway;

  48.     /** Simple constructor.
  49.      * @param station ground station from which measurement is performed
  50.      * @param twoWay flag indicating whether it is a two-way measurement
  51.      * @param date date of the measurement
  52.      * @param observed observed value
  53.      * @param sigma theoretical standard deviation
  54.      * @param baseWeight base weight
  55.      * @param satellite satellite related to this measurement
  56.      */
  57.     public GroundReceiverMeasurement(final GroundStation station, final boolean twoWay, final AbsoluteDate date,
  58.                                      final double observed, final double sigma, final double baseWeight,
  59.                                      final ObservableSatellite satellite) {
  60.         super(date, observed, sigma, baseWeight, Collections.singletonList(satellite));
  61.         addParameterDriver(station.getClockOffsetDriver());
  62.         addParameterDriver(station.getClockDriftDriver());
  63.         addParameterDriver(station.getClockAccelerationDriver());
  64.         addParameterDriver(station.getEastOffsetDriver());
  65.         addParameterDriver(station.getNorthOffsetDriver());
  66.         addParameterDriver(station.getZenithOffsetDriver());
  67.         addParameterDriver(station.getPrimeMeridianOffsetDriver());
  68.         addParameterDriver(station.getPrimeMeridianDriftDriver());
  69.         addParameterDriver(station.getPolarOffsetXDriver());
  70.         addParameterDriver(station.getPolarDriftXDriver());
  71.         addParameterDriver(station.getPolarOffsetYDriver());
  72.         addParameterDriver(station.getPolarDriftYDriver());
  73.         if (!twoWay) {
  74.             // for one way measurements, the satellite clock offset affects the measurement
  75.             addParameterDriver(satellite.getClockOffsetDriver());
  76.             addParameterDriver(satellite.getClockDriftDriver());
  77.             addParameterDriver(satellite.getClockAccelerationDriver());
  78.         }
  79.         this.station = station;
  80.         this.twoway  = twoWay;
  81.     }

  82.     /** Simple constructor.
  83.      * @param station ground station from which measurement is performed
  84.      * @param twoWay flag indicating whether it is a two-way measurement
  85.      * @param date date of the measurement
  86.      * @param observed observed value
  87.      * @param sigma theoretical standard deviation
  88.      * @param baseWeight base weight
  89.      * @param satellite satellite related to this measurement
  90.      */
  91.     public GroundReceiverMeasurement(final GroundStation station, final boolean twoWay, final AbsoluteDate date,
  92.                                      final double[] observed, final double[] sigma, final double[] baseWeight,
  93.                                      final ObservableSatellite satellite) {
  94.         super(date, observed, sigma, baseWeight, Collections.singletonList(satellite));
  95.         addParameterDriver(station.getClockOffsetDriver());
  96.         addParameterDriver(station.getClockDriftDriver());
  97.         addParameterDriver(station.getClockAccelerationDriver());
  98.         addParameterDriver(station.getEastOffsetDriver());
  99.         addParameterDriver(station.getNorthOffsetDriver());
  100.         addParameterDriver(station.getZenithOffsetDriver());
  101.         addParameterDriver(station.getPrimeMeridianOffsetDriver());
  102.         addParameterDriver(station.getPrimeMeridianDriftDriver());
  103.         addParameterDriver(station.getPolarOffsetXDriver());
  104.         addParameterDriver(station.getPolarDriftXDriver());
  105.         addParameterDriver(station.getPolarOffsetYDriver());
  106.         addParameterDriver(station.getPolarDriftYDriver());
  107.         if (!twoWay) {
  108.             // for one way measurements, the satellite clock offset affects the measurement
  109.             addParameterDriver(satellite.getClockOffsetDriver());
  110.             addParameterDriver(satellite.getClockDriftDriver());
  111.             addParameterDriver(satellite.getClockAccelerationDriver());
  112.         }
  113.         this.station = station;
  114.         this.twoway  = twoWay;
  115.     }

  116.     /** Get the ground station from which measurement is performed.
  117.      * @return ground station from which measurement is performed
  118.      */
  119.     public GroundStation getStation() {
  120.         return station;
  121.     }

  122.     /** Check if the instance represents a two-way measurement.
  123.      * @return true if the instance represents a two-way measurement
  124.      */
  125.     public boolean isTwoWay() {
  126.         return twoway;
  127.     }

  128.     /** Compute common estimation parameters.
  129.      * @param state orbital state at measurement date
  130.      * @return common parameters
  131.      */
  132.     protected GroundReceiverCommonParametersWithoutDerivatives computeCommonParametersWithout(final SpacecraftState state) {

  133.         // Coordinates of the spacecraft
  134.         final TimeStampedPVCoordinates pva = state.getPVCoordinates();

  135.         // transform between station and inertial frame
  136.         final Transform offsetToInertialDownlink =
  137.                         getStation().getOffsetToInertial(state.getFrame(), getDate(), false);
  138.         final AbsoluteDate downlinkDate = offsetToInertialDownlink.getDate();

  139.         // Station position in inertial frame at end of the downlink leg
  140.         final TimeStampedPVCoordinates origin = new TimeStampedPVCoordinates(downlinkDate,
  141.                                                                              Vector3D.ZERO, Vector3D.ZERO, Vector3D.ZERO);
  142.         final TimeStampedPVCoordinates stationDownlink = offsetToInertialDownlink.transformPVCoordinates(origin);

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

  146.         // Downlink delay
  147.         final double tauD = signalTimeOfFlightAdjustableEmitter(pva, stationDownlink.getPosition(), downlinkDate, state.getFrame());

  148.         // Transit state & Transit state (re)computed with gradients
  149.         final double          delta        = downlinkDate.durationFrom(state.getDate());
  150.         final double          deltaMTauD   = delta - tauD;
  151.         final SpacecraftState transitState = state.shiftedBy(deltaMTauD);

  152.         return new GroundReceiverCommonParametersWithoutDerivatives(state,
  153.                                                                     offsetToInertialDownlink,
  154.                                                                     stationDownlink,
  155.                                                                     tauD,
  156.                                                                     transitState,
  157.                                                                     transitState.getPVCoordinates());

  158.     }

  159.     /** Compute common estimation parameters.
  160.      * @param state orbital state at measurement date
  161.      * @return common parameters
  162.      */
  163.     protected GroundReceiverCommonParametersWithDerivatives computeCommonParametersWithDerivatives(final SpacecraftState state) {
  164.         int nbParams = 6;
  165.         final Map<String, Integer> indices = new HashMap<>();
  166.         for (ParameterDriver driver : getParametersDrivers()) {
  167.             if (driver.isSelected()) {
  168.                 for (Span<String> span = driver.getNamesSpanMap().getFirstSpan(); span != null; span = span.next()) {
  169.                     indices.put(span.getData(), nbParams++);
  170.                 }
  171.             }
  172.         }
  173.         final FieldVector3D<Gradient> zero = FieldVector3D.getZero(GradientField.getField(nbParams));

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

  176.         // transform between station and inertial frame, expressed as a gradient
  177.         // The components of station's position in offset frame are the 3 last derivative parameters
  178.         final FieldTransform<Gradient> offsetToInertialDownlink =
  179.                         getStation().getOffsetToInertial(state.getFrame(), getDate(), nbParams, indices);
  180.         final FieldAbsoluteDate<Gradient> downlinkDate = offsetToInertialDownlink.getFieldDate();

  181.         // Station position in inertial frame at end of the downlink leg
  182.         final TimeStampedFieldPVCoordinates<Gradient> stationDownlink =
  183.                         offsetToInertialDownlink.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(downlinkDate,
  184.                                                                                                             zero, zero, zero));

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

  188.         // Downlink delay
  189.         final Gradient tauD = signalTimeOfFlightAdjustableEmitter(pva, stationDownlink.getPosition(),
  190.                                                                   downlinkDate, state.getFrame());

  191.         // Transit state & Transit state (re)computed with gradients
  192.         final Gradient        delta        = downlinkDate.durationFrom(state.getDate());
  193.         final Gradient        deltaMTauD   = tauD.negate().add(delta);
  194.         final SpacecraftState transitState = state.shiftedBy(deltaMTauD.getValue());
  195.         final TimeStampedFieldPVCoordinates<Gradient> transitPV = pva.shiftedBy(deltaMTauD);

  196.         return new GroundReceiverCommonParametersWithDerivatives(state,
  197.                                                                  indices,
  198.                                                                  offsetToInertialDownlink,
  199.                                                                  stationDownlink,
  200.                                                                  tauD,
  201.                                                                  transitState,
  202.                                                                  transitPV);

  203.     }

  204.     /**
  205.      * Get the station position for a given frame.
  206.      * @param frame inertial frame for station position
  207.      * @return the station position in the given inertial frame
  208.      * @since 12.0
  209.      */
  210.     public Vector3D getGroundStationPosition(final Frame frame) {
  211.         return station.getBaseFrame().getPosition(getDate(), frame);
  212.     }

  213.     /**
  214.      * Get the station coordinates for a given frame.
  215.      * @param frame inertial frame for station position
  216.      * @return the station coordinates in the given inertial frame
  217.      * @since 12.0
  218.      */
  219.     public PVCoordinates getGroundStationCoordinates(final Frame frame) {
  220.         return station.getBaseFrame().getPVCoordinates(getDate(), frame);
  221.     }

  222. }