InterSatellitesRangeBuilder.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.InterSatellitesRange;
  22. import org.orekit.estimation.measurements.ObservableSatellite;
  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 InterSatellitesRange} measurements.
  28.  * @author Luc Maisonobe
  29.  * @since 9.3
  30.  */
  31. public class InterSatellitesRangeBuilder extends AbstractMeasurementBuilder<InterSatellitesRange> {

  32.     /** Flag indicating whether it is a two-way measurement. */
  33.     private final boolean twoway;

  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 in the one-way case,
  39.      * or reflects the signal in the two-way case.
  40.      * @since 12.0
  41.      */
  42.     private final ObservableSatellite remote;

  43.     /** Simple constructor.
  44.      * @param noiseSource noise source, may be null for generating perfect measurements
  45.      * @param local satellite which receives the signal and performs the measurement
  46.      * @param remote satellite which simply emits the signal in the one-way case,
  47.      * or reflects the signal in the two-way case
  48.      * @param twoWay flag indicating whether it is a two-way measurement
  49.      * @param sigma theoretical standard deviation
  50.      * @param baseWeight base weight
  51.      */
  52.     public InterSatellitesRangeBuilder(final CorrelatedRandomVectorGenerator noiseSource,
  53.                                        final ObservableSatellite local, final ObservableSatellite remote,
  54.                                        final boolean twoWay, final double sigma, final double baseWeight) {
  55.         super(noiseSource, sigma, baseWeight, local, remote);
  56.         this.twoway  = twoWay;
  57.         this.local      = local;
  58.         this.remote     = remote;
  59.     }

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

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

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

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

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

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

  90.         // generate measurement
  91.         final InterSatellitesRange measurement = new InterSatellitesRange(local, remote, twoway, relevant[0].getDate(),
  92.                                                                           range, sigma, baseWeight);
  93.         for (final EstimationModifier<InterSatellitesRange> modifier : getModifiers()) {
  94.             measurement.addModifier(modifier);
  95.         }
  96.         return measurement;

  97.     }

  98. }