Isis 3 Programmer Reference
Isis::SpacecraftPosition Class Reference

Provides swap observer/target and improved light time correction. More...

#include <SpacecraftPosition.h>

Inheritance diagram for Isis::SpacecraftPosition:
Inheritance graph
Collaboration diagram for Isis::SpacecraftPosition:
Collaboration graph

Public Types

enum  Source {
  Spice, Memcache, HermiteCache, PolyFunction,
  PolyFunctionOverHermiteConstant
}
 This enum indicates the status of the object. More...
 
enum  PartialType { WRT_X, WRT_Y, WRT_Z }
 
enum  OverrideType { NoOverrides, ScaleOnly, BaseAndScale }
 

Public Member Functions

 SpacecraftPosition (int targetCode, int observerCode, const LightTimeCorrectionState &ltState=LightTimeCorrectionState(), const Distance &radius=Distance(0.0, Distance::Meters))
 constructor for swapping observer/target parameters More...
 
double getRadiusLightTime () const
 Returns the time it takes for light to travel the radius of the target. More...
 
virtual void SetAberrationCorrection (const QString &correction)
 Set aberration correction value for determining positions. More...
 
virtual QString GetAberrationCorrection () const
 Returns the stellr aberration correction applied. More...
 
virtual void SetEphemerisTimeSpice ()
 Determine accurate position of target w.r.t. More...
 
const LightTimeCorrectionStategetLightTimeState () const
 Return the state of light time correction parameters. More...
 
void SetTimeBias (double timeBias)
 Apply a time bias when invoking SetEphemerisTime method. More...
 
double GetTimeBias () const
 Returns the value of the time bias added to ET. More...
 
double GetLightTime () const
 Return the light time coorection value. More...
 
const std::vector< double > & SetEphemerisTime (double et)
 Return J2000 coordinate at given time. More...
 
double EphemerisTime () const
 Return the current ephemeris time. More...
 
const std::vector< double > & GetCenterCoordinate ()
 Compute and return the coordinate at the center time. More...
 
const std::vector< double > & Coordinate ()
 Return the current J2000 position. More...
 
const std::vector< double > & Velocity ()
 Return the current J2000 velocity. More...
 
bool HasVelocity ()
 Return the flag indicating whether the velocity exists. More...
 
void LoadCache (double startTime, double endTime, int size)
 Cache J2000 position over a time range. More...
 
void LoadCache (double time)
 Cache J2000 position for a time. More...
 
void LoadCache (Table &table)
 Cache J2000 positions using a table file. More...
 
Table LineCache (const QString &tableName)
 Return a table with J2000 to reference positions. More...
 
Table LoadHermiteCache (const QString &tableName)
 Cache J2000 position over existing cached time range using polynomials stored as Hermite cubic spline knots. More...
 
void ReloadCache ()
 Cache J2000 positions over existing cached time range using polynomials. More...
 
void ReloadCache (Table &table)
 Cache J2000 position over existing cached time range using table. More...
 
Table Cache (const QString &tableName)
 Return a table with J2000 positions. More...
 
bool IsCached () const
 Is this position cached. More...
 
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 for the time period covered by the cache, component = c0 + c1*t + c2*t**2 + ... More...
 
void SetPolynomial (const std::vector< double > &XC, const std::vector< double > &YC, const std::vector< double > &ZC, const Source type=PolyFunction)
 Set the coefficients of a polynomial (parabola) fit to each of the three coordinates of the position vector for the time period covered by the cache, coord = c0 + c1*t + c2*t**2 + ... More...
 
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 time period covered by the cache, angle = c0 + c1*t + c2*t**2 + ... More...
 
void SetPolynomialDegree (int degree)
 Set the polynomial degree. More...
 
Source GetSource ()
 Return the source of the position. More...
 
void ComputeBaseTime ()
 Compute the base time using cached times. More...
 
double GetBaseTime ()
 Return the base time for the position. More...
 
void SetOverrideBaseTime (double baseTime, double timeScale)
 Set an override base time to be used with observations on scanners to allow all images in an observation to use the same base time and polynomials for the positions. More...
 
double GetTimeScale ()
 Return the time scale for the position. More...
 
double DPolynomial (const int coeffIndex)
 Evaluate the derivative of the fit polynomial (parabola) defined by the given coefficients with respect to the coefficient at the given index, at the current time. More...
 
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 the time period covered by the cache,. More...
 
std::vector< double > VelocityPartial (SpicePosition::PartialType partialVar, int coeffIndex)
 Compute the derivative of the velocity with respect to the specified variable. More...
 
void Memcache2HermiteCache (double tolerance)
 This method reduces the cache for position, time and velocity to the minimum number of values needed to interpolate the J2000 coordinates using a Hermite spline, given a tolerance of deviation from the NAIF values. More...
 
std::vector< double > Extrapolate (double timeEt)
 Extrapolate position for a given time assuming a constant velocity. More...
 
std::vector< double > HermiteCoordinate ()
 This method returns the Hermite coordinate for the current time for PolyFunctionOverHermiteConstant functions. More...
 

Static Public Member Functions

static double getDistanceLightTime (const Distance &distance)
 Returns the time it takes for light to travel a given distance. More...
 

Protected Member Functions

void SetEphemerisTimeMemcache ()
 This is a protected method that is called by SetEphemerisTime() when Source type is Memcache. More...
 
void SetEphemerisTimeHermiteCache ()
 This is a protected method that is called by SetEphemerisTime() when Source type is HermiteCache. More...
 
void SetEphemerisTimePolyFunction ()
 This is a protected method that is called by SetEphemerisTime() when Source type is PolyFunction. More...
 
void SetEphemerisTimePolyFunctionOverHermiteConstant ()
 This is a protected method that is called by SetEphemerisTime() when Source type is PolyFunctionOverHermiteConstant. More...
 
