1 /* Contributed in the public domain.
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.frames;
18
19 import org.orekit.bodies.CelestialBodies;
20 import org.orekit.time.TimeScales;
21 import org.orekit.utils.IERSConventions;
22
23 /**
24 * This class lazily loads auxiliary data when it is needed by a requested frame. It is
25 * designed to match the behavior of {@link FramesFactory} in Orekit 10.0.
26 *
27 * @author Guylaine Prat
28 * @author Luc Maisonobe
29 * @author Pascal Parraud
30 * @author Evan Ward
31 * @see LazyLoadedEop
32 * @since 10.1
33 */
34 public class LazyLoadedFrames extends AbstractFrames {
35
36 /** Delegate for all EOP loading. */
37 private final LazyLoadedEop lazyLoadedEop;
38
39 /**
40 * Create a collection of frames from the given auxiliary data.
41 *
42 * @param lazyLoadedEop loads Earth Orientation Parameters.
43 * @param timeScales defines the time scales used when computing frame
44 * transformations. For example, the TT time scale needed for
45 * {@link #getPZ9011(IERSConventions, boolean)}.
46 * @param celestialBodies defines the celestial bodies which, for example, are used in
47 * {@link #getICRF()}.
48 */
49 public LazyLoadedFrames(final LazyLoadedEop lazyLoadedEop,
50 final TimeScales timeScales,
51 final CelestialBodies celestialBodies) {
52 super(timeScales, () -> celestialBodies.getSolarSystemBarycenter()
53 .getInertiallyOrientedFrame());
54 this.lazyLoadedEop = lazyLoadedEop;
55 }
56
57 /** Add the default loaders EOP history (IAU 1980 precession/nutation).
58 * <p>
59 * The default loaders look for IERS EOP C04 and bulletins B files. They
60 * correspond to {@link IERSConventions#IERS_1996 IERS 1996} conventions.
61 * </p>
62 * @param rapidDataColumnsSupportedNames regular expression for supported
63 * rapid data columns EOP files names
64 * (may be null if the default IERS file names are used)
65 * @param rapidDataXMLSupportedNames regular expression for supported
66 * rapid data XML EOP files names
67 * (may be null if the default IERS file names are used)
68 * @param eopC04SupportedNames regular expression for supported EOP C04 files names
69 * (may be null if the default IERS file names are used)
70 * @param bulletinBSupportedNames regular expression for supported bulletin B files names
71 * (may be null if the default IERS file names are used)
72 * @param bulletinASupportedNames regular expression for supported bulletin A files names
73 * (may be null if the default IERS file names are used)
74 * @see <a href="http://hpiers.obspm.fr/eoppc/eop/eopc04/">IERS EOP C04 files</a>
75 * @see #addEOPHistoryLoader(IERSConventions, EOPHistoryLoader)
76 * @see #clearEOPHistoryLoaders()
77 * @see #addDefaultEOP2000HistoryLoaders(String, String, String, String, String)
78 */
79 public void addDefaultEOP1980HistoryLoaders(final String rapidDataColumnsSupportedNames,
80 final String rapidDataXMLSupportedNames,
81 final String eopC04SupportedNames,
82 final String bulletinBSupportedNames,
83 final String bulletinASupportedNames) {
84 lazyLoadedEop.addDefaultEOP1980HistoryLoaders(
85 rapidDataColumnsSupportedNames,
86 rapidDataXMLSupportedNames,
87 eopC04SupportedNames,
88 bulletinBSupportedNames,
89 bulletinASupportedNames,
90 () -> getTimeScales().getUTC());
91 }
92
93 /** Add the default loaders for EOP history (IAU 2000/2006 precession/nutation).
94 * <p>
95 * The default loaders look for IERS EOP C04 and bulletins B files. They
96 * correspond to both {@link IERSConventions#IERS_2003 IERS 2003} and {@link
97 * IERSConventions#IERS_2010 IERS 2010} conventions.
98 * </p>
99 * @param rapidDataColumnsSupportedNames regular expression for supported
100 * rapid data columns EOP files names
101 * (may be null if the default IERS file names are used)
102 * @param rapidDataXMLSupportedNames regular expression for supported
103 * rapid data XML EOP files names
104 * (may be null if the default IERS file names are used)
105 * @param eopC04SupportedNames regular expression for supported EOP C04 files names
106 * (may be null if the default IERS file names are used)
107 * @param bulletinBSupportedNames regular expression for supported bulletin B files names
108 * (may be null if the default IERS file names are used)
109 * @param bulletinASupportedNames regular expression for supported bulletin A files names
110 * (may be null if the default IERS file names are used)
111 * @see <a href="http://hpiers.obspm.fr/eoppc/eop/eopc04/">IERS EOP C04 files</a>
112 * @see #addEOPHistoryLoader(IERSConventions, EOPHistoryLoader)
113 * @see #clearEOPHistoryLoaders()
114 * @see #addDefaultEOP1980HistoryLoaders(String, String, String, String, String)
115 */
116 public void addDefaultEOP2000HistoryLoaders(final String rapidDataColumnsSupportedNames,
117 final String rapidDataXMLSupportedNames,
118 final String eopC04SupportedNames,
119 final String bulletinBSupportedNames,
120 final String bulletinASupportedNames) {
121 lazyLoadedEop.addDefaultEOP2000HistoryLoaders(
122 rapidDataColumnsSupportedNames,
123 rapidDataXMLSupportedNames,
124 eopC04SupportedNames,
125 bulletinBSupportedNames,
126 bulletinASupportedNames,
127 () -> getTimeScales().getUTC());
128 }
129
130 /** Add a loader for Earth Orientation Parameters history.
131 * @param conventions IERS conventions to which EOP history applies
132 * @param loader custom loader to add for the EOP history
133 * @see #addDefaultEOP1980HistoryLoaders(String, String, String, String, String)
134 * @see #clearEOPHistoryLoaders()
135 */
136 public void addEOPHistoryLoader(final IERSConventions conventions, final EOPHistoryLoader loader) {
137 lazyLoadedEop.addEOPHistoryLoader(conventions, loader);
138 }
139
140 /** Clear loaders for Earth Orientation Parameters history.
141 * @see #addEOPHistoryLoader(IERSConventions, EOPHistoryLoader)
142 * @see #addDefaultEOP1980HistoryLoaders(String, String, String, String, String)
143 */
144 public void clearEOPHistoryLoaders() {
145 lazyLoadedEop.clearEOPHistoryLoaders();
146 }
147
148 /** Set the threshold to check EOP continuity.
149 * <p>
150 * The default threshold (used if this method is never called)
151 * is 5 Julian days. If after loading EOP entries some holes
152 * between entries exceed this threshold, an exception will
153 * be triggered.
154 * </p>
155 * <p>
156 * One case when calling this method is really useful is for
157 * applications that use a single Bulletin A, as these bulletins
158 * have a roughly one month wide hole for the first bulletin of
159 * each month, which contains older final data in addition to the
160 * rapid data and the predicted data.
161 * </p>
162 * @param threshold threshold to use for checking EOP continuity (in seconds)
163 */
164 public void setEOPContinuityThreshold(final double threshold) {
165 lazyLoadedEop.setEOPContinuityThreshold(threshold);
166 }
167
168 /** {@inheritDoc}
169 * <p>
170 * If no {@link EOPHistoryLoader} has been added by calling {@link
171 * #addEOPHistoryLoader(IERSConventions, EOPHistoryLoader) addEOPHistoryLoader}
172 * or if {@link #clearEOPHistoryLoaders() clearEOPHistoryLoaders} has been
173 * called afterwards, the {@link #addDefaultEOP1980HistoryLoaders(String, String,
174 * String, String, String)} and {@link #addDefaultEOP2000HistoryLoaders(String,
175 * String, String, String, String)} methods will be called automatically with
176 * supported file names parameters all set to null, in order to get the default
177 * loaders configuration.
178 * </p>
179 */
180 @Override
181 public EOPHistory getEOPHistory(final IERSConventions conventions, final boolean simpleEOP) {
182 return lazyLoadedEop.getEOPHistory(conventions, simpleEOP, getTimeScales());
183 }
184
185 }