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