std::vector< int > HermiteIndices (double tol, std::vector< int > indexList)
 This method is called by Memcache2HermiteCache() to determine which indices from the orginal cache should be saved in the reduced cache. More...
 
int getObserverCode () const
 Returns observer code. More...
 
int getTargetCode () const
 Returns target code. More...
 
double getAdjustedEphemerisTime () const
 Returns adjusted ephemeris time. More...
 
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. More...
 
void setStateVector (const double state[6], const bool &hasVelocity)
 Sets the state of target relative to observer. More...
 
void setLightTime (const double &lightTime)
 Inheritors can set the light time if indicated. More...
 

Private Attributes

LightTimeCorrectionState m_abcorr
 Light time correction state. More...
 
Distance m_radius
 Radius of target. More...
 

Detailed Description

Provides swap observer/target and improved light time correction.

The process by which ISIS has determined the position of the spacecraft w.r.t a target body is by utilizing the NAIF spkez_c/spkezp_c routines. Recently it has been determined that the parameters for observer (or spacecraft) and target (typically a planet) has been swapped. This results in a slightly different location of the s/c. This class provides programmers with a way to swap these parameters at runtime by providing a different instantiation option.

This implementation was chosen to mostly hide this option as it the full impact of this chage is still being evaluated for all supported instruments in ISIS.

This implementation provides the ability to swap observer/target parameters selectively as deemed appropriate by API developers. See the Spice class for how this class is being utilized.

In addition, this class provides the ability to correct for stellar aberration and light time to the target body surface (via a reimplementation of SetEphemerisSpiceTime()). This mostly fixes the problem of accurate light time correction. What remains is applying this fix on a per pixel basis. It is most accurate at the subspacecraft lat/lon point on the target body surface.

See also
Spice
LightTimeCorrectionState
SpicePosition
Author
2012-10-11 Kris Becker
History:

2012-10-31 Kris Becker - New class implements swapping of observer/target and light time correction to surface. Fixes (mostly) #0909, #1136 and #1223.

2012-11-01 Kris Becker - Revised parameter order to computeStateVector to match comments. References #1136.

2012-12-04 Kris Becker - Corrected documentation

Definition at line 74 of file SpacecraftPosition.h.

Member Enumeration Documentation

◆ Source

This enum indicates the status of the object.

The class expects functions to be after MemCache in the list.

Enumerator
Spice 

Object is reading directly from the kernels.

Memcache 

Object is reading from cached table.

HermiteCache 

Object is reading from splined table.

PolyFunction 

Object is calculated from nth degree polynomial.

PolyFunctionOverHermiteConstant 

Object is reading from splined.

Definition at line 190 of file SpicePosition.h.

Constructor & Destructor Documentation

◆ SpacecraftPosition()

Isis::SpacecraftPosition::SpacecraftPosition ( int  targetCode,
int  observerCode,
const LightTimeCorrectionState ltState = LightTimeCorrectionState(),
const Distance radius = Distance(0.0, Distance::Meters) 
)

constructor for swapping observer/target parameters

This constructor utlizes a protected constructor in the SpicePosition class specially designed to handle this option. Passing false into this constructor results in preexisting behavior. True will swap observer/target when determining the s/c position.

It is critical that the targetCode and observerCode be of the same exact order as they are in preexisting code. This is consistent with the current SpicePosition constructor with an additional boolean parameter that indicates to treat the targetCode as the observer and the observerCode as the target.

Author
2012-10-11 Kris Becker
Parameters
targetCodeNAIF code for target
observerCodeNAIF code for observer
swapObserverTargetBoolean to specify swap

Definition at line 63 of file SpacecraftPosition.cpp.

References m_abcorr, and m_radius.

Member Function Documentation

◆ Cache()

Table Isis::SpicePosition::Cache ( const QString &  tableName)
inherited

Return a table with J2000 positions.

Return a table containg the cached coordinates with the given name. The table will have four or seven columns, J2000 x,y,z (optionally vx,vy,vx) and the ephemeris time.

Parameters
tableNameName of the table to create and return
History:

2009-08-03 Jeannie Walldren - Added CacheType keyword to output table. This is based on p_source and will be read by LoadCache(Table).

2011-01-05 Debbie A. Cook - Added PolyFunction

Definition at line 479 of file SpicePosition.cpp.

References _FILEINFO_, Isis::SpicePosition::CacheLabel(), Isis::TableField::Double, Isis::IException::Io, Isis::SpicePosition::LineCache(), Isis::SpicePosition::Memcache2HermiteCache(), Isis::SpicePosition::p_baseTime, Isis::SpicePosition::p_cache, Isis::SpicePosition::p_cacheTime, Isis::SpicePosition::p_cacheVelocity, Isis::SpicePosition::p_coefficients, Isis::SpicePosition::p_degree, Isis::SpicePosition::p_fullCacheSize, Isis::SpicePosition::p_hasVelocity, Isis::SpicePosition::p_source, Isis::SpicePosition::p_timeScale, Isis::SpicePosition::PolyFunction, and Isis::SpicePosition::PolyFunctionOverHermiteConstant.

Referenced by Isis::SpicePosition::LineCache(), and Isis::SpicePosition::LoadHermiteCache().

◆ ComputeBaseTime()

◆ computeStateVector()

void Isis::SpicePosition::computeStateVector ( double  et,
int  target,
int  observer,
const QString &  refFrame,
const QString &  abcorr,
double  state[6],
bool &  hasVelocity,
double &  lightTime 
) const
protectedinherited

Computes the state vector of the target w.r.t observer.

This method computes the state vector of the target that is relative of the observer. It first attempts to retrieve with velocity vectors. If that fails, it makes an additional attempt to get the state w/o velocity vectors. The final result is indicated by the hasVelocity parameter.

