PhaseAmbiguityModifier.java

  1. /* Copyright 2002-2018 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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.errors.OrekitException;
  22. import org.orekit.estimation.measurements.EstimatedMeasurement;
  23. import org.orekit.estimation.measurements.EstimationModifier;
  24. import org.orekit.estimation.measurements.Phase;
  25. import org.orekit.utils.ParameterDriver;

  26. /** Class modifying theoretical phase measurement with ambiguity.
  27.  *
  28.  * @author Luc Maisonobe
  29.  * @since 9.2
  30.  */
  31. public class PhaseAmbiguityModifier implements EstimationModifier<Phase> {

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

  39.     /** Ambiguity parameter. */
  40.     private final ParameterDriver ambiguity;

  41.     /** Constructor.
  42.      * <p>
  43.      * It is expected that many different ambiguities will be used at the
  44.      * same time during an orbit determination, therefore they are keyed
  45.      * using a simple integer. All ambiguities using the same key will
  46.      * be enforced to be equal. It is the responsibility of the caller to
  47.      * use a proper counter to manage the ambiguities properly.
  48.      * </p>
  49.      * @param key key to identify the ambiguity
  50.      * @param ambiguity initial value of ambiguity
  51.      * @exception OrekitException if parameter scale is too close to zero (never happens)
  52.      */
  53.     public PhaseAmbiguityModifier(final int key, final double ambiguity)
  54.         throws OrekitException {
  55.         this.ambiguity = new ParameterDriver("amgiguity-" + key,
  56.                                              ambiguity, AMBIGUITY_SCALE,
  57.                                              Double.NEGATIVE_INFINITY,
  58.                                              Double.POSITIVE_INFINITY);
  59.     }

  60.     /** {@inheritDoc} */
  61.     @Override
  62.     public List<ParameterDriver> getParametersDrivers() {
  63.         return Collections.singletonList(ambiguity);
  64.     }

  65.     @Override
  66.     public void modify(final EstimatedMeasurement<Phase> estimated)
  67.         throws OrekitException {

  68.         // apply the ambiguity to the measurement value
  69.         final double[] value = estimated.getEstimatedValue();
  70.         value[0] += ambiguity.getValue();
  71.         if (ambiguity.isSelected()) {
  72.             // add the partial derivatives
  73.             estimated.setParameterDerivatives(ambiguity, 1.0);
  74.         }
  75.         estimated.setEstimatedValue(value);

  76.     }

  77. }