SeasonalGrid.java

  1. /* Copyright 2022-2025 Thales Alenia Space
  2.  * Licensed to CS Communication & Systèmes (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.models.earth.troposphere.iturp834;

  18. import org.hipparchus.CalculusFieldElement;
  19. import org.hipparchus.util.FastMath;
  20. import org.hipparchus.util.MathUtils;
  21. import org.orekit.bodies.FieldGeodeticPoint;
  22. import org.orekit.bodies.GeodeticPoint;
  23. import org.orekit.utils.Constants;
  24. import org.orekit.utils.units.Unit;

  25. /** Grid data with harmonic seasonal fluctuation.
  26.  * @author Luc Maisonobe
  27.  * @since 13.0
  28.  */
  29. class SeasonalGrid extends AbstractGrid {

  30.     /** Annual pulsation. */
  31.     private static final double OMEGA = MathUtils.TWO_PI / Constants.JULIAN_YEAR;

  32.     /** Average data. */
  33.     private final double[][] average;

  34.     /** Seasonal fluctuation data. */
  35.     private final double[][] seasonal;

  36.     /** Second of minimum data. */
  37.     private final double[][] minSecond;

  38.     /** Build a grid by parsing three resource files.
  39.      * @param unit unit of the average and seasonal fluctuation values in resource files
  40.      * @param averageName name of the resource holding the average data
  41.      * @param seasonalName name of the resource holding the seasonal fluctuation data
  42.      * @param minDayName name of the resource holding the day of minimum data
  43.      */
  44.     SeasonalGrid(final Unit unit,
  45.                  final String averageName, final String seasonalName, final String minDayName) {
  46.         average   = parse(unit,     averageName);
  47.         seasonal  = parse(unit,     seasonalName);
  48.         // we convert from days to SI units (i.e. seconds) upon reading
  49.         minSecond = parse(Unit.DAY, minDayName);
  50.     }

  51.     /** {@inheritDoc} */
  52.     @Override
  53.     public GridCell getCell(final GeodeticPoint location, final double secondOfYear) {
  54.         return new GridCell((a, s, m) -> a - s * FastMath.cos(OMEGA * (secondOfYear - m)),
  55.                             getRawCell(location, average),
  56.                             getRawCell(location, seasonal),
  57.                             getRawCell(location, minSecond));
  58.     }

  59.     /** {@inheritDoc} */
  60.     @Override
  61.     public <T extends CalculusFieldElement<T>> FieldGridCell<T> getCell(final FieldGeodeticPoint<T> location,
  62.                                                                         final T secondOfYear) {
  63.         return new FieldGridCell<>((a, s, m) -> a.subtract(s.multiply(FastMath.cos(secondOfYear.subtract(m).multiply(OMEGA)))),
  64.                                    getRawCell(location, average),
  65.                                    getRawCell(location, seasonal),
  66.                                    getRawCell(location, minSecond));
  67.     }

  68. }