SHTOOLS/pysthools is a Fortran-95/Python library that can be used to perform spherical harmonic transforms, multitaper spectral analyses on the sphere, expansions of functions into Slepian bases, and standard operations on global gravitational and magnetic field data.
-
A wide range of supported spherical harmonic functions:
- real and complex,
- all standard normalizations (Geodesy 4π, Schmidt semi-normalized, orthonormalized, unnormalized),
- Condon-Shortley phase factor of (-1)m.
-
Clean implementation of the spherical harmonic transforms:
- exact quadrature rules using the sampling theorem of Driscoll and Healy (1994) or Gauss-Legendre quadrature,
- accurate and fast to approximately degree 2800,
- OpenMP compatible and OpenMP thread-safe.
-
Selected applications and routines:
- global spectral analysis, spherical harmonic rotations, and Wigner 3j symbols,
- localized multitaper spectral analyses, and expansions in Slepian basis functions,
- standard gravity and magnetic field calculations, computation of the geoid, and finite-amplitude potential from topography.
-
SHTOOLS is open source software (3-clause BSD license).
Binary install for linux/macOS/windows:
pip install pyshtools
Upgrade to a new version:
pip install --upgrade pyshtools
Build from source:
pip install pyshtools --no-binary pyshtools
Install fftw3 with fortran bindings and then install pyshtools using pip
:
conda install -c eumetsat fftw3
pip install pyshtools
Linux requirements:
sudo apt-get install libblas-dev liblapack-dev g++ gfortran libfftw3-dev tcsh
macOS requirements:
brew install fftw
To install the develop branch:
pip install git+https://github.com/SHTOOLS/SHTOOLS@develop
Alternatively, clone the shtools repo and then install:
git clone https://github.com/SHTOOLS/SHTOOLS.git
cd shtools
pip install . # install into the active python environment lib folder, or
pip install -v -e . # install into the SHTOOLS/pyshtools folder and link to the active python environment
Clone the shtools repo, and then execute one of the following commands in the shtools directory:
make fortran
make fortran-mp # for OpenMP Fortran routines
Or use the brew package manager (macOS):
brew tap shtools/shtools
brew install shtools
brew install shtools --with-openmp # to install shtools with the OpenMP components.
More installation instructions and options can be found in the web documentation.
SHTOOLS can be invoked in any Fortran 95 or Python program. The core software is written in Fortran 95, and Python wrappers allow simple access to the fortran-compiled routines. A variety of Python notebooks and example files are included that demonstrate the major features of the library.
To get started, check out the following Python tutorial notebooks:
- Introduction 1: Grids and Spherical Harmonic Coefficients
- Introduction 2: Localization Windows and Spectral Analysis
- Introduction 3: Gravity and Magnetic Fields
We work on the develop
branch and only push releases to master
. Please base all pull requests on develop
.
Mark A. Wieczorek and Matthias Meschede (2018). SHTools --- Tools for working with spherical harmonics, Geochemistry, Geophysics, Geosystems, 19, 2574-2592, doi:10.1029/2018GC007529.