The parameters to this routine are the same as the NAIF spkez_c/spkezp_c routines. See http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/spkez_c.html for complete description.

Note that this routine does not actually affect the internals of this object (hence the constness of the method). It is up to the caller to apply the results and potentially handle swapping of observer/target and light time correction. See SpacecraftPosition for additional details on this application of the results.

Author
2012-10-29 Kris Becker
Parameters
etTime to compute state vector for
targetNAIF target code
observerNAIF observer code
refFrameReference frame to express coordinates in (e.g., J2000)
abcorrStellar aberration correction option
stateReturns the 6-element state vector in target body fixed coordinates
hasVelocityReturns knowledge of whether the velocity vector is valid
lightTimeReturns the light time correct resulting from the request if applicable

Definition at line 1879 of file SpicePosition.cpp.

References Isis::NaifStatus::CheckErrors().

Referenced by SetEphemerisTimeSpice(), and Isis::SpicePosition::SetEphemerisTimeSpice().

◆ Coordinate()

const std::vector<double>& Isis::SpicePosition::Coordinate ( )
inlineinherited

◆ CoordinatePartial()

std::vector< double > Isis::SpicePosition::CoordinatePartial ( SpicePosition::PartialType  partialVar,
int  coeffIndex 
)
inherited

Set the coefficients of a polynomial fit to each of the three coordinates of the position vector for the time period covered by the cache,.

coordinate = c0 + c1*t + c2*t**2 + ... cn*t**n, where t = (time - p_basetime) / p_timeScale.

Parameters
partialVarDesignated variable of the partial derivative
Returns
Derivative of j2000 vector calculated with polynomial with respect to partialVar

Definition at line 1091 of file SpicePosition.cpp.

References Isis::SpicePosition::DPolynomial().

Referenced by Isis::CameraGroundMap::GetdXYdPosition(), and Isis::RadarGroundMap::GetdXYdPosition().

◆ DPolynomial()

double Isis::SpicePosition::DPolynomial ( const int  coeffIndex)
inherited

Evaluate the derivative of the fit polynomial (parabola) defined by the given coefficients with respect to the coefficient at the given index, at the current time.

Parameters
coeffIndexIndex of coefficient to differentiate with respect to
Returns
The derivative evaluated at the current time

Definition at line 1168 of file SpicePosition.cpp.

References _FILEINFO_, Isis::SpicePosition::p_baseTime, Isis::SpicePosition::p_degree, Isis::SpicePosition::p_et, Isis::SpicePosition::p_timeScale, Isis::IException::Programmer, and Isis::toString().

Referenced by Isis::SpicePosition::CoordinatePartial().

◆ EphemerisTime()

double Isis::SpicePosition::EphemerisTime ( ) const
inlineinherited

Return the current ephemeris time.

Definition at line 214 of file SpicePosition.h.

References Isis::SpicePosition::p_et.

Referenced by Isis::SpicePosition::getAdjustedEphemerisTime().

◆ Extrapolate()

std::vector< double > Isis::SpicePosition::Extrapolate ( double  timeEt)
inherited

Extrapolate position for a given time assuming a constant velocity.

The position and velocity at the current time will be used to extrapolate position at the input time. If velocity does not exist, the value at the current time will be output. The caller must make sure to call SetEphemerisTime to set the time to the time to be used for the extrapolation.

Parameters
[in]timeEtThe time of the position to be extrapolated
[out]Anextrapolated position at the input time

Definition at line 1763 of file SpicePosition.cpp.

References Isis::SpicePosition::p_coordinate, Isis::SpicePosition::p_et, Isis::SpicePosition::p_hasVelocity, and Isis::SpicePosition::p_velocity.

◆ GetAberrationCorrection()

QString Isis::SpacecraftPosition::GetAberrationCorrection ( ) const
virtual

Returns the stellr aberration correction applied.

Author
2012-10-29 Kris Becker

Reimplemented from Isis::SpicePosition.

Definition at line 125 of file SpacecraftPosition.cpp.

References Isis::LightTimeCorrectionState::getAberrationCorrection(), and m_abcorr.

Referenced by SetEphemerisTimeSpice().

◆ getAdjustedEphemerisTime()

double Isis::SpicePosition::getAdjustedEphemerisTime ( ) const
protectedinherited

Returns adjusted ephemeris time.

This method returns the actual ephemeris time adjusted by a specifed time bias. The bias typically comes explicitly from the camera model but could be adjusted by the environment they are utlized in.

Author
2012-10-29 Kris Becker
Returns
double Adjusted ephemeris time with time bias applied

Definition at line 1842 of file SpicePosition.cpp.

References Isis::SpicePosition::EphemerisTime(), and Isis::SpicePosition::GetTimeBias().

Referenced by SetEphemerisTimeSpice(), and Isis::SpicePosition::SetEphemerisTimeSpice().

◆ GetBaseTime()

double Isis::SpicePosition::GetBaseTime ( )
inlineinherited

Return the base time for the position.

Definition at line 272 of file SpicePosition.h.

References Isis::SpicePosition::p_baseTime.

◆ GetCenterCoordinate()

const std::vector< double > & Isis::SpicePosition::GetCenterCoordinate ( )
inherited

◆ getDistanceLightTime()

double Isis::SpacecraftPosition::getDistanceLightTime ( const Distance distance)
static

Returns the time it takes for light to travel a given distance.

Author
2012-10-23 Kris Becker
Parameters
radiusDistance to compute light time travel for
Returns
double Time in seconds it takes light to travel given distance

Definition at line 102 of file SpacecraftPosition.cpp.

References Isis::Distance::kilometers().

◆ GetLightTime()

