Welcome to fsph’s documentation!

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

Note

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\).

Installation

Install from PyPI:

pip install --no-build-isolation 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().

Parameters:
  • phi – Array-like object of polar angles in [0, 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.

Tensorflow Operations

As of version 0.2, fsph can also compute spherical harmonic series of points on the CPU and GPU using tensorflow. This module is automatically built when tensorflow is found while installing fsph. GPU support is enabled when CUDA (specifically, the nvcc binary) is found while installing fsph.

fsph.tf_ops.spherical_harmonic_series(inputs, lmax, negative_m)

Compute a spherical harmonic series for a set of input points.

Parameters:
  • inputs – (…, 2) array of (phi, theta) values
  • lmax – Maximum spherical harmonic l to compute
  • negative_m – If True, compute for negative as well as positive m values

Indices and tables