SinexEopEntry.java

  1. /* Copyright 2002-2024 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.files.sinex;

  18. import org.orekit.frames.EOPEntry;
  19. import org.orekit.frames.ITRFVersion;
  20. import org.orekit.time.AbsoluteDate;
  21. import org.orekit.time.TimeScale;
  22. import org.orekit.time.TimeStamped;
  23. import org.orekit.utils.IERSConventions;

  24. /**
  25.  * Container for EOP entry read in a Sinex file.
  26.  *
  27.  * @author Bryan Cazabonne
  28.  * @since 11.2
  29.  */
  30. public class SinexEopEntry implements TimeStamped {

  31.     /** Length of day (seconds). */
  32.     private double lod;

  33.     /** UT1-UTC (seconds). */
  34.     private double ut1MinusUtc;

  35.     /** X polar motion (radians). */
  36.     private double xPo;

  37.     /** Y polar motion (radians). */
  38.     private double yPo;

  39.     /** Nutation correction in longitude (radians). */
  40.     private double nutLn;

  41.     /** Nutation correction in obliquity (radians). */
  42.     private double nutOb;

  43.     /** Nutation correction X (radians). */
  44.     private double nutX;

  45.     /** Nutation correction Y (radians). */
  46.     private double nutY;

  47.     /** EOP entry reference epoch. */
  48.     private final AbsoluteDate epoch;

  49.     /**
  50.      * Constructor.
  51.      * @param epoch epoch of the data
  52.      */
  53.     public SinexEopEntry(final AbsoluteDate epoch) {
  54.         this.epoch = epoch;
  55.     }

  56.     /** {@inheritDoc} */
  57.     @Override
  58.     public AbsoluteDate getDate() {
  59.         return epoch;
  60.     }

  61.     /**
  62.      * Get the length of day.
  63.      * @return the length of day in seconds
  64.      */
  65.     public double getLod() {
  66.         return lod;
  67.     }

  68.     /**
  69.      * Set the length of day.
  70.      * @param lod the length of day to set in seconds
  71.      */
  72.     public void setLod(final double lod) {
  73.         this.lod = lod;
  74.     }

  75.     /**
  76.      * Get the UT1-UTC offset.
  77.      * @return the UT1-UTC offset in seconds
  78.      */
  79.     public double getUt1MinusUtc() {
  80.         return ut1MinusUtc;
  81.     }

  82.     /**
  83.      * Set the UT1-UTC offset.
  84.      * @param ut1MinusUtc the value to set in seconds
  85.      */
  86.     public void setUt1MinusUtc(final double ut1MinusUtc) {
  87.         this.ut1MinusUtc = ut1MinusUtc;
  88.     }

  89.     /**
  90.      * Get the X polar motion.
  91.      * @return the X polar motion in radians
  92.      */
  93.     public double getXPo() {
  94.         return xPo;
  95.     }

  96.     /**
  97.      * Set the X polar motion.
  98.      * @param xPo the X polar motion to set in radians
  99.      */
  100.     public void setxPo(final double xPo) {
  101.         this.xPo = xPo;
  102.     }

  103.     /**
  104.      * Get the Y polar motion.
  105.      * @return the Y polar motion in radians
  106.      */
  107.     public double getYPo() {
  108.         return yPo;
  109.     }

  110.     /**
  111.      * Set the Y polar motion.
  112.      * @param yPo the Y polar motion to set in radians
  113.      */
  114.     public void setyPo(final double yPo) {
  115.         this.yPo = yPo;
  116.     }

  117.     /**
  118.      * Get the nutation correction in longitude.
  119.      * @return the nutation correction in longitude in radians
  120.      */
  121.     public double getNutLn() {
  122.         return nutLn;
  123.     }

  124.     /**
  125.      * Set the nutation correction in longitude.
  126.      * @param nutLn the nutation correction in longitude to set in radians
  127.      */
  128.     public void setNutLn(final double nutLn) {
  129.         this.nutLn = nutLn;
  130.     }

  131.     /**
  132.      * Get the nutation correction in obliquity.
  133.      * @return the nutation correction in obliquity in radians
  134.      */
  135.     public double getNutOb() {
  136.         return nutOb;
  137.     }

  138.     /**
  139.      * Set the nutation correction in obliquity.
  140.      * @param nutOb the nutation correction in obliquity to set in radians
  141.      */
  142.     public void setNutOb(final double nutOb) {
  143.         this.nutOb = nutOb;
  144.     }

  145.     /**
  146.      * Get the nutation correction X.
  147.      * @return the nutation correction X in radians
  148.      */
  149.     public double getNutX() {
  150.         return nutX;
  151.     }

  152.     /**
  153.      * Set the nutation correction X.
  154.      * @param nutX the nutation correction X to set in radians
  155.      */
  156.     public void setNutX(final double nutX) {
  157.         this.nutX = nutX;
  158.     }

  159.     /**
  160.      * Get the nutation correction Y.
  161.      * @return the nutation correction Y in radians
  162.      */
  163.     public double getNutY() {
  164.         return nutY;
  165.     }

  166.     /**
  167.      * Set the nutation correction Y.
  168.      * @param nutY the nutation correction Y to set in radians
  169.      */
  170.     public void setNutY(final double nutY) {
  171.         this.nutY = nutY;
  172.     }

  173.     /**
  174.      * Converts to an {@link EOPEntry}.
  175.      * @param converter converter to use for nutation corrections
  176.      * @param version ITRF version
  177.      * @param scale time scale for epochs
  178.      * @return an {@code EOPEntry}
  179.      */
  180.     public EOPEntry toEopEntry(final IERSConventions.NutationCorrectionConverter converter,
  181.                                final ITRFVersion version, final TimeScale scale) {

  182.         // Modified Julian Day
  183.         final int mjd = epoch.getComponents(scale).getDate().getMJD();

  184.         // Array for equinox and non rotating origin
  185.         final double[] nro     = (nutX != 0  && nutY != 0)  ? new double[] {nutX, nutY}   : converter.toNonRotating(epoch, nutLn, nutOb);
  186.         final double[] equinox = (nutLn != 0 && nutOb != 0) ? new double[] {nutLn, nutOb} : converter.toEquinox(epoch, nutX, nutY);

  187.         // Create a new EOPEntry object storing the extracted data, then add it to the list of EOPEntries.
  188.         return new EOPEntry(mjd, ut1MinusUtc, lod,
  189.                             xPo, yPo, Double.NaN, Double.NaN,
  190.                             equinox[0], equinox[1],
  191.                             nro[0], nro[1],
  192.                             version, epoch);

  193.     }

  194. }