SP3Utils.java

  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. import org.hipparchus.util.FastMath;
  19. import org.orekit.utils.units.Unit;

  20. /** Constants for SP3 files.
  21.  * @since 12.0
  22.  * @author Luc Maisonobe
  23.  */
  24. public class SP3Utils {

  25.     /** Bad or absent clock values are to be set to 999999.999999. */
  26.     public static final double DEFAULT_CLOCK_VALUE = 999999.999999;

  27.     /** Bad or absent clock rate values are to be set to 999999.999999. */
  28.     public static final double DEFAULT_CLOCK_RATE_VALUE = 999999.999999;

  29.     /** Base for general position/velocity accuracy. */
  30.     public static final double POS_VEL_BASE_ACCURACY = 2.0;

  31.     /** Position unit. */
  32.     public static final Unit POSITION_UNIT = Unit.parse("km");

  33.     /** Position accuracy unit. */
  34.     public static final Unit POSITION_ACCURACY_UNIT = Unit.parse("mm");

  35.    /** Velocity unit. */
  36.     public static final Unit VELOCITY_UNIT = Unit.parse("dm/s");

  37.     /** Velocity accuracy unit. */
  38.     public static final Unit VELOCITY_ACCURACY_UNIT = Unit.parse("mm/s").scale("10⁻⁴mm/s", 1.0e-4);

  39.     /** Additional state name for clock.
  40.      * @since 12.1
  41.      */
  42.     public static final String CLOCK_ADDITIONAL_STATE = "clock";

  43.     /** Clock unit. */
  44.     public static final Unit CLOCK_UNIT = Unit.parse("µs");

  45.     /** Clock accuracy unit. */
  46.     public static final Unit CLOCK_ACCURACY_UNIT = Unit.parse("ps");

  47.     /** Clock rate unit. */
  48.     public static final Unit CLOCK_RATE_UNIT = Unit.parse("µs/s").scale("10⁻⁴µs/s", 1.0e-4);

  49.     /** Clock rate accuracy unit. */
  50.     public static final Unit CLOCK_RATE_ACCURACY_UNIT = Unit.parse("ps/s").scale("10⁻⁴ps/s", 1.0e-4);

  51.     /** Private constructor for utility class.
  52.      */
  53.     private SP3Utils() {
  54.         // nothing to do
  55.     }

  56.     /** Convert an accuracy to SI units.
  57.      * @param unit accuracy unit
  58.      * @param base base
  59.      * @param accuracyIndex index of accuracy
  60.      * @return accuracy in SI units
  61.      */
  62.     public static double siAccuracy(final Unit unit, final double base, final int accuracyIndex) {
  63.         return unit.toSI(FastMath.pow(base, accuracyIndex));
  64.     }

  65.     /** Convert an accuracy from SI units.
  66.      * @param unit accuracy unit
  67.      * @param base base
  68.      * @param accuracy in SI units
  69.      * @return accuracyIndex index of accuracy
  70.      */
  71.     public static int indexAccuracy(final Unit unit, final double base, final double accuracy) {
  72.         return (int) FastMath.ceil(FastMath.log(unit.fromSI(accuracy)) / FastMath.log(base));
  73.     }

  74. }