Isis 3 Programmer Reference
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 
184  public:
185  //??? jw
190  enum Source { Spice,
195  // table and adding nth degree polynomial
196  };
197 
198  SpicePosition(int targetCode, int observerCode);
199 
201  virtual ~SpicePosition();
202 
203  void SetTimeBias(double timeBias);
204  double GetTimeBias() const;
205 
206  virtual void SetAberrationCorrection(const QString &correction);
207  virtual QString GetAberrationCorrection() const;
208  double GetLightTime() const;
209 
210  const std::vector<double> &SetEphemerisTime(double et);
211  enum PartialType {WRT_X, WRT_Y, WRT_Z};
212 
214  double EphemerisTime() const {
215  return p_et;
216  };
217 
218  const std::vector<double> &GetCenterCoordinate();
219 
221  const std::vector<double> &Coordinate() {
222  return p_coordinate;
223  };
224 
226  const std::vector<double> &Velocity();
227 
229  bool HasVelocity() {
230  return p_hasVelocity;
231  };
232 
233  void LoadCache(double startTime, double endTime, int size);
234  void LoadCache(double time);
235  void LoadCache(Table &table);
236 
237  Table LineCache(const QString &tableName);
238  Table LoadHermiteCache(const QString &tableName);
239 
240  void ReloadCache();
241  void ReloadCache(Table &table);
242 
243  Table Cache(const QString &tableName);
244 
246  bool IsCached() const {
247  return (p_cache.size() > 0);
248  };
249 
250  void SetPolynomial(const Source type = PolyFunction);
251 
252  void SetPolynomial(const std::vector<double>& XC,
253  const std::vector<double>& YC,
254  const std::vector<double>& ZC,
255  const Source type = PolyFunction);
256 
257  void GetPolynomial(std::vector<double>& XC,
258  std::vector<double>& YC,
259  std::vector<double>& ZC);
260 
262  void SetPolynomialDegree(int degree);
263 
266  return p_source;
267  };
268 
269  void ComputeBaseTime();
270 
272  double GetBaseTime() {
273  return p_baseTime;
274  };
275 
276  void SetOverrideBaseTime(double baseTime, double timeScale);
277 
279  double GetTimeScale() {
280  return p_timeScale;
281  };
282 
283  double DPolynomial(const int coeffIndex);
284 
285  std::vector<double> CoordinatePartial(SpicePosition::PartialType partialVar, int coeffIndex);
286 
287  std::vector<double> VelocityPartial(SpicePosition::PartialType partialVar, int coeffIndex);
288  enum OverrideType {NoOverrides, ScaleOnly, BaseAndScale};
289  void Memcache2HermiteCache(double tolerance);
290  std::vector<double> Extrapolate(double timeEt);
291  std::vector<double> HermiteCoordinate();
292  protected:
295  virtual void SetEphemerisTimeSpice();
298 
299  std::vector<int> HermiteIndices(double tol, std::vector <int> indexList);
300 
301  //======================================================================
302  // New methods support for light time correction and swap of observer/target
303  SpicePosition(int targetCode, int observerCode, bool swapObserverTarget);
304  int getObserverCode() const;
305  int getTargetCode() const;
306  double getAdjustedEphemerisTime() const;
307  void computeStateVector(double et, int target, int observer,
308  const QString &refFrame,
309  const QString &abcorr,
310  double state[6], bool &hasVelocity,
311  double &lightTime) const;
312  void setStateVector(const double state[6], const bool &hasVelocity);
313  void setLightTime(const double &lightTime);
314  //======================================================================
315 
316  private:
317  void init(int targetCode, int observerCode,
318  const bool &swapObserverTarget = false);
319  void ClearCache();
320  void LoadTimeCache();
321  void CacheLabel(Table &table);
322  double ComputeVelocityInTime(PartialType var);
323 
326 
327  double p_timeBias;
329 
330  double p_et;
331  std::vector<double> p_coordinate;
332  std::vector<double> p_velocity;
333 
340 
342  std::vector<double> p_cacheTime;
343  std::vector<std::vector<double> > p_cache;
344  std::vector<std::vector<double> > p_cacheVelocity;
345  std::vector<double> p_coefficients[3];
346 
347  double p_baseTime;
348  double p_timeScale;
350  // of degree p_degree has been created and
351  // used to fill the cache
352  int p_degree;
357  OverrideType p_override;
360 
361  // Variables support observer/target swap and light time correction
362  bool m_swapObserverTarget;
363  double m_lt;
364  };
365 };
366 
367 #endif
int getObserverCode() const
Returns observer code.
double p_timeScale
Time scale used in fit equations.
Object is reading from splined table.
void CacheLabel(Table &table)
Add labels to a SpicePosition table.
const std::vector< double > & GetCenterCoordinate()
Compute and return the coordinate at the center time.
double p_timeBias
iTime bias when reading kernels
Source p_source
Enumerated value for the location of the SPK information used.
double GetLightTime() const
Return the light time coorection value.
virtual ~SpicePosition()
Destructor.
Object is calculated from nth degree polynomial.
int p_degree
Degree of polynomial function fit to the coordinates of the position.
virtual void SetAberrationCorrection(const QString &correction)
Set the aberration correction (light time)
std::vector< double > Extrapolate(double timeEt)
Extrapolate position for a given time assuming a constant velocity.
void SetTimeBias(double timeBias)
Apply a time bias when invoking SetEphemerisTime method.
int p_targetCode
target body code
OverrideType p_override
Time base and scale override options;.
double p_fullCacheStartTime
Original start time of the complete cache after spiceinit.
Object is reading from cached table.
double EphemerisTime() const
Return the current ephemeris time.
int getTargetCode() const
Returns target code.
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 ...
void ComputeBaseTime()
Compute the base time using cached times.
NumericalApproximation provides various numerical analysis methods of interpolation, extrapolation and approximation of a tabulated set of x, y data.
double ComputeVelocityInTime(PartialType var)
Compute the velocity with respect to time instead of scaled time.
void SetEphemerisTimePolyFunctionOverHermiteConstant()
This is a protected method that is called by SetEphemerisTime() when Source type is PolyFunctionOverH...
double p_fullCacheEndTime
Original end time of the complete cache after spiceinit.
void LoadCache(double startTime, double endTime, int size)
Cache J2000 position over a time range.
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.
bool IsCached() const
Is this position cached.
void init(int targetCode, int observerCode, const bool &swapObserverTarget=false)
Internal initialization of the object support observer/target swap.
void LoadTimeCache()
Load the time cache.
double p_fullCacheSize
Orignial size of the complete cache after spiceinit.
void ReloadCache()
Cache J2000 positions over existing cached time range using polynomials.
Table Cache(const QString &tableName)
Return a table with J2000 positions.
void SetEphemerisTimePolyFunction()
This is a protected method that is called by SetEphemerisTime() when Source type is PolyFunction...
std::vector< double > p_coordinate
J2000 position at time et.
NumericalApproximation * p_xhermite
Hermite spline for x coordinate if Source == HermiteCache.
Source GetSource()
Return the source of the position.
std::vector< double > p_coefficients[3]
Coefficients of polynomials fit to 3 coordinates.
virtual QString GetAberrationCorrection() const
Returns current state of stellar aberration correction.
double p_baseTime
Base time used in fit equations.
double getAdjustedEphemerisTime() const
Returns adjusted ephemeris time.
bool HasVelocity()
Return the flag indicating whether the velocity exists.
void ClearCache()
Removes the entire cache from memory.
bool p_hasVelocity
Flag to indicate velocity is available.
QString p_aberrationCorrection
Light time correction to apply.
void setStateVector(const double state[6], const bool &hasVelocity)
Sets the state of target relative to observer.
const std::vector< double > & Coordinate()
Return the current J2000 position.
void SetPolynomialDegree(int degree)
Set the polynomial degree.
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...
int p_observerCode
observer body code
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...
double p_overrideBaseTime
Value set by caller to override computed base time.
NumericalApproximation * p_zhermite
Hermite spline for z coordinate if Source == HermiteCache.
void SetEphemerisTimeHermiteCache()
This is a protected method that is called by SetEphemerisTime() when Source type is HermiteCache...
void Memcache2HermiteCache(double tolerance)
This method reduces the cache for position, time and velocity to the minimum number of values needed ...
double p_et
Current ephemeris time.
double DPolynomial(const int coeffIndex)
Evaluate the derivative of the fit polynomial (parabola) defined by the given coefficients with respe...
void SetEphemerisTimeMemcache()
This is a protected method that is called by SetEphemerisTime() when Source type is Memcache...
std::vector< double > p_velocity
J2000 velocity at time et.
bool p_degreeApplied
Flag indicating whether or not a polynomial.
Class for storing Table blobs information.
Definition: Table.h:77
NumericalApproximation * p_yhermite
Hermite spline for y coordinate if Source == HermiteCache.
double GetTimeScale()
Return the time scale for the position.
std::vector< double > VelocityPartial(SpicePosition::PartialType partialVar, int coeffIndex)
Compute the derivative of the velocity with respect to the specified variable.
Obtain SPICE position information for a body.
const std::vector< double > & Velocity()
Return the current J2000 velocity.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
Table LineCache(const QString &tableName)
Return a table with J2000 to reference positions.
void setLightTime(const double &lightTime)
Inheritors can set the light time if indicated.
double GetBaseTime()
Return the base time for the position.
Table LoadHermiteCache(const QString &tableName)
Cache J2000 position over existing cached time range using polynomials stored as Hermite cubic spline...
const std::vector< double > & SetEphemerisTime(double et)
Return J2000 coordinate at given time.
double m_lt
!< Swap traditional order
std::vector< std::vector< double > > p_cacheVelocity
Cached velocities.
std::vector< double > HermiteCoordinate()
This method returns the Hermite coordinate for the current time for PolyFunctionOverHermiteConstant f...
SpicePosition(int targetCode, int observerCode)
Construct an empty SpicePosition class using valid body codes.
Object is reading directly from the kernels.
std::vector< double > p_cacheTime
iTime for corresponding position
double p_overrideTimeScale
Value set by caller to override computed time scale.
virtual void SetEphemerisTimeSpice()
This is a protected method that is called by SetEphemerisTime() when Source type is Spice...
double GetTimeBias() const
Returns the value of the time bias added to ET.
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 ...
std::vector< std::vector< double > > p_cache
Cached positions.
Source
This enum indicates the status of the object.
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...