1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.propagation.conversion.osc2mean;
18
19 import org.hipparchus.CalculusFieldElement;
20 import org.hipparchus.Field;
21 import org.orekit.annotation.DefaultDataContext;
22 import org.orekit.data.DataContext;
23 import org.orekit.frames.Frame;
24 import org.orekit.orbits.FieldKeplerianOrbit;
25 import org.orekit.orbits.FieldOrbit;
26 import org.orekit.orbits.KeplerianOrbit;
27 import org.orekit.orbits.Orbit;
28 import org.orekit.orbits.OrbitType;
29 import org.orekit.propagation.analytical.tle.FieldTLE;
30 import org.orekit.propagation.analytical.tle.FieldTLEPropagator;
31 import org.orekit.propagation.analytical.tle.TLE;
32 import org.orekit.propagation.analytical.tle.TLEConstants;
33 import org.orekit.propagation.analytical.tle.TLEPropagator;
34 import org.orekit.propagation.analytical.tle.generation.TleGenerationUtil;
35 import org.orekit.time.FieldAbsoluteDate;
36 import org.orekit.time.TimeScale;
37
38
39
40
41
42
43
44 public class TLETheory implements MeanTheory {
45
46
47 public static final String TMP_L1 = "1 00000U 00000A 00001.00000000 .00000000 00000+0 00000+0 0 02";
48
49 public static final String TMP_L2 = "2 00000 0.0000 0.0000 0000000 0.0000 0.0000 0.00000000 02";
50
51
52 public static final String THEORY = "TLE";
53
54
55 private final TLE tmpTle;
56
57
58 private final TimeScale utc;
59
60
61 private final Frame teme;
62
63
64
65
66 @DefaultDataContext
67 public TLETheory() {
68 this(DataContext.getDefault());
69 }
70
71
72
73
74
75 @DefaultDataContext
76 public TLETheory(final TLE template) {
77 this(template, DataContext.getDefault());
78 }
79
80
81
82
83
84
85 @DefaultDataContext
86 public <T extends CalculusFieldElement<T>> TLETheory(final FieldTLE<T> template) {
87 this(template, DataContext.getDefault());
88 }
89
90
91
92
93
94 public TLETheory(final DataContext dataContext) {
95 this(dataContext.getTimeScales().getUTC(), dataContext.getFrames().getTEME());
96 }
97
98
99
100
101
102
103 public TLETheory(final TimeScale utc, final Frame teme) {
104 this(new TLE(TMP_L1, TMP_L2, utc), utc, teme);
105 }
106
107
108
109
110
111
112 public TLETheory(final TLE template, final DataContext dataContext) {
113 this(template, dataContext.getTimeScales().getUTC(), dataContext.getFrames().getTEME());
114 }
115
116
117
118
119
120
121
122 public TLETheory(final TLE template, final TimeScale utc, final Frame teme) {
123 this.tmpTle = template;
124 this.utc = utc;
125 this.teme = teme;
126 }
127
128
129
130
131
132
133
134 public <T extends CalculusFieldElement<T>> TLETheory(final FieldTLE<T> template, final DataContext dataContext) {
135 this(template, dataContext.getTimeScales().getUTC(), dataContext.getFrames().getTEME());
136 }
137
138
139
140
141
142
143
144
145 public <T extends CalculusFieldElement<T>> TLETheory(final FieldTLE<T> template, final TimeScale utc, final Frame teme) {
146 this.tmpTle = template.toTLE();
147 this.utc = utc;
148 this.teme = teme;
149 }
150
151
152 @Override
153 public String getTheoryName() {
154 return THEORY;
155 }
156
157
158 @Override
159 public double getReferenceRadius() {
160 return 1000 * TLEConstants.EARTH_RADIUS;
161 };
162
163
164
165
166 @Override
167 public Orbit preprocessing(final Orbit osculating) {
168 return new KeplerianOrbit(osculating.getPVCoordinates(teme), teme, TLEPropagator.getMU());
169 }
170
171
172 @Override
173 public Orbit meanToOsculating(final Orbit mean) {
174
175 final KeplerianOrbit meanKepl = (KeplerianOrbit) OrbitType.KEPLERIAN.convertType(mean);
176 final TLE meanTle = TleGenerationUtil.newTLE(meanKepl, tmpTle, tmpTle.getBStar(mean.getDate()), utc);
177 final TLEPropagator propagator = TLEPropagator.selectExtrapolator(meanTle, teme);
178 return propagator.getInitialState().getOrbit();
179 }
180
181
182
183
184 @Override
185 public Orbit postprocessing(final Orbit osculating, final Orbit mean) {
186 return OrbitType.KEPLERIAN.convertType(mean);
187 }
188
189
190
191
192 @Override
193 public <T extends CalculusFieldElement<T>> FieldOrbit<T> preprocessing(final FieldOrbit<T> osculating) {
194 final T mu = osculating.getDate().getField().getZero().newInstance(TLEConstants.MU);
195 return new FieldKeplerianOrbit<T>(osculating.getPVCoordinates(teme), teme, mu);
196 }
197
198
199 @Override
200 public <T extends CalculusFieldElement<T>> FieldOrbit<T> meanToOsculating(final FieldOrbit<T> mean) {
201 final FieldAbsoluteDate<T> date = mean.getDate();
202 final Field<T> field = date.getField();
203 final FieldTLE<T> fieldTmpTle = new FieldTLE<T>(field, tmpTle.getLine1(), tmpTle.getLine2(), utc);
204 final T bStar = field.getZero().newInstance(fieldTmpTle.getBStar());
205
206 final FieldKeplerianOrbit<T> meanKepl = (FieldKeplerianOrbit<T>) OrbitType.KEPLERIAN.convertType(mean);
207 final FieldTLE<T> meanTle = TleGenerationUtil.newTLE(meanKepl, fieldTmpTle, bStar, utc);
208 final FieldTLEPropagator<T> propagator = FieldTLEPropagator.selectExtrapolator(meanTle, teme, meanTle.getParameters(field));
209 return propagator.getInitialState().getOrbit();
210 }
211
212
213
214
215 @Override
216 public <T extends CalculusFieldElement<T>> FieldOrbit<T> postprocessing(final FieldOrbit<T> osculating,
217 final FieldOrbit<T> mean) {
218 return OrbitType.KEPLERIAN.convertType(mean);
219 }
220
221 }