1 /* Copyright 2002-2023 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
19 import org.hipparchus.CalculusFieldElement;
20 import org.orekit.frames.EOPHistory;
21
22 /** Universal Time 1.
23 * <p>UT1 is a time scale directly linked to the actual rotation of the Earth.
24 * It is an irregular scale, reflecting Earth irregular rotation rate. The offset
25 * between UT1 and {@link UTCScale UTC} is found in the Earth Orientation
26 * Parameters published by IERS.</p>
27 * @author Luc Maisonobe
28 * @see AbsoluteDate
29 * @since 5.1
30 */
31 public class UT1Scale implements TimeScale {
32
33 /** Serializable UID. */
34 private static final long serialVersionUID = 20131209L;
35
36 /** UTC scale. */
37 private final UTCScale utc;
38
39 /** EOP history. */
40 private final EOPHistory eopHistory;
41
42 /** Simple constructor.
43 * @param eopHistory user supplied EOP history (may be null)
44 * @param utc UTC time scale
45 */
46 protected UT1Scale(final EOPHistory eopHistory, final UTCScale utc) {
47 this.eopHistory = eopHistory;
48 this.utc = utc;
49 }
50
51 /** Get the associated UTC scale.
52 * @return associated UTC scale.
53 * @since 9.1
54 */
55 public UTCScale getUTCScale() {
56 return utc;
57 }
58
59 /** Get the EOP history.
60 * @return eop history (may be null)
61 */
62 public EOPHistory getEOPHistory() {
63 return eopHistory;
64 }
65
66 /** {@inheritDoc} */
67 @Override
68 public double offsetFromTAI(final AbsoluteDate date) {
69 final double dtu1 = eopHistory == null ? 0 : eopHistory.getUT1MinusUTC(date);
70 final double utcMinusTai = utc.offsetFromTAI(date);
71 return utcMinusTai + dtu1;
72 }
73
74 /** {@inheritDoc} */
75 @Override
76 public <T extends CalculusFieldElement<T>> T offsetFromTAI(final FieldAbsoluteDate<T> date) {
77 final T dtu1 = eopHistory == null ? date.getField().getZero() : eopHistory.getUT1MinusUTC(date);
78 final T utcMinusTai = utc.offsetFromTAI(date);
79 return utcMinusTai.add(dtu1);
80 }
81
82 /** {@inheritDoc} */
83 public String getName() {
84 return "UT1";
85 }
86
87 /** {@inheritDoc} */
88 public String toString() {
89 return getName();
90 }
91
92 }