1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.models.earth.troposphere.iturp834;
18
19 import org.hipparchus.CalculusFieldElement;
20 import org.hipparchus.analysis.interpolation.GridAxis;
21 import org.hipparchus.util.FastMath;
22 import org.orekit.bodies.FieldGeodeticPoint;
23 import org.orekit.bodies.GeodeticPoint;
24 import org.orekit.utils.units.Unit;
25
26
27
28
29
30
31
32
33
34
35
36
37
38 class Gravity {
39
40
41 public static final String AVERAGE_HEIGHT_REFERENCE_LEVEL_NAME = "hreflev.dat";
42
43
44 private static final Unit UNIT_PER_KM = Unit.parse("km⁻¹");
45
46
47 private static final double G_27G = 9.806;
48
49
50 private static final double GL_27G = 0.002637;
51
52
53 private static final double GH_27G = UNIT_PER_KM.toSI(0.00031);
54
55
56 private static final double G_27J = 9.784;
57
58
59 private static final double GL_27J = 0.00266;
60
61
62 private static final double GH_27J = UNIT_PER_KM.toSI(0.00028);
63
64
65 private static final ConstantGrid GS =
66 new ConstantGrid(Unit.METRE, AVERAGE_HEIGHT_REFERENCE_LEVEL_NAME).
67 apply((lat, lon, h) -> G_27G * (1 - GL_27G * FastMath.cos(2 * lat) - GH_27G * h));
68
69
70
71 private Gravity() {
72
73 }
74
75
76
77
78
79 public static GridCell getGravityAtSurface(final GeodeticPoint location) {
80 return GS.getCell(location, 0.0);
81 }
82
83
84
85
86
87
88 public static <T extends CalculusFieldElement<T>> FieldGridCell<T> getGravityAtSurface(final FieldGeodeticPoint<T> location) {
89 return GS.getCell(location, null);
90 }
91
92
93
94
95
96 public static GridCell getGravityAtAltitude(final GeodeticPoint location) {
97 final GridAxis latitudeAxis = GS.getLatitudeAxis();
98 final int southIndex = latitudeAxis.interpolationIndex(location.getLatitude());
99 final double northLatitude = latitudeAxis.node(southIndex + 1);
100 final double southLatitude = latitudeAxis.node(southIndex);
101 final GridAxis longitudeAxis = GS.getLongitudeAxis();
102 final int westIndex = longitudeAxis.interpolationIndex(location.getLongitude());
103 final double westLongitude = longitudeAxis.node(westIndex);
104 final double mga = -GH_27J * location.getAltitude();
105 final double gNorth = (mga + 1 - GL_27J * FastMath.cos(2 * northLatitude)) * G_27J;
106 final double gSouth = (mga + 1 - GL_27J * FastMath.cos(2 * southLatitude)) * G_27J;
107 return new GridCell(location.getLatitude() - southLatitude,
108 location.getLongitude() - westLongitude,
109 GS.getSizeLat(), GS.getSizeLon(),
110 gNorth, gSouth, gSouth, gNorth);
111 }
112
113
114
115
116
117
118 public static <T extends CalculusFieldElement<T>> FieldGridCell<T> getGravityAtAltitude(
119 final FieldGeodeticPoint<T> location) {
120 final GridAxis latitudeAxis = GS.getLatitudeAxis();
121 final int southIndex = latitudeAxis.interpolationIndex(location.getLatitude().getReal());
122 final double northLatitude = latitudeAxis.node(southIndex + 1);
123 final double southLatitude = latitudeAxis.node(southIndex);
124 final GridAxis longitudeAxis = GS.getLongitudeAxis();
125 final int westIndex = longitudeAxis.interpolationIndex(location.getLongitude().getReal());
126 final double westLongitude = longitudeAxis.node(westIndex);
127 final T mga = location.getAltitude().multiply(GH_27J).negate();
128 final T gNorth = mga.add(1 - GL_27J * FastMath.cos(2 * northLatitude)).multiply(G_27J);
129 final T gSouth = mga.add(1 - GL_27J * FastMath.cos(2 * southLatitude)).multiply(G_27J);
130 return new FieldGridCell<>(location.getLatitude().subtract(southLatitude),
131 location.getLongitude().subtract(westLongitude),
132 GS.getSizeLat(), GS.getSizeLon(), gNorth,
133 gSouth, gSouth, gNorth);
134 }
135
136 }