BistaticRangeBuilder.java

  1. /* Copyright 2002-2024 Mark Rutten
  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.  * Mark Rutten 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.BistaticRange;
  21. import org.orekit.estimation.measurements.EstimationModifier;
  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 BistaticRange} measurements.
  29.  * @author Pascal Parraud
  30.  * @author Mark Rutten
  31.  * @since 11.2
  32.  */
  33. public class BistaticRangeBuilder extends AbstractMeasurementBuilder<BistaticRange> {

  34.     /** Emitter ground station. */
  35.     private final GroundStation emitter;

  36.     /** Receiver ground station. */
  37.     private final GroundStation receiver;

  38.     /** Satellite related to this builder.
  39.      * @since 12.0
  40.      */
  41.     private final ObservableSatellite satellite;

  42.     /** Simple constructor.
  43.      * @param noiseSource noise source, may be null for generating perfect measurements
  44.      * @param emitter emitter ground station
  45.      * @param receiver receiver ground station, from which measurement is performed
  46.      * @param sigma theoretical standard deviation
  47.      * @param baseWeight base weight
  48.      * @param satellite satellite related to this builder
  49.      */
  50.     public BistaticRangeBuilder(final CorrelatedRandomVectorGenerator noiseSource,
  51.                                 final GroundStation emitter, final GroundStation receiver,
  52.                                 final double sigma, final double baseWeight,
  53.                                 final ObservableSatellite satellite) {
  54.         super(noiseSource, sigma, baseWeight, satellite);
  55.         this.emitter   = emitter;
  56.         this.receiver  = receiver;
  57.         this.satellite = satellite;
  58.     }

  59.     /** {@inheritDoc} */
  60.     @Override
  61.     public BistaticRange 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 BistaticRange dummy = new BistaticRange(emitter, receiver, relevant[0].getDate(),
  67.                                                       Double.NaN, sigma, baseWeight, satellite);
  68.         for (final EstimationModifier<BistaticRange> 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 range = dummy.estimateWithoutDerivatives(0, 0, relevant).getEstimatedValue()[0];

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

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

  93.     }

  94. }