1 /* Copyright 2002-2021 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 java.util.Collections;
20 import java.util.List;
21
22 import org.hipparchus.util.FastMath;
23 import org.orekit.estimation.measurements.EstimatedMeasurement;
24 import org.orekit.utils.ParameterDriver;
25
26 /**
27 * Base class for phase ambiguity modifier.
28 * @author Bryan Cazabonne
29 * @author Luc Maisonobe
30 * @since 10.3
31 */
32 public class AbstractAmbiguityModifier {
33
34 /** Ambiguity scale factor.
35 * <p>
36 * We use a power of 2 to avoid numeric noise introduction
37 * in the multiplications/divisions sequences.
38 * </p>
39 */
40 private static final double AMBIGUITY_SCALE = FastMath.scalb(1.0, 26);
41
42 /** Ambiguity parameter. */
43 private final ParameterDriver ambiguity;
44
45 /** Constructor.
46 * @param key key to identify the ambiguity
47 * @param ambiguity initial value of ambiguity
48 */
49 public AbstractAmbiguityModifier(final int key, final double ambiguity) {
50 this.ambiguity = new ParameterDriver("ambiguity-" + key, ambiguity, AMBIGUITY_SCALE,
51 Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
52 }
53
54 /** Get the drivers for this modifier.
55 * @return drivers for this modifier
56 */
57 protected List<ParameterDriver> getDrivers() {
58 return Collections.singletonList(ambiguity);
59 }
60
61 /** Modify measurement.
62 * @param estimated measurement to modify
63 */
64 protected void doModify(final EstimatedMeasurement<?> estimated) {
65 // Apply the ambiguity to the measurement value
66 final double[] value = estimated.getEstimatedValue();
67 value[0] += ambiguity.getValue();
68 if (ambiguity.isSelected()) {
69 // add the partial derivatives
70 estimated.setParameterDerivatives(ambiguity, 1.0);
71 }
72 estimated.setEstimatedValue(value);
73 }
74
75 }