TDOABuilder.java

  1. /* Copyright 2002-2022 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 org.hipparchus.random.CorrelatedRandomVectorGenerator;
  19. import org.orekit.estimation.measurements.EstimationModifier;
  20. import org.orekit.estimation.measurements.GroundStation;
  21. import org.orekit.estimation.measurements.ObservableSatellite;
  22. import org.orekit.estimation.measurements.TDOA;
  23. import org.orekit.propagation.SpacecraftState;
  24. import org.orekit.time.AbsoluteDate;
  25. import org.orekit.utils.ParameterDriver;


  26. /** Builder for {@link TDOA} measurements.
  27.  * @author Pascal Parraud
  28.  * @since 11.2
  29.  */
  30. public class TDOABuilder extends AbstractMeasurementBuilder<TDOA> {

  31.     /** Prime ground station. */
  32.     private final GroundStation primeStation;

  33.     /** Second ground station. */
  34.     private final GroundStation secondStation;

  35.     /** Simple constructor.
  36.      * @param noiseSource noise source, may be null for generating perfect measurements
  37.      * @param primeStation ground station that gives the date of the measurement
  38.      * @param secondStation ground station that gives the measurement
  39.      * @param sigma theoretical standard deviation
  40.      * @param baseWeight base weight
  41.      * @param satellite satellite related to this builder
  42.      */
  43.     public TDOABuilder(final CorrelatedRandomVectorGenerator noiseSource,
  44.                        final GroundStation primeStation,
  45.                        final GroundStation secondStation,
  46.                        final double sigma, final double baseWeight,
  47.                        final ObservableSatellite satellite) {
  48.         super(noiseSource, sigma, baseWeight, satellite);
  49.         this.primeStation  = primeStation;
  50.         this.secondStation = secondStation;
  51.     }

  52.     /** {@inheritDoc} */
  53.     @Override
  54.     public TDOA build(final SpacecraftState[] states) {

  55.         final ObservableSatellite satellite = getSatellites()[0];
  56.         final double sigma                  = getTheoreticalStandardDeviation()[0];
  57.         final double baseWeight             = getBaseWeight()[0];
  58.         final SpacecraftState[] relevant    = new SpacecraftState[] { states[satellite.getPropagatorIndex()] };

  59.         // create a dummy measurement
  60.         final TDOA dummy = new TDOA(primeStation, secondStation, relevant[0].getDate(),
  61.                                     Double.NaN, sigma, baseWeight, satellite);
  62.         for (final EstimationModifier<TDOA> modifier : getModifiers()) {
  63.             dummy.addModifier(modifier);
  64.         }

  65.         // set a reference date for parameters missing one
  66.         for (final ParameterDriver driver : dummy.getParametersDrivers()) {
  67.             if (driver.getReferenceDate() == null) {
  68.                 final AbsoluteDate start = getStart();
  69.                 final AbsoluteDate end   = getEnd();
  70.                 driver.setReferenceDate(start.durationFrom(end) <= 0 ? start : end);
  71.             }
  72.         }

  73.         // estimate the perfect value of the measurement
  74.         double tdoa = dummy.estimate(0, 0, relevant).getEstimatedValue()[0];

  75.         // add the noise
  76.         final double[] noise = getNoise();
  77.         if (noise != null) {
  78.             tdoa += noise[0];
  79.         }

  80.         // generate measurement
  81.         final TDOA measurement = new TDOA(primeStation, secondStation, relevant[0].getDate(),
  82.                                           tdoa, sigma, baseWeight, satellite);
  83.         for (final EstimationModifier<TDOA> modifier : getModifiers()) {
  84.             measurement.addModifier(modifier);
  85.         }
  86.         return measurement;

  87.     }

  88. }