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