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 xmlSupportedNames regular expression for supported XML EOP files names
  61.      * (may be null if the default IERS file names are used)
  62.      * @param eopC04SupportedNames regular expression for supported EOP C04 files names
  63.      * (may be null if the default IERS file names are used)
  64.      * @param bulletinBSupportedNames regular expression for supported bulletin B files names
  65.      * (may be null if the default IERS file names are used)
  66.      * @param bulletinASupportedNames regular expression for supported bulletin A files names
  67.      * (may be null if the default IERS file names are used)
  68.      * @param csvSupportedNames regular expression for supported csv files names
  69.      * (may be null if the default IERS file names are used)
  70.      * @see <a href="https://datacenter.iers.org/products/eop/">IERS https data download</a>
  71.      * @see #addEOPHistoryLoader(IERSConventions, EopHistoryLoader)
  72.      * @see #clearEOPHistoryLoaders()
  73.      * @see #addDefaultEOP2000HistoryLoaders(String, String, String, String, String, String)
  74.      * @since 12.0
  75.      */
  76.     public void addDefaultEOP1980HistoryLoaders(final String rapidDataColumnsSupportedNames,
  77.                                                 final String xmlSupportedNames,
  78.                                                 final String eopC04SupportedNames,
  79.                                                 final String bulletinBSupportedNames,
  80.                                                 final String bulletinASupportedNames,
  81.                                                 final String csvSupportedNames) {
  82.         lazyLoadedEop.addDefaultEOP1980HistoryLoaders(
  83.             rapidDataColumnsSupportedNames,
  84.             xmlSupportedNames,
  85.             eopC04SupportedNames,
  86.             bulletinBSupportedNames,
  87.             bulletinASupportedNames,
  88.             csvSupportedNames,
  89.             () -> getTimeScales().getUTC());
  90.     }

  91.     /** Add the default loaders for EOP history (IAU 2000/2006 precession/nutation).
  92.      * <p>
  93.      * The default loaders look for IERS EOP C04 and bulletins B files. They
  94.      * correspond to both {@link IERSConventions#IERS_2003 IERS 2003} and {@link
  95.      * IERSConventions#IERS_2010 IERS 2010} conventions.
  96.      * </p>
  97.      * @param rapidDataColumnsSupportedNames regular expression for supported
  98.      * rapid data columns EOP files names
  99.      * (may be null if the default IERS file names are used)
  100.      * @param xmlSupportedNames regular expression for supported XML EOP files names
  101.      * (may be null if the default IERS file names are used)
  102.      * @param eopC04SupportedNames regular expression for supported EOP C04 files names
  103.      * (may be null if the default IERS file names are used)
  104.      * @param bulletinBSupportedNames regular expression for supported bulletin B files names
  105.      * (may be null if the default IERS file names are used)
  106.      * @param bulletinASupportedNames regular expression for supported bulletin A files names
  107.      * (may be null if the default IERS file names are used)
  108.      * @param csvSupportedNames regular expression for supported csv files names
  109.      * (may be null if the default IERS file names are used)
  110.      * @see <a href="https://datacenter.iers.org/products/eop/">IERS https data download</a>
  111.      * @see #addEOPHistoryLoader(IERSConventions, EopHistoryLoader)
  112.      * @see #clearEOPHistoryLoaders()
  113.      * @see #addDefaultEOP1980HistoryLoaders(String, String, String, String, String, String)
  114.      * @since 12.0
  115.      */
  116.     public void addDefaultEOP2000HistoryLoaders(final String rapidDataColumnsSupportedNames,
  117.                                                 final String xmlSupportedNames,
  118.                                                 final String eopC04SupportedNames,
  119.                                                 final String bulletinBSupportedNames,
  120.                                                 final String bulletinASupportedNames,
  121.                                                 final String csvSupportedNames) {
  122.         lazyLoadedEop.addDefaultEOP2000HistoryLoaders(
  123.             rapidDataColumnsSupportedNames,
  124.             xmlSupportedNames,
  125.             eopC04SupportedNames,
  126.             bulletinBSupportedNames,
  127.             bulletinASupportedNames,
  128.             csvSupportedNames,
  129.             () -> getTimeScales().getUTC());
  130.     }

  131.     /** Add a loader for Earth Orientation Parameters history.
  132.      * @param conventions IERS conventions to which EOP history applies
  133.      * @param loader custom loader to add for the EOP history
  134.      * @see #addDefaultEOP1980HistoryLoaders(String, String, String, String, String, String)
  135.      * @see #clearEOPHistoryLoaders()
  136.      */
  137.     public void addEOPHistoryLoader(final IERSConventions conventions, final EopHistoryLoader loader) {
  138.         lazyLoadedEop.addEOPHistoryLoader(conventions, loader);
  139.     }

  140.     /** Clear loaders for Earth Orientation Parameters history.
  141.      * @see #addEOPHistoryLoader(IERSConventions, EopHistoryLoader)
  142.      * @see #addDefaultEOP1980HistoryLoaders(String, String, String, String, String, String)
  143.      */
  144.     public void clearEOPHistoryLoaders() {
  145.         lazyLoadedEop.clearEOPHistoryLoaders();
  146.     }

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

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

  182. }