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 18 package org.orekit.files.sinex; 19 20 import java.util.HashMap; 21 import java.util.HashSet; 22 23 import org.hipparchus.util.Pair; 24 import org.orekit.gnss.ObservationType; 25 import org.orekit.time.AbsoluteDate; 26 import org.orekit.utils.TimeSpanMap; 27 28 /** Container for differential signal bias for a single link endpoint 29 * (either emitter or receiver). 30 * <p> 31 * This class is made to handle both station and satellite DSB data. 32 * Bias values are stored in TimeSpanMaps associated with a given pair 33 * of observation types. Those TimeSpanMaps are stored in a Map, which 34 * associate a pair of observation types to a TimeSpanMap of double values. 35 * </p> 36 * @author Louis Aucouturier 37 * @since 12.0 38 */ 39 public class DifferentialSignalBias { 40 41 /** Set of observation type pairs available for the satellite. */ 42 private final HashSet<Pair<ObservationType, ObservationType>> observationSets; 43 44 /** Set of biases, identifiable by observation type pairs, 45 * each containing the corresponding TimeSpanMap of biases (DSB). 46 */ 47 private final HashMap<Pair<ObservationType, ObservationType>, TimeSpanMap<Double>> biases; 48 49 /** Simple constructor. 50 */ 51 public DifferentialSignalBias() { 52 this.observationSets = new HashSet<>(); 53 this.biases = new HashMap<>(); 54 } 55 56 /** Add a bias. 57 * @param obs1 first observation used for the DSB computation 58 * @param obs2 second observation used for the DSB computation 59 * @param spanBegin beginning of the validity span for this bias value 60 * @param spanEnd end of the validity span for this bias value 61 * @param biasValue DSB bias value (meters for code and cycle for phase) 62 */ 63 public void addBias(final ObservationType obs1, final ObservationType obs2, 64 final AbsoluteDate spanBegin, final AbsoluteDate spanEnd, 65 final double biasValue) { 66 67 // Setting a pair of observation type. 68 final Pair<ObservationType, ObservationType> observationPair = new Pair<>(obs1, obs2); 69 70 // If not present add a new bias to the map, identified by the Observation Pair. 71 // Then add the bias value and validity period. 72 if (observationSets.add(observationPair)) { 73 biases.put(observationPair, new TimeSpanMap<>(null)); 74 } 75 76 biases.get(observationPair).addValidBetween(biasValue, spanBegin, spanEnd); 77 78 } 79 80 /** Get the value of the Differential Signal Bias for a given observation pair at a given date. 81 * @param obs1 first observation type 82 * @param obs2 second observation type 83 * @param date date at which to obtain the DSB 84 * @return the value of the DSB (meters for code and cycle for phase) 85 */ 86 public double getBias(final ObservationType obs1, final ObservationType obs2, final AbsoluteDate date) { 87 return getTimeSpanMap(obs1, obs2).get(date); 88 } 89 90 /** Get all available observation type pairs for the satellite. 91 * @return observation type pairs obtained. 92 */ 93 public HashSet<Pair<ObservationType, ObservationType>> getAvailableObservationPairs() { 94 return observationSets; 95 } 96 97 /** Get the minimum valid date for a given observation pair. 98 * @param obs1 first observation type 99 * @param obs2 second observation type 100 * @return minimum valid date for the observation pair 101 */ 102 public AbsoluteDate getMinimumValidDateForObservationPair(final ObservationType obs1, final ObservationType obs2) { 103 return getTimeSpanMap(obs1, obs2).getFirstTransition().getDate(); 104 } 105 106 /** Get the maximum valid date for a given observation pair. 107 * @param obs1 first observation type 108 * @param obs2 second observation type 109 * @return maximum valid date for the observation pair 110 */ 111 public AbsoluteDate getMaximumValidDateForObservationPair(final ObservationType obs1, final ObservationType obs2) { 112 return getTimeSpanMap(obs1, obs2).getLastTransition().getDate(); 113 } 114 115 /** Get the TimeSpanMap object for a given observation type pair, 116 * for further operation on the object directly. 117 * 118 * @param obs1 first observation type 119 * @param obs2 second observation type 120 * @return the time span map for a given observation type pair 121 */ 122 private TimeSpanMap<Double> getTimeSpanMap(final ObservationType obs1, final ObservationType obs2) { 123 return biases.get(new Pair<>(obs1, obs2)); 124 } 125 126 }