AbstractAmbiguityModifier.java

  1. /* Copyright 2002-2020 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. import java.util.Collections;
  19. import java.util.List;

  20. import org.hipparchus.util.FastMath;
  21. import org.orekit.estimation.measurements.EstimatedMeasurement;
  22. import org.orekit.utils.ParameterDriver;

  23. /**
  24.  * Base class for phase ambiguity modifier.
  25.  * @author Bryan Cazabonne
  26.  * @author Luc Maisonobe
  27.  * @since 10.3
  28.  */
  29. public class AbstractAmbiguityModifier {

  30.     /** Ambiguity scale factor.
  31.      * <p>
  32.      * We use a power of 2 to avoid numeric noise introduction
  33.      * in the multiplications/divisions sequences.
  34.      * </p>
  35.      */
  36.     private static final double AMBIGUITY_SCALE = FastMath.scalb(1.0, 26);

  37.     /** Ambiguity parameter. */
  38.     private final ParameterDriver ambiguity;

  39.     /** Constructor.
  40.      * @param key key to identify the ambiguity
  41.      * @param ambiguity initial value of ambiguity
  42.      */
  43.     public AbstractAmbiguityModifier(final int key, final double ambiguity) {
  44.         this.ambiguity = new ParameterDriver("amgiguity-" + key, ambiguity, AMBIGUITY_SCALE,
  45.                                              Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
  46.     }

  47.     /** Get the drivers for this modifier.
  48.      * @return drivers for this modifier
  49.      */
  50.     protected List<ParameterDriver> getDrivers() {
  51.         return Collections.singletonList(ambiguity);
  52.     }

  53.     /** Modify measurement.
  54.      * @param estimated measurement to modify
  55.      */
  56.     protected void doModify(final EstimatedMeasurement<?> estimated) {
  57.         // Apply the ambiguity to the measurement value
  58.         final double[] value = estimated.getEstimatedValue();
  59.         value[0] += ambiguity.getValue();
  60.         if (ambiguity.isSelected()) {
  61.             // add the partial derivatives
  62.             estimated.setParameterDerivatives(ambiguity, 1.0);
  63.         }
  64.         estimated.setEstimatedValue(value);
  65.     }

  66. }