1   /* Copyright 2002-2022 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 java.util.List;
20  import java.util.Map;
21  
22  import org.hipparchus.geometry.euclidean.threed.Vector3D;
23  import org.hipparchus.util.FastMath;
24  import org.orekit.bodies.CelestialBody;
25  import org.orekit.bodies.GeodeticPoint;
26  import org.orekit.bodies.OneAxisEllipsoid;
27  import org.orekit.estimation.measurements.GroundStation;
28  import org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider;
29  import org.orekit.frames.TopocentricFrame;
30  import org.orekit.models.earth.displacement.StationDisplacement;
31  import org.orekit.orbits.CartesianOrbit;
32  import org.orekit.orbits.Orbit;
33  import org.orekit.orbits.PositionAngle;
34  import org.orekit.propagation.conversion.EcksteinHechlerPropagatorBuilder;
35  import org.orekit.time.TimeScale;
36  import org.orekit.time.UT1Scale;
37  import org.orekit.utils.IERSConventions;
38  import org.orekit.utils.PVCoordinates;
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 PositionAngle 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.getPVCoordinates().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          final EcksteinHechlerPropagatorBuilder propagatorBuilder =
77                          new EcksteinHechlerPropagatorBuilder(startOrbit, gravity, angleType, dP);
78  
79          // Return
80          return propagatorBuilder;
81  
82      }
83  
84      GroundStation createStation(double latitudeInDegrees, double longitudeInDegrees,
85                                  double altitude, String name) {
86          final GeodeticPoint gp = new GeodeticPoint(FastMath.toRadians(latitudeInDegrees),
87                                                     FastMath.toRadians(longitudeInDegrees),
88                                                     altitude);
89          return new GroundStation(new TopocentricFrame(earth, gp, name),
90                                   ut1.getEOPHistory(), displacements);
91      }
92  
93      @Override
94      public List<GroundStation> getStations() {
95          return stations;
96      }
97  
98  }