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
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 /** UTC scale. */
34 private final UTCScale utc;
35
36 /** EOP history. */
37 private final EOPHistory eopHistory;
38
39 /** Simple constructor.
40 * @param eopHistory user supplied EOP history (may be null)
41 * @param utc UTC time scale
42 */
43 protected UT1Scale(final EOPHistory eopHistory, final UTCScale utc) {
44 this.eopHistory = eopHistory;
45 this.utc = utc;
46 }
47
48 /** Get the associated UTC scale.
49 * @return associated UTC scale.
50 * @since 9.1
51 */
52 public UTCScale getUTCScale() {
53 return utc;
54 }
55
56 /** Get the EOP history.
57 * @return eop history (may be null)
58 */
59 public EOPHistory getEOPHistory() {
60 return eopHistory;
61 }
62
63 /** {@inheritDoc} */
64 @Override
65 public TimeOffset offsetFromTAI(final AbsoluteDate date) {
66 final double dtu1 = eopHistory == null ? 0 : eopHistory.getUT1MinusUTC(date);
67 final TimeOffset utcMinusTai = utc.offsetFromTAI(date);
68 return utcMinusTai.add(new TimeOffset(dtu1));
69 }
70
71 /** {@inheritDoc} */
72 @Override
73 public <T extends CalculusFieldElement<T>> T offsetFromTAI(final FieldAbsoluteDate<T> date) {
74 final T dtu1 = eopHistory == null ? date.getField().getZero() : eopHistory.getUT1MinusUTC(date);
75 final T utcMinusTai = utc.offsetFromTAI(date);
76 return utcMinusTai.add(dtu1);
77 }
78
79 /** {@inheritDoc} */
80 public String getName() {
81 return "UT1";
82 }
83
84 /** {@inheritDoc} */
85 public String toString() {
86 return getName();
87 }
88
89 }