Isis 3 Programmer Reference
SpacecraftPosition.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include "SpacecraftPosition.h"
8 
9 #include <cfloat>
10 #include <iomanip>
11 
12 #include <QVector>
13 
14 #include "Constants.h"
15 #include "Distance.h"
16 #include "EndianSwapper.h"
17 #include "FileName.h"
18 #include "IException.h"
19 #include "IString.h"
20 #include "iTime.h"
21 #include "Longitude.h"
22 #include "NaifStatus.h"
23 
24 using namespace std;
25 
26 namespace Isis {
27 
48  SpacecraftPosition::SpacecraftPosition(int targetCode, int observerCode,
49  const LightTimeCorrectionState &ltState,
50  const Distance &radius) :
51  SpicePosition(targetCode, observerCode,
52  ltState.isObserverTargetSwapped()) {
53  m_abcorr = ltState;
54  m_radius = radius;
55  return;
56  }
57 
58 
59 
74  return (m_radius.kilometers()/clight_c());
75  }
76 
88  return (distance.kilometers()/clight_c());
89  }
90 
91 
99  void SpacecraftPosition::SetAberrationCorrection(const QString &correction) {
100  SpicePosition::SetAberrationCorrection(correction); // Checks for validity
101  m_abcorr.setAberrationCorrection(correction);
102  }
103 
104 
112  }
113 
132 
133  // Both light time correction and surface light time correction *must* be requested
134  // in order to invoke the algorithm below, otherwise we can call the pre-existing
135  // implementation as it handles swap and light time adjustments as requested.
136  // The algorithm below only additionally handles light time surface correction.
139  return;
140  }
141 
143  // Proceed with applying light time corrections to surface. The
144  // steps to make this more accurate is as follows:
145  //
146  // 1) Compute vector from observer to target to acquire the light
147  // time correction (in seconds)
148  //
149  // 2) Acquire the vector from the solar system barycenter (SSB) to
150  // the spacecraft at the specified time.
151  //
152  // 3) Acquire the vector from the SSB to the target less the light
153  // time from 1) adding back in the time it takes for light to
154  // travel the radius of the target.
155  //
156  // 4) Compute the vector state of the target from the observer
157  // buy subtracting the result of 2) from 3).
159 
160  SpiceDouble state[6], lt;
161  bool hasVelocity;
162  const SpiceInt ssbCode(0);
163 
164  // 1) get observer/target light time
166  "J2000", GetAberrationCorrection(), state, hasVelocity, lt);
167 
168  // 2) get SSB to s/c
169  SpiceDouble ssbObs[6], ssbObs_lt;
170  bool dummy;
172  "J2000", "NONE", ssbObs, dummy, ssbObs_lt);
173 
174  // 3) get adjusted target position from SSB
175  double ltAdj_et = getAdjustedEphemerisTime() - lt + getRadiusLightTime();
176  SpiceDouble ssbTarg[6], ssbTarg_lt;
177  computeStateVector(ltAdj_et, getTargetCode(), ssbCode,
178  "J2000", "NONE", ssbTarg, dummy, ssbTarg_lt);
179 
180  // 4) compute target to observer
181  (void) vsubg_c(ssbTarg, ssbObs, 6, state);
182 
183  // Store vector and light time correction results
184  setStateVector(state, hasVelocity);
185  setLightTime(ltAdj_et);
186  return;
187  }
188 
189 
198  return (m_abcorr);
199  }
200 
201 
202 } // namespace Isis
Isis::SpacecraftPosition::getDistanceLightTime
static double getDistanceLightTime(const Distance &distance)
Returns the time it takes for light to travel a given distance.
Definition: SpacecraftPosition.cpp:87
Isis::Distance::kilometers
double kilometers() const
Get the distance in kilometers.
Definition: Distance.cpp:106
Isis::SpacecraftPosition::GetAberrationCorrection
virtual QString GetAberrationCorrection() const
Returns the stellr aberration correction applied.
Definition: SpacecraftPosition.cpp:110
Isis::SpicePosition
Obtain SPICE position information for a body.
Definition: SpicePosition.h:173
Isis::SpicePosition::SetEphemerisTimeSpice
virtual void SetEphemerisTimeSpice()
This is a protected method that is called by SetEphemerisTime() when Source type is Spice.
Definition: SpicePosition.cpp:1432
Isis::LightTimeCorrectionState::isLightTimeCorrected
bool isLightTimeCorrected() const
Is light time to target corrected?
Definition: LightTimeCorrectionState.cpp:230
Isis::SpicePosition::computeStateVector
void computeStateVector(double et, int target, int observer, const QString &refFrame, const QString &abcorr, double state[6], bool &hasVelocity, double &lightTime) const
Computes the state vector of the target w.r.t observer.
Definition: SpicePosition.cpp:1742
Isis::SpicePosition::SetAberrationCorrection
virtual void SetAberrationCorrection(const QString &correction)
Set the aberration correction (light time)
Definition: SpicePosition.cpp:186
Isis::SpicePosition::getAdjustedEphemerisTime
double getAdjustedEphemerisTime() const
Returns adjusted ephemeris time.
Definition: SpicePosition.cpp:1705
Isis::SpicePosition::getTargetCode
int getTargetCode() const
Returns target code.
Definition: SpicePosition.cpp:1689
Isis::SpicePosition::setStateVector
void setStateVector(const double state[6], const bool &hasVelocity)
Sets the state of target relative to observer.
Definition: SpicePosition.cpp:1794
Isis::Distance
Distance measurement, usually in meters.
Definition: Distance.h:34
Isis::SpicePosition::getObserverCode
int getObserverCode() const
Returns observer code.
Definition: SpicePosition.cpp:1675
Isis::SpacecraftPosition::m_radius
Distance m_radius
Radius of target.
Definition: SpacecraftPosition.h:83
Isis::SpicePosition::setLightTime
void setLightTime(const double &lightTime)
Inheritors can set the light time if indicated.
Definition: SpicePosition.cpp:1824
Isis::SpacecraftPosition::m_abcorr
LightTimeCorrectionState m_abcorr
Light time correction state.
Definition: SpacecraftPosition.h:82
Isis::LightTimeCorrectionState::setAberrationCorrection
void setAberrationCorrection(const QString &correction)
Sets the aberration correction directly.
Definition: LightTimeCorrectionState.cpp:134
std
Namespace for the standard library.
Isis::SpacecraftPosition::SetEphemerisTimeSpice
virtual void SetEphemerisTimeSpice()
Determine accurate position of target w.r.t.
Definition: SpacecraftPosition.cpp:131
Isis::SpacecraftPosition::getLightTimeState
const LightTimeCorrectionState & getLightTimeState() const
Return the state of light time correction parameters.
Definition: SpacecraftPosition.cpp:197
Isis::SpacecraftPosition::getRadiusLightTime
double getRadiusLightTime() const
Returns the time it takes for light to travel the radius of the target.
Definition: SpacecraftPosition.cpp:73
Isis::LightTimeCorrectionState::isLightTimeToSurfaceCorrected
bool isLightTimeToSurfaceCorrected() const
Returns state of light time from surface to center body correction.
Definition: LightTimeCorrectionState.cpp:323
Isis::SpacecraftPosition::SetAberrationCorrection
virtual void SetAberrationCorrection(const QString &correction)
Set aberration correction value for determining positions.
Definition: SpacecraftPosition.cpp:99
Isis::LightTimeCorrectionState
Provides interface to user configurable Light Time correction feature.
Definition: LightTimeCorrectionState.h:48
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::LightTimeCorrectionState::getAberrationCorrection
QString getAberrationCorrection() const
Returns the value of the current stellar aberration state.
Definition: LightTimeCorrectionState.cpp:147