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  
19  import org.hipparchus.util.FastMath;
20  import org.orekit.utils.ParameterDriver;
21  
22  /** Class modeling a satellite that can be observed.
23   *
24   * @author Luc Maisonobe
25   * @since 9.3
26   */
27  public class ObservableSatellite {
28  
29      /** Prefix for clock offset parameter driver, the propagator index will be appended to it. */
30      public static final String CLOCK_OFFSET_PREFIX = "clock-offset-satellite-";
31  
32      /** Prefix for clock drift parameter driver, the propagator index will be appended to it. */
33      public static final String CLOCK_DRIFT_PREFIX = "clock-drift-satellite-";
34  
35      /** Prefix for clock acceleration parameter driver, the propagator index will be appended to it.
36       * @since 12.1
37       */
38      public static final String CLOCK_ACCELERATION_PREFIX = "clock-acceleration-satellite-";
39  
40      /** Clock offset scaling factor.
41       * <p>
42       * We use a power of 2 to avoid numeric noise introduction
43       * in the multiplications/divisions sequences.
44       * </p>
45       */
46      private static final double CLOCK_OFFSET_SCALE = FastMath.scalb(1.0, -10);
47  
48      /** Prefix for satellite names. */
49      private static final String SAT_PREFIX = "sat-";
50  
51      /** Index of the propagator related to this satellite. */
52      private final int propagatorIndex;
53  
54      /** Parameter driver for satellite clock offset. */
55      private final ParameterDriver clockOffsetDriver;
56  
57      /** Parameter driver for satellite clock drift. */
58      private final ParameterDriver clockDriftDriver;
59  
60      /** Parameter driver for satellite clock acceleration.
61       * @since 12.1
62       */
63      private final ParameterDriver clockAccelerationDriver;
64  
65      /** Simple constructor.
66       * @param propagatorIndex index of the propagator related to this satellite
67       */
68      public ObservableSatellite(final int propagatorIndex) {
69          this.propagatorIndex   = propagatorIndex;
70          this.clockOffsetDriver = new ParameterDriver(CLOCK_OFFSET_PREFIX + propagatorIndex,
71                                                       0.0, CLOCK_OFFSET_SCALE,
72                                                       Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
73          this.clockDriftDriver = new ParameterDriver(CLOCK_DRIFT_PREFIX + propagatorIndex,
74                                                      0.0, CLOCK_OFFSET_SCALE,
75                                                      Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
76          this.clockAccelerationDriver = new ParameterDriver(CLOCK_ACCELERATION_PREFIX + propagatorIndex,
77                                                             0.0, CLOCK_OFFSET_SCALE,
78                                                             Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
79      }
80  
81      /** Build a name for the satellite.
82       * <p>
83       * This is mainly useful to build the arguments for {@link
84       * org.orekit.estimation.measurements.gnss.AmbiguityCache#getAmbiguity(String,
85       * String, double)}
86       * </p>
87       * @return name for the satellite (built from the propagator index)
88       * @since 12.1
89       */
90      public String getName() {
91          return SAT_PREFIX + propagatorIndex;
92      }
93  
94      /** Get the index of the propagator related to this satellite.
95       * @return index of the propagator related to this satellite
96       */
97      public int getPropagatorIndex() {
98          return propagatorIndex;
99      }
100 
101     /** Get the clock offset parameter driver.
102      * <p>
103      * The offset value is defined as the value in seconds that must be <em>subtracted</em> from
104      * the satellite clock reading of time to compute the real physical date. The offset
105      * is therefore negative if the satellite clock is slow and positive if it is fast.
106      * </p>
107      * @return clock offset parameter driver
108      */
109     public ParameterDriver getClockOffsetDriver() {
110         return clockOffsetDriver;
111     }
112 
113     /** Get the clock drift parameter driver.
114      * <p>
115      * The drift is negative if the satellite clock is slowing down and positive if it is speeding up.
116      * </p>
117      * @return clock drift parameter driver
118      * @since 10.3
119      */
120     public ParameterDriver getClockDriftDriver() {
121         return clockDriftDriver;
122     }
123 
124     /** Get the clock acceleration parameter driver.
125      * @return clock acceleration parameter driver
126      * @since 12.1
127      */
128     public ParameterDriver getClockAccelerationDriver() {
129         return clockAccelerationDriver;
130     }
131 
132     /** Get a quadratic clock model valid at some date.
133      * @return quadratic clock model
134      * @since 12.1
135      */
136     public QuadraticClockModel getQuadraticClockModel() {
137         return new QuadraticClockModel(clockOffsetDriver,
138                                        clockDriftDriver,
139                                        clockAccelerationDriver);
140     }
141 
142     /** {@inheritDoc}
143      * @since 12.0
144      */
145     @Override
146     public boolean equals(final Object other) {
147         if (other instanceof ObservableSatellite) {
148             return propagatorIndex == ((ObservableSatellite) other).propagatorIndex;
149         } else {
150             return false;
151 
152         }
153     }
154 
155     /** {@inheritDoc}
156      * @since 12.0
157      */
158     @Override
159     public int hashCode() {
160         return propagatorIndex;
161     }
162 
163 }