Tutorial to setup SPICE for VEX

Introduction

(To be writtern)

Preparation

Install SPICE

Install SpiceyPy module, if having not done.

pip install "git+https://github.com/AndrewAnnex/SpiceyPy.git"

If any problems below, considering updating the SpiceyPy.

pip install "git+https://github.com/AndrewAnnex/SpiceyPy.git" -U

Download SPICE kernels

Download the SPICE tree. Easiest is to copy the tree from aurora.irf.se:/irf/spaghetti/venus/spice. Please change the destination directory name as your preference.

mkdir -p /directory/for/vex/spice
rsync -e ssh -abuv aurora.irf.se:/irf/spaghetti/venus/spice/kernels /directory/for/vex/spice/

Note

The access to aurora is limited to IRF scientist.

Setup .irfpyrc

Add the following entries to .irfpyrc at your home directory, or the current directory.

[vexpvat]
# Used in spice
spiceroot = /directory/for/vex/spice/kernels/
metakernel = /directory/for/vex/spice/mk/VEX_OPS_LOCAL.TM

Confirming installation

>>> import spiceypy as spice
>>> spice.furnsh('/directory/for/vex/spice/kernels/lsk/NAIF0010.TLS')
>>> spice.str2et('2005-11-09T03:33:33')     # Date of launch!
184779277.18263602
>>> from irfpy.vexpvat import esaspice
>>> esaspice.furnsh_mk()   # Load the metakernel specified in .irfpyrc
>>> # Then call SpiceyPy directly, e.g.:
>>> # import spiceypy as spice
>>> # pos = spice.spkezr('VEX', spice.str2et('2010-01-01T00:00:00'), 'VSO', 'NONE', 'VENUS')

SPICE in irfpy

Import the irfpy.vexpvat.esaspice module.

>>> import irfpy.vexpvat.esaspice as espice

Then, load the metakernel by using irfpy.vexpvat.esaspice.furnsh_mk() function.

>>> espice.furnsh_mk()

To get the orbit

To get the spacecraft position, call SpiceyPy directly (e.g. spice.spkezr). The legacy irfpy.vexpvat.vexspice.get_position() is deprecated.

You may specify the target, origin and frame.

>>> import spiceypy as spice
>>> pos = spice.spkezr('VEX', spice.str2et('2010-01-01T00:00:00'), 'VSO', 'NONE', 'VENUS')[0]
>>> pos
[ 13651.59640042   1747.36719203 -59126.56129903]

This is the VEX position in VSO frame measured from Venus.

>>> pos = spice.spkezr('VEX', spice.str2et('2010-01-01T00:00:00'), 'J2000', 'NONE', 'Sun')[0]
>>> pos
[  7964027.35161654, -98721990.65307485, -44986288.39865705]

To get the attitude

(To be written)

SPICE functions

General spice functions (e.g. str2et, mxv or whatever) can be used via SpiceyPy directly, such as

>>> import spiceypy as spice
>>> spice.mxv([[1, 2, 3], [1, 2, 4], [1, 3, 5]], [0, 0, 1])
[ 3.,  4.,  5.]

Further learning of SPICE

(External link to be added)