SecularTrendSphericalHarmonics.java

  1. /* Copyright 2002-2015 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.forces.gravity.potential;

  18. import org.orekit.errors.OrekitException;
  19. import org.orekit.time.AbsoluteDate;
  20. import org.orekit.time.DateComponents;
  21. import org.orekit.time.TimeComponents;
  22. import org.orekit.time.TimeScalesFactory;

  23. /** Simple implementation of {@link RawSphericalHarmonicsProvider} for gravity fields with secular trend.
  24.  * @author Luc Maisonobe
  25.  * @since 6.0
  26.  */
  27. class SecularTrendSphericalHarmonics implements RawSphericalHarmonicsProvider {

  28.     /** Non-secular part of the field. */
  29.     private final RawSphericalHarmonicsProvider provider;

  30.     /** Reference date for the harmonics. */
  31.     private final AbsoluteDate referenceDate;

  32.     /** Secular trend of the cosine coefficients. */
  33.     private final double[][] cTrend;

  34.     /** Secular trend of the sine coefficients. */
  35.     private final double[][] sTrend;

  36.     /** Simple constructor.
  37.      * @param provider underlying provider for the non secular part
  38.      * @param referenceDate reference date for the harmonics (considered to be at 12:00 TT)
  39.      * @param cTrend secular trend of the cosine coefficients (s<sup>-1</sup>)
  40.      * @param sTrend secular trend of the sine coefficients (s<sup>-1</sup>)
  41.      */
  42.     public SecularTrendSphericalHarmonics(final RawSphericalHarmonicsProvider provider,
  43.                                           final DateComponents referenceDate,
  44.                                           final double[][] cTrend, final double[][] sTrend) {
  45.         this.provider      = provider;
  46.         this.referenceDate = new AbsoluteDate(referenceDate, TimeComponents.H12, TimeScalesFactory.getTT());
  47.         this.cTrend        = cTrend;
  48.         this.sTrend        = sTrend;
  49.     }

  50.     /** {@inheritDoc} */
  51.     public int getMaxDegree() {
  52.         return provider.getMaxDegree();
  53.     }

  54.     /** {@inheritDoc} */
  55.     public int getMaxOrder() {
  56.         return provider.getMaxOrder();
  57.     }

  58.     /** {@inheritDoc} */
  59.     public double getMu() {
  60.         return provider.getMu();
  61.     }

  62.     /** {@inheritDoc} */
  63.     public double getAe() {
  64.         return provider.getAe();
  65.     }

  66.     /** {@inheritDoc} */
  67.     public AbsoluteDate getReferenceDate() {
  68.         return referenceDate;
  69.     }

  70.     /** {@inheritDoc} */
  71.     public double getOffset(final AbsoluteDate date) {
  72.         return date.durationFrom(referenceDate);
  73.     }

  74.     /** {@inheritDoc} */
  75.     public TideSystem getTideSystem() {
  76.         return provider.getTideSystem();
  77.     }

  78.     @Override
  79.     public RawSphericalHarmonics onDate(final AbsoluteDate date) throws OrekitException {
  80.         final RawSphericalHarmonics harmonics = provider.onDate(date);
  81.         //compute date offset from reference
  82.         final double dateOffset = getOffset(date);
  83.         return new RawSphericalHarmonics() {

  84.             @Override
  85.             public AbsoluteDate getDate() {
  86.                 return date;
  87.             }

  88.             /** {@inheritDoc} */
  89.             public double getRawCnm(final int n, final int m)
  90.                 throws OrekitException {

  91.                 // retrieve the constant part of the coefficient
  92.                 double cnm = harmonics.getRawCnm(n, m);

  93.                 if (n < cTrend.length && m < cTrend[n].length) {
  94.                     // add secular trend
  95.                     cnm += dateOffset * cTrend[n][m];
  96.                 }

  97.                 return cnm;

  98.             }

  99.             /** {@inheritDoc} */
  100.             public double getRawSnm(final int n, final int m)
  101.                 throws OrekitException {

  102.                 // retrieve the constant part of the coefficient
  103.                 double snm = harmonics.getRawSnm(n, m);

  104.                 if (n < sTrend.length && m < sTrend[n].length) {
  105.                     // add secular trend
  106.                     snm += dateOffset * sTrend[n][m];
  107.                 }

  108.                 return snm;

  109.             }

  110.         };
  111.     }

  112. }