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 package org.orekit.models.earth.ionosphere;
18
19 import java.util.Collections;
20 import java.util.List;
21
22 import org.hipparchus.CalculusFieldElement;
23 import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
24 import org.hipparchus.geometry.euclidean.threed.Vector3D;
25 import org.hipparchus.util.FastMath;
26 import org.orekit.frames.TopocentricFrame;
27 import org.orekit.propagation.FieldSpacecraftState;
28 import org.orekit.propagation.SpacecraftState;
29 import org.orekit.utils.ParameterDriver;
30
31 /**
32 * An estimated ionospheric model. The ionospheric delay is computed according to the formula:
33 * <p>
34 * 40.3
35 * δ = -------- * STEC with, STEC = VTEC * F(elevation)
36 * f²
37 * </p>
38 * With:
39 * <ul>
40 * <li>f: The frequency of the signal in Hz.</li>
41 * <li>STEC: The Slant Total Electron Content in TECUnits.</li>
42 * <li>VTEC: The Vertical Total Electron Content in TECUnits.</li>
43 * <li>F(elevation): A mapping function which depends on satellite elevation.</li>
44 * </ul>
45 * The VTEC is estimated as a {@link ParameterDriver}
46 *
47 * @author Bryan Cazabonne
48 * @since 10.2
49 */
50 public class EstimatedIonosphericModel implements IonosphericModel {
51
52 /** Name of the parameter of this model: the Vertical Total Electron Content. */
53 public static final String VERTICAL_TOTAL_ELECTRON_CONTENT = "vertical total electron content";
54
55 /** Ionospheric delay factor. */
56 private static final double FACTOR = 40.3e16;
57
58 /** Ionospheric mapping Function model. */
59 private final transient IonosphericMappingFunction model;
60
61 /** Driver for the Vertical Total Electron Content.*/
62 private final transient ParameterDriver vtec;
63
64
65 /**
66 * Build a new instance.
67 * @param model ionospheric mapping function
68 * @param vtecValue value of the Vertical Total Electron Content in TECUnits
69 */
70 public EstimatedIonosphericModel(final IonosphericMappingFunction model, final double vtecValue) {
71 this.model = model;
72 this.vtec = new ParameterDriver(EstimatedIonosphericModel.VERTICAL_TOTAL_ELECTRON_CONTENT,
73 vtecValue, FastMath.scalb(1.0, 3), 0.0, 1000.0);
74 }
75
76 /** {@inheritDoc} */
77 @Override
78 public double pathDelay(final SpacecraftState state, final TopocentricFrame baseFrame,
79 final double frequency, final double[] parameters) {
80 // Elevation in radians
81 final Vector3D position = state.getPosition(baseFrame);
82 final double elevation = position.getDelta();
83
84 // Only consider measures above the horizon
85 if (elevation > 0.0) {
86 // Delay
87 return pathDelay(elevation, frequency, parameters);
88 }
89
90 return 0.0;
91 }
92
93 /**
94 * Calculates the ionospheric path delay for the signal path from a ground
95 * station to a satellite.
96 * <p>
97 * The path delay is computed for any elevation angle.
98 * </p>
99 * @param elevation elevation of the satellite in radians
100 * @param frequency frequency of the signal in Hz
101 * @param parameters ionospheric model parameters
102 * @return the path delay due to the ionosphere in m
103 */
104 public double pathDelay(final double elevation, final double frequency, final double[] parameters) {
105 // Square of the frequency
106 final double freq2 = frequency * frequency;
107 // Mapping factor
108 final double fz = model.mappingFactor(elevation);
109 // "Slant" Total Electron Content
110 final double stec = parameters[0] * fz;
111 // Delay computation
112 final double alpha = FACTOR / freq2;
113 return alpha * stec;
114 }
115
116 /** {@inheritDoc} */
117 @Override
118 public <T extends CalculusFieldElement<T>> T pathDelay(final FieldSpacecraftState<T> state, final TopocentricFrame baseFrame,
119 final double frequency, final T[] parameters) {
120 // Elevation and azimuth in radians
121 final FieldVector3D<T> position = state.getPosition(baseFrame);
122 final T elevation = position.getDelta();
123
124 if (elevation.getReal() > 0.0) {
125 // Delay
126 return pathDelay(elevation, frequency, parameters);
127 }
128
129 return elevation.getField().getZero();
130 }
131
132 /**
133 * Calculates the ionospheric path delay for the signal path from a ground
134 * station to a satellite.
135 * <p>
136 * The path delay is computed for any elevation angle.
137 * </p>
138 * @param <T> type of the elements
139 * @param elevation elevation of the satellite in radians
140 * @param frequency frequency of the signal in Hz
141 * @param parameters ionospheric model parameters at state date
142 * @return the path delay due to the ionosphere in m
143 */
144 public <T extends CalculusFieldElement<T>> T pathDelay(final T elevation, final double frequency, final T[] parameters) {
145 // Square of the frequency
146 final double freq2 = frequency * frequency;
147 // Mapping factor
148 final T fz = model.mappingFactor(elevation);
149 // "Slant" Total Electron Content
150 final T stec = parameters[0].multiply(fz);
151 // Delay computation
152 final double alpha = FACTOR / freq2;
153 return stec.multiply(alpha);
154 }
155
156 @Override
157 public List<ParameterDriver> getParametersDrivers() {
158 return Collections.singletonList(vtec);
159 }
160
161 }