1   /* Copyright 2022-2025 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 java.io.IOException;
20  
21  import org.hipparchus.CalculusFieldElement;
22  import org.orekit.data.DataSource;
23  import org.orekit.time.AbsoluteDate;
24  import org.orekit.time.FieldAbsoluteDate;
25  import org.orekit.time.TimeScale;
26  
27  /** The Global Pressure and Temperature 3 (GPT3) model.
28   * <p>
29   * This model adds horizontal gradient data to {@link GlobalPressureTemperature2w GPT2w}.
30   * </p>
31   * @author Luc Maisonobe
32   * @since 12.1
33   */
34  public class GlobalPressureTemperature3 extends AbstractGlobalPressureTemperature {
35  
36      /** UTC time scale. */
37      private final TimeScale utc;
38  
39      /**
40       * Constructor with source of GPT3 auxiliary data given by user.
41       *
42       * @param source grid data source
43       * @param utc UTC time scale.
44       * @exception IOException if grid data cannot be read
45       */
46      public GlobalPressureTemperature3(final DataSource source, final TimeScale utc)
47          throws IOException {
48          super(source,
49                SeasonalModelType.PRESSURE,
50                SeasonalModelType.TEMPERATURE,
51                SeasonalModelType.QV,
52                SeasonalModelType.DT,
53                SeasonalModelType.AH,
54                SeasonalModelType.AW,
55                SeasonalModelType.LAMBDA,
56                SeasonalModelType.TM,
57                SeasonalModelType.GN_H,
58                SeasonalModelType.GE_H,
59                SeasonalModelType.GN_W,
60                SeasonalModelType.GE_W);
61  
62          this.utc = utc;
63  
64      }
65  
66      /** {@inheritDoc} */
67      @Override
68      protected double deltaRef(final AbsoluteDate date) {
69          final AbsoluteDate reference =
70              new AbsoluteDate(date.getComponents(utc).getDate().getYear() - 1, 12, 31, utc);
71          return date.durationFrom(reference);
72      }
73  
74      /** {@inheritDoc} */
75      @Override
76      protected <T extends CalculusFieldElement<T>> T deltaRef(final FieldAbsoluteDate<T> date) {
77          final FieldAbsoluteDate<T> reference =
78              new FieldAbsoluteDate<>(date.getField(), date.getComponents(utc).getDate().getYear() - 1, 12, 31, utc);
79          return date.durationFrom(reference);
80      }
81  
82  }