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/
mk = /directory/for/vex/spice/vex.mk
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 vexspice as vspice
>>> vspice.init()
>>> import datetime
>>> vspice.get_position(datetime.datetime(2010, 1, 1, 0, 0, 0))
[ 13651.59640042 1747.36719203 -59126.56129903]
SPICE in irfpy¶
Import the irfpy.vexpvat.vexspice
module.
It is a usual practice to import the module as vspice
.
>>> import irfpy.vexpvat.vexspice as vspice
Then, initialize the spice by using irfpy.vexpvat.vexspice.init()
function.
>>> vspice.init()
To get the orbit¶
To get the spacecraft position, you can use irfpy.vexpvat.vexspice.get_position()
function.
>>> import irfpy.vexpvat.vexspice as vspice
>>> vspice.init()
>>> import datetime
>>> vspice.get_position(datetime.datetime(2010, 1, 1, 0, 0, 0))
[ 13651.59640042 1747.36719203 -59126.56129903]
This is the VEX position in VSO frame measured from Venus.
You may specify the target
, origin
and frame
.
>>> vspice.get_position(datetime.datetime(2010, 1, 1, 0, 0, 0), frame='J2000', origin='Sun', target='VEX')
[ 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 vspice.spice, such as
>>> vspice.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)