1   /* Copyright 2025-2026 Hawkeye 360 (HE360)
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.estimation.measurements;
19  
20  import java.util.Map;
21  
22  import org.hipparchus.analysis.differentiation.Gradient;
23  import org.hipparchus.analysis.differentiation.GradientField;
24  import org.orekit.time.AbsoluteDate;
25  import org.orekit.time.FieldAbsoluteDate;
26  import org.orekit.time.clocks.QuadraticClockModel;
27  import org.orekit.time.clocks.QuadraticFieldClockModel;
28  import org.orekit.utils.ParameterDriver;
29  import org.orekit.utils.ParameterDriversProvider;
30  
31  /** Interface underlying both observed and observing measurement objects. Contains the clock model.
32   *
33   * @author Brianna Aubin
34   * @since 14.0
35   */
36  public interface MeasurementParticipant extends ParameterDriversProvider {
37  
38      /** Suffix for ground station position parameters names. */
39      String OFFSET_SUFFIX = "-offset";
40  
41      /** Suffix for clock bias (a.k.a. systematic offset) parameters name. */
42      String BIAS_SUFFIX = "-bias";
43  
44      /** Suffix for ground clock drift parameters name. */
45      String DRIFT_SUFFIX = "-drift";
46  
47      /** Suffix for ground clock drift parameters name. */
48      String ACCELERATION_SUFFIX = "-acceleration";
49  
50      /** Get the MeasurementObject name.
51       * @return name for the object
52       */
53      String getName();
54  
55      /** Get the clock bias (a.k.a. systematic offset) driver.
56       * @return clock bias driver
57       */
58      default ParameterDriver getClockBiasDriver() {
59          return getQuadraticClockModel().getClockBiasDriver();
60      }
61  
62      /** Get the clock drift driver.
63       * @return clock drift driver
64       */
65      default ParameterDriver getClockDriftDriver() {
66          return getQuadraticClockModel().getClockDriftDriver();
67      }
68  
69      /** Get the clock acceleration driver.
70       * @return clock acceleration driver
71       */
72      default ParameterDriver getClockAccelerationDriver() {
73          return getQuadraticClockModel().getClockAccelerationDriver();
74      }
75  
76      /** Get the current clock offset as a function of time.
77       * @param date time of computations
78       * @return current clock offset value
79       */
80      default double getOffsetValue(final AbsoluteDate date) {
81          return getQuadraticClockModel().getOffset(date).getBias();
82      }
83  
84      /** Get the current clock drift as a function of time.
85       * @param date time of computations
86       * @return current clock drift value
87       */
88      default double getOffsetRate(final AbsoluteDate date) {
89          return getQuadraticClockModel().getOffset(date).getRate();
90      }
91  
92      /** Get the current gradient clock offset as a function of time.
93       * @param freeParameters total number of free parameters in the gradient
94       * @param date time of computations
95       * @param indices indices of the differentiation parameters in derivatives computations
96       * @return current gradient clock offset value
97       */
98      default Gradient getFieldOffsetValue(final int freeParameters,
99                                         final AbsoluteDate date,
100                                        final Map<String, Integer> indices) {
101 
102         final FieldAbsoluteDate<Gradient> fieldDate =
103             new FieldAbsoluteDate<Gradient>(GradientField.getField(freeParameters), date);
104         return getQuadraticFieldClock(freeParameters, date, indices).getOffset(fieldDate).getBias();
105     }
106 
107     /** Get the current gradient clock drift as a function of time.
108      * @param freeParameters total number of free parameters in the gradient
109      * @param date time of computations
110      * @param indices indices of the differentiation parameters in derivatives computations
111      * @return current gradient clock drift value
112      */
113     default Gradient getFieldOffsetRate(final int freeParameters,
114                                         final AbsoluteDate date,
115                                         final Map<String, Integer> indices) {
116 
117         final FieldAbsoluteDate<Gradient> fieldDate =
118             new FieldAbsoluteDate<Gradient>(GradientField.getField(freeParameters), date);
119         return getQuadraticFieldClock(freeParameters, date, indices).getOffset(fieldDate).getRate();
120     }
121 
122     /** Get a quadratic clock model valid at some date.
123      * @return quadratic clock model
124      */
125     QuadraticClockModel getQuadraticClockModel();
126 
127     /** Get Gradient clock model.
128      * @param freeParameters total number of free parameters in the gradient
129      * @param date time of computations
130      * @param indices indices of the differentiation parameters in derivatives computations,
131      * must be span name and not driver name
132      * @return clock provider
133      */
134     default QuadraticFieldClockModel<Gradient> getQuadraticFieldClock(final int freeParameters,
135                                                                       final AbsoluteDate date,
136                                                                       final Map<String, Integer> indices) {
137         return getQuadraticClockModel().toGradientModel(freeParameters, indices, date);
138     }
139 
140 }