UT1Scale.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 org.hipparchus.CalculusFieldElement;
  19. import org.orekit.frames.EOPHistory;

  20. /** Universal Time 1.
  21.  * <p>UT1 is a time scale directly linked to the actual rotation of the Earth.
  22.  * It is an irregular scale, reflecting Earth irregular rotation rate. The offset
  23.  * between UT1 and {@link UTCScale UTC} is found in the Earth Orientation
  24.  * Parameters published by IERS.</p>
  25.  * @author Luc Maisonobe
  26.  * @see AbsoluteDate
  27.  * @since 5.1
  28.  */
  29. public class UT1Scale implements TimeScale {

  30.     /** UTC scale. */
  31.     private final UTCScale utc;

  32.     /** EOP history. */
  33.     private final EOPHistory eopHistory;

  34.     /** Simple constructor.
  35.      * @param eopHistory user supplied EOP history (may be null)
  36.      * @param utc UTC time scale
  37.      */
  38.     protected UT1Scale(final EOPHistory eopHistory, final UTCScale utc) {
  39.         this.eopHistory = eopHistory;
  40.         this.utc        = utc;
  41.     }

  42.     /** Get the associated UTC scale.
  43.      * @return associated UTC scale.
  44.      * @since 9.1
  45.      */
  46.     public UTCScale getUTCScale() {
  47.         return utc;
  48.     }

  49.     /** Get the EOP history.
  50.      * @return eop history (may be null)
  51.      */
  52.     public EOPHistory getEOPHistory() {
  53.         return eopHistory;
  54.     }

  55.     /** {@inheritDoc} */
  56.     @Override
  57.     public TimeOffset offsetFromTAI(final AbsoluteDate date) {
  58.         final double    dtu1        = eopHistory == null ? 0 : eopHistory.getUT1MinusUTC(date);
  59.         final TimeOffset utcMinusTai = utc.offsetFromTAI(date);
  60.         return utcMinusTai.add(new TimeOffset(dtu1));
  61.     }

  62.     /** {@inheritDoc} */
  63.     @Override
  64.     public <T extends CalculusFieldElement<T>> T offsetFromTAI(final FieldAbsoluteDate<T> date) {
  65.         final T dtu1        = eopHistory == null ? date.getField().getZero() : eopHistory.getUT1MinusUTC(date);
  66.         final T utcMinusTai = utc.offsetFromTAI(date);
  67.         return utcMinusTai.add(dtu1);
  68.     }

  69.     /** {@inheritDoc} */
  70.     public String getName() {
  71.         return "UT1";
  72.     }

  73.     /** {@inheritDoc} */
  74.     public String toString() {
  75.         return getName();
  76.     }

  77. }