SHTOOLS --- Tools for working with spherical harmonics

> Home > Documentation

Using SHTOOLS in Python

To access the SHTOOLS routines from Python, it is necessary that the pyshtools directory be in the Python search path. From within Python, enter

import sys
sys.path.append('/path-to-pyshtools')

where /path-to-pyshtools is the directory that contains the pyshtools directory. Typically, this is located in a place such as /usr/local/lib/python2.7/site-packages. After setting the path, it is then only necessary to execute the statement

import pyshtools

This will load the following classes and submodules into the pyshtools namespace:

If you are using iPython, which adds improved functionality to Python, the available pyshtools routines can be explored by typing

pyshtools.[tab]

where [tab] is the tab key.

Documentation

To read the documentation of a routine in iPython, such as MakeGridDH, enter

pyshtools.MakeGridDH?

To read the info string of an SHTOOLS constant, such as a_mars, enter

pyshtools.constant.a_mars.info()

Documentation for the Python functions used in SHTOOLS can also be accessed by their unix man pages, appending py to the name and using all lower case letters. As an example, to access the python MakeGridDH man page, use

man pymakegriddh

Alternatively, the man pages can be accessed from the documentation link on this web site.

> Home > Documentation

Institut de Physique du Globe de Paris University of Sorbonne Paris Cité © 2016 SHTOOLS