EstimatedMeasurementBase.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;

  18. import org.orekit.propagation.SpacecraftState;
  19. import org.orekit.time.AbsoluteDate;
  20. import org.orekit.utils.TimeStampedPVCoordinates;

  21. import java.util.IdentityHashMap;

  22. /** Class holding an estimated theoretical value associated to an {@link ObservedMeasurement observed measurement}.
  23.  * @param <T> the type of the measurement
  24.  * @author Luc Maisonobe
  25.  * @since 8.0
  26.  */
  27. public class EstimatedMeasurementBase<T extends ObservedMeasurement<T>> implements ComparableMeasurement {

  28.     /** Associated observed measurement. */
  29.     private final T observedMeasurement;

  30.     /** Iteration number. */
  31.     private final int iteration;

  32.     /** Evaluations counter. */
  33.     private final int count;

  34.     /** States of the spacecrafts. */
  35.     private final SpacecraftState[] states;

  36.     /** Coordinates of the participants in signal travel order. */
  37.     private final TimeStampedPVCoordinates[] participants;

  38.     /** Original estimated value prior to any modification.
  39.      * @since 12.1
  40.      */
  41.     private double[] originalEstimatedValue;

  42.     /** Estimated value. */
  43.     private double[] estimatedValue;

  44.     /** Applied modifiers effects.
  45.      * @since 12.1
  46.      */
  47.     private final IdentityHashMap<EstimationModifier<T>, double[]> appliedEffects;

  48.     /** Measurement status. */
  49.     private Status status;

  50.     /** Simple constructor.
  51.      * @param observedMeasurement associated observed measurement
  52.      * @param iteration iteration number
  53.      * @param count evaluations counter
  54.      * @param states states of the spacecrafts
  55.      * @param participants coordinates of the participants in signal travel order
  56.      * in inertial frame
  57.      */
  58.     public EstimatedMeasurementBase(final T observedMeasurement,
  59.                                     final int iteration, final int count,
  60.                                     final SpacecraftState[] states,
  61.                                     final TimeStampedPVCoordinates[] participants) {
  62.         this.observedMeasurement = observedMeasurement;
  63.         this.iteration           = iteration;
  64.         this.count               = count;
  65.         this.states              = states.clone();
  66.         this.participants        = participants.clone();
  67.         this.status              = Status.PROCESSED;
  68.         this.appliedEffects      = new IdentityHashMap<>();
  69.     }

  70.     /** Get the associated observed measurement.
  71.      * @return associated observed measurement
  72.      */
  73.     public T getObservedMeasurement() {
  74.         return observedMeasurement;
  75.     }

  76.     /** {@inheritDoc} */
  77.     @Override
  78.     public AbsoluteDate getDate() {
  79.         return observedMeasurement.getDate();
  80.     }

  81.     /** Get the iteration number.
  82.      * @return iteration number
  83.      */
  84.     public int getIteration() {
  85.         return iteration;
  86.     }

  87.     /** Get the evaluations counter.
  88.      * @return evaluations counter
  89.      */
  90.     public int getCount() {
  91.         return count;
  92.     }

  93.     /** Get the states of the spacecrafts.
  94.      * @return states of the spacecrafts
  95.      */
  96.     public SpacecraftState[] getStates() {
  97.         return states.clone();
  98.     }

  99.     /** Get the coordinates of the measurements participants in signal travel order.
  100.      * <p>
  101.      * First participant (at index 0) emits the signal (it is for example a ground
  102.      * station for two-way range measurement). Last participant receives the signal
  103.      * (it is also the ground station for two-way range measurement, but a few
  104.      * milliseconds later). Intermediate participants relfect the signal (it is the
  105.      * spacecraft for two-way range measurement).
  106.      * </p>
  107.      * @return coordinates of the measurements participants in signal travel order
  108.      * in inertial frame
  109.      */
  110.     public TimeStampedPVCoordinates[] getParticipants() {
  111.         return participants.clone();
  112.     }

  113.     /** Get the time offset from first state date to measurement date.
  114.      * @return time offset from first state date to measurement date
  115.      */
  116.     public double getTimeOffset() {
  117.         return observedMeasurement.getDate().durationFrom(states[0].getDate());
  118.     }

  119.     /** {@inheritDoc} */
  120.     @Override
  121.     public double[] getObservedValue() {
  122.         return observedMeasurement.getObservedValue();
  123.     }

  124.     /** Get the original estimated value prior to any modification.
  125.      * @return original estimated value prior to any modification
  126.      * @since 12.1
  127.      */
  128.     public double[] getOriginalEstimatedValue() {
  129.         return originalEstimatedValue.clone();
  130.     }

  131.     /** Get the applied effects of modifiers.
  132.      * <p>
  133.      * The effects have already accounted for in {@link #getEstimatedValue()}
  134.      * </p>
  135.      * @return applied modifier effects
  136.      * @since 12.1
  137.      */
  138.     public IdentityHashMap<EstimationModifier<T>, double[]> getAppliedEffects() {
  139.         return appliedEffects;
  140.     }

  141.     /** Get the estimated value.
  142.      * @return estimated value
  143.      */
  144.     public double[] getEstimatedValue() {
  145.         return estimatedValue.clone();
  146.     }

  147.     /** Set the estimated value.
  148.      * @param estimatedValue estimated value
  149.      * @see #modifyEstimatedValue(EstimationModifier, double...)
  150.      */
  151.     public void setEstimatedValue(final double... estimatedValue) {
  152.         if (originalEstimatedValue == null) {
  153.             this.originalEstimatedValue = estimatedValue.clone();
  154.         }
  155.         this.estimatedValue = estimatedValue.clone();
  156.     }

  157.     /** Modify the estimated value.
  158.      * @param modifier modifier that generates this estimated value
  159.      * @param newEstimatedValue new estimated value
  160.      * @since 12.1
  161.      */
  162.     public void modifyEstimatedValue(final EstimationModifier<T> modifier, final double... newEstimatedValue) {

  163.         if (modifier == null) {
  164.             setEstimatedValue(newEstimatedValue);
  165.         } else {
  166.             final double[] effect = new double[newEstimatedValue.length];
  167.             for (int i = 0; i < effect.length; ++i) {
  168.                 // compute effect
  169.                 effect[i] = newEstimatedValue[i] - estimatedValue[i];
  170.                 // update value
  171.                 estimatedValue[i] = newEstimatedValue[i];
  172.             }

  173.             // store effect
  174.             appliedEffects.put(modifier, effect);
  175.         }

  176.     }

  177.     /** Get the status.
  178.      * <p>
  179.      * The status is set to {@link Status#PROCESSED PROCESSED} at construction, and
  180.      * can be reset to {@link Status#REJECTED REJECTED} later on, typically by
  181.      * {@link org.orekit.estimation.measurements.modifiers.OutlierFilter OutlierFilter}
  182.      * or {@link org.orekit.estimation.measurements.modifiers.DynamicOutlierFilter DynamicOutlierFilter}
  183.      * </p>
  184.      * @return status
  185.      */
  186.     public Status getStatus() {
  187.         return status;
  188.     }

  189.     /** Set the status.
  190.      * @param status status to set
  191.      */
  192.     public void setStatus(final Status status) {
  193.         this.status = status;
  194.     }

  195.     /** Enumerate for the status of the measurement. */
  196.     public enum Status {

  197.         /** Status for processed measurements. */
  198.         PROCESSED,

  199.         /** Status for rejected measurements. */
  200.         REJECTED

  201.     }

  202. }