FDOABuilder.java

  1. /* Copyright 2002-2024 Bryan Cazabonne
  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.  * Bryan Cazabonne 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.FDOA;
  22. import org.orekit.estimation.measurements.GroundStation;
  23. import org.orekit.estimation.measurements.ObservableSatellite;
  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 FDOA} measurements.
  29.  * @author Bryan Cazabonne
  30.  * @since 12.0
  31.  */
  32. public class FDOABuilder extends AbstractMeasurementBuilder<FDOA> {

  33.     /** Prime ground station. */
  34.     private final GroundStation primeStation;

  35.     /** Second ground station. */
  36.     private final GroundStation secondStation;

  37.     /** Centre frequency of the signal emitted from the satellite. */
  38.     private final double centreFrequency;

  39.     /** Satellite related to this builder. */
  40.     private final ObservableSatellite satellite;

  41.     /** Simple constructor.
  42.      * @param noiseSource noise source, may be null for generating perfect measurements
  43.      * @param primeStation ground station that gives the date of the measurement
  44.      * @param secondStation ground station that gives the measurement
  45.      * @param centreFrequency satellite emitter frequency
  46.      * @param sigma theoretical standard deviation
  47.      * @param baseWeight base weight
  48.      * @param satellite satellite related to this builder
  49.      */
  50.     public FDOABuilder(final CorrelatedRandomVectorGenerator noiseSource,
  51.                        final GroundStation primeStation,
  52.                        final GroundStation secondStation,
  53.                        final double centreFrequency,
  54.                        final double sigma, final double baseWeight,
  55.                        final ObservableSatellite satellite) {
  56.         super(noiseSource, sigma, baseWeight, satellite);
  57.         this.primeStation    = primeStation;
  58.         this.secondStation   = secondStation;
  59.         this.centreFrequency = centreFrequency;
  60.         this.satellite       = satellite;
  61.     }

  62.     /** {@inheritDoc} */
  63.     @Override
  64.     public FDOA build(final AbsoluteDate date, final Map<ObservableSatellite, OrekitStepInterpolator> interpolators) {

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

  68.         // create a dummy measurement
  69.         final FDOA dummy = new FDOA(primeStation, secondStation, centreFrequency, relevant[0].getDate(),
  70.                                     Double.NaN, sigma, baseWeight, satellite);
  71.         for (final EstimationModifier<FDOA> modifier : getModifiers()) {
  72.             dummy.addModifier(modifier);
  73.         }

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

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

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

  89.         // generate measurement
  90.         final FDOA measurement = new FDOA(primeStation, secondStation, centreFrequency, relevant[0].getDate(),
  91.                                           fdoa, sigma, baseWeight, satellite);
  92.         for (final EstimationModifier<FDOA> modifier : getModifiers()) {
  93.             measurement.addModifier(modifier);
  94.         }
  95.         return measurement;

  96.     }

  97. }