File failed to load: https://isis.astrogeology.usgs.gov/6.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
LightTimeCorrectionState.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include "LightTimeCorrectionState.h"
8 
9 #include <cfloat>
10 #include <iomanip>
11 
12 #include <string>
13 #include <vector>
14 
15 #include <QString>
16 
17 #include <SpiceZdf.h>
18 
19 #include "IException.h"
20 #include "IString.h"
21 #include "Kernels.h"
22 #include "Pvl.h"
23 #include "PvlGroup.h"
24 #include "NaifStatus.h"
25 #include "Spice.h"
26 
27 namespace Isis {
28 
44  }
45 
46 
61  Spice *spice) {
63  checkObserverTargetSwap(ikCode, spice);
64  checkAberrationCorrection(ikCode, spice);
65  checkLightTimeToSurfaceCorrect(ikCode, spice);
66  }
67 
68 
79  const {
81  return (false);
82  }
84  return (false);
85  }
87  return (false);
88  }
89  return (true);
90  }
91 
108  Spice *spice) {
109  try {
110  QString ikernKey = "INS" + toString(ikCode) + "_LIGHTTIME_CORRECTION";
111  QString abcorr = spice->getString(ikernKey);
112  m_abcorr = abcorr;
113  return (true);
114  }
115  catch (IException &ie) {
116  // Keyword not found or error encountered - ignore
117  }
118  return (false);
119  }
120 
121 
134  void LightTimeCorrectionState::setAberrationCorrection(const QString &correction) {
135  m_abcorr = correction;
136  return;
137  }
138 
139 
148  return (m_abcorr);
149  }
150 
151 
174  // Determine loaded-only kernels. Our search is restricted to only
175  // kernels that are loaded and, currently, only of SPK type is of
176  // interest.
177  Kernels kernels;
178  kernels.Discover();
179 
180  // Init the tag to Qt QString for effective searching
181  QString qtag("ID:USGS_SPK_ABCORR");
182  QString abcorr("");
183 
184  // Retrieve list of loaded SPKs from Kernel object
185  QStringList spks = kernels.getKernelList("SPK");
187  for ( int k = 0 ; k < spks.size() ; k++ ) {
188  QString spkFile = spks[k];
189  SpiceChar ktype[32];
190  SpiceChar source[128];
191  SpiceInt handle;
192  SpiceBoolean found;
193  // Get info on SPK kernel mainly the NAIF handle for comment parsing
194  (void) kinfo_c(spkFile.toLatin1().data(), sizeof(ktype), sizeof(source), ktype,
195  source, &handle, &found);
196  if (found == SPICETRUE) {
197  // SPK is open so read and parse all the comments.
198  SpiceChar commnt[1001];
199  SpiceBoolean done(SPICEFALSE);
200  SpiceInt n;
201 
202  // NOTE it is specially important to read all comments so this routine
203  // is reentrant! NAIF will automatically reset the pointer to the
204  // first comment line when and only when the last comment line is
205  // read. This is not apparent in the NAIF documentation.
206  while ( !done ) {
207  dafec_c(handle, 1, sizeof(commnt), &n, commnt, &done);
208  QString cmmt(commnt);
209  int pos = 0;
210  if ( (pos = cmmt.indexOf(qtag, pos, Qt::CaseInsensitive)) != -1 ) {
211  // We can put more effort into this when the need arises and
212  // we have a better handle on options.
213  abcorr = "NONE";
214  }
215  }
216  // Don't need to read any more kernel comments if we found one with
217  // the tag in it.
218  if ( !abcorr.isEmpty() ) break;
219  }
220  }
222 
223  // Set internal state only if it was found in the kernels, otherwise the
224  // existing state is preserved.
225  if (!abcorr.isEmpty()) { m_abcorr = abcorr; }
226  return (!abcorr.isEmpty());
227  }
228 
231  return ("NONE" != m_abcorr);
232  }
233 
234 
255  Spice *spice) {
256 
257  try {
258  QString ikernKey = "INS" + toString(ikCode) + "_SWAP_OBSERVER_TARGET";
259  QString value = spice->getString(ikernKey).toUpper();
260  m_swapObserverTarget = ("TRUE" == value);
261  }
262  catch (IException &ie) {
263  // Not there is a false condition
264  m_swapObserverTarget = false;
265  }
266 
267  return (m_swapObserverTarget);
268  }
269 
270 
273  return (m_swapObserverTarget);
274  }
275 
278  m_swapObserverTarget = true;
279  }
280 
283  m_swapObserverTarget = false;
284  }
285 
286 
307  Spice *spice) {
308 
309  try {
310  QString ikernKey = "INS" + toString(ikCode) + "_LT_SURFACE_CORRECT";
311  QString value = spice->getString(ikernKey).toUpper();
312  m_sc_to_surf_ltcorr = ("TRUE" == value);
313  }
314  catch (IException &ie) {
315  // Not there is a false condition
316  m_sc_to_surf_ltcorr = false;
317  }
318 
319  return (m_sc_to_surf_ltcorr);
320  }
321 
324  return (m_sc_to_surf_ltcorr);
325  }
326 
329  m_sc_to_surf_ltcorr = true;
330  }
331 
335  m_sc_to_surf_ltcorr = false;
336  }
337 
338 
350  m_abcorr = "LT+S";
351  m_swapObserverTarget = false;
352  m_sc_to_surf_ltcorr = false;
353  return;
354  }
355 
356 
357 } // namespace Isis
Isis::Kernels
Determine SPICE kernels defined in an ISIS file.
Definition: Kernels.h:94
Isis::LightTimeCorrectionState::setDefaultState
void setDefaultState()
Set default conditions for light time correction state.
Definition: LightTimeCorrectionState.cpp:349
Isis::LightTimeCorrectionState::isLightTimeCorrected
bool isLightTimeCorrected() const
Is light time to target corrected?
Definition: LightTimeCorrectionState.cpp:230
Isis::Spice::getString
QString getString(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition: Spice.cpp:1261
Isis::LightTimeCorrectionState::checkSpkKernelsForAberrationCorrection
bool checkSpkKernelsForAberrationCorrection()
Check for light time/stellar aberration tag in SPK comments.
Definition: LightTimeCorrectionState.cpp:173
Isis::LightTimeCorrectionState::setSwapObserverTarget
void setSwapObserverTarget()
Turns on swapping of observer/target
Definition: LightTimeCorrectionState.cpp:277
Isis::Kernels::Discover
int Discover()
Determine which NAIF kernels are currently loaded in the pool.
Definition: Kernels.cpp:235
Isis::Kernels::getKernelList
QStringList getKernelList(const QString &ktype="") const
Provide a list of all the kernels found.
Definition: Kernels.cpp:672
Isis::NaifStatus::CheckErrors
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Definition: NaifStatus.cpp:28
QStringList
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
Isis::LightTimeCorrectionState::checkLightTimeToSurfaceCorrect
bool checkLightTimeToSurfaceCorrect(int ikCode, Spice *spice)
Determines state of surface to s/c light time correction.
Definition: LightTimeCorrectionState.cpp:306
Isis::LightTimeCorrectionState::LightTimeCorrectionState
LightTimeCorrectionState()
Default constructor sets default state of light time corrections.
Definition: LightTimeCorrectionState.cpp:42
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::Spice
Obtain SPICE information for a spacecraft.
Definition: Spice.h:283
Isis::LightTimeCorrectionState::setAberrationCorrection
void setAberrationCorrection(const QString &correction)
Sets the aberration correction directly.
Definition: LightTimeCorrectionState.cpp:134
Isis::LightTimeCorrectionState::checkAberrationCorrection
bool checkAberrationCorrection(int ikCode, Spice *spice)
Apply instrument (team) specific light time/stellar aborration option.
Definition: LightTimeCorrectionState.cpp:107
Isis::LightTimeCorrectionState::isObserverTargetSwapped
bool isObserverTargetSwapped() const
Returns state swap observer/target
Definition: LightTimeCorrectionState.cpp:272
Isis::LightTimeCorrectionState::checkObserverTargetSwap
bool checkObserverTargetSwap(int ikCode, Spice *spice)
Check status of target/observer swap specification.
Definition: LightTimeCorrectionState.cpp:254
Isis::LightTimeCorrectionState::setNoSwapObserverTarget
void setNoSwapObserverTarget()
Turns off swapping of observer/target (default)
Definition: LightTimeCorrectionState.cpp:282
Isis::LightTimeCorrectionState::setNoCorrectLightTimeToSurface
void setNoCorrectLightTimeToSurface()
Disables state of light time from surface to center body for correction.
Definition: LightTimeCorrectionState.cpp:334
Isis::LightTimeCorrectionState::isLightTimeToSurfaceCorrected
bool isLightTimeToSurfaceCorrected() const
Returns state of light time from surface to center body correction.
Definition: LightTimeCorrectionState.cpp:323
Isis::LightTimeCorrectionState::operator==
bool operator==(const LightTimeCorrectionState &state) const
Compare two instances of the LightTimeCorrectionState objects.
Definition: LightTimeCorrectionState.cpp:78
Isis::LightTimeCorrectionState::setCorrectLightTimeToSurface
void setCorrectLightTimeToSurface()
Sets state of light time from surface to center body for orrection.
Definition: LightTimeCorrectionState.cpp:328
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

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the USGS Astrogeology Discussion Board
To report a bug, or suggest a feature go to: ISIS Github
File Modified: 07/13/2023 15:16:47