1   /* Copyright 2002-2025 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.estimation;
18  
19  import org.hipparchus.geometry.euclidean.threed.Vector3D;
20  import org.hipparchus.util.FastMath;
21  import org.orekit.bodies.CelestialBody;
22  import org.orekit.bodies.GeodeticPoint;
23  import org.orekit.bodies.OneAxisEllipsoid;
24  import org.orekit.estimation.measurements.GroundStation;
25  import org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider;
26  import org.orekit.frames.TopocentricFrame;
27  import org.orekit.models.earth.displacement.StationDisplacement;
28  import org.orekit.orbits.CartesianOrbit;
29  import org.orekit.orbits.Orbit;
30  import org.orekit.orbits.PositionAngleType;
31  import org.orekit.propagation.conversion.EcksteinHechlerPropagatorBuilder;
32  import org.orekit.time.TimeScale;
33  import org.orekit.time.UT1Scale;
34  import org.orekit.utils.IERSConventions;
35  import org.orekit.utils.PVCoordinates;
36  
37  import java.util.List;
38  import java.util.Map;
39  
40  public class EcksteinHechlerContext implements StationDataProvider {
41  
42      public IERSConventions                        conventions;
43      public OneAxisEllipsoid                       earth;
44      public CelestialBody                          sun;
45      public CelestialBody                          moon;
46      public UnnormalizedSphericalHarmonicsProvider gravity;
47      public TimeScale                              utc;
48      public UT1Scale                               ut1;
49      public Orbit                                  initialOrbit;
50      public StationDisplacement[]                  displacements;
51      public List<GroundStation>                    stations;
52      // Stations for turn-around range
53      // Map entry = primary station
54      // Map value = secondary station associated
55      public Map<GroundStation, GroundStation>     TARstations;
56  
57      public EcksteinHechlerPropagatorBuilder createBuilder(final PositionAngleType angleType, final boolean perfectStart, final double dP) {
58  
59          final Orbit startOrbit;
60          if (perfectStart) {
61              // orbit estimation will start from a perfect orbit
62              startOrbit = initialOrbit;
63          } else {
64              // orbit estimation will start from a wrong point
65              final Vector3D initialPosition = initialOrbit.getPosition();
66              final Vector3D initialVelocity = initialOrbit.getPVCoordinates().getVelocity();
67              final Vector3D wrongPosition   = initialPosition.add(new Vector3D(1000.0, 0, 0));
68              final Vector3D wrongVelocity   = initialVelocity.add(new Vector3D(0, 0, 0.01));
69              startOrbit                     = new CartesianOrbit(new PVCoordinates(wrongPosition, wrongVelocity),
70                                                                  initialOrbit.getFrame(),
71                                                                  initialOrbit.getDate(),
72                                                                  initialOrbit.getMu());
73          }
74  
75          // Initialize builder
76          return new EcksteinHechlerPropagatorBuilder(startOrbit, gravity, angleType, dP);
77  
78      }
79  
80      GroundStation createStation(double latitudeInDegrees, double longitudeInDegrees,
81                                  double altitude, String name) {
82          final GeodeticPoint gp = new GeodeticPoint(FastMath.toRadians(latitudeInDegrees),
83                                                     FastMath.toRadians(longitudeInDegrees),
84                                                     altitude);
85          return new GroundStation(new TopocentricFrame(earth, gp, name), ut1.getEOPHistory(), displacements);
86      }
87  
88      @Override
89      public List<GroundStation> getStations() {
90          return stations;
91      }
92  
93  }