double Isis::SpicePosition::GetLightTime ( ) const
inherited

Return the light time coorection value.

This method returns the light time correction of the last call to SetEphemerisTimeSpice. This is the actual time after adjustments that has resulting int the adjustment of the target body. The observer position should be unchanged.

Author
2012-10-29 Kris Becker
Returns
double Returns the light time determined from the last call to SetEphemerisTime[Spice].

Definition at line 223 of file SpicePosition.cpp.

References Isis::SpicePosition::m_lt.

◆ getLightTimeState()

const LightTimeCorrectionState & Isis::SpacecraftPosition::getLightTimeState ( ) const

Return the state of light time correction parameters.

Author
Kris Becker - 10/23/2012
Returns
LightTimeCorrectionState Light time state

Definition at line 212 of file SpacecraftPosition.cpp.

References m_abcorr.

◆ getObserverCode()

int Isis::SpicePosition::getObserverCode ( ) const
protectedinherited

Returns observer code.

This methods returns the proper observer code as specified in constructor. Code has been subjected to swapping if requested.

Author
2012-10-29 Kris Becker
Returns
int NAIF code of observer

Definition at line 1812 of file SpicePosition.cpp.

References Isis::SpicePosition::p_observerCode.

Referenced by SetEphemerisTimeSpice(), and Isis::SpicePosition::SetEphemerisTimeSpice().

◆ GetPolynomial()

void Isis::SpicePosition::GetPolynomial ( std::vector< double > &  XC,
std::vector< double > &  YC,
std::vector< double > &  ZC 
)
inherited

Return the coefficients of a polynomial fit to each of the three coordinates of the position for the time period covered by the cache, angle = c0 + c1*t + c2*t**2 + ...

  • cn*t**n, where t = (time - p_basetime) / p_timeScale.
Parameters
[out]XCCoefficients of fit to first coordinate of position
[out]YCCoefficients of fit to second coordinate of position
[out]ZCCoefficients of fit to third coordinate of position

Definition at line 1027 of file SpicePosition.cpp.

References Isis::SpicePosition::p_coefficients.

◆ getRadiusLightTime()

double Isis::SpacecraftPosition::getRadiusLightTime ( ) const

Returns the time it takes for light to travel the radius of the target.

This method returns the time in seconds it takes to travel the distance of the radius of the target body. This is a function of the Distance parameter provided at the time this object was constructed.

Author
2012-10-23 Kris Becker
Returns
double Time in seconds it takes light to travel the distance of the radius provided/set in the object

Definition at line 88 of file SpacecraftPosition.cpp.

References Isis::Distance::kilometers(), and m_radius.

Referenced by SetEphemerisTimeSpice().

◆ GetSource()

Source Isis::SpicePosition::GetSource ( )
inlineinherited

Return the source of the position.

Definition at line 265 of file SpicePosition.h.

References Isis::SpicePosition::p_source.

◆ getTargetCode()

int Isis::SpicePosition::getTargetCode ( ) const
protectedinherited

Returns target code.

This methods returns the proper target code as specified in constructor. Code has been subjected to swapping if requested.

Author
2012-10-29 Kris Becker
Returns
int NAIF code for target body

Definition at line 1826 of file SpicePosition.cpp.

References Isis::SpicePosition::p_targetCode.

Referenced by SetEphemerisTimeSpice(), and Isis::SpicePosition::SetEphemerisTimeSpice().

◆ GetTimeBias()

double Isis::SpicePosition::GetTimeBias ( ) const
inherited

Returns the value of the time bias added to ET.

Author
2012-10-29 Kris Becker
Returns
double Returns time bias for current object

Definition at line 154 of file SpicePosition.cpp.

References Isis::SpicePosition::p_timeBias.

Referenced by Isis::SpicePosition::getAdjustedEphemerisTime().

◆ GetTimeScale()

double Isis::SpicePosition::GetTimeScale ( )
inlineinherited

Return the time scale for the position.

Definition at line 279 of file SpicePosition.h.

References Isis::SpicePosition::p_timeScale.

◆ HasVelocity()

bool Isis::SpicePosition::HasVelocity ( )
inlineinherited

Return the flag indicating whether the velocity exists.

Definition at line 229 of file SpicePosition.h.

References Isis::SpicePosition::p_hasVelocity.

◆ HermiteCoordinate()

std::vector< double > Isis::SpicePosition::HermiteCoordinate ( )
inherited

This method returns the Hermite coordinate for the current time for PolyFunctionOverHermiteConstant functions.

See also
SetEphemerisTime()
History:
2012-02-05 Debbie A. Cook - Original version

Definition at line 1783 of file SpicePosition.cpp.

References _FILEINFO_, Isis::SpicePosition::p_coordinate, Isis::SpicePosition::p_source, Isis::SpicePosition::PolyFunctionOverHermiteConstant, Isis::IException::Programmer, and Isis::SpicePosition::SetEphemerisTimeHermiteCache().

◆ HermiteIndices()

std::vector< int > Isis::SpicePosition::HermiteIndices ( double  tolerance,
std::vector< int >  indexList 
)
protectedinherited

This method is called by Memcache2HermiteCache() to determine which indices from the orginal cache should be saved in the reduced cache.

It is a recursive method that starts with an index list of 3 elements (first, center and last index values) and adds values to this list if the tolerance is not met.

Parameters
toleranceMaximum error allowed between NAIF kernel coordinate values and values interpolated by the Hermite spline.
indexListVector containing the list of indices to be kept in the cache. This list grows as the method is recursively called
Returns
vector/<double> Vector containing final list of indices that will be kept for the Hermite cache.
History:

2009-08-03 Jeannie Walldren - Original version.

2009-08-14 Debbie A. Cook - Corrected indexing error in loop.

Definition at line 1540 of file SpicePosition.cpp.

