1 /* Copyright 2022-2025 Luc Maisonobe
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.files.sp3;
18
19 import org.hipparchus.util.FastMath;
20 import org.orekit.utils.units.Unit;
21
22 /** Constants for SP3 files.
23 * @since 12.0
24 * @author Luc Maisonobe
25 */
26 public class SP3Utils {
27
28 /** Bad or absent clock values are to be set to 999999.999999. */
29 public static final double DEFAULT_CLOCK_VALUE = 999999.999999;
30
31 /** Bad or absent clock rate values are to be set to 999999.999999. */
32 public static final double DEFAULT_CLOCK_RATE_VALUE = 999999.999999;
33
34 /** Base for general position/velocity accuracy. */
35 public static final double POS_VEL_BASE_ACCURACY = 2.0;
36
37 /** Position unit. */
38 public static final Unit POSITION_UNIT = Unit.parse("km");
39
40 /** Position accuracy unit. */
41 public static final Unit POSITION_ACCURACY_UNIT = Unit.parse("mm");
42
43 /** Velocity unit. */
44 public static final Unit VELOCITY_UNIT = Unit.parse("dm/s");
45
46 /** Velocity accuracy unit. */
47 public static final Unit VELOCITY_ACCURACY_UNIT = Unit.parse("mm/s").scale("10⁻⁴mm/s", 1.0e-4);
48
49 /** Additional state name for clock.
50 * @since 12.1
51 */
52 public static final String CLOCK_ADDITIONAL_STATE = "clock";
53
54 /** Clock unit. */
55 public static final Unit CLOCK_UNIT = Unit.parse("µs");
56
57 /** Clock accuracy unit. */
58 public static final Unit CLOCK_ACCURACY_UNIT = Unit.parse("ps");
59
60 /** Clock rate unit. */
61 public static final Unit CLOCK_RATE_UNIT = Unit.parse("µs/s").scale("10⁻⁴µs/s", 1.0e-4);
62
63 /** Clock rate accuracy unit. */
64 public static final Unit CLOCK_RATE_ACCURACY_UNIT = Unit.parse("ps/s").scale("10⁻⁴ps/s", 1.0e-4);
65
66 /** Private constructor for utility class.
67 */
68 private SP3Utils() {
69 // nothing to do
70 }
71
72 /** Convert an accuracy to SI units.
73 * @param unit accuracy unit
74 * @param base base
75 * @param accuracyIndex index of accuracy
76 * @return accuracy in SI units
77 */
78 public static double siAccuracy(final Unit unit, final double base, final int accuracyIndex) {
79 return unit.toSI(FastMath.pow(base, accuracyIndex));
80 }
81
82 /** Convert an accuracy from SI units.
83 * @param unit accuracy unit
84 * @param base base
85 * @param accuracy in SI units
86 * @return accuracyIndex index of accuracy
87 */
88 public static int indexAccuracy(final Unit unit, final double base, final double accuracy) {
89 return (int) FastMath.ceil(FastMath.log(unit.fromSI(accuracy)) / FastMath.log(base));
90 }
91
92 }