| Basics, Building SPICE Applications (Python) |
Table of ContentsBasics, Building SPICE Applications (Python) Note About HTML Links Environment Set-up Confirm that Python can access SpiceyPy A simple example program SpiceyPy Documentation Basics, Building SPICE Applications (Python)
Note About HTML Links
In order for the links to be resolved, if not done already by installing the lessons package under the Toolkit's ``doc/html'' directory, create a subdirectory called ``lessons'' under the ``doc/html'' directory of the ``cspice/'' tree and copy this document to that subdirectory before loading it into a Web browser. Environment Set-up
In order to install SpiceyPy, using pip, first install the following required packages:
$ pip install six
$ pip install numpy
$ pip install spiceypy
Python2 users would need to use the future package in order to get the
same behavior from the Python3 input function in Python2. This package
is installed by running:
$ pip install future
Using anaconda, miniconda or conda:
$ conda install -c https://conda.anaconda.org/andrewannex spiceypy
Confirm that Python can access SpiceyPy
$ pip list --format=columns
Package Version
---------- -------
pip 9.0.1
numpy 1.13.3
setuptools 36.5.0
six 1.11.0
...
spicepy 2.1.1
...
A simple example program
File tkvrsn.py
from __future__ import print_function
import spiceypy
def print_ver():
"""Prints the TOOLKIT version
"""
print(spiceypy.tkvrsn('TOOLKIT'))
if __name__ == '__main__':
print_ver()
From the command line, execute the function:
$ python tkvrsn.py
CSPICE_N0066
From Python, execute the function:
$ python
>>> import tkvrsn
>>> tkvrsn.print_ver()
CSPICE_N0066
SpiceyPy Documentation
>>> import spiceypy >>> help(spiceypy.)which produces
Help on function tkvrsn in module spiceypy.spiceypy:
tkvrsn(item)
Given an item such as the Toolkit or an entry point name, return
the latest version string.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/tkvrsn_c.
html
:param item: Item for which a version string is desired.
:type item: str
:return: the latest version string.
:rtype: str
As indicated in the help on the function, the complete documentation is
available on the CSPICE toolkit version. Therefore it is recommended to
have the CSPICE toolkit version installed locally in order to access its
documentation offline.
|