1 /* Copyright 2002-2026 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.propagation.analytical.gnss.data;
18
19 import org.hipparchus.CalculusFieldElement;
20 import org.orekit.frames.Frame;
21 import org.orekit.orbits.FieldKeplerianOrbit;
22 import org.orekit.orbits.KeplerianOrbit;
23 import org.orekit.time.FieldGNSSDate;
24 import org.orekit.time.GNSSDate;
25 import org.orekit.time.TimeScales;
26
27 import java.util.function.DoubleFunction;
28
29 /**
30 * This class holds a GPS almanac as read from SEM or YUMA files.
31 *
32 * <p>Depending on the source (SEM or YUMA), some fields may be filled in or not.
33 * An almanac read from a YUMA file doesn't hold SVN number, average URA and satellite
34 * configuration.</p>
35 *
36 * @author Pascal Parraud
37 * @since 8.0
38 *
39 */
40 public class GPSAlmanac extends GNSSOrbitalElements<GPSAlmanac> {
41
42 /** Source of the almanac. */
43 private final String source;
44
45 /** SVN number. */
46 private final int svn;
47
48 /** Health status. */
49 private final int health;
50
51 /** Average URA. */
52 private final int ura;
53
54 /** Satellite configuration. */
55 private final int satConfiguration;
56
57 /**
58 * Constructor.
59 * @param timeScales known time scales
60 * @param prn PRN number of the satellite
61 * @param toe time of ephemeris (<em>must</em> be consistent with {@code orbit})
62 * @param orbit Keplerian orbit in Earth-frozen frame
63 * @param aDot change rate in semi-major axis (m/s)
64 * @param deltaN0 delta of satellite mean motion
65 * @param deltaN0Dot change rate in Δn₀
66 * @param iDot inclination rate (rad/s)
67 * @param omegaDot rate of right ascension (rad/s)
68 * @param cuc amplitude of the cosine harmonic correction term to the argument of latitude
69 * @param cus amplitude of the sine harmonic correction term to the argument of latitude
70 * @param crc amplitude of the cosine harmonic correction term to the orbit radius
71 * @param crs amplitude of the sine harmonic correction term to the orbit radius
72 * @param cic amplitude of the cosine harmonic correction term to the inclination
73 * @param cis amplitude of the sine harmonic correction term to the inclination
74 * @param af0 zero-th order clock correction (s)
75 * @param af1 first order clock correction (s/s)
76 * @param af2 second order clock correction (s/s²)
77 * @param tgd group delay differential TGD for L1-L2 correction
78 * @param toc time of clock
79 * @param source source of the almanac
80 * @param svn SVN number
81 * @param health health status
82 * @param ura average URA
83 * @param satConfiguration satellite configuration
84 */
85 public GPSAlmanac(final TimeScales timeScales, final int prn,
86 final GNSSDate toe, final KeplerianOrbit orbit,
87 final double aDot, final double deltaN0, final double deltaN0Dot,
88 final double iDot, final double omegaDot,
89 final double cuc, final double cus,
90 final double crc, final double crs,
91 final double cic, final double cis,
92 final double af0, final double af1, final double af2,
93 final double tgd, final GNSSDate toc, final String source, final int svn,
94 final int health, final int ura, final int satConfiguration) {
95 super(GNSSConstants.GPS_AV, GNSSConstants.GPS_WEEK_NB,
96 timeScales, null, prn,
97 toe, orbit, aDot, deltaN0, deltaN0Dot, iDot, omegaDot,
98 cuc, cus, crc, crs, cic, cis, af0, af1, af2, tgd, toc);
99 this.source = source;
100 this.svn = svn;
101 this.health = health;
102 this.ura = ura;
103 this.satConfiguration = satConfiguration;
104 }
105
106 /** Constructor from field instance.
107 * @param <T> type of the field elements
108 * @param original regular field instance
109 */
110 public <T extends CalculusFieldElement<T>> GPSAlmanac(final FieldGPSAlmanac<T> original) {
111 super(original);
112 source = original.getSource();
113 svn = original.getSVN();
114 health = original.getHealth();
115 ura = original.getURA();
116 satConfiguration = original.getSatConfiguration();
117 }
118
119 /** {@inheritDoc} */
120 @Override
121 public <T extends CalculusFieldElement<T>> FieldGPSAlmanac<T>
122 toField(final FieldKeplerianOrbit<T> orbit,
123 final T[] nonKeplerian,
124 final DoubleFunction<T> converter) {
125 return new FieldGPSAlmanac<>(getAngularVelocity(), getWeeksInCycle(), getTimeScales(),
126 getType(), getPrn(),
127 new FieldGNSSDate<>(orbit.getDate().getField(), getTimeOfEphemeris()),
128 orbit, nonKeplerian,
129 converter.apply(getTgd()),
130 new FieldGNSSDate<>(orbit.getDate().getField(), getTimeOfClock()),
131 getSource(), getSVN(),
132 getHealth(), getURA(), getSatConfiguration());
133 }
134
135 /** Get the source of this GPS almanac.
136 * <p>Sources can be SEM or YUMA, when the almanac is read from a file.</p>
137 * @return the source of this GPS almanac
138 */
139 public String getSource() {
140 return source;
141 }
142
143 /** Get the satellite "SVN" reference number.
144 * @return the satellite "SVN" reference number
145 */
146 public int getSVN() {
147 return svn;
148 }
149
150 /** Get the Health status.
151 * @return the Health status
152 */
153 public int getHealth() {
154 return health;
155 }
156
157 /** Get the average URA number.
158 * @return the average URA number
159 */
160 public int getURA() {
161 return ura;
162 }
163
164 /** Get the satellite configuration.
165 * @return the satellite configuration
166 */
167 public int getSatConfiguration() {
168 return satConfiguration;
169 }
170
171 /** {@inheritDoc} */
172 @Override
173 public GPSAlmanacFactory baseFactory(final Frame inertial, final Frame bodyFixed) {
174 return new GPSAlmanacFactory(getTimeScales(), getTimeOfEphemeris().getSystem(),
175 inertial, bodyFixed);
176 }
177
178 }