DifferentialSignalBias.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.files.sinex;

  18. import java.util.HashMap;
  19. import java.util.HashSet;

  20. import org.hipparchus.util.Pair;
  21. import org.orekit.gnss.ObservationType;
  22. import org.orekit.time.AbsoluteDate;
  23. import org.orekit.utils.TimeSpanMap;

  24. /** Container for differential signal bias for a single link endpoint
  25.  * (either emitter or receiver).
  26.  * <p>
  27.  * This class is made to handle both station and satellite DSB data.
  28.  * Bias values are stored in TimeSpanMaps associated with a given pair
  29.  * of observation types. Those TimeSpanMaps are stored in a Map, which
  30.  * associate a pair of observation types to a TimeSpanMap of double values.
  31.  * </p>
  32.  * @author Louis Aucouturier
  33.  * @since 12.0
  34.  */
  35. public class DifferentialSignalBias {

  36.     /** Set of observation type pairs available for the satellite. */
  37.     private final HashSet<Pair<ObservationType, ObservationType>> observationSets;

  38.     /** Set of biases, identifiable by observation type pairs,
  39.      * each containing the corresponding TimeSpanMap of biases (DSB).
  40.      */
  41.     private final HashMap<Pair<ObservationType, ObservationType>, TimeSpanMap<Double>> biases;

  42.     /** Simple constructor.
  43.      */
  44.     public DifferentialSignalBias() {
  45.         this.observationSets = new HashSet<>();
  46.         this.biases          = new HashMap<>();
  47.     }

  48.     /** Add a bias.
  49.      * @param obs1 first observation used for the DSB computation
  50.      * @param obs2 second observation used for the DSB computation
  51.      * @param spanBegin beginning of the validity span for this bias value
  52.      * @param spanEnd end of the validity span for this bias value
  53.      * @param biasValue DSB bias value (meters for code and cycle for phase)
  54.      */
  55.     public void addBias(final ObservationType obs1, final ObservationType obs2,
  56.                         final AbsoluteDate spanBegin, final AbsoluteDate spanEnd,
  57.                         final double biasValue) {

  58.         // Setting a pair of observation type.
  59.         final Pair<ObservationType, ObservationType> observationPair = new Pair<>(obs1, obs2);

  60.         // If not present add a new bias to the map, identified by the Observation Pair.
  61.         // Then add the bias value and validity period.
  62.         if (observationSets.add(observationPair)) {
  63.             biases.put(observationPair, new TimeSpanMap<>(null));
  64.         }

  65.         biases.get(observationPair).addValidBetween(biasValue, spanBegin, spanEnd);

  66.     }

  67.     /** Get the value of the Differential Signal Bias for a given observation pair at a given date.
  68.      * @param obs1 first observation type
  69.      * @param obs2 second observation type
  70.      * @param date date at which to obtain the DSB
  71.      * @return the value of the DSB (meters for code and cycle for phase)
  72.      */
  73.     public double getBias(final ObservationType obs1, final ObservationType obs2, final AbsoluteDate date) {
  74.         return getTimeSpanMap(obs1, obs2).get(date);
  75.     }

  76.     /** Get all available observation type pairs for the satellite.
  77.      * @return observation type pairs obtained.
  78.      */
  79.     public HashSet<Pair<ObservationType, ObservationType>> getAvailableObservationPairs() {
  80.         return observationSets;
  81.     }

  82.     /** Get the minimum valid date for a given observation pair.
  83.      * @param obs1 first observation type
  84.      * @param obs2 second observation type
  85.      * @return minimum valid date for the observation pair
  86.      */
  87.     public AbsoluteDate getMinimumValidDateForObservationPair(final ObservationType obs1, final ObservationType obs2) {
  88.         return getTimeSpanMap(obs1, obs2).getFirstTransition().getDate();
  89.     }

  90.     /** Get the maximum valid date for a given observation pair.
  91.      * @param obs1 first observation type
  92.      * @param obs2 second observation type
  93.      * @return maximum valid date for the observation pair
  94.      */
  95.     public AbsoluteDate getMaximumValidDateForObservationPair(final ObservationType obs1, final ObservationType obs2) {
  96.         return getTimeSpanMap(obs1, obs2).getLastTransition().getDate();
  97.     }

  98.     /** Get the TimeSpanMap object for a given observation type pair,
  99.      * for further operation on the object directly.
  100.      *
  101.      * @param obs1 first observation type
  102.      * @param obs2 second observation type
  103.      * @return the time span map for a given observation type pair
  104.      */
  105.     private TimeSpanMap<Double> getTimeSpanMap(final ObservationType obs1, final ObservationType obs2) {
  106.         return biases.get(new Pair<>(obs1, obs2));
  107.     }

  108. }