AngularAzElBuilder.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.AngularAzEl;
  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 AngularAzEl} measurements.
  29.  * @author Luc Maisonobe
  30.  * @since 9.3
  31.  */
  32. public class AngularAzElBuilder extends AbstractMeasurementBuilder<AngularAzEl> {

  33.     /** Ground station from which measurement is performed. */
  34.     private final GroundStation station;

  35.     /** Satellite related to this builder.
  36.      * @since 12.0
  37.      */
  38.     private final ObservableSatellite satellite;

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

  54.     /** {@inheritDoc} */
  55.     @Override
  56.     public AngularAzEl build(final AbsoluteDate date, final Map<ObservableSatellite, OrekitStepInterpolator> interpolators) {

  57.         final double[] sigma                = getTheoreticalStandardDeviation();
  58.         final double[] baseWeight           = getBaseWeight();
  59.         final SpacecraftState[] relevant    = new SpacecraftState[] { interpolators.get(satellite).getInterpolatedState(date) };

  60.         // create a dummy measurement
  61.         final AngularAzEl dummy = new AngularAzEl(station, relevant[0].getDate(),
  62.                                                   new double[] {
  63.                                                       0.0, 0.0
  64.                                                   }, sigma, baseWeight, satellite);
  65.         for (final EstimationModifier<AngularAzEl> modifier : getModifiers()) {
  66.             dummy.addModifier(modifier);
  67.         }

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

  76.         // estimate the perfect value of the measurement
  77.         final double[] angular = dummy.estimateWithoutDerivatives(relevant).getEstimatedValue();

  78.         // add the noise
  79.         final double[] noise = getNoise();
  80.         if (noise != null) {
  81.             angular[0] += noise[0];
  82.             angular[1] += noise[1];
  83.         }

  84.         // generate measurement
  85.         final AngularAzEl measurement = new AngularAzEl(station, relevant[0].getDate(), angular,
  86.                                                         sigma, baseWeight, satellite);
  87.         for (final EstimationModifier<AngularAzEl> modifier : getModifiers()) {
  88.             measurement.addModifier(modifier);
  89.         }
  90.         return measurement;

  91.     }

  92. }