Isis 3.0
Back | Home
SpicePosition.h
Go to the documentation of this file.
1 #ifndef SpicePosition_h
2 #define SpicePosition_h
3 
25 #include <string>
26 #include <vector>
27 
28 #include <SpiceUsr.h>
29 #include <SpiceZfc.h>
30 #include <SpiceZmc.h>
31 
32 #include "Table.h"
33 #include "PolynomialUnivariate.h"
34 
35 namespace Isis {
36  class NumericalApproximation;
37 
181  public:
182  //??? jw
187  enum Source { Spice,
192  // table and adding nth degree polynomial
193  };
194 
195  SpicePosition(int targetCode, int observerCode);
196 
198  virtual ~SpicePosition();
199 
200  void SetTimeBias(double timeBias);
201  double GetTimeBias() const;
202 
203  virtual void SetAberrationCorrection(const QString &correction);
204  virtual QString GetAberrationCorrection() const;
205  double GetLightTime() const;
206 
207  const std::vector<double> &SetEphemerisTime(double et);
209 
211  double EphemerisTime() const {
212  return p_et;
213  };
214 
215  const std::vector<double> &GetCenterCoordinate();
216 
218  const std::vector<double> &Coordinate() {
219  return p_coordinate;
220  };
221 
223  const std::vector<double> &Velocity();
224 
226  bool HasVelocity() {
227  return p_hasVelocity;
228  };
229 
230  void LoadCache(double startTime, double endTime, int size);
231  void LoadCache(double time);
232  void LoadCache(Table &table);
233 
234  Table LineCache(const QString &tableName);
235  Table LoadHermiteCache(const QString &tableName);
236 
237  void ReloadCache();
238  void ReloadCache(Table &table);
239 
240  Table Cache(const QString &tableName);
241 
243  bool IsCached() const {
244  return (p_cache.size() > 0);
245  };
246 
247  void SetPolynomial(const Source type = PolyFunction);
248 
249  void SetPolynomial(const std::vector<double>& XC,
250  const std::vector<double>& YC,
251  const std::vector<double>& ZC,
252  const Source type = PolyFunction);
253 
254  void GetPolynomial(std::vector<double>& XC,
255  std::vector<double>& YC,
256  std::vector<double>& ZC);
257 
259  void SetPolynomialDegree(int degree);
260 
263  return p_source;
264  };
265 
266  void ComputeBaseTime();
267 
269  double GetBaseTime() {
270  return p_baseTime;
271  };
272 
273  void SetOverrideBaseTime(double baseTime, double timeScale);
274 
276  double GetTimeScale() {
277  return p_timeScale;
278  };
279 
280  double DPolynomial(const int coeffIndex);
281 
282  std::vector<double> CoordinatePartial(SpicePosition::PartialType partialVar, int coeffIndex);
283 
284  std::vector<double> VelocityPartial(SpicePosition::PartialType partialVar, int coeffIndex);
286  void Memcache2HermiteCache(double tolerance);
287  std::vector<double> Extrapolate(double timeEt);
288  std::vector<double> HermiteCoordinate();
289  protected:
292  virtual void SetEphemerisTimeSpice();
295 
296  std::vector<int> HermiteIndices(double tol, std::vector <int> indexList);
297 
298  //======================================================================
299  // New methods support for light time correction and swap of observer/target
300  SpicePosition(int targetCode, int observerCode, bool swapObserverTarget);
301  int getObserverCode() const;
302  int getTargetCode() const;
303  double getAdjustedEphemerisTime() const;
304  void computeStateVector(double et, int target, int observer,
305  const QString &refFrame,
306  const QString &abcorr,
307  double state[6], bool &hasVelocity,
308  double &lightTime) const;
309  void setStateVector(const double state[6], const bool &hasVelocity);
310  void setLightTime(const double &lightTime);
311  //======================================================================
312 
313  private:
314  void init(int targetCode, int observerCode,
315  const bool &swapObserverTarget = false);
316  void ClearCache();
317  void LoadTimeCache();
318  void CacheLabel(Table &table);
319  double ComputeVelocityInTime(PartialType var);
320 
321  int p_targetCode;
322  int p_observerCode;
323 
324  double p_timeBias;
325  QString p_aberrationCorrection;
326 
327  double p_et;
328  std::vector<double> p_coordinate;
329  std::vector<double> p_velocity;
330 
332  NumericalApproximation *p_xhermite;
334  NumericalApproximation *p_yhermite;
336  NumericalApproximation *p_zhermite;
337 
338  Source p_source;
339  std::vector<double> p_cacheTime;
340  std::vector<std::vector<double> > p_cache;
341  std::vector<std::vector<double> > p_cacheVelocity;
342  std::vector<double> p_coefficients[3];
343 
344  double p_baseTime;
345  double p_timeScale;
346  bool p_degreeApplied;
347  // of degree p_degree has been created and
348  // used to fill the cache
349  int p_degree;
350  double p_fullCacheStartTime;
351  double p_fullCacheEndTime;
352  double p_fullCacheSize;
353  bool p_hasVelocity;
354  OverrideType p_override;
355  double p_overrideBaseTime;
356  double p_overrideTimeScale;
357 
358  // Variables support observer/target swap and light time correction
359  bool m_swapObserverTarget;
360  double m_lt;
361  };
362 };
363 
364 #endif
Definition: SpicePosition.h:285
Object is reading from splined table.
Definition: SpicePosition.h:189
virtual QString GetAberrationCorrection() const
Returns current state of stellar aberration correction.
Definition: SpicePosition.cpp:206
const std::vector< double > & GetCenterCoordinate()
Compute and return the coordinate at the center time.
Definition: SpicePosition.cpp:1721
virtual ~SpicePosition()
Destructor.
Definition: SpicePosition.cpp:126
int getTargetCode() const
Returns target code.
Definition: SpicePosition.cpp:1824
Object is calculated from nth degree polynomial.
Definition: SpicePosition.h:190
virtual void SetAberrationCorrection(const QString &correction)
Set the aberration correction (light time)
Definition: SpicePosition.cpp:179
std::vector< double > Extrapolate(double timeEt)
Extrapolate position for a given time assuming a constant velocity.
Definition: SpicePosition.cpp:1761
Definition: SpicePosition.h:208
void SetTimeBias(double timeBias)
Apply a time bias when invoking SetEphemerisTime method.
Definition: SpicePosition.cpp:143
double GetLightTime() const
Return the light time coorection value.
Definition: SpicePosition.cpp:223
Object is reading from cached table.
Definition: SpicePosition.h:188
bool IsCached() const
Is this position cached.
Definition: SpicePosition.h:243
std::vector< double > CoordinatePartial(SpicePosition::PartialType partialVar, int coeffIndex)
Set the coefficients of a polynomial fit to each of the three coordinates of the position vector for ...
Definition: SpicePosition.cpp:1091
Definition: SpicePosition.h:285
void ComputeBaseTime()
Compute the base time using cached times.
Definition: SpicePosition.cpp:1040
NumericalApproximation provides various numerical analysis methods of interpolation, extrapolation and approximation of a tabulated set of x, y data.
Definition: NumericalApproximation.h:720
void SetEphemerisTimePolyFunctionOverHermiteConstant()
This is a protected method that is called by SetEphemerisTime() when Source type is PolyFunctionOverH...
Definition: SpicePosition.cpp:1416
void LoadCache(double startTime, double endTime, int size)
Cache J2000 position over a time range.
Definition: SpicePosition.cpp:287
void ReloadCache()
Cache J2000 positions over existing cached time range using polynomials.
Definition: SpicePosition.cpp:660
OverrideType
Definition: SpicePosition.h:285
Table Cache(const QString &tableName)
Return a table with J2000 positions.
Definition: SpicePosition.cpp:479
void SetEphemerisTimePolyFunction()
This is a protected method that is called by SetEphemerisTime() when Source type is PolyFunction...
Definition: SpicePosition.cpp:1369
int getObserverCode() const
Returns observer code.
Definition: SpicePosition.cpp:1810
Source GetSource()
Return the source of the position.
Definition: SpicePosition.h:262
Object is reading from splined.
Definition: SpicePosition.h:191
bool HasVelocity()
Return the flag indicating whether the velocity exists.
Definition: SpicePosition.h:226
Definition: SpicePosition.h:285
PartialType
Definition: SpicePosition.h:208
void setStateVector(const double state[6], const bool &hasVelocity)
Sets the state of target relative to observer.
Definition: SpicePosition.cpp:1929
const std::vector< double > & Coordinate()
Return the current J2000 position.
Definition: SpicePosition.h:218
void SetPolynomialDegree(int degree)
Set the polynomial degree.
Definition: SpicePosition.cpp:1638
void SetOverrideBaseTime(double baseTime, double timeScale)
Set an override base time to be used with observations on scanners to allow all images in an observat...
Definition: SpicePosition.cpp:1071
std::vector< int > HermiteIndices(double tol, std::vector< int > indexList)
This method is called by Memcache2HermiteCache() to determine which indices from the orginal cache sh...
Definition: SpicePosition.cpp:1538
double GetTimeBias() const
Returns the value of the time bias added to ET.
Definition: SpicePosition.cpp:154
void SetEphemerisTimeHermiteCache()
This is a protected method that is called by SetEphemerisTime() when Source type is HermiteCache...
Definition: SpicePosition.cpp:1281
Definition: SpicePosition.h:208
void Memcache2HermiteCache(double tolerance)
This method reduces the cache for position, time and velocity to the minimum number of values needed ...
Definition: SpicePosition.cpp:1478
double DPolynomial(const int coeffIndex)
Evaluate the derivative of the fit polynomial (parabola) defined by the given coefficients with respe...
Definition: SpicePosition.cpp:1168
void SetEphemerisTimeMemcache()
This is a protected method that is called by SetEphemerisTime() when Source type is Memcache...
Definition: SpicePosition.cpp:1218
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:1877
Class for storing Table blobs information.
Definition: Table.h:74
double GetTimeScale()
Return the time scale for the position.
Definition: SpicePosition.h:276
std::vector< double > VelocityPartial(SpicePosition::PartialType partialVar, int coeffIndex)
Compute the derivative of the velocity with respect to the specified variable.
Definition: SpicePosition.cpp:1132
Obtain SPICE position information for a body.
Definition: SpicePosition.h:180
const std::vector< double > & Velocity()
Return the current J2000 velocity.
Definition: SpicePosition.cpp:1193
Table LineCache(const QString &tableName)
Return a table with J2000 to reference positions.
Definition: SpicePosition.cpp:635
void setLightTime(const double &lightTime)
Inheritors can set the light time if indicated.
Definition: SpicePosition.cpp:1959
double GetBaseTime()
Return the base time for the position.
Definition: SpicePosition.h:269
Table LoadHermiteCache(const QString &tableName)
Cache J2000 position over existing cached time range using polynomials stored as Hermite cubic spline...
Definition: SpicePosition.cpp:720
const std::vector< double > & SetEphemerisTime(double et)
Return J2000 coordinate at given time.
Definition: SpicePosition.cpp:242
Definition: SpicePosition.h:208
std::vector< double > HermiteCoordinate()
This method returns the Hermite coordinate for the current time for PolyFunctionOverHermiteConstant f...
Definition: SpicePosition.cpp:1781
SpicePosition(int targetCode, int observerCode)
Construct an empty SpicePosition class using valid body codes.
Definition: SpicePosition.cpp:29
Object is reading directly from the kernels.
Definition: SpicePosition.h:187
virtual void SetEphemerisTimeSpice()
This is a protected method that is called by SetEphemerisTime() when Source type is Spice...
Definition: SpicePosition.cpp:1447
double getAdjustedEphemerisTime() const
Returns adjusted ephemeris time.
Definition: SpicePosition.cpp:1840
double EphemerisTime() const
Return the current ephemeris time.
Definition: SpicePosition.h:211
void GetPolynomial(std::vector< double > &XC, std::vector< double > &YC, std::vector< double > &ZC)
Return the coefficients of a polynomial fit to each of the three coordinates of the position for the ...
Definition: SpicePosition.cpp:1027
Source
This enum indicates the status of the object.
Definition: SpicePosition.h:187
void SetPolynomial(const Source type=PolyFunction)
Set the coefficients of a polynomial fit to each of the components (X, Y, Z) of the position vector f...
Definition: SpicePosition.cpp:855

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 ISIS Support Center
File Modified: 07/12/2023 23:29:18