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.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.drag.DragSensitive;
26  import org.orekit.forces.gravity.potential.UnnormalizedSphericalHarmonicsProvider;
27  import org.orekit.forces.radiation.RadiationSensitive;
28  import org.orekit.frames.TopocentricFrame;
29  import org.orekit.models.earth.displacement.StationDisplacement;
30  import org.orekit.models.earth.troposphere.TroposphericModelUtils;
31  import org.orekit.orbits.EquinoctialOrbit;
32  import org.orekit.propagation.PropagationType;
33  import org.orekit.propagation.conversion.DSSTPropagatorBuilder;
34  import org.orekit.propagation.conversion.DormandPrince853IntegratorBuilder;
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  import java.util.List;
41  import java.util.Map;
42  
43  public class DSSTContext implements StationDataProvider {
44  
45      public IERSConventions                        conventions;
46      public OneAxisEllipsoid                       earth;
47      public CelestialBody                          sun;
48      public CelestialBody                          moon;
49      public RadiationSensitive                     radiationSensitive;
50      public DragSensitive                          dragSensitive;
51      public UnnormalizedSphericalHarmonicsProvider gravity;
52      public TimeScale                              utc;
53      public UT1Scale                               ut1;
54      public EquinoctialOrbit                       initialOrbit;
55      public StationDisplacement[]                  displacements;
56      public List<GroundStation>                    stations;
57      // Stations for turn-around range
58      // Map entry = primary station
59      // Map value = secondary station associated
60      public Map<GroundStation, GroundStation>      TARstations;
61  
62      /**
63       * By default propagation type and initial state type are set to {@link PropagationType.MEAN}
64       * @see #createBuilder(PropagationType, PropagationType, boolean, double, double, double, DSSTForce...)
65       */
66      public DSSTPropagatorBuilder createBuilder(final boolean perfectStart,
67                                                 final double minStep, final double maxStep, final double dP,
68                                                 final DSSTForce... forces) {
69          return createBuilder(PropagationType.MEAN, PropagationType.MEAN, perfectStart, minStep, maxStep, dP, forces);
70      }
71  
72      public DSSTPropagatorBuilder createBuilder(final PropagationType propagationType,
73                                                 final PropagationType stateType, final boolean perfectStart,
74                                                 final double minStep, final double maxStep, final double dP,
75                                                 final DSSTForce... forces) {
76  
77          final EquinoctialOrbit startOrbit;
78          if (perfectStart) {
79              // orbit estimation will start from a perfect orbit
80              startOrbit = initialOrbit;
81          } else {
82              // orbit estimation will start from a wrong point
83              final Vector3D initialPosition = initialOrbit.getPosition();
84              final Vector3D initialVelocity = initialOrbit.getPVCoordinates().getVelocity();
85              final Vector3D wrongPosition   = initialPosition.add(new Vector3D(1000.0, 0, 0));
86              final Vector3D wrongVelocity   = initialVelocity.add(new Vector3D(0, 0, 0.01));
87              startOrbit                     = new EquinoctialOrbit(new PVCoordinates(wrongPosition, wrongVelocity),
88                                                                    initialOrbit.getFrame(),
89                                                                    initialOrbit.getDate(),
90                                                                    initialOrbit.getMu());
91          }
92          final DSSTPropagatorBuilder propagatorBuilder =
93                          new DSSTPropagatorBuilder(startOrbit,
94                                                    new DormandPrince853IntegratorBuilder(minStep, maxStep, dP),
95                                                    dP,
96                                                    propagationType, stateType);
97          for (DSSTForce force : forces) {
98              propagatorBuilder.addForceModel(force.getForceModel(this));
99          }
100 
101         return propagatorBuilder;
102 
103     }
104 
105     GroundStation createStation(double latitudeInDegrees, double longitudeInDegrees,
106                                 double altitude, String name) {
107         final GeodeticPoint gp = new GeodeticPoint(FastMath.toRadians(latitudeInDegrees),
108                                                    FastMath.toRadians(longitudeInDegrees),
109                                                    altitude);
110         return new GroundStation(new TopocentricFrame(earth, gp, name),
111                                  TroposphericModelUtils.STANDARD_ATMOSPHERE_PROVIDER,
112                                  ut1.getEOPHistory(), displacements);
113     }
114 
115     @Override
116     public List<GroundStation> getStations() {
117         return stations;
118     }
119 
120 }