TimeScalesFactory.java

  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.time;

  18. import java.io.Serializable;

  19. import org.orekit.annotation.DefaultDataContext;
  20. import org.orekit.data.DataContext;
  21. import org.orekit.frames.EOPHistory;
  22. import org.orekit.frames.LazyLoadedEop;
  23. import org.orekit.utils.IERSConventions;


  24. /** Factory for predefined time scales.
  25.  * <p>
  26.  * This is a utility class, so its constructor is private.
  27.  * </p>
  28.  * @author Luc Maisonobe
  29.  * @see TimeScales
  30.  * @see LazyLoadedTimeScales
  31.  */
  32. public class TimeScalesFactory implements Serializable {

  33.     /** Serializable UID. */
  34.     private static final long serialVersionUID = 20190927L;

  35.     /** Private constructor.
  36.      * <p>This class is a utility class, it should neither have a public
  37.      * nor a default constructor. This private constructor prevents
  38.      * the compiler from generating one automatically.</p>
  39.      */
  40.     private TimeScalesFactory() {
  41.     }

  42.     /**
  43.      * Get the instance of {@link TimeScales} that is called by all of the static methods
  44.      * in this class.
  45.      *
  46.      * @return the time scales used by this factory.
  47.      */
  48.     @DefaultDataContext
  49.     public static LazyLoadedTimeScales getTimeScales() {
  50.         return DataContext.getDefault().getTimeScales();
  51.     }

  52.     /** Add a loader for UTC-TAI offsets history files.
  53.      * @param loader custom loader to add
  54.      * @see TAIUTCDatFilesLoader
  55.      * @see UTCTAIHistoryFilesLoader
  56.      * @see UTCTAIBulletinAFilesLoader
  57.      * @see #getUTC()
  58.      * @see #clearUTCTAIOffsetsLoaders()
  59.      * @since 7.1
  60.      */
  61.     @DefaultDataContext
  62.     public static void addUTCTAIOffsetsLoader(final UTCTAIOffsetsLoader loader) {
  63.         getTimeScales().addUTCTAIOffsetsLoader(loader);
  64.     }

  65.     /** Add the default loaders for UTC-TAI offsets history files (both IERS and USNO).
  66.      * <p>
  67.      * The default loaders are {@link TAIUTCDatFilesLoader} that looks for
  68.      * a file named {@code tai-utc.dat} that must be in USNO format and
  69.      * {@link UTCTAIHistoryFilesLoader} that looks fir a file named
  70.      * {@code UTC-TAI.history} that must be in the IERS format. The
  71.      * {@link UTCTAIBulletinAFilesLoader} is <em>not</em> added by default
  72.      * as it is not recommended. USNO warned us that the TAI-UTC data present
  73.      * in bulletin A was for convenience only and was not reliable, there
  74.      * have been errors in several bulletins regarding these data.
  75.      * </p>
  76.      * @see <a href="http://maia.usno.navy.mil/ser7/tai-utc.dat">USNO tai-utc.dat file</a>
  77.      * @see <a href="http://hpiers.obspm.fr/eoppc/bul/bulc/UTC-TAI.history">IERS UTC-TAI.history file</a>
  78.      * @see TAIUTCDatFilesLoader
  79.      * @see UTCTAIHistoryFilesLoader
  80.      * @see #getUTC()
  81.      * @see #clearUTCTAIOffsetsLoaders()
  82.      * @since 7.1
  83.      */
  84.     @DefaultDataContext
  85.     public static void addDefaultUTCTAIOffsetsLoaders() {
  86.         getTimeScales().addDefaultUTCTAIOffsetsLoaders();
  87.     }

  88.     /** Clear loaders for UTC-TAI offsets history files.
  89.      * @see #getUTC()
  90.      * @see #addUTCTAIOffsetsLoader(UTCTAIOffsetsLoader)
  91.      * @see #addDefaultUTCTAIOffsetsLoaders()
  92.      * @since 7.1
  93.      */
  94.     @DefaultDataContext
  95.     public static void clearUTCTAIOffsetsLoaders() {
  96.         getTimeScales().clearUTCTAIOffsetsLoaders();
  97.     }

  98.     /** Get the International Atomic Time scale.
  99.      * @return International Atomic Time scale
  100.      */
  101.     @DefaultDataContext
  102.     public static TAIScale getTAI() {
  103.         return getTimeScales().getTAI();
  104.     }

  105.     /** Get the Universal Time Coordinate scale.
  106.      * <p>
  107.      * If no {@link UTCTAIOffsetsLoader} has been added by calling {@link
  108.      * #addUTCTAIOffsetsLoader(UTCTAIOffsetsLoader) addUTCTAIOffsetsLoader} or if {@link
  109.      * #clearUTCTAIOffsetsLoaders() clearUTCTAIOffsetsLoaders} has been called afterwards,
  110.      * the {@link #addDefaultUTCTAIOffsetsLoaders() addDefaultUTCTAILoaders} method
  111.      * will be called automatically.
  112.      * </p>
  113.      * @return Universal Time Coordinate scale
  114.      * @see #addDefaultUTCTAIOffsetsLoaders()
  115.      */
  116.     @DefaultDataContext
  117.     public static UTCScale getUTC() {
  118.         return getTimeScales().getUTC();
  119.     }

  120.     /** Get the Universal Time 1 scale.
  121.      * <p>
  122.      * UT1 scale depends on both UTC scale and Earth Orientation Parameters,
  123.      * so this method loads these data sets. See the {@link #getUTC()
  124.      * TimeScalesFactory.getUTC()} and {@link
  125.      * LazyLoadedEop#getEOPHistory(IERSConventions, boolean, TimeScales)} methods
  126.      * for an explanation of how the corresponding data loaders can be configured.
  127.      * </p>
  128.      * @param conventions IERS conventions for which EOP parameters will provide dUT1
  129.      * @param simpleEOP if true, tidal effects are ignored when interpolating EOP
  130.      * @return Universal Time 1 scale
  131.      * @see #getUTC()
  132.      * @see LazyLoadedEop#getEOPHistory(IERSConventions, boolean, TimeScales)
  133.      */
  134.     @DefaultDataContext
  135.     public static UT1Scale getUT1(final IERSConventions conventions, final boolean simpleEOP) {
  136.         return getTimeScales().getUT1(conventions, simpleEOP);
  137.     }

  138.     /** Get the Universal Time 1 scale.
  139.      * <p>
  140.      * As this method allow associating any history with the time scale,
  141.      * it may involve large data sets. So this method does <em>not</em>
  142.      * cache the resulting {@link UT1Scale UT1Scale} instance, a new
  143.      * instance will be returned each time. In order to avoid wasting
  144.      * memory, calling {@link #getUT1(IERSConventions, boolean)}
  145.      * with the single enumerate corresponding to the conventions may be
  146.      * a better solution. This method is made available only for expert use.
  147.      * </p>
  148.      * @param history EOP parameters providing dUT1
  149.      * (may be null if no correction is desired)
  150.      * @return Universal Time 1 scale
  151.      * @see #getUT1(IERSConventions, boolean)
  152.      */
  153.     @DefaultDataContext
  154.     public static UT1Scale getUT1(final EOPHistory history) {
  155.         return getTimeScales().getUT1(history);
  156.     }

  157.     /** Get the Terrestrial Time scale.
  158.      * @return Terrestrial Time scale
  159.      */
  160.     @DefaultDataContext
  161.     public static TTScale getTT() {
  162.         return getTimeScales().getTT();
  163.     }

  164.     /** Get the Galileo System Time scale.
  165.      * @return Galileo System Time scale
  166.      */
  167.     @DefaultDataContext
  168.     public static GalileoScale getGST() {
  169.         return getTimeScales().getGST();
  170.     }

  171.     /** Get the GLObal NAvigation Satellite System time scale.
  172.      * @return  GLObal NAvigation Satellite System time scale
  173.      */
  174.     @DefaultDataContext
  175.     public static GLONASSScale getGLONASS() {
  176.         return getTimeScales().getGLONASS();
  177.     }

  178.     /** Get the Quasi-Zenith Satellite System time scale.
  179.      * @return  Quasi-Zenith Satellite System time scale
  180.      */
  181.     @DefaultDataContext
  182.     public static QZSSScale getQZSS() {
  183.         return getTimeScales().getQZSS();
  184.     }

  185.     /** Get the Global Positioning System scale.
  186.      * @return Global Positioning System scale
  187.      */
  188.     @DefaultDataContext
  189.     public static GPSScale getGPS() {
  190.         return getTimeScales().getGPS();
  191.     }

  192.     /** Get the Geocentric Coordinate Time scale.
  193.      * @return Geocentric Coordinate Time scale
  194.      */
  195.     @DefaultDataContext
  196.     public static TCGScale getTCG() {
  197.         return getTimeScales().getTCG();
  198.     }

  199.     /** Get the Barycentric Dynamic Time scale.
  200.      * @return Barycentric Dynamic Time scale
  201.      */
  202.     @DefaultDataContext
  203.     public static TDBScale getTDB() {
  204.         return getTimeScales().getTDB();
  205.     }

  206.     /** Get the Barycentric Coordinate Time scale.
  207.      * @return Barycentric Coordinate Time scale
  208.      */
  209.     @DefaultDataContext
  210.     public static TCBScale getTCB() {
  211.         return getTimeScales().getTCB();
  212.     }

  213.     /** Get the Greenwich Mean Sidereal Time scale.
  214.      * @param conventions IERS conventions for which EOP parameters will provide dUT1
  215.      * @param simpleEOP if true, tidal effects are ignored when interpolating EOP
  216.      * @return Greenwich Mean Sidereal Time scale
  217.      * @since 7.0
  218.      */
  219.     @DefaultDataContext
  220.     public static GMSTScale getGMST(final IERSConventions conventions, final boolean simpleEOP) {
  221.         return getTimeScales().getGMST(conventions, simpleEOP);
  222.     }

  223.     /** Get the Navigation with Indian Constellation time scale.
  224.      * @return Navigation with Indian Constellation time scale
  225.      */
  226.     @DefaultDataContext
  227.     public static NavicScale getNavIC() {
  228.         return getTimeScales().getNavIC();
  229.     }

  230.     /** Get the BeiDou Navigation Satellite System time scale.
  231.      * @return  BeiDou Navigation Satellite System time scale
  232.      */
  233.     @DefaultDataContext
  234.     public static BDTScale getBDT() {
  235.         return getTimeScales().getBDT();
  236.     }


  237. }