Isis Developer Reference
SpicePosition.h
Go to the documentation of this file.
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"
18
19// ale includes
20#include "ale/States.h"
21
22#include <nlohmann/json.hpp>
23
24namespace Isis {
25 class NumericalApproximation;
26
175 public:
176 //??? jw
181 enum Source { Spice,
186 // table and adding nth degree polynomial
187 };
188
189 SpicePosition(int targetCode, int observerCode);
190
192 virtual ~SpicePosition();
193
194 void SetTimeBias(double timeBias);
195 double GetTimeBias() const;
196
197 virtual void SetAberrationCorrection(const QString &correction);
198 virtual QString GetAberrationCorrection() const;
199 double GetLightTime() const;
200
201 virtual const std::vector<double> &SetEphemerisTime(double et);
203
205 virtual double EphemerisTime() const {
206 return p_et;
207 };
208
209 double scaledTime() const;
210
211 const std::vector<double> &GetCenterCoordinate();
212
214 virtual const std::vector<double> &Coordinate() {
215 return p_coordinate;
216 };
217
219 const std::vector<double> &Velocity();
220
222 bool HasVelocity() {
223 return p_hasVelocity;
224 };
225
226 void LoadCache(double startTime, double endTime, int size);
227 void LoadCache(double time);
228 void LoadCache(Table &table);
229 void LoadCache(nlohmann::json &isd);
230
231 Table LineCache(const QString &tableName);
232 Table LoadHermiteCache(const QString &tableName);
233
234 void ReloadCache();
235 void ReloadCache(Table &table);
236
237 Table Cache(const QString &tableName);
238
240 bool IsCached() const {
241 return (m_state != NULL);
242 };
243
245 int cacheSize() const {
246 if (m_state) {
247 return m_state->getStates().size();
248 }
249 return 0;
250 };
251
252 void SetPolynomial(const Source type = PolyFunction);
253
254 void SetPolynomial(const std::vector<double>& XC,
255 const std::vector<double>& YC,
256 const std::vector<double>& ZC,
257 const Source type = PolyFunction);
258
259 void GetPolynomial(std::vector<double>& XC,
260 std::vector<double>& YC,
261 std::vector<double>& ZC);
262
264 void SetPolynomialDegree(int degree);
265
268 return p_source;
269 };
270
271 void ComputeBaseTime();
272
274 double GetBaseTime() {
275 return p_baseTime;
276 };
277
278 void SetOverrideBaseTime(double baseTime, double timeScale);
279
281 double GetTimeScale() {
282 return p_timeScale;
283 };
284
285 double DPolynomial(const int coeffIndex);
286
287 std::vector<double> CoordinatePartial(SpicePosition::PartialType partialVar, int coeffIndex);
288
289 std::vector<double> VelocityPartial(SpicePosition::PartialType partialVar, int coeffIndex);
291 void Memcache2HermiteCache(double tolerance);
292 std::vector<double> Extrapolate(double timeEt);
293 std::vector<double> HermiteCoordinate();
294 protected:
297 virtual void SetEphemerisTimeSpice();
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
324 int p_targetCode;
325 int p_observerCode;
326
327 double p_timeBias;
328 QString p_aberrationCorrection;
329
330 double p_et;
331 std::vector<double> p_coordinate;
332 std::vector<double> p_velocity;
333
334 Source p_source;
335 std::vector<double> p_cacheTime;
336 std::vector<double> p_coefficients[3];
337
338 double p_baseTime;
339 double p_timeScale;
340 bool p_degreeApplied;
341 // of degree p_degree has been created and
342 // used to fill the cache
343 int p_degree;
344 double p_fullCacheStartTime;
345 double p_fullCacheEndTime;
346 double p_fullCacheSize;
347 bool p_hasVelocity;
348 OverrideType p_override;
349 double p_overrideBaseTime;
350 double p_overrideTimeScale;
351
352 // Variables support observer/target swap and light time correction
353 bool m_swapObserverTarget;
354 double m_lt;
355
356 ale::States *m_state;
357 };
358};
359
360#endif
Obtain SPICE position information for a body.
Definition: SpicePosition.h:174
int cacheSize() const
Get the size of the current cached positions.
Definition: SpicePosition.h:245
double GetTimeScale()
Return the time scale for the position.
Definition: SpicePosition.h:281
double DPolynomial(const int coeffIndex)
Evaluate the derivative of the fit polynomial (parabola) defined by the given coefficients with respe...
Definition: SpicePosition.cpp:1244
void Memcache2HermiteCache(double tolerance)
This method reduces the cache for position, time and velocity to the minimum number of values needed ...
Definition: SpicePosition.cpp:1463
void ComputeBaseTime()
Compute the base time using cached times.
Definition: SpicePosition.cpp:1116
Table LineCache(const QString &tableName)
Return a table with J2000 to reference positions.
Definition: SpicePosition.cpp:704
bool HasVelocity()
Return the flag indicating whether the velocity exists.
Definition: SpicePosition.h:222
double GetTimeBias() const
Returns the value of the time bias added to ET.
Definition: SpicePosition.cpp:161
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:1147
virtual void SetEphemerisTimeSpice()
This is a protected method that is called by SetEphemerisTime() when Source type is Spice.
Definition: SpicePosition.cpp:1432
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:1103
void setLightTime(const double &lightTime)
Inheritors can set the light time if indicated.
Definition: SpicePosition.cpp:1833
const std::vector< double > & Velocity()
Return the current J2000 velocity.
Definition: SpicePosition.cpp:1269
double GetBaseTime()
Return the base time for the position.
Definition: SpicePosition.h:274
void ReloadCache()
Cache J2000 positions over existing cached time range using polynomials.
Definition: SpicePosition.cpp:729
Source
This enum indicates the status of the object.
Definition: SpicePosition.h:181
@ HermiteCache
Object is reading from splined table.
Definition: SpicePosition.h:183
@ PolyFunction
Object is calculated from nth degree polynomial.
Definition: SpicePosition.h:184
@ Memcache
Object is reading from cached table.
Definition: SpicePosition.h:182
@ Spice
Object is reading directly from the kernels.
Definition: SpicePosition.h:181
@ PolyFunctionOverHermiteConstant
Object is reading from splined.
Definition: SpicePosition.h:185
void LoadCache(double startTime, double endTime, int size)
Cache J2000 position over a time range.
Definition: SpicePosition.cpp:297
void SetEphemerisTimeMemcache()
This is a protected method that is called by SetEphemerisTime() when Source type is Memcache.
Definition: SpicePosition.cpp:1294
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:930
Table LoadHermiteCache(const QString &tableName)
Cache J2000 position over existing cached time range using polynomials stored as Hermite cubic spline...
Definition: SpicePosition.cpp:793
bool IsCached() const
Is this position cached.
Definition: SpicePosition.h:240
std::vector< double > Extrapolate(double timeEt)
Extrapolate position for a given time assuming a constant velocity.
Definition: SpicePosition.cpp:1635
void setStateVector(const double state[6], const bool &hasVelocity)
Sets the state of target relative to observer.
Definition: SpicePosition.cpp:1803
PartialType
Definition: SpicePosition.h:202
@ WRT_Z
Definition: SpicePosition.h:202
@ WRT_X
Definition: SpicePosition.h:202
@ WRT_Y
Definition: SpicePosition.h:202
OverrideType
Definition: SpicePosition.h:290
@ BaseAndScale
Definition: SpicePosition.h:290
@ NoOverrides
Definition: SpicePosition.h:290
@ ScaleOnly
Definition: SpicePosition.h:290
int getTargetCode() const
Returns target code.
Definition: SpicePosition.cpp:1698
const std::vector< double > & GetCenterCoordinate()
Compute and return the coordinate at the center time.
Definition: SpicePosition.cpp:1595
double scaledTime() const
Return the scaled time.
Definition: SpicePosition.cpp:1551
double getAdjustedEphemerisTime() const
Returns adjusted ephemeris time.
Definition: SpicePosition.cpp:1714
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:1167
void SetEphemerisTimeHermiteCache()
This is a protected method that is called by SetEphemerisTime() when Source type is HermiteCache.
Definition: SpicePosition.cpp:1324
virtual double EphemerisTime() const
Return the current ephemeris time.
Definition: SpicePosition.h:205
void SetTimeBias(double timeBias)
Apply a time bias when invoking SetEphemerisTime method.
Definition: SpicePosition.cpp:150
virtual ~SpicePosition()
Destructor.
Definition: SpicePosition.cpp:133
void SetEphemerisTimePolyFunction()
This is a protected method that is called by SetEphemerisTime() when Source type is PolyFunction.
Definition: SpicePosition.cpp:1355
int getObserverCode() const
Returns observer code.
Definition: SpicePosition.cpp:1684
virtual const std::vector< double > & SetEphemerisTime(double et)
Return J2000 coordinate at given time.
Definition: SpicePosition.cpp:249
void SetEphemerisTimePolyFunctionOverHermiteConstant()
This is a protected method that is called by SetEphemerisTime() when Source type is PolyFunctionOverH...
Definition: SpicePosition.cpp:1403
Source GetSource()
Return the source of the position.
Definition: SpicePosition.h:267
double GetLightTime() const
Return the light time coorection value.
Definition: SpicePosition.cpp:230
std::vector< double > HermiteCoordinate()
This method returns the Hermite coordinate for the current time for PolyFunctionOverHermiteConstant f...
Definition: SpicePosition.cpp:1655
virtual const std::vector< double > & Coordinate()
Return the current J2000 position.
Definition: SpicePosition.h:214
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:1751
virtual void SetAberrationCorrection(const QString &correction)
Set the aberration correction (light time)
Definition: SpicePosition.cpp:186
void SetPolynomialDegree(int degree)
Set the polynomial degree.
Definition: SpicePosition.cpp:1502
std::vector< double > VelocityPartial(SpicePosition::PartialType partialVar, int coeffIndex)
Compute the derivative of the velocity with respect to the specified variable.
Definition: SpicePosition.cpp:1208
Table Cache(const QString &tableName)
Return a table with J2000 positions.
Definition: SpicePosition.cpp:549
virtual QString GetAberrationCorrection() const
Returns current state of stellar aberration correction.
Definition: SpicePosition.cpp:213
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