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
$ pip install -U pip setuptools wheel $ pip install -U numpyThen install SpiceyPy:
$ pip install spiceypyUsing anaconda, miniconda or conda:
$ conda config --add channels conda-forge $ conda install spiceypyThe instructions above are for SpiceyPy 5.1.2. Instructions for earlier and later SpiceyPy versions may be different. Please refer to the SpiceyPy documentation for additional details. Confirm that Python can access SpiceyPy
$ pip list --format=columns Package Version ---------- ------- ... numpy 1.23.3 ... pip 22.2.2 ... setuptools 65.4.1 ... spiceypy 5.1.2 ... wheel 0.37.1 ... A simple example program
File tk_ver.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 tk_ver.py CSPICE_N0067From Python, execute the function:
$ python >>> import tkvrsn >>> tkvrsn.print_ver() CSPICE_N0067 SpiceyPy Documentation
>>> import spiceypy >>> help(spiceypy.tkvrsn)which produces
Help on function tkvrsn in module spiceypy.spiceypy: tkvrsn(item: str) -> str Given an item such as the Toolkit or an entry point name, return the latest version string. https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ tkvrsn_c.html :param item: Item for which a version string is desired. :return: the latest version string.As indicated in the help on the function, the complete documentation is available on the CSPICE toolkit docs. Therefore it is recommended to have the CSPICE toolkit installed locally in order to access its documentation offline.
|