GTODProvider.java

  1. /* Copyright 2002-2016 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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.frames;

  18. import java.io.Serializable;

  19. import org.hipparchus.analysis.differentiation.DerivativeStructure;
  20. import org.hipparchus.geometry.euclidean.threed.Rotation;
  21. import org.hipparchus.geometry.euclidean.threed.RotationConvention;
  22. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  23. import org.orekit.errors.OrekitException;
  24. import org.orekit.errors.OrekitInternalError;
  25. import org.orekit.time.AbsoluteDate;
  26. import org.orekit.time.TimeFunction;
  27. import org.orekit.time.TimeScalesFactory;
  28. import org.orekit.time.UT1Scale;
  29. import org.orekit.utils.Constants;
  30. import org.orekit.utils.IERSConventions;

  31. /** Greenwich True Of Date Frame, also known as True of Date Rotating frame (TDR)
  32.  * or Greenwich Rotating Coordinate frame (GCR).
  33.  * <p> This frame handles the sidereal time according to IAU-82 model.</p>
  34.  * <p> Its parent frame is the {@link TODProvider}.</p>
  35.  * <p> The pole motion is not applied here.</p>
  36.  * @author Pascal Parraud
  37.  * @author Thierry Ceolin
  38.  */
  39. public class GTODProvider implements EOPBasedTransformProvider {

  40.     /** Serializable UID. */
  41.     private static final long serialVersionUID = 20141228L;

  42.     /** Angular velocity of the Earth, in rad/s. */
  43.     private static final double AVE = 7.292115146706979e-5;

  44.     /** Conventions. */
  45.     private final IERSConventions conventions;

  46.     /** EOP history. */
  47.     private final EOPHistory eopHistory;

  48.     /** GAST function. */
  49.     private final transient TimeFunction<DerivativeStructure> gastFunction;

  50.     /** Simple constructor.
  51.      * @param conventions IERS conventions to use
  52.      * @param eopHistory EOP history (may be null)
  53.      * @exception OrekitException if EOP parameters are desired but cannot be read
  54.      */
  55.     protected GTODProvider(final IERSConventions conventions, final EOPHistory eopHistory)
  56.         throws OrekitException {
  57.         final UT1Scale ut1 = TimeScalesFactory.getUT1(eopHistory);
  58.         this.conventions   = conventions;
  59.         this.eopHistory    = eopHistory;
  60.         this.gastFunction  = conventions.getGASTFunction(ut1, eopHistory);
  61.     }

  62.     /** {@inheritDoc} */
  63.     @Override
  64.     public EOPHistory getEOPHistory() {
  65.         return eopHistory;
  66.     }

  67.     /** {@inheritDoc} */
  68.     @Override
  69.     public GTODProvider getNonInterpolatingProvider()
  70.         throws OrekitException {
  71.         return new GTODProvider(conventions, eopHistory.getNonInterpolatingEOPHistory());
  72.     }

  73.     /** Get the transform from TOD at specified date.
  74.      * <p>The update considers the Earth rotation from IERS data.</p>
  75.      * @param date new value of the date
  76.      * @return transform at the specified date
  77.      * @exception OrekitException if the nutation model data embedded in the
  78.      * library cannot be read
  79.      */
  80.     public Transform getTransform(final AbsoluteDate date) throws OrekitException {

  81.         // compute Greenwich apparent sidereal time, in radians
  82.         final double gast = gastFunction.value(date).getValue();

  83.         // compute true angular rotation of Earth, in rad/s
  84.         final double lod = (eopHistory == null) ? 0.0 : eopHistory.getLOD(date);
  85.         final double omp = AVE * (1 - lod / Constants.JULIAN_DAY);
  86.         final Vector3D rotationRate = new Vector3D(omp, Vector3D.PLUS_K);

  87.         // set up the transform from parent TOD
  88.         return new Transform(date, new Rotation(Vector3D.PLUS_K, gast, RotationConvention.FRAME_TRANSFORM), rotationRate);

  89.     }

  90.     /** Replace the instance with a data transfer object for serialization.
  91.      * <p>
  92.      * This intermediate class serializes only the frame key.
  93.      * </p>
  94.      * @return data transfer object that will be serialized
  95.      */
  96.     private Object writeReplace() {
  97.         return new DataTransferObject(conventions, eopHistory);
  98.     }

  99.     /** Internal class used only for serialization. */
  100.     private static class DataTransferObject implements Serializable {

  101.         /** Serializable UID. */
  102.         private static final long serialVersionUID = 20131209L;

  103.         /** Conventions. */
  104.         private final IERSConventions conventions;

  105.         /** EOP history. */
  106.         private final EOPHistory eopHistory;

  107.         /** Simple constructor.
  108.          * @param conventions IERS conventions to apply
  109.          * @param eopHistory EOP history
  110.          */
  111.         DataTransferObject(final IERSConventions conventions, final EOPHistory eopHistory) {
  112.             this.conventions = conventions;
  113.             this.eopHistory  = eopHistory;
  114.         }

  115.         /** Replace the deserialized data transfer object with a {@link GTODProvider}.
  116.          * @return replacement {@link GTODProvider}
  117.          */
  118.         private Object readResolve() {
  119.             try {
  120.                 // retrieve a managed frame
  121.                 return new GTODProvider(conventions, eopHistory);
  122.             } catch (OrekitException oe) {
  123.                 throw new OrekitInternalError(oe);
  124.             }
  125.         }

  126.     }

  127. }