1   /* Copyright 2022-2025 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      /** Get the name of the effect modifying the measurement.
55       * @return name of the effect modifying the measurement
56       * @since 13.0
57       */
58      public String getEffectName() {
59          return "mean phase center";
60      }
61  
62      /** Compute distance modification for one way measurement.
63       * @param estimated estimated measurement to modify
64       * @return distance modification to add to raw measurement
65       */
66      public double oneWayDistanceModification(final EstimatedMeasurementBase<T> estimated) {
67  
68          // The participants are satellite 2 at emission, satellite 1 at reception
69          final TimeStampedPVCoordinates[] participants  = estimated.getParticipants();
70          final AbsoluteDate               emissionDate  = participants[0].getDate();
71          final AbsoluteDate               receptionDate = participants[1].getDate();
72  
73          // transforms from spacecraft to inertial frame at emission/reception dates
74          final SpacecraftState localState                 = estimated.getStates()[0];
75          final SpacecraftState receptionState             = localState.shiftedBy(receptionDate.durationFrom(localState.getDate()));
76          final StaticTransform receptionSpacecraftToInert = receptionState.toStaticTransform().getInverse();
77          final SpacecraftState remoteState                = estimated.getStates()[1];
78          final SpacecraftState emissionState              = remoteState.shiftedBy(emissionDate.durationFrom(remoteState.getDate()));
79          final StaticTransform emissionSpacecraftToInert  = emissionState.toStaticTransform().getInverse();
80  
81          // compute offset due to phase centers
82          return downlink.offset(emissionSpacecraftToInert, receptionSpacecraftToInert);
83  
84      }
85  
86      /** Compute distance modification for two way measurement.
87       * @param estimated estimated measurement to modify
88       * @return distance modification to add to raw measurement
89       */
90      public double twoWayDistanceModification(final EstimatedMeasurementBase<InterSatellitesRange> estimated) {
91  
92          // the participants are satellite 1 at emission, satellite 2 at transit, satellite 1 at reception
93          final TimeStampedPVCoordinates[] participants  = estimated.getParticipants();
94          final AbsoluteDate               emissionDate  = participants[0].getDate();
95          final AbsoluteDate               transitDate   = participants[1].getDate();
96          final AbsoluteDate               receptionDate = participants[2].getDate();
97  
98          // transforms from spacecraft to inertial frame at emission/reception dates
99          final SpacecraftState refState1                  = estimated.getStates()[0];
100         final SpacecraftState receptionState             = refState1.shiftedBy(receptionDate.durationFrom(refState1.getDate()));
101         final StaticTransform receptionSpacecraftToInert = receptionState.toStaticTransform().getInverse();
102         final SpacecraftState refState2                  = estimated.getStates()[1];
103         final SpacecraftState transitState               = refState2.shiftedBy(transitDate.durationFrom(refState2.getDate()));
104         final StaticTransform transitSpacecraftToInert   = transitState.toStaticTransform().getInverse();
105         final SpacecraftState emissionState              = refState1.shiftedBy(emissionDate.durationFrom(refState1.getDate()));
106         final StaticTransform emissionSpacecraftToInert  = emissionState.toStaticTransform().getInverse();
107 
108         // compute offsets due to phase centers
109         final double uplinkOffset   = uplink.offset(emissionSpacecraftToInert, transitSpacecraftToInert);
110         final double downlinkOffset = downlink.offset(transitSpacecraftToInert, receptionSpacecraftToInert);
111 
112         return 0.5 * (uplinkOffset + downlinkOffset);
113 
114     }
115 
116 }