IonosphereKlobucharMessage.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.rinex.navigation;

  18. import org.orekit.gnss.SatelliteSystem;
  19. import org.orekit.propagation.analytical.gnss.data.GNSSConstants;
  20. import org.orekit.utils.units.Unit;

  21. /** Container for data contained in a ionosphere Klobuchar message.
  22.  * @author Luc Maisonobe
  23.  * @since 12.0
  24.  */
  25. public class IonosphereKlobucharMessage extends IonosphereBaseMessage {

  26.     /** Converters for Klobuchar parameters. */
  27.     static final Unit[] S_PER_SC_N;
  28.     static {
  29.         final Unit sc = Unit.RADIAN.scale("sc", GNSSConstants.GNSS_PI);
  30.         S_PER_SC_N = new Unit[4];
  31.         S_PER_SC_N[0] = Unit.SECOND;
  32.         S_PER_SC_N[1] = S_PER_SC_N[0].divide("s/sc",  sc);
  33.         S_PER_SC_N[2] = S_PER_SC_N[1].divide("s/sc²", sc);
  34.         S_PER_SC_N[3] = S_PER_SC_N[2].divide("s/sc³", sc);
  35.     }

  36.     /** α (s/radⁿ). */
  37.     private final double[] alpha;

  38.     /** β (s/radⁿ). */
  39.     private final double[] beta;

  40.     /** Region code. */
  41.     private RegionCode regionCode;

  42.     /** Simple constructor.
  43.      * @param system satellite system
  44.      * @param prn satellite number
  45.      * @param navigationMessageType navigation message type
  46.      */
  47.     public IonosphereKlobucharMessage(final SatelliteSystem system, final int prn, final String navigationMessageType) {
  48.         super(system, prn, navigationMessageType);
  49.         alpha = new double[4];
  50.         beta  = new double[4];
  51.     }

  52.     /** Get the α coefficients.
  53.      * <p>
  54.      * Beware Orekit uses SI units here.
  55.      * In order to retrieve the more traditional s/semi-circleⁿ, use
  56.      * {@code IonosphereKlobucharMessage.S_PER_SC_N[i].fromSI(alpha[i])}
  57.      * </p>
  58.      * @return α coefficients (s/radⁿ)
  59.      * @see #S_PER_SC_N
  60.      */
  61.     public double[] getAlpha() {
  62.         return alpha.clone();
  63.     }

  64.     /** Set one α coefficient.
  65.      * <p>
  66.      * Beware Orekit uses SI units here.
  67.      * In order to use the more traditional s/semi-circleⁿ, use
  68.      * {@code setAlphaI(i, IonosphereKlobucharMessage.S_PER_SC_N[i].toSi(alpha[i]))}
  69.      * </p>
  70.      * @param i index of the coefficient
  71.      * @param alphaI α coefficient to set (s/radⁿ)
  72.      * @see #S_PER_SC_N
  73.      */
  74.     public void setAlphaI(final int i, final double alphaI) {
  75.         alpha[i] = alphaI;
  76.     }

  77.     /** Get the β coefficients.
  78.      * <p>
  79.      * Beware Orekit uses SI units here.
  80.      * In order to retrieve the more traditional s/semi-circleⁿ, use
  81.      * {@code IonosphereKlobucharMessage.S_PER_SC_N[i].fromSI(beta[i])}
  82.      * </p>
  83.      * @return β coefficients (s/radⁿ)
  84.      * @see #S_PER_SC_N
  85.      */
  86.     public double[] getBeta() {
  87.         return beta.clone();
  88.     }

  89.     /** Set one β coefficient.
  90.      * <p>
  91.      * Beware Orekit uses SI units here.
  92.      * In order to use the more traditional s/semi-circleⁿ, use
  93.      * {@code setBetaI(i, IonosphereKlobucharMessage.S_PER_SC_N[i].toSi(beta[i]))}
  94.      * </p>
  95.      * @param i index of the coefficient
  96.      * @param betaI β coefficient to set (s/radⁿ)
  97.      * @see #S_PER_SC_N
  98.      */
  99.     public void setBetaI(final int i, final double betaI) {
  100.         beta[i] = betaI;
  101.     }

  102.     /** Get the region code.
  103.      * @return region code
  104.      */
  105.     public RegionCode getRegionCode() {
  106.         return regionCode;
  107.     }

  108.     /** Set the region code.
  109.      * @param regionCode region code
  110.      */
  111.     public void setRegionCode(final RegionCode regionCode) {
  112.         this.regionCode = regionCode;
  113.     }

  114. }