LazyLoadedFrames.java

  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. import org.orekit.bodies.CelestialBodies;
  19. import org.orekit.time.TimeScales;
  20. import org.orekit.utils.IERSConventions;

  21. /**
  22.  * This class lazily loads auxiliary data when it is needed by a requested frame. It is
  23.  * designed to match the behavior of {@link FramesFactory} in Orekit 10.0.
  24.  *
  25.  * @author Guylaine Prat
  26.  * @author Luc Maisonobe
  27.  * @author Pascal Parraud
  28.  * @author Evan Ward
  29.  * @see LazyLoadedEop
  30.  * @since 10.1
  31.  */
  32. public class LazyLoadedFrames extends AbstractFrames {

  33.     /** Delegate for all EOP loading. */
  34.     private final LazyLoadedEop lazyLoadedEop;

  35.     /**
  36.      * Create a collection of frames from the given auxiliary data.
  37.      *
  38.      * @param lazyLoadedEop   loads Earth Orientation Parameters.
  39.      * @param timeScales      defines the time scales used when computing frame
  40.      *                        transformations. For example, the TT time scale needed for
  41.      *                        {@link #getPZ9011(IERSConventions, boolean)}.
  42.      * @param celestialBodies defines the celestial bodies which, for example, are used in
  43.      *                        {@link #getICRF()}.
  44.      */
  45.     public LazyLoadedFrames(final LazyLoadedEop lazyLoadedEop,
  46.                             final TimeScales timeScales,
  47.                             final CelestialBodies celestialBodies) {
  48.         super(timeScales, () -> celestialBodies.getSolarSystemBarycenter()
  49.                 .getInertiallyOrientedFrame());
  50.         this.lazyLoadedEop = lazyLoadedEop;
  51.     }

  52.     /** Add the default loaders EOP history (IAU 1980 precession/nutation).
  53.      * <p>
  54.      * The default loaders look for IERS EOP C04 and bulletins B files. They
  55.      * correspond to {@link IERSConventions#IERS_1996 IERS 1996} conventions.
  56.      * </p>
  57.      * @param rapidDataColumnsSupportedNames regular expression for supported
  58.      * rapid data columns EOP files names
  59.      * (may be null if the default IERS file names are used)
  60.      * @param rapidDataXMLSupportedNames regular expression for supported
  61.      * rapid data XML EOP files names
  62.      * (may be null if the default IERS file names are used)
  63.      * @param eopC04SupportedNames regular expression for supported EOP C04 files names
  64.      * (may be null if the default IERS file names are used)
  65.      * @param bulletinBSupportedNames regular expression for supported bulletin B files names
  66.      * (may be null if the default IERS file names are used)
  67.      * @param bulletinASupportedNames regular expression for supported bulletin A files names
  68.      * (may be null if the default IERS file names are used)
  69.      * @see <a href="http://hpiers.obspm.fr/eoppc/eop/eopc04/">IERS EOP C04 files</a>
  70.      * @see #addEOPHistoryLoader(IERSConventions, EOPHistoryLoader)
  71.      * @see #clearEOPHistoryLoaders()
  72.      * @see #addDefaultEOP2000HistoryLoaders(String, String, String, String, String)
  73.      */
  74.     public void addDefaultEOP1980HistoryLoaders(final String rapidDataColumnsSupportedNames,
  75.                                                        final String rapidDataXMLSupportedNames,
  76.                                                        final String eopC04SupportedNames,
  77.                                                        final String bulletinBSupportedNames,
  78.                                                        final String bulletinASupportedNames) {
  79.         lazyLoadedEop.addDefaultEOP1980HistoryLoaders(
  80.             rapidDataColumnsSupportedNames,
  81.             rapidDataXMLSupportedNames,
  82.             eopC04SupportedNames,
  83.             bulletinBSupportedNames,
  84.             bulletinASupportedNames,
  85.             () -> getTimeScales().getUTC());
  86.     }

  87.     /** Add the default loaders for EOP history (IAU 2000/2006 precession/nutation).
  88.      * <p>
  89.      * The default loaders look for IERS EOP C04 and bulletins B files. They
  90.      * correspond to both {@link IERSConventions#IERS_2003 IERS 2003} and {@link
  91.      * IERSConventions#IERS_2010 IERS 2010} conventions.
  92.      * </p>
  93.      * @param rapidDataColumnsSupportedNames regular expression for supported
  94.      * rapid data columns EOP files names
  95.      * (may be null if the default IERS file names are used)
  96.      * @param rapidDataXMLSupportedNames regular expression for supported
  97.      * rapid data XML EOP files names
  98.      * (may be null if the default IERS file names are used)
  99.      * @param eopC04SupportedNames regular expression for supported EOP C04 files names
  100.      * (may be null if the default IERS file names are used)
  101.      * @param bulletinBSupportedNames regular expression for supported bulletin B files names
  102.      * (may be null if the default IERS file names are used)
  103.      * @param bulletinASupportedNames regular expression for supported bulletin A files names
  104.      * (may be null if the default IERS file names are used)
  105.      * @see <a href="http://hpiers.obspm.fr/eoppc/eop/eopc04/">IERS EOP C04 files</a>
  106.      * @see #addEOPHistoryLoader(IERSConventions, EOPHistoryLoader)
  107.      * @see #clearEOPHistoryLoaders()
  108.      * @see #addDefaultEOP1980HistoryLoaders(String, String, String, String, String)
  109.      */
  110.     public void addDefaultEOP2000HistoryLoaders(final String rapidDataColumnsSupportedNames,
  111.                                                        final String rapidDataXMLSupportedNames,
  112.                                                        final String eopC04SupportedNames,
  113.                                                        final String bulletinBSupportedNames,
  114.                                                        final String bulletinASupportedNames) {
  115.         lazyLoadedEop.addDefaultEOP2000HistoryLoaders(
  116.             rapidDataColumnsSupportedNames,
  117.             rapidDataXMLSupportedNames,
  118.             eopC04SupportedNames,
  119.             bulletinBSupportedNames,
  120.             bulletinASupportedNames,
  121.             () -> getTimeScales().getUTC());
  122.     }

  123.     /** Add a loader for Earth Orientation Parameters history.
  124.      * @param conventions IERS conventions to which EOP history applies
  125.      * @param loader custom loader to add for the EOP history
  126.      * @see #addDefaultEOP1980HistoryLoaders(String, String, String, String, String)
  127.      * @see #clearEOPHistoryLoaders()
  128.      */
  129.     public void addEOPHistoryLoader(final IERSConventions conventions, final EOPHistoryLoader loader) {
  130.         lazyLoadedEop.addEOPHistoryLoader(conventions, loader);
  131.     }

  132.     /** Clear loaders for Earth Orientation Parameters history.
  133.      * @see #addEOPHistoryLoader(IERSConventions, EOPHistoryLoader)
  134.      * @see #addDefaultEOP1980HistoryLoaders(String, String, String, String, String)
  135.      */
  136.     public void clearEOPHistoryLoaders() {
  137.         lazyLoadedEop.clearEOPHistoryLoaders();
  138.     }

  139.     /** Set the threshold to check EOP continuity.
  140.      * <p>
  141.      * The default threshold (used if this method is never called)
  142.      * is 5 Julian days. If after loading EOP entries some holes
  143.      * between entries exceed this threshold, an exception will
  144.      * be triggered.
  145.      * </p>
  146.      * <p>
  147.      * One case when calling this method is really useful is for
  148.      * applications that use a single Bulletin A, as these bulletins
  149.      * have a roughly one month wide hole for the first bulletin of
  150.      * each month, which contains older final data in addition to the
  151.      * rapid data and the predicted data.
  152.      * </p>
  153.      * @param threshold threshold to use for checking EOP continuity (in seconds)
  154.      */
  155.     public void setEOPContinuityThreshold(final double threshold) {
  156.         lazyLoadedEop.setEOPContinuityThreshold(threshold);
  157.     }

  158.     /** {@inheritDoc}
  159.      * <p>
  160.      * If no {@link EOPHistoryLoader} has been added by calling {@link
  161.      * #addEOPHistoryLoader(IERSConventions, EOPHistoryLoader) addEOPHistoryLoader}
  162.      * or if {@link #clearEOPHistoryLoaders() clearEOPHistoryLoaders} has been
  163.      * called afterwards, the {@link #addDefaultEOP1980HistoryLoaders(String, String,
  164.      * String, String, String)} and {@link #addDefaultEOP2000HistoryLoaders(String,
  165.      * String, String, String, String)} methods will be called automatically with
  166.      * supported file names parameters all set to null, in order to get the default
  167.      * loaders configuration.
  168.      * </p>
  169.      */
  170.     @Override
  171.     public EOPHistory getEOPHistory(final IERSConventions conventions, final boolean simpleEOP) {
  172.         return lazyLoadedEop.getEOPHistory(conventions, simpleEOP, getTimeScales());
  173.     }

  174. }