GroundReceiverMeasurement.java

  1. /* Copyright 2002-2024 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.getEastOffsetDriver());
  64.         addParameterDriver(station.getNorthOffsetDriver());
  65.         addParameterDriver(station.getZenithOffsetDriver());
  66.         addParameterDriver(station.getPrimeMeridianOffsetDriver());
  67.         addParameterDriver(station.getPrimeMeridianDriftDriver());
  68.         addParameterDriver(station.getPolarOffsetXDriver());
  69.         addParameterDriver(station.getPolarDriftXDriver());
  70.         addParameterDriver(station.getPolarOffsetYDriver());
  71.         addParameterDriver(station.getPolarDriftYDriver());
  72.         if (!twoWay) {
  73.             // for one way measurements, the satellite clock offset affects the measurement
  74.             addParameterDriver(satellite.getClockOffsetDriver());
  75.             addParameterDriver(satellite.getClockDriftDriver());
  76.         }
  77.         this.station = station;
  78.         this.twoway  = twoWay;
  79.     }

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

  112.     /** Get the ground station from which measurement is performed.
  113.      * @return ground station from which measurement is performed
  114.      */
  115.     public GroundStation getStation() {
  116.         return station;
  117.     }

  118.     /** Check if the instance represents a two-way measurement.
  119.      * @return true if the instance represents a two-way measurement
  120.      */
  121.     public boolean isTwoWay() {
  122.         return twoway;
  123.     }

  124.     /** Compute common estimation parameters.
  125.      * @param state orbital state at measurement date
  126.      * @return common parameters
  127.      */
  128.     protected GroundReceiverCommonParametersWithoutDerivatives computeCommonParametersWithout(final SpacecraftState state) {

  129.         // Coordinates of the spacecraft
  130.         final TimeStampedPVCoordinates pva = state.getPVCoordinates();

  131.         // transform between station and inertial frame
  132.         final Transform offsetToInertialDownlink =
  133.                         getStation().getOffsetToInertial(state.getFrame(), getDate(), false);
  134.         final AbsoluteDate downlinkDate = offsetToInertialDownlink.getDate();

  135.         // Station position in inertial frame at end of the downlink leg
  136.         final TimeStampedPVCoordinates origin = new TimeStampedPVCoordinates(downlinkDate,
  137.                                                                              Vector3D.ZERO, Vector3D.ZERO, Vector3D.ZERO);
  138.         final TimeStampedPVCoordinates stationDownlink = offsetToInertialDownlink.transformPVCoordinates(origin);

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

  142.         // Downlink delay
  143.         final double tauD = signalTimeOfFlight(pva, stationDownlink.getPosition(), downlinkDate);

  144.         // Transit state & Transit state (re)computed with gradients
  145.         final double          delta        = downlinkDate.durationFrom(state.getDate());
  146.         final double          deltaMTauD   = delta - tauD;
  147.         final SpacecraftState transitState = state.shiftedBy(deltaMTauD);

  148.         return new GroundReceiverCommonParametersWithoutDerivatives(state,
  149.                                                                     offsetToInertialDownlink,
  150.                                                                     stationDownlink,
  151.                                                                     tauD,
  152.                                                                     transitState,
  153.                                                                     transitState.getPVCoordinates());

  154.     }

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

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

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

  177.         // Station position in inertial frame at end of the downlink leg
  178.         final TimeStampedFieldPVCoordinates<Gradient> stationDownlink =
  179.                         offsetToInertialDownlink.transformPVCoordinates(new TimeStampedFieldPVCoordinates<>(downlinkDate,
  180.                                                                                                             zero, zero, zero));

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

  184.         // Downlink delay
  185.         final Gradient tauD = signalTimeOfFlight(pva, stationDownlink.getPosition(), downlinkDate);

  186.         // Transit state & Transit state (re)computed with gradients
  187.         final Gradient        delta        = downlinkDate.durationFrom(state.getDate());
  188.         final Gradient        deltaMTauD   = tauD.negate().add(delta);
  189.         final SpacecraftState transitState = state.shiftedBy(deltaMTauD.getValue());
  190.         final TimeStampedFieldPVCoordinates<Gradient> transitPV = pva.shiftedBy(deltaMTauD);

  191.         return new GroundReceiverCommonParametersWithDerivatives(state,
  192.                                                                  indices,
  193.                                                                  offsetToInertialDownlink,
  194.                                                                  stationDownlink,
  195.                                                                  tauD,
  196.                                                                  transitState,
  197.                                                                  transitPV);

  198.     }

  199.     /**
  200.      * Get the station position for a given frame.
  201.      * @param frame inertial frame for station position
  202.      * @return the station position in the given inertial frame
  203.      * @since 12.0
  204.      */
  205.     public Vector3D getGroundStationPosition(final Frame frame) {
  206.         return station.getBaseFrame().getPosition(getDate(), frame);
  207.     }

  208.     /**
  209.      * Get the station coordinates for a given frame.
  210.      * @param frame inertial frame for station position
  211.      * @return the station coordinates in the given inertial frame
  212.      * @since 12.0
  213.      */
  214.     public PVCoordinates getGroundStationCoordinates(final Frame frame) {
  215.         return station.getBaseFrame().getPVCoordinates(getDate(), frame);
  216.     }

  217. }