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

  18. import java.util.Collection;
  19. import java.util.function.BiFunction;

  20. import org.orekit.frames.EOPEntry;
  21. import org.orekit.frames.Frames;
  22. import org.orekit.utils.IERSConventions;

  23. /**
  24.  * A collection of {@link TimeScale}s. This interface defines methods for obtaining
  25.  * instances of many common time scales.
  26.  *
  27.  * @author Luc Maisonobe
  28.  * @author Evan Ward
  29.  * @see TimeScalesFactory
  30.  * @see TimeScale
  31.  * @see LazyLoadedTimeScales
  32.  * @see #of(Collection, BiFunction)
  33.  * @since 10.1
  34.  */
  35. public interface TimeScales {

  36.     /**
  37.      * Get the International Atomic Time scale.
  38.      *
  39.      * @return International Atomic Time scale
  40.      */
  41.     TAIScale getTAI();

  42.     /**
  43.      * Get the Universal Time Coordinate scale.
  44.      *
  45.      * @return Universal Time Coordinate scale
  46.      */
  47.     UTCScale getUTC();

  48.     /**
  49.      * Get the Universal Time 1 scale.
  50.      *
  51.      * @param conventions IERS conventions for which EOP parameters will provide dUT1
  52.      * @param simpleEOP   if true, tidal effects are ignored when interpolating EOP
  53.      * @return Universal Time 1 scale
  54.      * @see #getUTC()
  55.      * @see Frames#getEOPHistory(IERSConventions, boolean)
  56.      */
  57.     UT1Scale getUT1(IERSConventions conventions, boolean simpleEOP);

  58.     /**
  59.      * Get the Terrestrial Time scale.
  60.      *
  61.      * @return Terrestrial Time scale
  62.      */
  63.     TTScale getTT();

  64.     /**
  65.      * Get the Galileo System Time scale.
  66.      *
  67.      * @return Galileo System Time scale
  68.      */
  69.     GalileoScale getGST();

  70.     /**
  71.      * Get the GLObal NAvigation Satellite System time scale.
  72.      *
  73.      * @return GLObal NAvigation Satellite System time scale
  74.      */
  75.     GLONASSScale getGLONASS();

  76.     /**
  77.      * Get the Quasi-Zenith Satellite System time scale.
  78.      *
  79.      * @return Quasi-Zenith Satellite System time scale
  80.      */
  81.     QZSSScale getQZSS();

  82.     /**
  83.      * Get the Global Positioning System scale.
  84.      *
  85.      * @return Global Positioning System scale
  86.      */
  87.     GPSScale getGPS();

  88.     /**
  89.      * Get the Geocentric Coordinate Time scale.
  90.      *
  91.      * @return Geocentric Coordinate Time scale
  92.      */
  93.     TCGScale getTCG();

  94.     /**
  95.      * Get the Barycentric Dynamic Time scale.
  96.      *
  97.      * @return Barycentric Dynamic Time scale
  98.      */
  99.     TDBScale getTDB();

  100.     /**
  101.      * Get the Barycentric Coordinate Time scale.
  102.      *
  103.      * @return Barycentric Coordinate Time scale
  104.      */
  105.     TCBScale getTCB();

  106.     /**
  107.      * Get the Greenwich Mean Sidereal Time scale.
  108.      *
  109.      * @param conventions IERS conventions for which EOP parameters will provide dUT1
  110.      * @param simpleEOP   if true, tidal effects are ignored when interpolating EOP
  111.      * @return Greenwich Mean Sidereal Time scale
  112.      * @since 7.0
  113.      */
  114.     GMSTScale getGMST(IERSConventions conventions, boolean simpleEOP);

  115.     /**
  116.      * Get the Navigation with Indian Constellation time scale.
  117.      *
  118.      * @return Navigation with Indian Constellation time scale
  119.      */
  120.     NavicScale getNavIC();

  121.     /**
  122.      * Get the BeiDou Navigation Satellite System time scale.
  123.      *
  124.      * @return BeiDou Navigation Satellite System time scale
  125.      */
  126.     BDTScale getBDT();

  127.     /**
  128.      * Reference epoch for julian dates: -4712-01-01T12:00:00 Terrestrial Time.
  129.      * <p>Both <code>java.util.Date</code> and {@link DateComponents} classes
  130.      * follow the astronomical conventions and consider a year 0 between years -1 and +1,
  131.      * hence this reference date lies in year -4712 and not in year -4713 as can be seen
  132.      * in other documents or programs that obey a different convention (for example the
  133.      * <code>convcal</code> utility).</p>
  134.      *
  135.      * @return Julian epoch.
  136.      */
  137.     AbsoluteDate getJulianEpoch();

  138.     /**
  139.      * Reference epoch for modified julian dates: 1858-11-17T00:00:00 Terrestrial Time.
  140.      *
  141.      * @return Modified Julian Epoch
  142.      */
  143.     AbsoluteDate getModifiedJulianEpoch();

  144.     /**
  145.      * Reference epoch for 1950 dates: 1950-01-01T00:00:00 Terrestrial Time.
  146.      *
  147.      * @return Fifties Epoch
  148.      */
  149.     AbsoluteDate getFiftiesEpoch();

  150.     /**
  151.      * Reference epoch for CCSDS Time Code Format (CCSDS 301.0-B-4): 1958-01-01T00:00:00
  152.      * International Atomic Time (<em>not</em> UTC).
  153.      *
  154.      * @return CCSDS Epoch
  155.      */
  156.     AbsoluteDate getCcsdsEpoch();

  157.     /**
  158.      * Reference epoch for Galileo System Time: 1999-08-22T00:00:00 GST.
  159.      *
  160.      * @return Galileo Epoch
  161.      */
  162.     AbsoluteDate getGalileoEpoch();

  163.     /**
  164.      * Reference epoch for GPS weeks: 1980-01-06T00:00:00 GPS time.
  165.      *
  166.      * @return GPS Epoch
  167.      */
  168.     AbsoluteDate getGpsEpoch();

  169.     /**
  170.      * Reference epoch for QZSS weeks: 1980-01-06T00:00:00 QZSS time.
  171.      *
  172.      * @return QZSS Epoch
  173.      */
  174.     AbsoluteDate getQzssEpoch();

  175.     /**
  176.      * Reference epoch for NavIC weeks: 1999-08-22T00:00:00 NavIC time.
  177.      *
  178.      * @return NavIC Epoch
  179.      */
  180.     AbsoluteDate getNavicEpoch();

  181.     /**
  182.      * Reference epoch for BeiDou weeks: 2006-01-01T00:00:00 UTC.
  183.      *
  184.      * @return Beidou Epoch
  185.      */
  186.     AbsoluteDate getBeidouEpoch();

  187.     /**
  188.      * Reference epoch for GLONASS four-year interval number: 1996-01-01T00:00:00 GLONASS
  189.      * time.
  190.      * <p>By convention, TGLONASS = UTC + 3 hours.</p>
  191.      *
  192.      * @return GLONASS Epoch
  193.      */
  194.     AbsoluteDate getGlonassEpoch();

  195.     /**
  196.      * J2000.0 Reference epoch: 2000-01-01T12:00:00 Terrestrial Time (<em>not</em> UTC).
  197.      *
  198.      * @return J2000 Epoch
  199.      * @see AbsoluteDate#createJulianEpoch(double)
  200.      * @see AbsoluteDate#createBesselianEpoch(double)
  201.      */
  202.     AbsoluteDate getJ2000Epoch();

  203.     /**
  204.      * Java Reference epoch: 1970-01-01T00:00:00 Universal Time Coordinate.
  205.      * <p>
  206.      * Between 1968-02-01 and 1972-01-01, UTC-TAI = 4.213 170 0s + (MJD - 39 126) x 0.002
  207.      * 592s. As on 1970-01-01 MJD = 40587, UTC-TAI = 8.000082s
  208.      * </p>
  209.      *
  210.      * @return Java Epoch
  211.      */
  212.     AbsoluteDate getJavaEpoch();

  213.     /**
  214.      * Dummy date at infinity in the past direction.
  215.      *
  216.      * @return the earliest date.
  217.      */
  218.     AbsoluteDate getPastInfinity();

  219.     /**
  220.      * Dummy date at infinity in the future direction.
  221.      *
  222.      * @return the latest date.
  223.      */
  224.     AbsoluteDate getFutureInfinity();

  225.     /**
  226.      * Build an instance corresponding to a Julian Epoch (JE).
  227.      * <p>According to Lieske paper: <a
  228.      * href="http://articles.adsabs.harvard.edu/cgi-bin/nph-iarticle_query?1979A%26A....73..282L&amp;defaultprint=YES&amp;filetype=.pdf.">
  229.      * Precession Matrix Based on IAU (1976) System of Astronomical Constants</a>,
  230.      * Astronomy and Astrophysics, vol. 73, no. 3, Mar. 1979, p. 282-284, Julian Epoch is
  231.      * related to Julian Ephemeris Date as:</p>
  232.      * <pre>
  233.      * JE = 2000.0 + (JED - 2451545.0) / 365.25
  234.      * </pre>
  235.      * <p>
  236.      * This method reverts the formula above and computes an {@code AbsoluteDate} from the
  237.      * Julian Epoch.
  238.      * </p>
  239.      *
  240.      * @param julianEpoch Julian epoch, like 2000.0 for defining the classical reference
  241.      *                    J2000.0
  242.      * @return a new instant
  243.      * @see #getJ2000Epoch()
  244.      * @see #createBesselianEpoch(double)
  245.      */
  246.     AbsoluteDate createJulianEpoch(double julianEpoch);

  247.     /**
  248.      * Build an instance corresponding to a Besselian Epoch (BE).
  249.      * <p>According to Lieske paper: <a
  250.      * href="http://articles.adsabs.harvard.edu/cgi-bin/nph-iarticle_query?1979A%26A....73..282L&amp;defaultprint=YES&amp;filetype=.pdf.">
  251.      * Precession Matrix Based on IAU (1976) System of Astronomical Constants</a>,
  252.      * Astronomy and Astrophysics, vol. 73, no. 3, Mar. 1979, p. 282-284, Besselian Epoch
  253.      * is related to Julian Ephemeris Date as:</p>
  254.      * <pre>
  255.      * BE = 1900.0 + (JED - 2415020.31352) / 365.242198781
  256.      * </pre>
  257.      * <p>
  258.      * This method reverts the formula above and computes an {@code AbsoluteDate} from the
  259.      * Besselian Epoch.
  260.      * </p>
  261.      *
  262.      * @param besselianEpoch Besselian epoch, like 1950 for defining the classical
  263.      *                       reference B1950.0
  264.      * @return a new instant
  265.      * @see #createJulianEpoch(double)
  266.      */
  267.     AbsoluteDate createBesselianEpoch(double besselianEpoch);

  268.     /* Helpers for creating new instances. */

  269.     /**
  270.      * Create a set of time scales where all the data is loaded from the given functions.
  271.      *
  272.      * @param utcMinusTai offsets used to compute UTC. If the pre-1972 linear offsets are
  273.      *                    missing they will be added.
  274.      * @param eopSupplier function to retrieve the EOP data. Since the EOP have to be
  275.      *                    reloaded every time a different {@link IERSConventions} is
  276.      *                    requested this function may be called multiple times. The
  277.      *                    requested conventions and the created time scales are passed as
  278.      *                    arguments. Attempting to call {@link #getUT1(IERSConventions,
  279.      *                    boolean)} or {@link #getGMST(IERSConventions, boolean)} on the
  280.      *                    time scales argument may result in unbounded recursion. To
  281.      *                    ignore EOP corrections this function should return an empty
  282.      *                    collection.
  283.      * @return a set of time scales based on the given data.
  284.      * @see UTCTAIOffsetsLoader.Parser
  285.      * @see org.orekit.frames.EopHistoryLoader.Parser
  286.      */
  287.     static TimeScales of(
  288.             final Collection<? extends OffsetModel> utcMinusTai,
  289.             final BiFunction<
  290.                     ? super IERSConventions,
  291.                     ? super TimeScales,
  292.                     ? extends Collection<? extends EOPEntry>> eopSupplier) {
  293.         return new PreloadedTimeScales(utcMinusTai, eopSupplier);
  294.     }

  295. }