References _FILEINFO_, Isis::NumericalApproximation::AddCubicHermiteDeriv(), Isis::NumericalApproximation::AddData(), Isis::NumericalApproximation::CubicHermite, Isis::NumericalApproximation::Evaluate(), Isis::IException::Io, Isis::SpicePosition::p_baseTime, Isis::SpicePosition::p_cache, Isis::SpicePosition::p_cacheTime, Isis::SpicePosition::p_cacheVelocity, Isis::SpicePosition::p_hasVelocity, and Isis::SpicePosition::p_timeScale.

Referenced by Isis::SpicePosition::Memcache2HermiteCache().

◆ IsCached()

bool Isis::SpicePosition::IsCached ( ) const
inlineinherited

Is this position cached.

Definition at line 246 of file SpicePosition.h.

References Isis::SpicePosition::p_cache.

◆ LineCache()

Table Isis::SpicePosition::LineCache ( const QString &  tableName)
inherited

Return a table with J2000 to reference positions.

Return a table containing the cached positions with the given name. The table will have seven columns, positionX, positionY, positionZ, angular velocity X, angular velocity Y, angular velocity Z, and time of J2000 position.

Parameters
tableNameName of the table to create and return
History:
2012-01-25 Debbie A. Cook - Modified error checking for p_source to allow all function sources (>=HermiteCache)

Definition at line 635 of file SpicePosition.cpp.

References _FILEINFO_, Isis::SpicePosition::Cache(), Isis::SpicePosition::HermiteCache, Isis::SpicePosition::Memcache, Isis::SpicePosition::p_source, Isis::IException::Programmer, and Isis::SpicePosition::ReloadCache().

Referenced by Isis::SpicePosition::Cache().

◆ LoadCache() [1/3]

void Isis::SpicePosition::LoadCache ( double  startTime,
double  endTime,
int  size 
)
inherited

Cache J2000 position over a time range.

This method will load an internal cache with coordinates over a time range. This prevents the NAIF kernels from being read over-and-over again and slowing a application down due to I/O performance. Once the cache has been loaded then the kernels can be unloaded from the NAIF system.

Parameters
startTimeStarting ephemeris time in seconds for the cache
endTimeEnding ephemeris time in seconds for the cache
sizeNumber of coordinates/positions to keep in the cache

Definition at line 287 of file SpicePosition.cpp.

References _FILEINFO_, Isis::SpicePosition::HermiteCache, Isis::SpicePosition::LoadTimeCache(), Isis::SpicePosition::Memcache, Isis::SpicePosition::p_cache, Isis::SpicePosition::p_cacheTime, Isis::SpicePosition::p_cacheVelocity, Isis::SpicePosition::p_coordinate, Isis::SpicePosition::p_fullCacheEndTime, Isis::SpicePosition::p_fullCacheSize, Isis::SpicePosition::p_fullCacheStartTime, Isis::SpicePosition::p_hasVelocity, Isis::SpicePosition::p_source, Isis::SpicePosition::p_velocity, Isis::IException::Programmer, and Isis::SpicePosition::SetEphemerisTime().

Referenced by Isis::SpicePosition::LoadCache(), and Isis::SpicePosition::ReloadCache().

◆ LoadCache() [2/3]

void Isis::SpicePosition::LoadCache ( double  time)
inherited

Cache J2000 position for a time.

This method will load an internal cache with coordinates for a single time (e.g. useful for framing cameras). This prevents the NAIF kernels from being read over-and-over again and slowing a application down due to I/O performance. Once the cache has been loaded then the kernels can be unloaded from the NAIF system. This calls the LoadCache(stime,etime,size) method using the time as both the starting and ending time with a size of 1.

Parameters
timesingle ephemeris time in seconds to cache

Definition at line 335 of file SpicePosition.cpp.

References Isis::SpicePosition::LoadCache().

◆ LoadCache() [3/3]

void Isis::SpicePosition::LoadCache ( Table table)
inherited

Cache J2000 positions using a table file.

This method will load an internal cache with coordinates from an ISIS table file. The table must have 4 columns, or 7 (if velocity) is included, and at least one row. The 4 columns contain the following information, body position x,y,z in J2000 and the ephemeris time of that position. If there are multiple rows it is assumed you can interpolate position at times in between the rows.

Parameters
tableAn ISIS table blob containing valid J2000 coordinate/time values
History:

2009-08-03 Jeannie Walldren - Reads CacheType keyword from table and sets p_source. If no CacheType keyword, we know this is an older image, so set p_source to Memcache.

2011-01-05 Debbie A. Cook - Added PolyFunction type

2011-04-08 Debbie A. Cook - Corrected loop counter in PolyFunction section to only go up to table.Records() - 1

Definition at line 362 of file SpicePosition.cpp.

References _FILEINFO_, Isis::TableRecord::Fields(), Isis::PvlObject::findKeyword(), Isis::PvlObject::hasKeyword(), Isis::SpicePosition::HermiteCache, Isis::IException::Io, Isis::Blob::Label(), Isis::SpicePosition::Memcache, Isis::Blob::Name(), Isis::SpicePosition::p_cache, Isis::SpicePosition::p_cacheTime, Isis::SpicePosition::p_cacheVelocity, Isis::SpicePosition::p_fullCacheEndTime, Isis::SpicePosition::p_fullCacheSize, Isis::SpicePosition::p_fullCacheStartTime, Isis::SpicePosition::p_hasVelocity, Isis::SpicePosition::p_override, Isis::SpicePosition::p_overrideTimeScale, Isis::SpicePosition::p_source, Isis::SpicePosition::PolyFunction, Isis::IException::Programmer, Isis::Table::Records(), Isis::SpicePosition::SetOverrideBaseTime(), Isis::SpicePosition::SetPolynomial(), Isis::SpicePosition::SetPolynomialDegree(), and Isis::toDouble().

