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.displacement;
18  
19  import java.net.URISyntaxException;
20  import java.net.URL;
21  import java.util.Map;
22  
23  import org.hipparchus.geometry.euclidean.threed.Vector3D;
24  import org.junit.jupiter.api.Assertions;
25  import org.junit.jupiter.api.BeforeEach;
26  import org.junit.jupiter.api.Test;
27  import org.orekit.Utils;
28  import org.orekit.data.BodiesElements;
29  import org.orekit.data.DataSource;
30  import org.orekit.data.FundamentalNutationArguments;
31  import org.orekit.files.sinex.SinexParser;
32  import org.orekit.files.sinex.Station;
33  import org.orekit.frames.Frame;
34  import org.orekit.frames.FramesFactory;
35  import org.orekit.time.AbsoluteDate;
36  import org.orekit.time.TimeScale;
37  import org.orekit.time.TimeScalesFactory;
38  import org.orekit.utils.Constants;
39  import org.orekit.utils.IERSConventions;
40  import org.orekit.utils.units.Unit;
41  
42  public class TectonicsDisplacementTest {
43  
44      @Test
45      public void testLviv() throws URISyntaxException {
46          final URL url = TectonicsDisplacementTest.class.getClassLoader().
47                          getResource("sinex/SLRF2008_150928_2015.09.28.snx");
48          final Map<String, Station>         stations    = new SinexParser(TimeScalesFactory.getTimeScales()).
49                                                           parse(new DataSource(url.toURI())).
50                                                           getStations();
51          final IERSConventions              conventions = IERSConventions.IERS_2010;
52          final TimeScale                    utc         = TimeScalesFactory.getUTC();
53          final TimeScale                    ut1         = TimeScalesFactory.getUT1(conventions, false);
54          final FundamentalNutationArguments fna         = conventions.getNutationArguments(ut1);
55          final Frame                        earthFrame  = FramesFactory.getITRF(conventions, false);
56  
57          // 1831  A 12368S001 L Lviv       LVIV         23 57 15.8  49 55  3.2   359.8     18318501
58          // ...
59          // 13 STAX   1831  A    1 05:001:00000 m    2 0.376067473563698E+07 0.32330E-02
60          // 14 STAY   1831  A    1 05:001:00000 m    2 0.167077643037227E+07 0.36276E-02
61          // 15 STAZ   1831  A    1 05:001:00000 m    2 0.485716543779447E+07 0.26569E-02
62          // 16 VELX   1831  A    1 05:001:00000 m/y  2 -.228163272262724E-02 0.28320E-02
63          // 17 VELY   1831  A    1 05:001:00000 m/y  2 0.175681714423597E-01 0.34733E-02
64          // 18 VELZ   1831  A    1 05:001:00000 m/y  2 0.408218739007309E-01 0.24574E-02
65          final Station lviv = stations.get("1831");
66          Assertions.assertEquals(0.0,
67                                  Vector3D.distance(new Vector3D(0.376067473563698E+07,
68                                                                 0.167077643037227E+07,
69                                                                 0.485716543779447E+07),
70                                                    lviv.getPosition()),
71                                  1.0e-8);
72          final Unit mPy = Unit.parse("m/yr");
73          Assertions.assertEquals(0.0,
74                                  Vector3D.distance(new Vector3D(mPy.toSI(-.228163272262724E-02),
75                                                                 mPy.toSI(0.175681714423597E-01),
76                                                                 mPy.toSI(0.408218739007309E-01)),
77                                                    lviv.getVelocity()),
78                                  1.0e-20);
79          Assertions.assertEquals(0.0,
80                                  lviv.getEpoch().durationFrom(new AbsoluteDate(2005, 1, 1, utc)),
81                                  1.0e-15);
82  
83          final TectonicsDisplacement displacement = new TectonicsDisplacement(lviv.getEpoch(),
84                                                                               lviv.getVelocity());
85          final AbsoluteDate          sixMonthsLater = lviv.getEpoch().shiftedBy(0.5 * Constants.JULIAN_YEAR);
86          final BodiesElements        elements       = fna.evaluateAll(sixMonthsLater);
87          final Vector3D              dP             = displacement.displacement(elements, earthFrame, lviv.getPosition());
88          Assertions.assertEquals(0.5 * -.228163272262724E-02, dP.getX(), 1.0e-16);
89          Assertions.assertEquals(0.5 * 0.175681714423597E-01, dP.getY(), 1.0e-16);
90          Assertions.assertEquals(0.5 * 0.408218739007309E-01, dP.getZ(), 1.0e-16);
91          
92  
93      }
94  
95      @BeforeEach
96      public void setUp() throws Exception {
97          Utils.setDataRoot("regular-data");
98      }
99  
100 }