Isis 3 Programmer Reference
SpicePosition.h
1#ifndef SpicePosition_h
2#define SpicePosition_h
8/* SPDX-License-Identifier: CC0-1.0 */
9#include <string>
10#include <vector>
11
12#include <SpiceUsr.h>
13#include <SpiceZfc.h>
14#include <SpiceZmc.h>
15
16#include "Table.h"
17#include "PolynomialUnivariate.h"
18
19// ale includes
20#include "ale/States.h"
21
22#include <nlohmann/json.hpp>
23
24class IsisIlluminator_Velocity_Test;
25
26namespace Isis {
27 class NumericalApproximation;
28
177 public:
178 //??? jw
183 enum Source { Spice,
188 // table and adding nth degree polynomial
189 };
190
191 SpicePosition(int targetCode, int observerCode);
192
194 virtual ~SpicePosition();
195
196 void SetTimeBias(double timeBias);
197 double GetTimeBias() const;
198
199 virtual void SetAberrationCorrection(const QString &correction);
200 virtual QString GetAberrationCorrection() const;
201 double GetLightTime() const;
202
203 virtual const std::vector<double> &SetEphemerisTime(double et);
204 enum PartialType {WRT_X, WRT_Y, WRT_Z};
205
207 virtual double EphemerisTime() const {
208 return p_et;
209 };
210
211 double scaledTime() const;
212
213 const std::vector<double> &GetCenterCoordinate();
214
216 virtual const std::vector<double> &Coordinate() {
217 return p_coordinate;
218 };
219
221 const std::vector<double> &Velocity();
222
224 bool HasVelocity() {
225 return p_hasVelocity;
226 };
227
228 void LoadCache(double startTime, double endTime, int size);
229 void LoadCache(double time);
230 void LoadCache(Table &table);
231 void LoadCache(nlohmann::json &isd);
232
233 Table LineCache(const QString &tableName);
234 Table LoadHermiteCache(const QString &tableName);
235
236 void ReloadCache();
237 void ReloadCache(Table &table);
238
239 Table Cache(const QString &tableName);
240
242 bool IsCached() const {
243 return (m_state != NULL);
244 };
245
247 int cacheSize() const {
248 if (m_state) {
249 return m_state->getStates().size();
250 }
251 return 0;
252 };
253
254 void SetPolynomial(const Source type = PolyFunction);
255
256 void SetPolynomial(const std::vector<double>& XC,
257 const std::vector<double>& YC,
258 const std::vector<double>& ZC,
259 const Source type = PolyFunction);
260
261 void GetPolynomial(std::vector<double>& XC,
262 std::vector<double>& YC,
263 std::vector<double>& ZC);
264
266 void SetPolynomialDegree(int degree);
267
270 return p_source;
271 };
272
273 void ComputeBaseTime();
274
276 double GetBaseTime() {
277 return p_baseTime;
278 };
279
280 void SetOverrideBaseTime(double baseTime, double timeScale);
281
283 double GetTimeScale() {
284 return p_timeScale;
285 };
286
287 double DPolynomial(const int coeffIndex);
288
289 std::vector<double> CoordinatePartial(SpicePosition::PartialType partialVar, int coeffIndex);
290
291 std::vector<double> VelocityPartial(SpicePosition::PartialType partialVar, int coeffIndex);
292 enum OverrideType {NoOverrides, ScaleOnly, BaseAndScale};
293 void Memcache2HermiteCache(double tolerance);
294 std::vector<double> Extrapolate(double timeEt);
295 std::vector<double> HermiteCoordinate();
296 protected:
297 friend class ::IsisIlluminator_Velocity_Test;
300 virtual void SetEphemerisTimeSpice();
303
304 //======================================================================
305 // New methods support for light time correction and swap of observer/target
306 SpicePosition(int targetCode, int observerCode, bool swapObserverTarget);
307 int getObserverCode() const;
308 int getTargetCode() const;
309 double getAdjustedEphemerisTime() const;
310 void computeStateVector(double et, int target, int observer,
311 const QString &refFrame,
312 const QString &abcorr,
313 double state[6], bool &hasVelocity,
314 double &lightTime) const;
315 void setStateVector(const double state[6], const bool &hasVelocity);
316 void setLightTime(const double &lightTime);
317 //======================================================================
318
319 private:
320 void init(int targetCode, int observerCode,
321 const bool &swapObserverTarget = false);
322 void ClearCache();
323 void LoadTimeCache();
324 void CacheLabel(Table &table);
325 double ComputeVelocityInTime(PartialType var);
326
329
330 double p_timeBias;
332
333 double p_et;
334 std::vector<double> p_coordinate;
335 std::vector<double> p_velocity;
336
338 std::vector<double> p_cacheTime;
339 std::vector<double> p_coefficients[3];
340
341 double p_baseTime;
342 double p_timeScale;
344 // of degree p_degree has been created and
345 // used to fill the cache
351 OverrideType p_override;
354
355 // Variables support observer/target swap and light time correction
356 bool m_swapObserverTarget;
357 double m_lt;
358
359 ale::States *m_state;
360 };
361};
362
363#endif
Obtain SPICE position information for a body.
int cacheSize() const
Get the size of the current cached positions.
double GetTimeScale()
Return the time scale for the position.
double DPolynomial(const int coeffIndex)
Evaluate the derivative of the fit polynomial (parabola) defined by the given coefficients with respe...
void Memcache2HermiteCache(double tolerance)
This method reduces the cache for position, time and velocity to the minimum number of values needed ...
void ComputeBaseTime()
Compute the base time using cached times.
Table LineCache(const QString &tableName)
Return a table with J2000 to reference positions.
bool HasVelocity()
Return the flag indicating whether the velocity exists.
double p_timeScale
Time scale used in fit equations.
std::vector< double > p_coordinate
J2000 position at time et.
double GetTimeBias() const
Returns the value of the time bias added to ET.
double ComputeVelocityInTime(PartialType var)
Compute the velocity with respect to time instead of scaled time.
Source p_source
Enumerated value for the location of the SPK information used.
std::vector< double > p_coefficients[3]
Coefficients of polynomials fit to 3 coordinates.
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...
virtual void SetEphemerisTimeSpice()
This is a protected method that is called by SetEphemerisTime() when Source type is Spice.
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 ...
void setLightTime(const double &lightTime)
Inheritors can set the light time if indicated.
const std::vector< double > & Velocity()
Return the current J2000 velocity.
double GetBaseTime()
Return the base time for the position.
void ReloadCache()
Cache J2000 positions over existing cached time range using polynomials.
Source
This enum indicates the status of the object.
@ HermiteCache
Object is reading from splined table.
@ PolyFunction
Object is calculated from nth degree polynomial.
@ Memcache
Object is reading from cached table.
@ Spice
Object is reading directly from the kernels.
@ PolyFunctionOverHermiteConstant
Object is reading from splined.
ale::States * m_state
!< Light time correction
void LoadCache(double startTime, double endTime, int size)
Cache J2000 position over a time range.
double p_baseTime
Base time used in fit equations.
void SetEphemerisTimeMemcache()
This is a protected method that is called by SetEphemerisTime() when Source type is Memcache.
void LoadTimeCache()
Load the time cache.
int p_observerCode
observer body code
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...
Table LoadHermiteCache(const QString &tableName)
Cache J2000 position over existing cached time range using polynomials stored as Hermite cubic spline...
bool IsCached() const
Is this position cached.
std::vector< double > Extrapolate(double timeEt)
Extrapolate position for a given time assuming a constant velocity.
void setStateVector(const double state[6], const bool &hasVelocity)
Sets the state of target relative to observer.
double m_lt
!< Swap traditional order
std::vector< double > p_cacheTime
iTime for corresponding position
std::vector< double > p_velocity
J2000 velocity at time et.
double p_overrideTimeScale
Value set by caller to override computed time scale.
bool p_degreeApplied
Flag indicating whether or not a polynomial.
bool p_hasVelocity
Flag to indicate velocity is available.
void ClearCache()
Removes the entire cache from memory.
double p_fullCacheEndTime
Original end time of the complete cache after spiceinit.
int getTargetCode() const
Returns target code.
double p_overrideBaseTime
Value set by caller to override computed base time.
const std::vector< double > & GetCenterCoordinate()
Compute and return the coordinate at the center time.
void CacheLabel(Table &table)
Add labels to a SpicePosition table.
double scaledTime() const
Return the scaled time.
int p_targetCode
target body code
double getAdjustedEphemerisTime() const
Returns adjusted ephemeris time.
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 SetEphemerisTimeHermiteCache()
This is a protected method that is called by SetEphemerisTime() when Source type is HermiteCache.
virtual double EphemerisTime() const
Return the current ephemeris time.
void init(int targetCode, int observerCode, const bool &swapObserverTarget=false)
Internal initialization of the object support observer/target swap.
double p_et
Current ephemeris time.
void SetTimeBias(double timeBias)
Apply a time bias when invoking SetEphemerisTime method.
virtual ~SpicePosition()
Destructor.
double p_timeBias
iTime bias when reading kernels
void SetEphemerisTimePolyFunction()
This is a protected method that is called by SetEphemerisTime() when Source type is PolyFunction.
int getObserverCode() const
Returns observer code.
virtual const std::vector< double > & SetEphemerisTime(double et)
Return J2000 coordinate at given time.
SpicePosition(int targetCode, int observerCode)
Construct an empty SpicePosition class using valid body codes.
void SetEphemerisTimePolyFunctionOverHermiteConstant()
This is a protected method that is called by SetEphemerisTime() when Source type is PolyFunctionOverH...
Source GetSource()
Return the source of the position.
double GetLightTime() const
Return the light time coorection value.
double p_fullCacheSize
Orignial size of the complete cache after spiceinit.
std::vector< double > HermiteCoordinate()
This method returns the Hermite coordinate for the current time for PolyFunctionOverHermiteConstant f...
OverrideType p_override
Time base and scale override options;.
int p_degree
Degree of polynomial function fit to the coordinates of the position.
double p_fullCacheStartTime
Original start time of the complete cache after spiceinit.
virtual const std::vector< double > & Coordinate()
Return the current J2000 position.
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.
QString p_aberrationCorrection
Light time correction to apply.
virtual void SetAberrationCorrection(const QString &correction)
Set the aberration correction (light time)
void SetPolynomialDegree(int degree)
Set the polynomial degree.
std::vector< double > VelocityPartial(SpicePosition::PartialType partialVar, int coeffIndex)
Compute the derivative of the velocity with respect to the specified variable.
Table Cache(const QString &tableName)
Return a table with J2000 positions.
virtual QString GetAberrationCorrection() const
Returns current state of stellar aberration correction.
Class for storing Table blobs information.
Definition Table.h:61
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16