1   /* Copyright 2022-2025 Luc Maisonobe
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.frames;
18  
19  import java.io.Serializable;
20  
21  /** Earth Orientation Parameters fitter for {@link PredictedEOPHistory EOP prediction}.
22   * @see PredictedEOPHistory
23   * @see SingleParameterFitter
24   * @since 12.0
25   * @author Luc Maisonobe
26   */
27  public class EOPFitter implements Serializable {
28  
29      /** Serializable UID. */
30      private static final long serialVersionUID = 20230309L;
31  
32      /** Fitter for dut1 and LOD. */
33      private final SingleParameterFitter dut1Fitter;
34  
35      /** Fitter for pole x component. */
36      private final SingleParameterFitter xPFitter;
37  
38      /** Fitter for pole y component. */
39      private final SingleParameterFitter yPFitter;
40  
41      /** Fitter for nutation x component. */
42      private final SingleParameterFitter dxFitter;
43  
44      /** Fitter for nutation y component. */
45      private final SingleParameterFitter dyFitter;
46  
47      /** Simple constructor.
48       * @param dut1Fitter fitter for dut1 and LOD
49       * @param xPFitter fitter for pole x component
50       * @param yPFitter fitter for pole y component
51       * @param dxFitter fitter for nutation x component
52       * @param dyFitter fitter for nutation y component
53       */
54      public EOPFitter(final SingleParameterFitter dut1Fitter,
55                       final SingleParameterFitter xPFitter, final SingleParameterFitter yPFitter,
56                       final SingleParameterFitter dxFitter, final SingleParameterFitter dyFitter) {
57          this.dut1Fitter = dut1Fitter;
58          this.xPFitter   = xPFitter;
59          this.yPFitter   = yPFitter;
60          this.dxFitter   = dxFitter;
61          this.dyFitter   = dyFitter;
62      }
63  
64      /** Fit raw history.
65       * @param rawHistory raw EOP history to fit.
66       * @return fitted model
67       */
68      public EOPFittedModel fit(final EOPHistory rawHistory) {
69          return new EOPFittedModel(dut1Fitter.fit(rawHistory, EOPEntry::getUT1MinusUTC),
70                                    xPFitter.fit(rawHistory, EOPEntry::getX),
71                                    yPFitter.fit(rawHistory, EOPEntry::getY),
72                                    dxFitter.fit(rawHistory, EOPEntry::getDx),
73                                    dyFitter.fit(rawHistory, EOPEntry::getDy));
74      }
75  
76  }