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 org.orekit.gnss.ObservationType;
21 import org.orekit.time.AbsoluteDate;
22 import org.orekit.utils.TimeSpanMap;
23
24 import java.util.HashMap;
25 import java.util.HashSet;
26
27 /** Container for observation-specific 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 OSB data.
31 * Bias values are stored in TimeSpanMaps associated with a given
32 * observation type. Those TimeSpanMaps are stored in a Map, which
33 * associate an observation code to a TimeSpanMap of double values.
34 * </p>
35 * @author Louis Aucouturier
36 * @author Luc Maisonobe
37 * @since 13.0
38 */
39 public class ObservableSpecificSignalBias {
40
41 /** Set of observation types available for the satellite. */
42 private final HashSet<ObservationType> observationSets;
43
44 /** Set of biases, identifiable by observation types,
45 * each containing the corresponding TimeSpanMap of biases.
46 */
47 private final HashMap<ObservationType, TimeSpanMap<Double>> biases;
48
49 /** Simple constructor.
50 */
51 public ObservableSpecificSignalBias() {
52 this.observationSets = new HashSet<>();
53 this.biases = new HashMap<>();
54 }
55
56 /** Add a bias.
57 * @param obs observation used for the OSB 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 Observable-specific Signal Bias value (meters for code and cycle for phase)
61 */
62 public void addBias(final ObservationType obs,
63 final AbsoluteDate spanBegin, final AbsoluteDate spanEnd,
64 final double biasValue) {
65
66 // If not present add a new bias to the map, identified by the Observation type.
67 // Then add the bias value and validity period.
68 if (observationSets.add(obs)) {
69 biases.put(obs, new TimeSpanMap<>(null));
70 }
71
72 biases.get(obs).addValidBetween(biasValue, spanBegin, spanEnd);
73 }
74
75 /** Get the value of the Observable-specific Signal Bias for a given observation type at a given date.
76 * @param obs observation type
77 * @param date date at which to obtain the Observable-specific Signal Bias
78 * @return the value of the Observable-specific Signal Bias (meters for code and cycle for phase)
79 */
80 public double getBias(final ObservationType obs, final AbsoluteDate date) {
81 return getTimeSpanMap(obs).get(date);
82 }
83
84 /** Get all available observation types for the satellite.
85 * @return Observation types obtained.
86 */
87 public HashSet<ObservationType> getAvailableObservations() {
88 return observationSets;
89 }
90
91 /** Get the minimum valid date for a given observation type.
92 * @param obs observation type
93 * @return minimum valid date for the observation pair
94 */
95 public AbsoluteDate getMinimumValidDateForObservation(final ObservationType obs) {
96 return getTimeSpanMap(obs).getFirstTransition().getDate();
97 }
98
99 /** Get the maximum valid date for a given observation type.
100 * @param obs observation type
101 * @return maximum valid date for the observation pair
102 */
103 public AbsoluteDate getMaximumValidDateForObservation(final ObservationType obs) {
104 return getTimeSpanMap(obs).getLastTransition().getDate();
105 }
106
107 /** Get the TimeSpanMap object for a given observation type,
108 * for further operation on the object directly.
109 *
110 * @param obs observation type
111 * @return the time span map for a given observation code pair
112 */
113 private TimeSpanMap<Double> getTimeSpanMap(final ObservationType obs) {
114 return biases.get(obs);
115 }
116
117 }