AngularAzElBuilder.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.AngularAzEl;
  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.propagation.SpacecraftState;
  24. import org.orekit.time.AbsoluteDate;
  25. import org.orekit.utils.ParameterDriver;


  26. /** Builder for {@link AngularAzEl} measurements.
  27.  * @author Luc Maisonobe
  28.  * @since 9.3
  29.  */
  30. public class AngularAzElBuilder extends AbstractMeasurementBuilder<AngularAzEl> {

  31.     /** Ground station from which measurement is performed. */
  32.     private final GroundStation station;

  33.     /** Simple constructor.
  34.      * @param noiseSource noise source, may be null for generating perfect measurements
  35.      * @param station ground station from which measurement is performed
  36.      * @param sigma theoretical standard deviation
  37.      * @param baseWeight base weight
  38.      * @param satellite satellite related to this builder
  39.      */
  40.     public AngularAzElBuilder(final CorrelatedRandomVectorGenerator noiseSource,
  41.                               final GroundStation station,
  42.                               final double[] sigma, final double[] baseWeight,
  43.                               final ObservableSatellite satellite) {
  44.         super(noiseSource, sigma, baseWeight, satellite);
  45.         this.station = station;
  46.     }

  47.     /** {@inheritDoc} */
  48.     @Override
  49.     public AngularAzEl build(final SpacecraftState[] states) {

  50.         final ObservableSatellite satellite = getSatellites()[0];
  51.         final double[] sigma                = getTheoreticalStandardDeviation();
  52.         final double[] baseWeight           = getBaseWeight();
  53.         final SpacecraftState[] relevant    = new SpacecraftState[] { states[satellite.getPropagatorIndex()] };

  54.         // create a dummy measurement
  55.         final AngularAzEl dummy = new AngularAzEl(station, relevant[0].getDate(),
  56.                                                   new double[] {
  57.                                                       0.0, 0.0
  58.                                                   }, sigma, baseWeight, satellite);
  59.         for (final EstimationModifier<AngularAzEl> modifier : getModifiers()) {
  60.             dummy.addModifier(modifier);
  61.         }

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

  70.         // estimate the perfect value of the measurement
  71.         final double[] angular = dummy.estimate(0, 0, relevant).getEstimatedValue();

  72.         // add the noise
  73.         final double[] noise = getNoise();
  74.         if (noise != null) {
  75.             angular[0] += noise[0];
  76.             angular[1] += noise[1];
  77.         }

  78.         // generate measurement
  79.         final AngularAzEl measurement = new AngularAzEl(station, relevant[0].getDate(), angular,
  80.                                                         sigma, baseWeight, satellite);
  81.         for (final EstimationModifier<AngularAzEl> modifier : getModifiers()) {
  82.             measurement.addModifier(modifier);
  83.         }
  84.         return measurement;

  85.     }

  86. }