HOME | DOWNLOAD | DOCUMENTATION | FAQ |
> 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:
- SHCoeffs - A high level class for spherical harmonic coefficients.
- SHGrid - A high level classes for global grids.
- SHWindow - A high level classes for localization windows.
- shclasses - All pyshtools classes and subclasses.
- shtools - All pyshtools routines.
- legendre - Legendre functions.
- expand - Spherical harmonic expansion routines.
- shio - Spherical harmonic I/O, storage, and conversion routines.
- spectralanalysis - Global spectral analysis routines.
- localizedspectralanalysis - Localized spectral analysis routines.
- rotate - Spherical harmonic rotation routines.
- gravmag - Gravity and magnetics routines.
- constant - pyshtools constants.
- other - Other routines.
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 |