1   /* Copyright 2002-2024 Thales Alenia Space
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.modifiers;
18  
19  import org.orekit.estimation.measurements.AbstractMeasurement;
20  import org.orekit.estimation.measurements.EstimatedMeasurementBase;
21  import org.orekit.estimation.measurements.InterSatellitesRange;
22  import org.orekit.frames.StaticTransform;
23  import org.orekit.gnss.antenna.FrequencyPattern;
24  import org.orekit.propagation.SpacecraftState;
25  import org.orekit.time.AbsoluteDate;
26  import org.orekit.utils.TimeStampedPVCoordinates;
27  
28  /** On-board antenna offset effect on inter-satellites phase measurements.
29   * @param <T> type of the measurement
30   * @author Luc Maisonobe
31   * @since 12.1
32   */
33  public class PhaseCentersInterSatellitesBaseModifier<T extends AbstractMeasurement<T>> {
34  
35      /** Uplink offset model. */
36      private final PhaseCentersOffsetComputer uplink;
37  
38      /** Downlink offset model. */
39      private final PhaseCentersOffsetComputer downlink;
40  
41      /** Simple constructor.
42       * @param pattern1 pattern for satellite 1
43       * (i.e. the satellite which receives the signal and performs the measurement)
44       * @param pattern2  pattern for satellite 2
45       * (i.e. the satellite which simply emits the signal in the one-way
46       * case, or reflects the signal in the two-way case)
47       */
48      public PhaseCentersInterSatellitesBaseModifier(final FrequencyPattern pattern1,
49                                                     final FrequencyPattern pattern2) {
50          this.uplink   = new PhaseCentersOffsetComputer(pattern1, pattern2);
51          this.downlink = new PhaseCentersOffsetComputer(pattern2, pattern1);
52      }
53  
54      /** Compute distance modification for one way measurement.
55       * @param estimated estimated measurement to modify
56       * @return distance modification to add to raw measurement
57       */
58      public double oneWayDistanceModification(final EstimatedMeasurementBase<T> estimated) {
59  
60          // The participants are satellite 2 at emission, satellite 1 at reception
61          final TimeStampedPVCoordinates[] participants  = estimated.getParticipants();
62          final AbsoluteDate               emissionDate  = participants[0].getDate();
63          final AbsoluteDate               receptionDate = participants[1].getDate();
64  
65          // transforms from spacecraft to inertial frame at emission/reception dates
66          final SpacecraftState localState                 = estimated.getStates()[0];
67          final SpacecraftState receptionState             = localState.shiftedBy(receptionDate.durationFrom(localState.getDate()));
68          final StaticTransform receptionSpacecraftToInert = receptionState.toStaticTransform().getInverse();
69          final SpacecraftState remoteState                = estimated.getStates()[1];
70          final SpacecraftState emissionState              = remoteState.shiftedBy(emissionDate.durationFrom(remoteState.getDate()));
71          final StaticTransform emissionSpacecraftToInert  = emissionState.toStaticTransform().getInverse();
72  
73          // compute offset due to phase centers
74          return downlink.offset(emissionSpacecraftToInert, receptionSpacecraftToInert);
75  
76      }
77  
78      /** Compute distance modification for two way measurement.
79       * @param estimated estimated measurement to modify
80       * @return distance modification to add to raw measurement
81       */
82      public double twoWayDistanceModification(final EstimatedMeasurementBase<InterSatellitesRange> estimated) {
83  
84          // the participants are satellite 1 at emission, satellite 2 at transit, satellite 1 at reception
85          final TimeStampedPVCoordinates[] participants  = estimated.getParticipants();
86          final AbsoluteDate               emissionDate  = participants[0].getDate();
87          final AbsoluteDate               transitDate   = participants[1].getDate();
88          final AbsoluteDate               receptionDate = participants[2].getDate();
89  
90          // transforms from spacecraft to inertial frame at emission/reception dates
91          final SpacecraftState refState1                  = estimated.getStates()[0];
92          final SpacecraftState receptionState             = refState1.shiftedBy(receptionDate.durationFrom(refState1.getDate()));
93          final StaticTransform receptionSpacecraftToInert = receptionState.toStaticTransform().getInverse();
94          final SpacecraftState refState2                  = estimated.getStates()[1];
95          final SpacecraftState transitState               = refState2.shiftedBy(transitDate.durationFrom(refState2.getDate()));
96          final StaticTransform transitSpacecraftToInert   = transitState.toStaticTransform().getInverse();
97          final SpacecraftState emissionState              = refState1.shiftedBy(emissionDate.durationFrom(refState1.getDate()));
98          final StaticTransform emissionSpacecraftToInert  = emissionState.toStaticTransform().getInverse();
99  
100         // compute offsets due to phase centers
101         final double uplinkOffset   = uplink.offset(emissionSpacecraftToInert, transitSpacecraftToInert);
102         final double downlinkOffset = downlink.offset(transitSpacecraftToInert, receptionSpacecraftToInert);
103 
104         return 0.5 * (uplinkOffset + downlinkOffset);
105 
106     }
107 
108 }