SHTns 3.6.1
Using SHTns with Python

SHTns provides a Python interface that uses NumPy arrays to perform Spherical Harmonic Transforms.

The Python interface has been generated using SWIG (but you don't need it to compile the the Python package).

  • You can install the python module from the pypi repository:
    pip install shtns
    It is also possible to install from the source tree with:
    pip install .
    or
    python setup.py install --user
    In case you don't want OpenMP support, you can disable it by adding SHTNS_OPENMP=0 in front of the above commands.
  • Use within a python script or shell
    import shtns

To start using SHTns you must then create an sht object, from which you can call the transform functions and more. The arrays should be created using NumPy.

See also
See the Python example to get started, and the full working example shallow_water.py that solves the non-linear shallow water equations.

In case of segfaults, you may have alignment problems (should not occur on 64 bit systems). Please file a bugreport or contact the author.