◆ LoadHermiteCache()

Table Isis::SpicePosition::LoadHermiteCache ( const QString &  tableName)
inherited

◆ Memcache2HermiteCache()

void Isis::SpicePosition::Memcache2HermiteCache ( double  tolerance)
inherited

This method reduces the cache for position, time and velocity to the minimum number of values needed to interpolate the J2000 coordinates using a Hermite spline, given a tolerance of deviation from the NAIF values.

Parameters
toleranceMaximum error allowed between NAIF kernel coordinate values and values interpolated by the Hermite spline.
History:
2009-08-03 Jeannie Walldren - Original version.

Definition at line 1480 of file SpicePosition.cpp.

References _FILEINFO_, Isis::SpicePosition::ComputeBaseTime(), Isis::SpicePosition::HermiteCache, Isis::SpicePosition::HermiteIndices(), Isis::SpicePosition::Memcache, Isis::SpicePosition::p_cache, Isis::SpicePosition::p_cacheTime, Isis::SpicePosition::p_cacheVelocity, Isis::SpicePosition::p_override, Isis::SpicePosition::p_overrideTimeScale, Isis::SpicePosition::p_source, and Isis::IException::Programmer.

Referenced by Isis::SpicePosition::Cache().

◆ ReloadCache() [1/2]

void Isis::SpicePosition::ReloadCache ( )
inherited

Cache J2000 positions over existing cached time range using polynomials.

This method will reload an internal cache with positions calculated from functions fit to the coordinates of the position over a time range.

History:
2012-01-25 Debbie A. Cook - Modified error checking for type to allow all function types (>=HermiteCache)

Definition at line 660 of file SpicePosition.cpp.

References _FILEINFO_, Isis::NaifStatus::CheckErrors(), Isis::SpicePosition::HermiteCache, Isis::SpicePosition::LoadTimeCache(), Isis::SpicePosition::Memcache, Isis::SpicePosition::p_cache, Isis::SpicePosition::p_cacheTime, Isis::SpicePosition::p_cacheVelocity, Isis::SpicePosition::p_coordinate, Isis::SpicePosition::p_degree, Isis::SpicePosition::p_et, Isis::SpicePosition::p_fullCacheSize, Isis::SpicePosition::p_source, Isis::SpicePosition::p_velocity, Isis::IException::Programmer, and Isis::SpicePosition::SetEphemerisTime().

Referenced by Isis::SpicePosition::LineCache().

◆ ReloadCache() [2/2]

void Isis::SpicePosition::ReloadCache ( Table table)
inherited

Cache J2000 position over existing cached time range using table.

This method will reload an internal cache with positions formed from coordinates in a table

Parameters
tableAn ISIS table blob containing valid J2000 coordinate/time values.
History:
2009-08-03 Jeannie Walldren - Original version.

Definition at line 1696 of file SpicePosition.cpp.

References Isis::SpicePosition::ClearCache(), Isis::SpicePosition::LoadCache(), Isis::SpicePosition::p_source, and Isis::SpicePosition::Spice.

◆ SetAberrationCorrection()

void Isis::SpacecraftPosition::SetAberrationCorrection ( const QString &  correction)
virtual

Set aberration correction value for determining positions.

Author
2012-10-29 Kris Becker
Parameters
correctionType of stellar aberration correction to apply

Reimplemented from Isis::SpicePosition.

Definition at line 114 of file SpacecraftPosition.cpp.

References m_abcorr, Isis::LightTimeCorrectionState::setAberrationCorrection(), and Isis::SpicePosition::SetAberrationCorrection().

◆ SetEphemerisTime()

const std::vector< double > & Isis::SpicePosition::SetEphemerisTime ( double  et)
inherited

Return J2000 coordinate at given time.

This method returns the J2000 coordinates (x,y,z) of the body at a given et in seconds. The coordinates are obtained from either a valid NAIF spk kernel, or alternatively from an internal cache loaded from an ISIS Table object. In the first case, the SPK kernel must contain positions for the body code specified in the constructor at the given time and it must be loaded using the SpiceKernel class.

Parameters
etephemeris time in seconds
History:
2009-08-03 Jeannie Walldren - Moved code to individual methods for each Source type to make software more readable.

Definition at line 242 of file SpicePosition.cpp.

References Isis::NaifStatus::CheckErrors(), Isis::SpicePosition::HermiteCache, Isis::SpicePosition::Memcache, Isis::SpicePosition::p_coordinate, Isis::SpicePosition::p_et, Isis::SpicePosition::p_source, Isis::SpicePosition::PolyFunction, Isis::SpicePosition::PolyFunctionOverHermiteConstant, Isis::SpicePosition::SetEphemerisTimeHermiteCache(), Isis::SpicePosition::SetEphemerisTimeMemcache(), Isis::SpicePosition::SetEphemerisTimePolyFunction(), Isis::SpicePosition::SetEphemerisTimePolyFunctionOverHermiteConstant(), and Isis::SpicePosition::SetEphemerisTimeSpice().

Referenced by Isis::SpicePosition::GetCenterCoordinate(), Isis::SpicePosition::LoadCache(), Isis::SpicePosition::LoadHermiteCache(), Isis::SpicePosition::ReloadCache(), and Isis::SpicePosition::SetPolynomial().

◆ SetEphemerisTimeHermiteCache()

void Isis::SpicePosition::SetEphemerisTimeHermiteCache ( )
protectedinherited

◆ SetEphemerisTimeMemcache()

void Isis::SpicePosition::SetEphemerisTimeMemcache ( )
protectedinherited

This is a protected method that is called by SetEphemerisTime() when Source type is Memcache.

