TDOABuilder.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.GroundStation;
  22. import org.orekit.estimation.measurements.ObservableSatellite;
  23. import org.orekit.estimation.measurements.TDOA;
  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 TDOA} measurements.
  29.  * @author Pascal Parraud
  30.  * @since 11.2
  31.  */
  32. public class TDOABuilder extends AbstractMeasurementBuilder<TDOA> {

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

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

  37.     /** Satellite related to this builder.
  38.      * @since 12.0
  39.      */
  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 sigma theoretical standard deviation
  46.      * @param baseWeight base weight
  47.      * @param satellite satellite related to this builder
  48.      */
  49.     public TDOABuilder(final CorrelatedRandomVectorGenerator noiseSource,
  50.                        final GroundStation primeStation,
  51.                        final GroundStation secondStation,
  52.                        final double sigma, final double baseWeight,
  53.                        final ObservableSatellite satellite) {
  54.         super(noiseSource, sigma, baseWeight, satellite);
  55.         this.primeStation  = primeStation;
  56.         this.secondStation = secondStation;
  57.         this.satellite     = satellite;
  58.     }

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

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

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

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

  79.         // estimate the perfect value of the measurement
  80.         double tdoa = dummy.estimateWithoutDerivatives(relevant).getEstimatedValue()[0];

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

  86.         // generate measurement
  87.         final TDOA measurement = new TDOA(primeStation, secondStation, relevant[0].getDate(),
  88.                                           tdoa, sigma, baseWeight, satellite);
  89.         for (final EstimationModifier<TDOA> modifier : getModifiers()) {
  90.             measurement.addModifier(modifier);
  91.         }
  92.         return measurement;

  93.     }

  94. }