Basics, Building SPICE Applications (Python) |
Table of ContentsBasics, Building SPICE Applications (Python) Note About HTML Links Environment Set-up Unix/Linux/Windows Mac 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
Unix/Linux/Windows
$ pip install six $ pip install numpy $ pip install spiceypyUsing anaconda, miniconda or conda:
$ conda install -c https://conda.anaconda.org/andrewannex spiceypy Mac
$ brew update $ brew install openssl
$ setenv PATH /usr/local/opt/openssl/bin:$PATH
$ brew link openssl --force $ brew install python --with-brewed-openssl
$ setenv PATH /usr/local/opt/python/libexec/bin:$PATH
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.0.0 ... 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_N0066From 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: strAs 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.
|