InterSatellitesPhaseBuilder.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.generation;

  18. import java.util.Map;

  19. import org.hipparchus.random.CorrelatedRandomVectorGenerator;
  20. import org.orekit.estimation.measurements.EstimationModifier;
  21. import org.orekit.estimation.measurements.ObservableSatellite;
  22. import org.orekit.estimation.measurements.gnss.AmbiguityCache;
  23. import org.orekit.estimation.measurements.gnss.InterSatellitesPhase;
  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 InterSatellitesPhase} measurements.
  29.  * @author Bryan Cazabonne
  30.  * @since 10.3
  31.  */
  32. public class InterSatellitesPhaseBuilder extends AbstractMeasurementBuilder<InterSatellitesPhase> {

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

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

  39.     /** Satellite which receives the signal and performs the measurement.
  40.      * @since 12.0
  41.      */
  42.     private final ObservableSatellite local;

  43.     /** Satellite which simply emits the signal.
  44.      * @since 12.0
  45.      */
  46.     private final ObservableSatellite remote;

  47.     /** Simple constructor.
  48.      * @param noiseSource noise source, may be null for generating perfect measurements
  49.      * @param local satellite which receives the signal and performs the measurement
  50.      * @param remote satellite which simply emits the signal
  51.      * @param wavelength phase observed value wavelength (m)
  52.      * @param sigma theoretical standard deviation
  53.      * @param baseWeight base weight
  54.      * @deprecated as of 12.1, replaced by {@link #InterSatellitesPhaseBuilder(CorrelatedRandomVectorGenerator,
  55.      * ObservableSatellite, ObservableSatellite, double, double, double, AmbiguityCache)}
  56.      */
  57.     @Deprecated
  58.     public InterSatellitesPhaseBuilder(final CorrelatedRandomVectorGenerator noiseSource,
  59.                                        final ObservableSatellite local, final ObservableSatellite remote,
  60.                                        final double wavelength, final double sigma, final double baseWeight) {
  61.         this(noiseSource, local, remote, wavelength, sigma, baseWeight,
  62.              AmbiguityCache.DEFAULT_CACHE);
  63.     }

  64.     /** Simple constructor.
  65.      * @param noiseSource noise source, may be null for generating perfect measurements
  66.      * @param local satellite which receives the signal and performs the measurement
  67.      * @param remote satellite which simply emits the signal
  68.      * @param wavelength phase observed value wavelength (m)
  69.      * @param sigma theoretical standard deviation
  70.      * @param baseWeight base weight
  71.      * @param cache from which ambiguity drive should come
  72.      * @since 12.1
  73.      */
  74.     public InterSatellitesPhaseBuilder(final CorrelatedRandomVectorGenerator noiseSource,
  75.                                        final ObservableSatellite local, final ObservableSatellite remote,
  76.                                        final double wavelength, final double sigma, final double baseWeight,
  77.                                        final AmbiguityCache cache) {
  78.         super(noiseSource, sigma, baseWeight, local, remote);
  79.         this.cache      = cache;
  80.         this.wavelength = wavelength;
  81.         this.local      = local;
  82.         this.remote     = remote;
  83.     }

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

  87.         final double sigma                     = getTheoreticalStandardDeviation()[0];
  88.         final double baseWeight                = getBaseWeight()[0];
  89.         final SpacecraftState[] relevant       = new SpacecraftState[] {
  90.             interpolators.get(local).getInterpolatedState(date),
  91.             interpolators.get(remote).getInterpolatedState(date)
  92.         };

  93.         // create a dummy measurement
  94.         final InterSatellitesPhase dummy = new InterSatellitesPhase(local, remote, relevant[0].getDate(),
  95.                                                                     Double.NaN, wavelength, sigma, baseWeight,
  96.                                                                     cache);
  97.         for (final EstimationModifier<InterSatellitesPhase> modifier : getModifiers()) {
  98.             dummy.addModifier(modifier);
  99.         }

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

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

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

  115.         // generate measurement
  116.         final InterSatellitesPhase measurement = new InterSatellitesPhase(local, remote, relevant[0].getDate(),
  117.                                                                           phase, wavelength, sigma, baseWeight,
  118.                                                                           cache);
  119.         for (final EstimationModifier<InterSatellitesPhase> modifier : getModifiers()) {
  120.             measurement.addModifier(modifier);
  121.         }
  122.         return measurement;

  123.     }

  124. }