It calculates J2000 coordinates (x,y,z) of the body that correspond to a given et in seconds. These coordinates are obtained from an internal cache loaded from an ISIS Table object.

See also
SetEphemerisTime()
History:
2009-08-03 Jeannie Walldren - Original version (moved code from SetEphemerisTime() to its own method)

Definition at line 1218 of file SpicePosition.cpp.

References Isis::SpicePosition::p_cache, Isis::SpicePosition::p_cacheTime, Isis::SpicePosition::p_cacheVelocity, Isis::SpicePosition::p_coordinate, Isis::SpicePosition::p_et, Isis::SpicePosition::p_hasVelocity, and Isis::SpicePosition::p_velocity.

Referenced by Isis::SpicePosition::SetEphemerisTime().

◆ SetEphemerisTimePolyFunction()

void Isis::SpicePosition::SetEphemerisTimePolyFunction ( )
protectedinherited

This is a protected method that is called by SetEphemerisTime() when Source type is PolyFunction.

It calculates J2000 coordinates (x,y,z) of the body that correspond to a given et in seconds. These coordinates are obtained by using an nth degree polynomial function fit to each coordinate of the position vector.

See also
SetEphemerisTime()
History:
2011-01-05 Debbie A. Cook - Original version

Definition at line 1369 of file SpicePosition.cpp.

References Isis::SpicePosition::ComputeVelocityInTime(), Isis::BasisFunction::Evaluate(), Isis::SpicePosition::p_baseTime, Isis::SpicePosition::p_cacheVelocity, Isis::SpicePosition::p_coefficients, Isis::SpicePosition::p_coordinate, Isis::SpicePosition::p_degree, Isis::SpicePosition::p_et, Isis::SpicePosition::p_hasVelocity, Isis::SpicePosition::p_timeScale, Isis::SpicePosition::p_velocity, and Isis::BasisFunction::SetCoefficients().

Referenced by Isis::SpicePosition::SetEphemerisTime(), and Isis::SpicePosition::SetEphemerisTimePolyFunctionOverHermiteConstant().

◆ SetEphemerisTimePolyFunctionOverHermiteConstant()

void Isis::SpicePosition::SetEphemerisTimePolyFunctionOverHermiteConstant ( )
protectedinherited

This is a protected method that is called by SetEphemerisTime() when Source type is PolyFunctionOverHermiteConstant.

It calculates J2000 coordinates (x,y,z) of the body that correspond to a given et in seconds. These coordinates are obtained by adding a constant cubic Hermite spline added to an nth degree polynomial function fit to each coordinate of the position vector.

See also
SetEphemerisTime()
History:
2012-01-25 Debbie A. Cook - Original version

Definition at line 1418 of file SpicePosition.cpp.

References Isis::SpicePosition::p_coordinate, Isis::SpicePosition::p_velocity, Isis::SpicePosition::SetEphemerisTimeHermiteCache(), and Isis::SpicePosition::SetEphemerisTimePolyFunction().

Referenced by Isis::SpicePosition::SetEphemerisTime().

◆ SetEphemerisTimeSpice()

void Isis::SpacecraftPosition::SetEphemerisTimeSpice ( )
virtual

Determine accurate position of target w.r.t.

observer

This method computes the position of the target w.r.t. the observer with additional specialized light time position of target and to a more accurate correction to the surface.

NAIF routines are used to compute state vectors that have optional light time correction applied. However, this uses the center of the body as the reference

Author
2012-10-29 Kris Becker
History:
2012-11-01 Kris Becker - Revised parameters to computeStateVector to match comments. References #1136.

Reimplemented from Isis::SpicePosition.

Definition at line 146 of file SpacecraftPosition.cpp.

References Isis::SpicePosition::computeStateVector(), GetAberrationCorrection(), Isis::SpicePosition::getAdjustedEphemerisTime(), Isis::SpicePosition::getObserverCode(), getRadiusLightTime(), Isis::SpicePosition::getTargetCode(), Isis::LightTimeCorrectionState::isLightTimeCorrected(), Isis::LightTimeCorrectionState::isLightTimeToSurfaceCorrected(), m_abcorr, Isis::SpicePosition::SetEphemerisTimeSpice(), Isis::SpicePosition::setLightTime(), and Isis::SpicePosition::setStateVector().

◆ setLightTime()

void Isis::SpicePosition::setLightTime ( const double &  lightTime)
protectedinherited

Inheritors can set the light time if indicated.

Definition at line 1961 of file SpicePosition.cpp.

References Isis::SpicePosition::m_lt.

Referenced by SetEphemerisTimeSpice(), and Isis::SpicePosition::SetEphemerisTimeSpice().

◆ SetOverrideBaseTime()

void Isis::SpicePosition::SetOverrideBaseTime ( double  baseTime,
double  timeScale 
)
inherited

Set an override base time to be used with observations on scanners to allow all images in an observation to use the same base time and polynomials for the positions.

Parameters
[in]baseTimeThe baseTime to use and override the computed base time
History:
2011-04-08 Debbie A. Cook - Corrected p_override set to BaseAndScale

Definition at line 1071 of file SpicePosition.cpp.

References Isis::SpicePosition::p_override, Isis::SpicePosition::p_overrideBaseTime, and Isis::SpicePosition::p_overrideTimeScale.

Referenced by Isis::BundleObservation::initializeExteriorOrientation(), and Isis::SpicePosition::LoadCache().

◆ SetPolynomial() [1/2]

◆ SetPolynomial() [2/2]

void Isis::SpicePosition::SetPolynomial ( const std::vector< double > &  XC,
const std::vector< double > &  YC,
const std::vector< double > &  ZC,
const Source  type = PolyFunction 
)
inherited

