1   /* Copyright 2002-2024 Thales Alenia Space
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.models.earth.weather;
18  
19  import org.hipparchus.util.FastMath;
20  import org.hipparchus.util.SinCos;
21  
22  /** Seasonal model used in Global Pressure Temperature models.
23   * @see "Landskron, D. & Böhm, J. J Geod (2018)
24   *      VMF3/GPT3: refined discrete and empirical troposphere mapping functions
25   *      92: 349. https://doi.org/10.1007/s00190-017-1066-2"
26   * @author Luc Maisonobe
27   * @since 12.1
28   */
29  class SeasonalModel {
30  
31      /** Constant. */
32      private final double a0;
33  
34      /** Annual cosine amplitude. */
35      private final double a1;
36  
37      /** Annual sine amplitude. */
38      private final double b1;
39  
40      /** Semi-annual cosine amplitude. */
41      private final double a2;
42  
43      /** Semi-annual sine amplitude. */
44      private final double b2;
45  
46      /** Simple constructor.
47       * @param a0 constant
48       * @param a1 annual cosine amplitude
49       * @param b1 annual sine amplitude
50       * @param a2 semi-annual cosine amplitude
51       * @param b2 semi-annual sine amplitude
52       */
53      SeasonalModel(final double a0, final double a1, final double b1, final double a2, final double b2) {
54          this.a0 = a0;
55          this.a1 = a1;
56          this.b1 = b1;
57          this.a2 = a2;
58          this.b2 = b2;
59      }
60  
61      /** Evaluate a model for some day.
62       * @param dayOfYear day to evaluate
63       * @return model value at specified day
64       */
65      public double evaluate(final int dayOfYear) {
66  
67          final double coef = (dayOfYear / 365.25) * 2 * FastMath.PI;
68          final SinCos sc1  = FastMath.sinCos(coef);
69          final SinCos sc2  = FastMath.sinCos(2.0 * coef);
70  
71          return a0 + a1 * sc1.cos() + b1 * sc1.sin() + a2 * sc2.cos() + b2 * sc2.sin();
72  
73      }
74  
75  }