EstimatedMeasurementBase.java

  1. /* Copyright 2002-2025 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. import java.util.Map;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  125.     /** {@inheritDoc} */
  126.     @Override
  127.     public void setObservedValue(final double[] observed) {
  128.         observedMeasurement.setObservedValue(observed);
  129.     }

  130.     /** Get the original estimated value prior to any modification.
  131.      * @return original estimated value prior to any modification
  132.      * @since 12.1
  133.      */
  134.     public double[] getOriginalEstimatedValue() {
  135.         return originalEstimatedValue.clone();
  136.     }

  137.     /** Get the applied effects of modifiers.
  138.      * <p>
  139.      * The effects have already accounted for in {@link #getEstimatedValue()}
  140.      * </p>
  141.      * @return applied modifier effects
  142.      * @since 12.1
  143.      */
  144.     public Map<EstimationModifier<T>, double[]> getAppliedEffects() {
  145.         return appliedEffects;
  146.     }

  147.     /** Get the estimated value.
  148.      * @return estimated value
  149.      */
  150.     public double[] getEstimatedValue() {
  151.         return estimatedValue.clone();
  152.     }

  153.     /** Set the estimated value.
  154.      * @param estimatedValue estimated value
  155.      * @see #modifyEstimatedValue(EstimationModifier, double...)
  156.      */
  157.     public void setEstimatedValue(final double... estimatedValue) {
  158.         if (originalEstimatedValue == null) {
  159.             this.originalEstimatedValue = estimatedValue.clone();
  160.         }
  161.         this.estimatedValue = estimatedValue.clone();
  162.     }

  163.     /** Modify the estimated value.
  164.      * @param modifier modifier that generates this estimated value
  165.      * @param newEstimatedValue new estimated value
  166.      * @since 12.1
  167.      */
  168.     public void modifyEstimatedValue(final EstimationModifier<T> modifier, final double... newEstimatedValue) {

  169.         if (modifier == null) {
  170.             setEstimatedValue(newEstimatedValue);
  171.         } else {
  172.             final double[] effect = new double[newEstimatedValue.length];
  173.             for (int i = 0; i < effect.length; ++i) {
  174.                 // compute effect
  175.                 effect[i] = newEstimatedValue[i] - estimatedValue[i];
  176.                 // update value
  177.                 estimatedValue[i] = newEstimatedValue[i];
  178.             }

  179.             // store effect
  180.             appliedEffects.put(modifier, effect);
  181.         }

  182.     }

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

  195.     /** Set the status.
  196.      * @param status status to set
  197.      */
  198.     public void setStatus(final Status status) {
  199.         this.status = status;
  200.     }

  201.     /** Enumerate for the status of the measurement. */
  202.     public enum Status {

  203.         /** Status for processed measurements. */
  204.         PROCESSED,

  205.         /** Status for rejected measurements. */
  206.         REJECTED

  207.     }

  208. }