Welcome to fsph’s documentation!

fsph is a library to compute series of complex spherical harmonics.


The Condon-Shortley phase is not included, although it is often used by many other libraries; to incorporate it, multiply the positive-m spherical harmonics by \((-1)^m\).


Install from PyPI:

pip install fsph

Or from source:

git clone https://github.com/glotzerlab/fsph.git
cd fsph
python setup.py install

API Reference

fsph.pointwise_sph(phi, theta, lmax, negative_m=True)

Evaluate a series of spherical harmonics on an array of spherical coordinates.

The array objects phi and theta should have the same length and can hold single- or double-precision floating point numbers. The resulting array will be of length (N_coordinates, N_sphs) where N_coordinates is the length of the given coordinate arrays.

To map the columns of the result array to particular (l, m) values, see get_LMs().

  • phi – Array-like object of polar angles in [-pi, pi]
  • theta – Array-like object of azimuthal angles in [0, 2*pi]
  • lmax – Integer maximum spherical harmonic degree to compute (inclusive)
  • negative_m – Set to False to disable the negative-m spherical harmonics
fsph.get_LMs(lmax, negative_m=True)

Returns the (l, m) indices in the order that they are exposed by fsph.

Creates a (N_sphs, 2) array where the first column corresponds to the l values and the second column corresponds to the m values for any index in the series.

Indices and tables