UT1Scale.java

  1. /* Copyright 2002-2013 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.orekit.frames.EOPHistory;

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

  29.     /** Serializable UID. */
  30.     private static final long serialVersionUID = 20131209L;

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

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

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

  43.     /** Get the EOP history.
  44.      * @return eop history (may be null)
  45.      */
  46.     public EOPHistory getEOPHistory() {
  47.         return eopHistory;
  48.     }

  49.     /** {@inheritDoc} */
  50.     public double offsetFromTAI(final AbsoluteDate date) {
  51.         final double dtu1        = eopHistory == null ? 0 : eopHistory.getUT1MinusUTC(date);
  52.         final double utcMinusTai = utc.offsetFromTAI(date);
  53.         return utcMinusTai + dtu1;
  54.     }

  55.     /** {@inheritDoc} */
  56.     public double offsetToTAI(final DateComponents date, final TimeComponents time) {
  57.         final AbsoluteDate reference = new AbsoluteDate(date, time, TimeScalesFactory.getTAI());
  58.         double offset = 0;
  59.         for (int i = 0; i < 3; i++) {
  60.             offset = -offsetFromTAI(reference.shiftedBy(offset));
  61.         }
  62.         return offset;
  63.     }

  64.     /** {@inheritDoc} */
  65.     public String getName() {
  66.         return "UT1";
  67.     }

  68.     /** {@inheritDoc} */
  69.     public String toString() {
  70.         return getName();
  71.     }

  72. }