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.files.sinex;
18
19 import org.orekit.frames.EOPEntry;
20 import org.orekit.frames.ITRFVersion;
21 import org.orekit.time.AbsoluteDate;
22 import org.orekit.time.TimeScale;
23 import org.orekit.time.TimeStamped;
24 import org.orekit.utils.IERSConventions;
25
26 /**
27 * Container for EOP entry read in a Sinex file.
28 *
29 * @author Bryan Cazabonne
30 * @since 11.2
31 */
32 public class SinexEopEntry implements TimeStamped {
33
34 /** Length of day (seconds). */
35 private double lod;
36
37 /** UT1-UTC (seconds). */
38 private double ut1MinusUtc;
39
40 /** X polar motion (radians). */
41 private double xPo;
42
43 /** Y polar motion (radians). */
44 private double yPo;
45
46 /** Nutation correction in longitude (radians). */
47 private double nutLn;
48
49 /** Nutation correction in obliquity (radians). */
50 private double nutOb;
51
52 /** Nutation correction X (radians). */
53 private double nutX;
54
55 /** Nutation correction Y (radians). */
56 private double nutY;
57
58 /** EOP entry reference epoch. */
59 private final AbsoluteDate epoch;
60
61 /**
62 * Constructor.
63 * @param epoch epoch of the data
64 */
65 public SinexEopEntry(final AbsoluteDate epoch) {
66 this.epoch = epoch;
67 }
68
69 /** {@inheritDoc} */
70 @Override
71 public AbsoluteDate getDate() {
72 return epoch;
73 }
74
75 /**
76 * Get the length of day.
77 * @return the length of day in seconds
78 */
79 public double getLod() {
80 return lod;
81 }
82
83 /**
84 * Set the length of day.
85 * @param lod the length of day to set in seconds
86 */
87 public void setLod(final double lod) {
88 this.lod = lod;
89 }
90
91 /**
92 * Get the UT1-UTC offset.
93 * @return the UT1-UTC offset in seconds
94 */
95 public double getUt1MinusUtc() {
96 return ut1MinusUtc;
97 }
98
99 /**
100 * Set the UT1-UTC offset.
101 * @param ut1MinusUtc the value to set in seconds
102 */
103 public void setUt1MinusUtc(final double ut1MinusUtc) {
104 this.ut1MinusUtc = ut1MinusUtc;
105 }
106
107 /**
108 * Get the X polar motion.
109 * @return the X polar motion in radians
110 */
111 public double getXPo() {
112 return xPo;
113 }
114
115 /**
116 * Set the X polar motion.
117 * @param xPo the X polar motion to set in radians
118 */
119 public void setxPo(final double xPo) {
120 this.xPo = xPo;
121 }
122
123 /**
124 * Get the Y polar motion.
125 * @return the Y polar motion in radians
126 */
127 public double getYPo() {
128 return yPo;
129 }
130
131 /**
132 * Set the Y polar motion.
133 * @param yPo the Y polar motion to set in radians
134 */
135 public void setyPo(final double yPo) {
136 this.yPo = yPo;
137 }
138
139 /**
140 * Get the nutation correction in longitude.
141 * @return the nutation correction in longitude in radians
142 */
143 public double getNutLn() {
144 return nutLn;
145 }
146
147 /**
148 * Set the nutation correction in longitude.
149 * @param nutLn the nutation correction in longitude to set in radians
150 */
151 public void setNutLn(final double nutLn) {
152 this.nutLn = nutLn;
153 }
154
155 /**
156 * Get the nutation correction in obliquity.
157 * @return the nutation correction in obliquity in radians
158 */
159 public double getNutOb() {
160 return nutOb;
161 }
162
163 /**
164 * Set the nutation correction in obliquity.
165 * @param nutOb the nutation correction in obliquity to set in radians
166 */
167 public void setNutOb(final double nutOb) {
168 this.nutOb = nutOb;
169 }
170
171 /**
172 * Get the nutation correction X.
173 * @return the nutation correction X in radians
174 */
175 public double getNutX() {
176 return nutX;
177 }
178
179 /**
180 * Set the nutation correction X.
181 * @param nutX the nutation correction X to set in radians
182 */
183 public void setNutX(final double nutX) {
184 this.nutX = nutX;
185 }
186
187 /**
188 * Get the nutation correction Y.
189 * @return the nutation correction Y in radians
190 */
191 public double getNutY() {
192 return nutY;
193 }
194
195 /**
196 * Set the nutation correction Y.
197 * @param nutY the nutation correction Y to set in radians
198 */
199 public void setNutY(final double nutY) {
200 this.nutY = nutY;
201 }
202
203 /**
204 * Converts to an {@link EOPEntry}.
205 * @param converter converter to use for nutation corrections
206 * @param version ITRF version
207 * @param scale time scale for epochs
208 * @return an {@code EOPEntry}
209 */
210 public EOPEntry toEopEntry(final IERSConventions.NutationCorrectionConverter converter,
211 final ITRFVersion version, final TimeScale scale) {
212
213 // Modified Julian Day
214 final int mjd = epoch.getComponents(scale).getDate().getMJD();
215
216 // Array for equinox and non rotating origin
217 final double[] nro = (nutX != 0 && nutY != 0) ? new double[] {nutX, nutY} : converter.toNonRotating(epoch, nutLn, nutOb);
218 final double[] equinox = (nutLn != 0 && nutOb != 0) ? new double[] {nutLn, nutOb} : converter.toEquinox(epoch, nutX, nutY);
219
220 // Create a new EOPEntry object storing the extracted data, then add it to the list of EOPEntries.
221 return new EOPEntry(mjd, ut1MinusUtc, lod,
222 xPo, yPo, Double.NaN, Double.NaN,
223 equinox[0], equinox[1],
224 nro[0], nro[1],
225 version, epoch);
226
227 }
228
229 /** Copy an EOP entry to another epoch.
230 * <p>
231 * Only the data epoch is updated.
232 * </p>
233 * @param date new epoch
234 * @return a new entry with changed epoch
235 */
236 SinexEopEntry toNewEpoch(final AbsoluteDate date) {
237
238 // Initialize
239 final SinexEopEntry newEntry = new SinexEopEntry(date);
240
241 // Fill
242 newEntry.setLod(getLod());
243 newEntry.setUt1MinusUtc(getUt1MinusUtc());
244 newEntry.setxPo(getXPo());
245 newEntry.setyPo(getYPo());
246 newEntry.setNutX(getNutX());
247 newEntry.setNutY(getNutY());
248 newEntry.setNutLn(getNutLn());
249 newEntry.setNutOb(getNutOb());
250
251 // Return
252 return newEntry;
253
254 }
255
256 }