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.sequential;
18  
19  import org.junit.jupiter.api.Assertions;
20  import org.junit.jupiter.api.Test;
21  import org.orekit.errors.OrekitException;
22  import org.orekit.errors.OrekitMessages;
23  import org.orekit.estimation.measurements.EstimatedMeasurement;
24  import org.orekit.estimation.measurements.EstimatedMeasurementBase.Status;
25  import org.orekit.estimation.measurements.Range;
26  import org.orekit.propagation.SpacecraftState;
27  import org.orekit.utils.ParameterDriver;
28  import org.orekit.utils.ParameterDriversList;
29  import org.orekit.utils.TimeStampedPVCoordinates;
30  
31  public class KalmanEstimatorUtilTest {
32  
33  	@Test
34  	public void testDimension() {
35  
36  		// Orbital drivers
37  		final ParameterDriversList orbital = new ParameterDriversList();
38  		orbital.add(createDriver("a", false));
39  		orbital.add(createDriver("e", true));
40  
41  		// Propagation drivers
42  		final ParameterDriversList prop = new ParameterDriversList();
43  		prop.add(createDriver("Cr", false));
44  		prop.add(createDriver("Cd", true));
45  
46  		// Measurement drivers
47  		final ParameterDriversList meas = new ParameterDriversList();
48  		meas.add(createDriver("Range_bias", false));
49  		meas.add(createDriver("Clock", true));
50  
51  		// Works
52  		KalmanEstimatorUtil.checkDimension(3, orbital, prop, meas);
53  
54  		// Test exception
55          try {
56          	KalmanEstimatorUtil.checkDimension(4, orbital, prop, meas);
57              Assertions.fail("an exception should have been thrown");
58          } catch (OrekitException oe) {
59              Assertions.assertEquals(OrekitMessages.DIMENSION_INCONSISTENT_WITH_PARAMETERS, oe.getSpecifier());
60          }
61  		
62  	}
63  
64  	@Test
65  	public void testRejectedMeasurement() {
66  		final EstimatedMeasurement<Range> estimated = new EstimatedMeasurement<>(null, 1, 1, new SpacecraftState[1], new TimeStampedPVCoordinates[1]);
67  		estimated.setStatus(Status.REJECTED);
68  		Assertions.assertNull(KalmanEstimatorUtil.computeInnovationVector(estimated, new double[1]));
69  	}
70  
71  	private ParameterDriver createDriver(final String name, final boolean estimated) {
72  		final ParameterDriver driver = new ParameterDriver(name, 1.0, 1.0, 0.0, 2.0);
73  		driver.setSelected(estimated);
74  		return driver;
75  	}
76  
77  }