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 org.hipparchus.geometry.euclidean.threed.Vector3D;
20  import org.hipparchus.util.FastMath;
21  import org.junit.jupiter.api.Assertions;
22  import org.junit.jupiter.api.BeforeEach;
23  import org.junit.jupiter.api.Test;
24  import org.orekit.Utils;
25  import org.orekit.bodies.GeodeticPoint;
26  import org.orekit.bodies.OneAxisEllipsoid;
27  import org.orekit.data.DataSource;
28  import org.orekit.data.FundamentalNutationArguments;
29  import org.orekit.files.sinex.SinexParser;
30  import org.orekit.files.sinex.Station;
31  import org.orekit.frames.Frame;
32  import org.orekit.frames.FramesFactory;
33  import org.orekit.time.AbsoluteDate;
34  import org.orekit.time.TimeScale;
35  import org.orekit.time.TimeScalesFactory;
36  import org.orekit.utils.Constants;
37  import org.orekit.utils.IERSConventions;
38  
39  import java.net.URISyntaxException;
40  import java.net.URL;
41  
42  public class PostSeismicDeformationTest {
43  
44      @Test
45      public void testShintotsukawa() throws URISyntaxException {
46          final URL url = PostSeismicDeformationTest.class.getClassLoader().
47                          getResource("sinex/ITRF2020-psd-gnss.snx");
48          final Station stk2 = new SinexParser(TimeScalesFactory.getTimeScales()).
49                               parse(new DataSource(url.toURI())).
50                               getStations().get("STK2");
51  
52          final IERSConventions              conventions = IERSConventions.IERS_2010;
53          final TimeScale                    utc         = TimeScalesFactory.getUTC();
54          final TimeScale                    ut1         = TimeScalesFactory.getUT1(conventions, false);
55          final FundamentalNutationArguments fna         = conventions.getNutationArguments(ut1);
56          final Frame                        earthFrame  = FramesFactory.getITRF(conventions, false);
57          final OneAxisEllipsoid             earth       = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
58                                                                                Constants.WGS84_EARTH_FLATTENING,
59                                                                                earthFrame);
60  
61          // https://earthquake.usgs.gov/earthquakes/eventpage/usp000c8kv/executive
62          final AbsoluteDate date2003 =  new AbsoluteDate(2003, 9, 25, 19, 50, 6, utc);
63          final GeodeticPoint base    = earth.transform(stk2.getPosition(), earthFrame, null);
64          final PostSeismicDeformation psd = new PostSeismicDeformation(base, stk2.getPsdTimeSpanMap());
65  
66          for (double years = 0; years < 1.0; years += 0.01) {
67              final Vector3D dp = psd.displacement(fna.evaluateAll( date2003.shiftedBy(years * Constants.JULIAN_YEAR)),
68                                                   earthFrame, stk2.getPosition());
69  
70              // reference values from manual analysis of PSD data file
71              final double refEast  = -3.12544483981059e-02 * (1 - FastMath.exp(-years / 3.90382962596289e-01)) +
72                                       2.74994599757755e-02 * FastMath.log(1 + years / 6.84349501571032e-02);
73              final double refNorth = -3.97046280518505e-02 * (1 - FastMath.exp(-years / 1.38871759192151e+00)) +
74                                      -1.44921478188329e-02 * (1 - FastMath.exp(-years / 6.08619870701242e-02));
75              final double refUp    = 0.0;
76  
77              Assertions.assertEquals(refEast,  Vector3D.dotProduct(dp, base.getEast()),   1.0e-15);
78              Assertions.assertEquals(refNorth, Vector3D.dotProduct(dp, base.getNorth()),  1.0e-15);
79              Assertions.assertEquals(refUp,    Vector3D.dotProduct(dp, base.getZenith()), 1.0e-15);
80  
81          }
82  
83      }
84  
85      @BeforeEach
86      public void setUp() throws Exception {
87          Utils.setDataRoot("regular-data");
88      }
89  
90  }