SubFrameAlmanac.java

  1. /* Copyright 2002-2024 Thales Alenia Space
  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.gnss.rflink.gps;

  18. import org.hipparchus.util.FastMath;
  19. import org.orekit.gnss.metric.parser.Units;

  20. /**
  21.  * Container for sub-frames 5, page 1-24.
  22.  * <p>
  23.  * Table 20-1, sheet 4 and table 40-1, sheet 4 in
  24.  * <a href="https://navcen.uscg.gov/sites/default/files/pdf/gps/IS-GPS-200N.pdf">NAVSTAR
  25.  * GPS Space Segment/Navigation User Segment Interface</a>, IS-GPS-200N, 22 Aug 2022
  26.  * </p>
  27.  * @author Luc Maisonobe
  28.  * @since 12.0
  29.  */
  30. public class SubFrameAlmanac extends SubFrame45 {

  31.     /** Index of e field. */
  32.     private static final int E = 9;

  33.     /** Index of TOA field. */
  34.     private static final int TOA = 10;

  35.     /** Index of δi field. */
  36.     private static final int DELTA_I = 11;

  37.     /** Index of dot(Ω) field. */
  38.     private static final int OMEGA_DOT = 12;

  39.     /** Index of SV health field. */
  40.     private static final int SV_HEALTH = 13;

  41.     /** Index of √a field. */
  42.     private static final int SQRT_A = 14;

  43.     /** Index of Ω₀ field. */
  44.     private static final int UPPERCASE_OMEGA_0 = 15;

  45.     /** Index of ω field. */
  46.     private static final int LOWERCASE_OMEGA = 16;

  47.     /** Index of M₀ field. */
  48.     private static final int M0 = 17;

  49.     /** Index of AF0 field. */
  50.     private static final int AF0 = 18;

  51.     /** Index of AF1 field. */
  52.     private static final int AF1 = 19;

  53.     /** Simple constructor.
  54.      * @param words raw words
  55.      */
  56.     SubFrameAlmanac(final int[] words) {

  57.         // create raw container
  58.         super(words, AF1 + 1);

  59.         // populate container
  60.         setField(E,                  3,  6, 16, words);
  61.         setField(TOA,                4, 22,  8, words);
  62.         setField(DELTA_I,            4,  6, 16, words);
  63.         setField(OMEGA_DOT,          5, 14, 16, words);
  64.         setField(SV_HEALTH,          5,  6,  8, words);
  65.         setField(SQRT_A,             6,  6, 24, words);
  66.         setField(UPPERCASE_OMEGA_0,  7,  6, 24, words);
  67.         setField(LOWERCASE_OMEGA,    8,  6, 24, words);
  68.         setField(M0,                 9,  6, 24, words);
  69.         setField(AF0,               10, 22,  8, 10,  8,  3, words);
  70.         setField(AF1,               10, 11, 11, words);

  71.     }

  72.     /** Get the PRN code phase of the SV.
  73.      * @return PRN code phase
  74.      */
  75.     public int getPRN() {
  76.         // sub-frames that contain almanacs use the SV-ID for the PRN
  77.         return getSvId();
  78.     }

  79.     /** Get eccentricity.
  80.      * @return eccentricity
  81.      */
  82.     public double getE() {
  83.         return FastMath.scalb((double) getField(E), -21);
  84.     }

  85.     /** Get Time Of Almanac.
  86.      * @return Time Of Almanac (seconds)
  87.      */
  88.     public int getToaA() {
  89.         return getField(TOA) << 12;
  90.     }

  91.     /** Get Δi.
  92.      * @return Δi (rad)
  93.      */
  94.     public double getDeltai() {
  95.         return Units.SEMI_CIRCLE.toSI(FastMath.scalb((double) getField(DELTA_I), -19));
  96.     }

  97.     /** Get dot(Ω).
  98.      * @return dot(Ω) (rad/s)
  99.      */
  100.     public double getOmegaDot() {
  101.         return Units.SEMI_CIRCLE.toSI(FastMath.scalb((double) getField(OMEGA_DOT), -38));
  102.     }

  103.     /** Get SV health.
  104.      * @return SV health
  105.      */
  106.     public int getSvHealth() {
  107.         return getField(SV_HEALTH);
  108.     }

  109.     /** Get √a.
  110.      * @return d√a (√m)
  111.      */
  112.     public double getSqrtA() {
  113.         return FastMath.scalb((double) getField(SQRT_A), -11);
  114.     }

  115.     /** Get Ω₀.
  116.      * @return Ω₀ (rad)
  117.      */
  118.     public double getUppercaseOmega0() {
  119.         return Units.SEMI_CIRCLE.toSI(FastMath.scalb((double) getField(UPPERCASE_OMEGA_0), -23));
  120.     }

  121.     /** Get ω.
  122.      * @return ω(rad)
  123.      */
  124.     public double getLowercaseOmega() {
  125.         return Units.SEMI_CIRCLE.toSI(FastMath.scalb((double) getField(LOWERCASE_OMEGA), -23));
  126.     }

  127.     /** Get M₀.
  128.      * @return M₀ (rad)
  129.      */
  130.     public double getM0() {
  131.         return Units.SEMI_CIRCLE.toSI(FastMath.scalb((double) getField(M0), -23));
  132.     }

  133.     /** Get af₀.
  134.      * @return af₀ (second)
  135.      */
  136.     public double getAF0() {
  137.         return FastMath.scalb((double) getField(AF0), -20);
  138.     }

  139.     /** Get af₁.
  140.      * @return af₁ (second/second)
  141.      */
  142.     public double getAF1() {
  143.         return FastMath.scalb((double) getField(AF1), -38);
  144.     }

  145. }