UT1Scale.java

  1. /* Copyright 2002-2018 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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.RealFieldElement;
  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.     /** Serializable UID. */
  31.     private static final long serialVersionUID = 20131209L;

  32.     /** UTC scale. */
  33.     private final UTCScale utc;

  34.     /** EOP history. */
  35.     private final EOPHistory eopHistory;

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

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

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

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

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

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

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

  79. }