Set the coefficients of a polynomial (parabola) fit to each of the three coordinates of the position vector for the time period covered by the cache, coord = c0 + c1*t + c2*t**2 + ...

  • cn*t**n, where t = (time - p_baseTime) / p_timeScale.
Parameters
[in]XCCoefficients of fit to X coordinate
[in]YCCoefficients of fit to Y coordinate
[in]ZCCoefficients of fit to Z coordinate
History:
2012-02-05 Debbie A. Cook - Added type argument

Definition at line 978 of file SpicePosition.cpp.

References Isis::SpicePosition::ComputeBaseTime(), Isis::SpicePosition::p_coefficients, Isis::SpicePosition::p_degree, Isis::SpicePosition::p_degreeApplied, Isis::SpicePosition::p_et, Isis::SpicePosition::p_source, Isis::BasisFunction::SetCoefficients(), and Isis::SpicePosition::SetEphemerisTime().

◆ SetPolynomialDegree()

void Isis::SpicePosition::SetPolynomialDegree ( int  degree)
inherited

Set the polynomial degree.

Set the degree of the polynomials to be fit to the three position coordinates for the time period covered by the cache, coordinate = c0 + c1*t + c2*t**2 + ...

  • cn*t**n, where t = (time - p_baseTime) / p_timeScale, and n = p_degree.
Parameters
[in]degreeDegree of the polynomial to be fit

Definition at line 1640 of file SpicePosition.cpp.

References Isis::SpicePosition::p_coefficients, Isis::SpicePosition::p_degree, Isis::SpicePosition::p_degreeApplied, Isis::SpicePosition::p_fullCacheSize, and Isis::SpicePosition::SetPolynomial().

Referenced by Isis::BundleObservation::initializeExteriorOrientation(), and Isis::SpicePosition::LoadCache().

◆ setStateVector()

void Isis::SpicePosition::setStateVector ( const double  state[6],
const bool &  hasVelocity 
)
protectedinherited

Sets the state of target relative to observer.

This method sets the state of the target (vector) relative to the observer. Note that is the only place where the swap of observer/target adjustment to the state vector is handled. All contributors to this computation must compute the state vector representing the position and velocity of the target relative to the observer where the first three components of state[] are the x-, y- and z-component cartesian coordinates of the target's position; the last three are the corresponding velocity vector.

This routine maintains the directional integrity of the state vector should the observer/target be swapped. See the documentation for the spkez_c at http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/spkez_c.html.

Author
2012-10-29 Kris Becker
Parameters
stateState vector. First three components of this 6 element array is the body fixed coordinates of the vector from the target to the observer. The last three components are the velocity state.
hasVelocityIf true, then the velocity components of the state vector are valid, otherwise they should be ignored.

Definition at line 1931 of file SpicePosition.cpp.

References Isis::SpicePosition::p_coordinate, Isis::SpicePosition::p_hasVelocity, and Isis::SpicePosition::p_velocity.

Referenced by SetEphemerisTimeSpice(), and Isis::SpicePosition::SetEphemerisTimeSpice().

◆ SetTimeBias()

void Isis::SpicePosition::SetTimeBias ( double  timeBias)
inherited

Apply a time bias when invoking SetEphemerisTime method.

The bias is used only when reading from NAIF kernels. It is added to the ephermeris time passed into SetEphemerisTime and then the body position is read from the NAIF kernels and returned. When the cache is loaded from a table the bias is ignored as it is assumed to have already been applied. If this method is never called the default bias is 0.0 seconds.

Parameters
timeBiastime bias in seconds

Definition at line 143 of file SpicePosition.cpp.

References Isis::SpicePosition::p_timeBias.

◆ Velocity()

const std::vector< double > & Isis::SpicePosition::Velocity ( )
inherited

Return the current J2000 velocity.

Return the velocity vector if available.

Returns
The velocity vector evaluated at the current time

Definition at line 1193 of file SpicePosition.cpp.

References _FILEINFO_, Isis::SpicePosition::p_hasVelocity, Isis::SpicePosition::p_velocity, and Isis::IException::Programmer.

Referenced by Isis::RadarGroundMap::GetXY(), Isis::RadarGroundMap::SetFocalPlane(), and Isis::RadarGroundMap::SetGround().

◆ VelocityPartial()

std::vector< double > Isis::SpicePosition::VelocityPartial ( SpicePosition::PartialType  partialVar,
int  coeffIndex 
)
inherited

Compute the derivative of the velocity with respect to the specified variable.

The velocity is the derivative of the coordinate with respect to time.

coordinate = C0 + C1*t + C2*t**2 + ... +Cn*t**n , where t = (time - p_basetime) / p_timeScale. velocity = (1/p_timeScale) * (C1 + 2*C2*t + ... + n*Cn*t**(n-1)) partial(velocity) with respect to C0 = 0. partial(velocity) with respect to C1 = 1/p_timeScale. partial(velocity) with respect to C2 = 2*t/p_timeScale partial(velocity) with respect to CN = n*t**(n-1)/p_timeScale

Parameters
partialVarDesignated variable of the partial derivative
Returns
Derivative of j2000 velocity vector calculated with respect to partialVar

Definition at line 1132 of file SpicePosition.cpp.

References Isis::SpicePosition::p_baseTime, Isis::SpicePosition::p_et, and Isis::SpicePosition::p_timeScale.

Referenced by Isis::RadarGroundMap::GetdXYdPosition().

Member Data Documentation

◆ m_abcorr

LightTimeCorrectionState Isis::SpacecraftPosition::m_abcorr
private

◆ m_radius

Distance Isis::SpacecraftPosition::m_radius
private

Radius of target.

Definition at line 97 of file SpacecraftPosition.h.

Referenced by getRadiusLightTime(), and SpacecraftPosition().


The documentation for this class was generated from the following files: