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  
19  import java.util.SortedSet;
20  
21  import org.hipparchus.util.FastMath;
22  import org.junit.Assert;
23  import org.junit.Before;
24  import org.junit.Test;
25  import org.orekit.estimation.Context;
26  import org.orekit.estimation.EstimationTestUtils;
27  import org.orekit.estimation.Force;
28  import org.orekit.estimation.measurements.AngularAzEl;
29  import org.orekit.estimation.measurements.ObservableSatellite;
30  import org.orekit.estimation.measurements.ObservedMeasurement;
31  import org.orekit.estimation.measurements.Range;
32  import org.orekit.orbits.OrbitType;
33  import org.orekit.orbits.PositionAngle;
34  import org.orekit.propagation.Propagator;
35  import org.orekit.propagation.conversion.NumericalPropagatorBuilder;
36  import org.orekit.propagation.events.ElevationDetector;
37  import org.orekit.propagation.events.EventDetector;
38  import org.orekit.time.AbsoluteDate;
39  import org.orekit.time.FixedStepSelector;
40  import org.orekit.time.TimeScalesFactory;
41  import org.orekit.utils.Constants;
42  
43  public class GeneratorTest {
44  
45      @Test
46      public void testIssue557() {
47  
48          final EventDetector detector = new ElevationDetector(context.stations.get(0).getBaseFrame());
49  
50          double[] azElError = new double[] {
51              FastMath.toRadians(0.015),
52              FastMath.toRadians(0.015)
53          };
54          double[] baseweight = new double[] {
55              1.0,
56              1.0
57          };
58  
59          double rangeSigma = 40.0;
60          double rangeBW = 1;
61          ObservableSatellite obs = new ObservableSatellite(0);
62          RangeBuilder rB = new RangeBuilder(null, context.stations.get(0), false, rangeSigma, rangeBW,obs);
63          AngularAzElBuilder aAEB = new AngularAzElBuilder(null, context.stations.get(0), azElError, baseweight, obs);  
64          double  timeToEnd = Constants.JULIAN_DAY;
65  
66          AbsoluteDate initialDate = context.initialOrbit.getDate();
67          AbsoluteDate finalDate = initialDate.shiftedBy(timeToEnd);
68          Propagator numProp = EstimationTestUtils.createPropagator(context.initialOrbit, propagatorBuilder);
69          FixedStepSelector fssAE = new FixedStepSelector(10., TimeScalesFactory.getUTC());
70          EventBasedScheduler<Range> eBS = new EventBasedScheduler<>(rB, fssAE, numProp, detector, SignSemantic.FEASIBLE_MEASUREMENT_WHEN_NEGATIVE);
71          FixedStepSelector fssR = new FixedStepSelector(10., TimeScalesFactory.getUTC());
72          EventBasedScheduler<AngularAzEl> aeBS = new EventBasedScheduler<>(aAEB, fssR, numProp, detector, SignSemantic.FEASIBLE_MEASUREMENT_WHEN_NEGATIVE);      
73          Generator genR = new Generator();
74          genR.addPropagator(numProp);
75          genR.addScheduler(aeBS);
76          genR.addScheduler(eBS);
77  
78          SortedSet<ObservedMeasurement<?>> generated = genR.generate(initialDate, finalDate);
79  
80          int nbAzEl  = 0;
81          int nbRange = 0;
82          for (final ObservedMeasurement<?> m : generated) {
83              if (m instanceof AngularAzEl) {
84                  ++nbAzEl;
85              } else if (m instanceof Range) {
86                  ++nbRange;
87              } else {
88                  Assert.fail("unexpected measurement type: " + m.getClass().getSimpleName());
89              }
90          }
91          Assert.assertEquals(740, nbAzEl);
92          Assert.assertEquals(740, nbRange);
93  
94      }
95  
96      @Before
97      public void setUp() {
98          context = EstimationTestUtils.eccentricContext("regular-data:potential:tides");
99  
100         propagatorBuilder = context.createBuilder(OrbitType.KEPLERIAN, PositionAngle.TRUE, true,
101                                                   1.0e-6, 300.0, 0.001, Force.POTENTIAL,
102                                                   Force.THIRD_BODY_SUN, Force.THIRD_BODY_MOON);
103     }
104 
105     Context context;
106     NumericalPropagatorBuilder propagatorBuilder;
107 
108 }