AbstractMeasurementBuilder.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 java.util.ArrayList;
  19. import java.util.Collections;
  20. import java.util.List;

  21. import org.hipparchus.random.CorrelatedRandomVectorGenerator;
  22. import org.orekit.estimation.measurements.EstimationModifier;
  23. import org.orekit.estimation.measurements.ObservableSatellite;
  24. import org.orekit.estimation.measurements.ObservedMeasurement;
  25. import org.orekit.time.AbsoluteDate;


  26. /** Base class for {@link MeasurementBuilder measurements builders}.
  27.  * @param <T> the type of the measurement
  28.  * @author Luc Maisonobe
  29.  * @since 9.3
  30.  */
  31. public abstract class AbstractMeasurementBuilder<T extends ObservedMeasurement<T>> implements MeasurementBuilder<T> {

  32.     /** Noise source (may be null). */
  33.     private final CorrelatedRandomVectorGenerator noiseSource;

  34.     /** Modifiers that apply to the measurement.*/
  35.     private final List<EstimationModifier<T>> modifiers;

  36.     /** Theoretical standard deviation. */
  37.     private final double[] sigma;

  38.     /** Base weight. */
  39.     private final double[] baseWeight;

  40.     /** Satellites related to this measurement. */
  41.     private final ObservableSatellite[] satellites;

  42.     /** Start of the measurements time span. */
  43.     private AbsoluteDate spanStart;

  44.     /** End of the measurements time span. */
  45.     private AbsoluteDate spanEnd;

  46.     /** Simple constructor.
  47.      * @param noiseSource noise source, may be null for generating perfect measurements
  48.      * @param sigma theoretical standard deviation
  49.      * @param baseWeight base weight
  50.      * @param satellites satellites related to this builder
  51.      */
  52.     protected AbstractMeasurementBuilder(final CorrelatedRandomVectorGenerator noiseSource,
  53.                                          final double sigma, final double baseWeight,
  54.                                          final ObservableSatellite... satellites) {
  55.         this(noiseSource,
  56.              new double[] {
  57.                  sigma
  58.              }, new double[] {
  59.                  baseWeight
  60.              }, satellites);
  61.     }

  62.     /** Simple constructor.
  63.      * @param noiseSource noise source, may be null for generating perfect measurements
  64.      * @param sigma theoretical standard deviation
  65.      * @param baseWeight base weight
  66.      * @param satellites satellites related to this builder
  67.      */
  68.     protected AbstractMeasurementBuilder(final CorrelatedRandomVectorGenerator noiseSource,
  69.                                          final double[] sigma, final double[] baseWeight,
  70.                                          final ObservableSatellite... satellites) {
  71.         this.noiseSource = noiseSource;
  72.         this.modifiers   = new ArrayList<>();
  73.         this.sigma       = sigma.clone();
  74.         this.baseWeight  = baseWeight.clone();
  75.         this.satellites  = satellites.clone();
  76.     }

  77.     /** {@inheritDoc}
  78.      * <p>
  79.      * This implementation stores the time span of the measurements generation.
  80.      * </p>
  81.      */
  82.     @Override
  83.     public void init(final AbsoluteDate start, final AbsoluteDate end) {
  84.         spanStart = start;
  85.         spanEnd   = end;
  86.     }

  87.     /** {@inheritDoc} */
  88.     @Override
  89.     public void addModifier(final EstimationModifier<T> modifier) {
  90.         modifiers.add(modifier);
  91.     }

  92.     /** {@inheritDoc} */
  93.     @Override
  94.     public List<EstimationModifier<T>> getModifiers() {
  95.         return Collections.unmodifiableList(modifiers);
  96.     }

  97.     /** Get the start of the measurements time span.
  98.      * @return start of the measurements time span
  99.      */
  100.     protected AbsoluteDate getStart() {
  101.         return spanStart;
  102.     }

  103.     /** Get the end of the measurements time span.
  104.      * @return end of the measurements time span
  105.      */
  106.     protected AbsoluteDate getEnd() {
  107.         return spanEnd;
  108.     }

  109.     /** Generate a noise vector.
  110.      * @return noise vector (null if we generate perfect measurements)
  111.      */
  112.     protected double[] getNoise() {
  113.         return noiseSource == null ? null : noiseSource.nextVector();
  114.     }

  115.     /** Get the theoretical standard deviation.
  116.      * <p>
  117.      * The theoretical standard deviation is a theoretical value
  118.      * used for normalizing the residuals. It acts as a weighting
  119.      * factor to mix appropriately measurements with different units
  120.      * and different accuracy. The value has the same dimension as
  121.      * the measurement itself (i.e. when a residual is divided by
  122.      * this value, it becomes dimensionless).
  123.      * </p>
  124.      * @return expected standard deviation
  125.      * @see #getBaseWeight()
  126.      */
  127.     protected double[] getTheoreticalStandardDeviation() {
  128.         return sigma.clone();
  129.     }

  130.     /** Get the base weight associated with the measurement
  131.      * <p>
  132.      * The base weight is used on residuals already normalized thanks to
  133.      * {@link #getTheoreticalStandardDeviation()} to increase or
  134.      * decrease relative effect of some measurements with respect to
  135.      * other measurements. It is a dimensionless value, typically between
  136.      * 0 and 1 (but it can really have any non-negative value).
  137.      * </p>
  138.      * @return base weight
  139.      * @see #getTheoreticalStandardDeviation()
  140.      */
  141.     protected double[] getBaseWeight() {
  142.         return baseWeight.clone();
  143.     }

  144.     /** Get the satellites related to this measurement.
  145.      * @return satellites related to this measurement
  146.      */
  147.     protected ObservableSatellite[] getSatellites() {
  148.         return satellites.clone();
  149.     }

  150. }