PhaseBuilder.java

  1. /* Copyright 2002-2024 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.gnss;

  18. import java.util.Map;

  19. import org.hipparchus.random.CorrelatedRandomVectorGenerator;
  20. import org.orekit.estimation.measurements.EstimationModifier;
  21. import org.orekit.estimation.measurements.GroundStation;
  22. import org.orekit.estimation.measurements.ObservableSatellite;
  23. import org.orekit.estimation.measurements.generation.AbstractMeasurementBuilder;
  24. import org.orekit.propagation.SpacecraftState;
  25. import org.orekit.propagation.sampling.OrekitStepInterpolator;
  26. import org.orekit.time.AbsoluteDate;
  27. import org.orekit.utils.ParameterDriver;


  28. /** Builder for {@link Phase} measurements.
  29.  * @author Luc Maisonobe
  30.  * @since 10.1
  31.  */
  32. public class PhaseBuilder extends AbstractMeasurementBuilder<Phase> {

  33.     /** Cache for ambiguities.
  34.      * @since 12.1
  35.      */
  36.     private final AmbiguityCache cache;

  37.     /** Ground station from which measurement is performed. */
  38.     private final GroundStation station;

  39.     /** Wavelength of the phase observed value [m]. */
  40.     private final double wavelength;

  41.     /** Satellite related to this builder.
  42.      * @since 12.0
  43.      */
  44.     private final ObservableSatellite satellite;

  45.     /** Simple constructor.
  46.      * @param noiseSource noise source, may be null for generating perfect measurements
  47.      * @param station ground station from which measurement is performed
  48.      * @param wavelength phase observed value wavelength (m)
  49.      * @param sigma theoretical standard deviation
  50.      * @param baseWeight base weight
  51.      * @param satellite satellite related to this builder
  52.      * @deprecated as of 12.1, replaced by {@link #PhaseBuilder(CorrelatedRandomVectorGenerator,
  53.      * GroundStation, double, double, double, ObservableSatellite,
  54.      * AmbiguityCache)}
  55.      */
  56.     @Deprecated
  57.     public PhaseBuilder(final CorrelatedRandomVectorGenerator noiseSource,
  58.                         final GroundStation station, final double wavelength,
  59.                         final double sigma, final double baseWeight,
  60.                         final ObservableSatellite satellite) {
  61.         this(noiseSource, station, wavelength, sigma, baseWeight, satellite,
  62.              AmbiguityCache.DEFAULT_CACHE);
  63.     }

  64.     /** Simple constructor.
  65.      * @param noiseSource noise source, may be null for generating perfect measurements
  66.      * @param station ground station from which measurement is performed
  67.      * @param wavelength phase observed value wavelength (m)
  68.      * @param sigma theoretical standard deviation
  69.      * @param baseWeight base weight
  70.      * @param satellite satellite related to this builder
  71.      * @param cache from which ambiguity drive should come
  72.      * @since 12.1
  73.      */
  74.     public PhaseBuilder(final CorrelatedRandomVectorGenerator noiseSource,
  75.                         final GroundStation station, final double wavelength,
  76.                         final double sigma, final double baseWeight,
  77.                         final ObservableSatellite satellite,
  78.                         final AmbiguityCache cache) {
  79.         super(noiseSource, sigma, baseWeight, satellite);
  80.         this.station    = station;
  81.         this.wavelength = wavelength;
  82.         this.satellite  = satellite;
  83.         this.cache      = cache;
  84.     }

  85.     /** {@inheritDoc} */
  86.     @Override
  87.     public Phase build(final AbsoluteDate date, final Map<ObservableSatellite, OrekitStepInterpolator> interpolators) {

  88.         final double sigma                  = getTheoreticalStandardDeviation()[0];
  89.         final double baseWeight             = getBaseWeight()[0];
  90.         final SpacecraftState[] relevant    = new SpacecraftState[] { interpolators.get(satellite).getInterpolatedState(date) };

  91.         // create a dummy measurement
  92.         final Phase dummy = new Phase(station, relevant[0].getDate(), Double.NaN, wavelength,
  93.                                       sigma, baseWeight, satellite, cache);
  94.         for (final EstimationModifier<Phase> modifier : getModifiers()) {
  95.             dummy.addModifier(modifier);
  96.         }

  97.         // set a reference date for parameters missing one
  98.         for (final ParameterDriver driver : dummy.getParametersDrivers()) {
  99.             if (driver.getReferenceDate() == null) {
  100.                 final AbsoluteDate start = getStart();
  101.                 final AbsoluteDate end   = getEnd();
  102.                 driver.setReferenceDate(start.durationFrom(end) <= 0 ? start : end);
  103.             }
  104.         }

  105.         // estimate the perfect value of the measurement
  106.         double phase = dummy.estimateWithoutDerivatives(relevant).getEstimatedValue()[0];

  107.         // add the noise
  108.         final double[] noise = getNoise();
  109.         if (noise != null) {
  110.             phase += noise[0];
  111.         }

  112.         // generate measurement
  113.         final Phase measurement = new Phase(station, relevant[0].getDate(), phase, wavelength,
  114.                                             sigma, baseWeight, satellite, cache);
  115.         for (final EstimationModifier<Phase> modifier : getModifiers()) {
  116.             measurement.addModifier(modifier);
  117.         }
  118.         return measurement;

  119.     }

  120. }