.. _tutorial_vex_spice: =============================== Tutorial to setup SPICE for VEX =============================== Introduction ============ (To be writtern) Preparation =========== Install SPICE ------------- Install ``SpiceyPy`` module, if having not done. .. code-block:: sh pip install "git+https://github.com/AndrewAnnex/SpiceyPy.git" If any problems below, considering updating the SpiceyPy. .. code-block:: sh 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. .. code-block:: sh 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 ----------------------- .. code-block:: python >>> 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 .. code-block:: python >>> 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 :mod:`irfpy.vexpvat.vexspice` module. It is a usual practice to import the module as ``vspice``. .. code-block:: python >>> import irfpy.vexpvat.vexspice as vspice Then, initialize the spice by using :func:`irfpy.vexpvat.vexspice.init` function. .. code-block:: python >>> vspice.init() To get the orbit ---------------- To get the spacecraft position, you can use :func:`irfpy.vexpvat.vexspice.get_position` function. .. code-block:: python >>> 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``. .. code-block:: python >>> 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 .. code-block:: python >>> 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)