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.measurements.modifiers;
18
19 import org.hipparchus.geometry.euclidean.threed.Vector3D;
20 import org.hipparchus.util.FastMath;
21 import org.orekit.estimation.measurements.EstimatedMeasurementBase;
22 import org.orekit.estimation.measurements.EstimationModifier;
23 import org.orekit.estimation.measurements.ObservedMeasurement;
24 import org.orekit.utils.Constants;
25 import org.orekit.utils.TimeStampedPVCoordinates;
26
27 /** Class modifying theoretical range measurement with Shapiro time delay.
28 * <p>
29 * Shapiro time delay is a relativistic effect due to gravity.
30 * </p>
31 * @author Luc Maisonobe
32 * @since 10.0
33 */
34 public class AbstractShapiroBaseModifier {
35
36 /** Shapiro effect scale factor. */
37 private final double s;
38
39 /** Simple constructor.
40 * @param gm gravitational constant for main body in signal path vicinity.
41 */
42 public AbstractShapiroBaseModifier(final double gm) {
43 this.s = 2 * gm / (Constants.SPEED_OF_LIGHT * Constants.SPEED_OF_LIGHT);
44 }
45
46 /** Get the name of the effect modifying the measurement.
47 * @return name of the effect modifying the measurement
48 * @since 13.0
49 */
50 public String getEffectName() {
51 return "Shapiro";
52 }
53
54 /** Modify measurement.
55 * @param <T> type of the measurements
56 * @param modifier applied modifier
57 * @param estimated measurement to modify
58 * @since 12.1
59 */
60 protected <T extends ObservedMeasurement<T>> void doModify(final EstimationModifier<T> modifier,
61 final EstimatedMeasurementBase<T> estimated) {
62
63 // compute correction, for one way or two way measurements
64 final TimeStampedPVCoordinates[] pv = estimated.getParticipants();
65 final double correction = pv.length < 3 ?
66 shapiroCorrection(pv[0], pv[1]) :
67 0.5 * (shapiroCorrection(pv[0], pv[1]) + shapiroCorrection(pv[1], pv[2]));
68
69 // update estimated value taking into account the Shapiro time delay.
70 final double[] newValue = estimated.getEstimatedValue().clone();
71 newValue[0] = newValue[0] + correction;
72 estimated.modifyEstimatedValue(modifier, newValue);
73
74 }
75
76 /** Compute Shapiro path dilation between two points in a gravity field.
77 * @param pvEmitter coordinates of emitter in body-centered frame
78 * @param pvReceiver coordinates of receiver in body-centered frame
79 * @return path dilation to add to raw measurement
80 */
81 protected double shapiroCorrection(final TimeStampedPVCoordinates pvEmitter, final TimeStampedPVCoordinates pvReceiver) {
82 final Vector3D pEmitter = pvEmitter.getPosition();
83 final Vector3D pReceiver = pvReceiver.getPosition();
84 final double rEpR = pEmitter.getNorm() + pReceiver.getNorm();
85 final double d = Vector3D.distance(pEmitter, pReceiver);
86 return s * FastMath.log((rEpR + d) / (rEpR - d));
87 }
88
89 }