1   /* Copyright 2002-2022 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.models.earth.ionosphere;
18  
19  import java.io.Serializable;
20  import java.util.List;
21  
22  import org.hipparchus.Field;
23  import org.hipparchus.CalculusFieldElement;
24  import org.hipparchus.util.MathArrays;
25  import org.orekit.frames.TopocentricFrame;
26  import org.orekit.propagation.FieldSpacecraftState;
27  import org.orekit.propagation.SpacecraftState;
28  import org.orekit.utils.ParameterDriver;
29  
30  /** Defines a ionospheric model, used to calculate the path delay imposed to
31   * electro-magnetic signals between an orbital satellite and a ground station.
32   * <p>
33   * Since 10.0, this interface can be used for models that aspire to estimate
34   * ionospheric parameters.
35   * </p>
36   *
37   * @author Joris Olympio
38   * @author Bryan Cazabonne
39   * @since 7.1
40   */
41  public interface IonosphericModel extends Serializable {
42  
43      /**
44       * Calculates the ionospheric path delay for the signal path from a ground
45       * station to a satellite.
46       * <p>
47       * This method is intended to be used for orbit determination issues.
48       * In that respect, if the elevation is below 0° the path delay will be equal to zero.
49       * </p><p>
50       * For individual use of the ionospheric model (i.e. not for orbit determination), another
51       * method signature can be implemented to compute the path delay for any elevation angle.
52       * </p>
53       * @param state       spacecraft state
54       * @param baseFrame   base frame associated with the station
55       * @param frequency   frequency of the signal in Hz
56       * @param parameters  ionospheric model parameters
57       * @return the path delay due to the ionosphere in m
58       */
59      double pathDelay(SpacecraftState state, TopocentricFrame baseFrame, double frequency, double[] parameters);
60  
61      /**
62       * Calculates the ionospheric path delay for the signal path from a ground
63       * station to a satellite.
64       * <p>
65       * This method is intended to be used for orbit determination issues.
66       * In that respect, if the elevation is below 0° the path delay will be equal to zero.
67       * </p><p>
68       * For individual use of the ionospheric model (i.e. not for orbit determination), another
69       * method signature can be implemented to compute the path delay for any elevation angle.
70       * </p>
71       * @param <T>         type of the elements
72       * @param state       spacecraft state
73       * @param baseFrame   base frame associated with the station
74       * @param frequency   frequency of the signal in Hz
75       * @param parameters  ionospheric model parameters
76       * @return the path delay due to the ionosphere in m
77       */
78      <T extends CalculusFieldElement<T>> T pathDelay(FieldSpacecraftState<T> state, TopocentricFrame baseFrame, double frequency, T[] parameters);
79  
80      /** Get the drivers for ionospheric model parameters.
81       * @return drivers for ionospheric model parameters
82       */
83      List<ParameterDriver> getParametersDrivers();
84  
85      /** Get ionospheric model parameters.
86       * @return ionospheric model parameters
87       */
88      default double[] getParameters() {
89          final List<ParameterDriver> drivers = getParametersDrivers();
90          final double[] parameters = new double[drivers.size()];
91          for (int i = 0; i < drivers.size(); ++i) {
92              parameters[i] = drivers.get(i).getValue();
93          }
94          return parameters;
95      }
96  
97      /** Get ionospheric model parameters.
98       * @param field field to which the elements belong
99       * @param <T> type of the elements
100      * @return ionospheric model parameters
101      */
102     default <T extends CalculusFieldElement<T>> T[] getParameters(final Field<T> field) {
103         final List<ParameterDriver> drivers = getParametersDrivers();
104         final T[] parameters = MathArrays.buildArray(field, drivers.size());
105         for (int i = 0; i < drivers.size(); ++i) {
106             parameters[i] = field.getZero().add(drivers.get(i).getValue());
107         }
108         return parameters;
109     }
110 
111 }