InterSatellitesPhaseBuilder.java

  1. /* Copyright 2002-2023 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.InterSatellitesPhase;
  23. import org.orekit.propagation.SpacecraftState;
  24. import org.orekit.propagation.sampling.OrekitStepInterpolator;
  25. import org.orekit.time.AbsoluteDate;
  26. import org.orekit.utils.ParameterDriver;


  27. /** Builder for {@link InterSatellitesPhase} measurements.
  28.  * @author Bryan Cazabonne
  29.  * @since 10.3
  30.  */
  31. public class InterSatellitesPhaseBuilder extends AbstractMeasurementBuilder<InterSatellitesPhase> {

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

  34.     /** Satellite which receives the signal and performs the measurement.
  35.      * @since 12.0
  36.      */
  37.     private final ObservableSatellite local;

  38.     /** Satellite which simply emits the signal.
  39.      * @since 12.0
  40.      */
  41.     private final ObservableSatellite remote;

  42.     /** Simple constructor.
  43.      * @param noiseSource noise source, may be null for generating perfect measurements
  44.      * @param local satellite which receives the signal and performs the measurement
  45.      * @param remote satellite which simply emits the signal
  46.      * @param wavelength phase observed value wavelength (m)
  47.      * @param sigma theoretical standard deviation
  48.      * @param baseWeight base weight
  49.      */
  50.     public InterSatellitesPhaseBuilder(final CorrelatedRandomVectorGenerator noiseSource,
  51.                                        final ObservableSatellite local, final ObservableSatellite remote,
  52.                                        final double wavelength, final double sigma, final double baseWeight) {
  53.         super(noiseSource, sigma, baseWeight, local, remote);
  54.         this.wavelength = wavelength;
  55.         this.local      = local;
  56.         this.remote     = remote;
  57.     }

  58.     /** {@inheritDoc} */
  59.     @Override
  60.     public InterSatellitesPhase build(final AbsoluteDate date, final Map<ObservableSatellite, OrekitStepInterpolator> interpolators) {

  61.         final double sigma                     = getTheoreticalStandardDeviation()[0];
  62.         final double baseWeight                = getBaseWeight()[0];
  63.         final SpacecraftState[] relevant       = new SpacecraftState[] {
  64.             interpolators.get(local).getInterpolatedState(date),
  65.             interpolators.get(remote).getInterpolatedState(date)
  66.         };

  67.         // create a dummy measurement
  68.         final InterSatellitesPhase dummy = new InterSatellitesPhase(local, remote, relevant[0].getDate(),
  69.                                                                     Double.NaN, wavelength, sigma, baseWeight);
  70.         for (final EstimationModifier<InterSatellitesPhase> modifier : getModifiers()) {
  71.             dummy.addModifier(modifier);
  72.         }

  73.         // set a reference date for parameters missing one
  74.         for (final ParameterDriver driver : dummy.getParametersDrivers()) {
  75.             if (driver.getReferenceDate() == null) {
  76.                 final AbsoluteDate start = getStart();
  77.                 final AbsoluteDate end   = getEnd();
  78.                 driver.setReferenceDate(start.durationFrom(end) <= 0 ? start : end);
  79.             }
  80.         }

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

  83.         // add the noise
  84.         final double[] noise = getNoise();
  85.         if (noise != null) {
  86.             phase += noise[0];
  87.         }

  88.         // generate measurement
  89.         final InterSatellitesPhase measurement = new InterSatellitesPhase(local, remote, relevant[0].getDate(),
  90.                                                                           phase, wavelength, sigma, baseWeight);
  91.         for (final EstimationModifier<InterSatellitesPhase> modifier : getModifiers()) {
  92.             measurement.addModifier(modifier);
  93.         }
  94.         return measurement;

  95.     }

  96. }