spk.h

spk.h#

Defines

SPK_CACHE_ITEM_SIZE#

Size of each item in the cache. It is set to 32, which is a bit of a buffer on the usual number of 27 SpiceBodies in each PropSimulation (Sun+8planets+Moon+Pluto+16Asteriods).

SPK_CACHE_SIZE#

Number of items in the cache. This is the number of spk queries that are remembered.

SPK_RECORD_LEN#

Length of a record in an SPK file.

Functions

void spk_free(SpkInfo *bsp)#

Free the memory allocated for an SpkInfo structure.

Parameters:

bsp[in] SpkInfo structure.

SpkInfo *spk_init(const std::string &path)#

Initialise a SPK file.

Parameters:

path[in] Path to the SPK file.

Returns:

SpkInfo* Pointer to the SpkInfo structure.

void spk_calc(SpkInfo *bsp, double epoch, int spiceId, double *state)#

Compute pos, vel, and acc for a given body at a given time using an SpkInfo structure.

Parameters:
  • bsp[in] SpkInfo structure.

  • epoch[in] Epoch to compute the state at (MJD ET).

  • spiceId[in] SPICE ID of the body.

  • state[out] State+acceleration of the body at the requested epoch [AU, AU/day, AU/day^2].

void get_spk_state(const int &spiceId, const double &t0_mjd, SpkEphemeris &ephem, double *state, const bool &writeCache = false)#

Top level function to get the state of a body at a given time using the ephemeris data in a PropSimulation.

Parameters:
  • spiceId[in] SPICE ID of the body.

  • t0_mjd[in] Epoch to compute the state at (MJD ET).

  • ephem[in] Ephemeris data from the PropSimulation.

  • state[out] State+acceleration of the body at the requested epoch [AU, AU/day, AU/day^2].

  • writeCache[in] If true, the state will be written to the cache.

struct SpkCacheItem#
#include <spk.h>

Structure to hold a single time,pos,vel,accel record from an SPK file.

Param spiceId:

SPICE ID of the body.

Param t:

Time of the state.

Param x:

X position of the state.

Param y:

Y position of the state.

Param z:

Z position of the state.

Param vx:

X velocity of the state.

Param vy:

Y velocity of the state.

Param vz:

Z velocity of the state.

Param ax:

X acceleration of the state.

Param ay:

Y acceleration of the state.

Param az:

Z acceleration of the state.

Public Members

int spiceId = -99999#
double t#
double state[9]#
struct SpkCache#
#include <spk.h>

Structure to hold a cache of SPK data.

Param t:

Time of the cache.

Param items:

Array of CacheItems.

Public Members

double t#
SpkCacheItem items[SPK_CACHE_ITEM_SIZE]#
struct SpkTarget#
#include <spk.h>

Structure to hold the data for a single body in an SPK file.

Param code:

SPICE ID of the body.

Param cen:

Center of the target (usually SSB/Sun).

Param beg:

Starting epoch.

Param end:

End epoch.

Param res:

Epoch span.

Param one:

First record index.

Param two:

Final record index.

Param ind:

Span of the records.

Public Members

int code#
int cen#
double beg#
double end#
double res#
int *one#
int *two#
int ind#
struct SpkInfo#
#include <spk.h>

Structure to hold the data for a single SPK file.

Param targets:

Array of SpkTarget.

Param num:

Number of targets.

Param allocatedNum:

Number of allocated targets.

Param map:

Memory map of the SPK file.

Param len:

Length of the memory map.

Param spiceIdToIdx:

Map of SPICE ID to index in the targets array.

Public Members

SpkTarget *targets#
int num#
int allocatedNum#
void *map#
size_t len#
std::unordered_map<int, int> spiceIdToIdx#
struct SpkEphemeris#
#include <spk.h>

Structure to hold all the data for the SPK files in a PropSimulation.

Param mbPath:

Path to the main-body SPK file.

Param sbPath:

Path to the small-body SPK file.

Param mb:

SpkInfo structure for the main-body SPK file.

Param sb:

SpkInfo structure for the small-body SPK file.

Param nextIdxToWrite:

Index of the next cache item to write.

Param cache:

Array of SpkCache containing recently queried SPK data.

Public Members

std::string mbPath#
std::string sbPath#
SpkInfo *mb = nullptr#
SpkInfo *sb = nullptr#
size_t nextIdxToWrite = -1#
std::vector<SpkCache> cache = std::vector<SpkCache>(SPK_CACHE_SIZE)#