1   /* Copyright 2002-2024 CS GROUP
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.displacement;
18  
19  import org.orekit.bodies.GeodeticPoint;
20  
21  /**
22   * Site specific coefficients for ocean loading.
23   * <p>
24   * Instances of this class are typically created by
25   * {@link OceanLoadingCoefficientsBLQFactory} that parses
26   * files from Onsala Space Observatory files in BLQ format
27   * found in the Orekit data configuration.
28   * </p>
29   * <p>
30   * Instances of this class are guaranteed to be immutable
31   * </p>
32   * @see org.orekit.estimation.measurements.GroundStation
33   * @see OceanLoadingCoefficientsBLQFactory
34   * @see OceanLoading
35   * @since 9.1
36   * @author Luc Maisonobe
37   */
38  public class OceanLoadingCoefficients {
39  
40      /** Site name. */
41      private final String siteName;
42  
43      /** Site location. */
44      private final GeodeticPoint siteLocation;
45  
46      /** Main tides by species and increasing rate. */
47      private final Tide[][] tides;
48  
49      /** Amplitude along zenith axis for main tides by species and increasing rate. */
50      private final double[][] zAmplitude;
51  
52      /** Phase along zenith axis for main tides by species and increasing rate. */
53      private final double[][] zPhase;
54  
55      /** Amplitude along West axis for main tides by species and increasing rate. */
56      private final double[][] wAmplitude;
57  
58      /** Phase along West axis for main tides by species and increasing rate. */
59      private final double[][] wPhase;
60  
61      /** Amplitude along South axis for main tides by species and increasing rate. */
62      private final double[][] sAmplitude;
63  
64      /** Phase along South axis for main tides by species and increasing rate. */
65      private final double[][] sPhase;
66  
67      /** Simple constructor.
68       * <p>
69       * Arrays must be organized by species and sorted in increasing rate order.
70       * @param siteName site name
71       * @param siteLocation site location
72       * @param tides main tides, by species and increasing rate
73       * @param zAmplitude amplitude along zenith axis
74       * @param zPhase phase along zenith axis
75       * @param wAmplitude amplitude along West
76       * @param wPhase phase along West axis
77       * @param sAmplitude amplitude along South
78       * @param sPhase phase along South axis
79       */
80      public OceanLoadingCoefficients(final String siteName, final GeodeticPoint siteLocation,
81                                      final Tide[][] tides,
82                                      final double[][] zAmplitude, final double[][] zPhase,
83                                      final double[][] wAmplitude, final double[][] wPhase,
84                                      final double[][] sAmplitude, final double[][] sPhase) {
85          this.siteName     = siteName;
86          this.siteLocation = siteLocation;
87          this.tides        = copy(tides);
88          this.zAmplitude   = copy(zAmplitude);
89          this.zPhase       = copy(zPhase);
90          this.wAmplitude   = copy(wAmplitude);
91          this.wPhase       = copy(wPhase);
92          this.sAmplitude   = copy(sAmplitude);
93          this.sPhase       = copy(sPhase);
94      }
95  
96      /** Deep copy of a variable rows tides array.
97       * @param array to copy
98       * @return copied array
99       */
100     private Tide[][] copy(final Tide[][] array) {
101         final Tide[][] copied = new Tide[array.length][];
102         for (int i = 0; i < array.length; ++i) {
103             copied[i] = array[i].clone();
104         }
105         return copied;
106     }
107 
108     /** Deep copy of a variable rows double array.
109      * @param array to copy
110      * @return copied array
111      */
112     private double[][] copy(final double[][] array) {
113         final double[][] copied = new double[array.length][];
114         for (int i = 0; i < array.length; ++i) {
115             copied[i] = array[i].clone();
116         }
117         return copied;
118     }
119 
120     /** Get the site name.
121      * @return site name
122      */
123     public String getSiteName() {
124         return siteName;
125     }
126 
127     /** Get the site location.
128      * @return site location
129      */
130     public GeodeticPoint getSiteLocation() {
131         return siteLocation;
132     }
133 
134     /** Get the tide.
135      * @param i species
136      * @param j tide in the species
137      * @return tide
138      */
139     public Tide getTide(final int i, final int j) {
140         return tides[i][j];
141     }
142 
143     /** Get the amplitude along zenith axis.
144      * @param i species
145      * @param j tide in the species
146      * @return amplitude along zenith axis
147      */
148     public double getZenithAmplitude(final int i, final int j) {
149         return zAmplitude[i][j];
150     }
151 
152     /** Get the phase along zenith axis.
153      * @param i species
154      * @param j tide in the species
155      * @return phase along zenith axis
156      */
157     public double getZenithPhase(final int i, final int j) {
158         return zPhase[i][j];
159     }
160 
161     /** Get the amplitude along west axis.
162      * @param i species
163      * @param j tide in the species
164      * @return amplitude along west axis
165      */
166     public double getWestAmplitude(final int i, final int j) {
167         return wAmplitude[i][j];
168     }
169 
170     /** Get the phase along West axis.
171      * @param i species
172      * @param j tide in the species
173      * @return phase along West axis
174      */
175     public double getWestPhase(final int i, final int j) {
176         return wPhase[i][j];
177     }
178 
179     /** Get the amplitude along South axis.
180      * @param i species
181      * @param j tide in the species
182      * @return amplitude along South axis
183      */
184     public double getSouthAmplitude(final int i, final int j) {
185         return sAmplitude[i][j];
186     }
187 
188     /** Get the phase along South axis.
189      * @param i species
190      * @param j tide in the species
191      * @return phase along South axis
192      */
193     public double getSouthPhase(final int i, final int j) {
194         return sPhase[i][j];
195     }
196 
197     /** Get the number of species.
198      * @return number of species
199      */
200     public int getNbSpecies() {
201         return tides.length;
202     }
203 
204     /** Get the number of tides for one species.
205      * @param species species index
206      * @return number of tides for one species
207      */
208     public int getNbTides(final int species) {
209         return tides[species].length;
210     }
211 
212 }
213