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.hipparchus.util.Pair;
22  import org.orekit.bodies.CelestialBody;
23  import org.orekit.bodies.GeodeticPoint;
24  import org.orekit.bodies.OneAxisEllipsoid;
25  import org.orekit.estimation.measurements.GroundStation;
26  import org.orekit.forces.drag.DragSensitive;
27  import org.orekit.forces.gravity.potential.NormalizedSphericalHarmonicsProvider;
28  import org.orekit.forces.radiation.RadiationSensitive;
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.OrbitType;
34  import org.orekit.orbits.PositionAngleType;
35  import org.orekit.propagation.conversion.DormandPrince853IntegratorBuilder;
36  import org.orekit.propagation.conversion.NumericalPropagatorBuilder;
37  import org.orekit.time.TimeScale;
38  import org.orekit.time.UT1Scale;
39  import org.orekit.utils.IERSConventions;
40  import org.orekit.utils.PVCoordinates;
41  
42  import java.util.List;
43  import java.util.Map;
44  
45  public class Context implements StationDataProvider {
46      public IERSConventions                      conventions;
47      public OneAxisEllipsoid                     earth;
48      public CelestialBody                        sun;
49      public CelestialBody                        moon;
50      public RadiationSensitive                   radiationSensitive;
51      public DragSensitive                        dragSensitive;
52      public NormalizedSphericalHarmonicsProvider gravity;
53      public TimeScale                            utc;
54      public UT1Scale                             ut1;
55      public Orbit                                initialOrbit;
56      public StationDisplacement[]                displacements;
57      public List<GroundStation>                  stations;
58      // Stations for turn-around range
59      // Map entry = primary station
60      // Map value = secondary station associated
61      public Map<GroundStation, GroundStation>     TARstations;
62      // Stations for bistatic range rate
63      // key/first    = emitter station
64      // value/second = receiver station
65      public Pair<GroundStation, GroundStation>    BRRstations;
66      // Stations for TDOA
67      // key/first    = primary station that dates the measurement
68      // value/second = secondary station associated
69      public Pair<GroundStation, GroundStation>    TDOAstations;
70      // Stations for FDOA
71      // key/first    = primary station that dates the measurement
72      // value/second = secondary station associated
73      public Pair<GroundStation, GroundStation>    FDOAstations;
74  
75      public NumericalPropagatorBuilder createBuilder(final OrbitType orbitType, final PositionAngleType positionAngleType,
76                                                      final boolean perfectStart,
77                                                      final double minStep, final double maxStep, final double dP,
78                                                      final Force... forces) {
79  
80          final Orbit startOrbit;
81          if (perfectStart) {
82              // orbit estimation will start from a perfect orbit
83              startOrbit = initialOrbit;
84          } else {
85              // orbit estimation will start from a wrong point
86              final Vector3D initialPosition = initialOrbit.getPosition();
87              final Vector3D initialVelocity = initialOrbit.getPVCoordinates().getVelocity();
88              final Vector3D wrongPosition   = initialPosition.add(new Vector3D(1000.0, 0, 0));
89              final Vector3D wrongVelocity   = initialVelocity.add(new Vector3D(0, 0, 0.01));
90              startOrbit                     = new CartesianOrbit(new PVCoordinates(wrongPosition, wrongVelocity),
91                                                                  initialOrbit.getFrame(),
92                                                                  initialOrbit.getDate(),
93                                                                  initialOrbit.getMu());
94          }
95          final NumericalPropagatorBuilder propagatorBuilder =
96                          new NumericalPropagatorBuilder(orbitType.convertType(startOrbit),
97                                                         new DormandPrince853IntegratorBuilder(minStep, maxStep, dP),
98                                  positionAngleType, dP);
99          for (Force force : forces) {
100             propagatorBuilder.addForceModel(force.getForceModel(this));
101         }
102 
103         return propagatorBuilder;
104 
105     }
106 
107     GroundStation createStation(double latitudeInDegrees, double longitudeInDegrees,
108                                 double altitude, String name) {
109         final GeodeticPoint gp = new GeodeticPoint(FastMath.toRadians(latitudeInDegrees),
110                                                    FastMath.toRadians(longitudeInDegrees),
111                                                    altitude);
112         return new GroundStation(new TopocentricFrame(earth, gp, name), ut1.getEOPHistory(), displacements);
113     }
114 
115     @Override
116     public List<GroundStation> getStations() {
117         return stations;
118     }
119 
120 }