1
$\begingroup$

The scipy.special.sph_harm function evaluates a spherical harmonic function at a point. Does Scipy provide any functions to compute the spherical harmonic coefficients for a data set?

$\endgroup$
3
  • 1
    $\begingroup$ What do you mean by "the spherical harmonic coefficients for a data set"? $\endgroup$
    – nicoguaro
    Jun 16, 2017 at 16:58
  • $\begingroup$ I have some data defined on the surface of a sphere, and I'd like to create a spherical harmonic expansion for this data. I can integrate this data against the harmonic basis functions to get the coefficients, but I'm hoping this is built in to SciPy somehow. $\endgroup$ Jun 16, 2017 at 17:03
  • $\begingroup$ Just use Spherepack. There's a python wrapper: pypi.python.org/pypi/pyspharm $\endgroup$
    – user20857
    Jun 16, 2017 at 17:12

1 Answer 1

3
$\begingroup$

Given samples of a function $f(\theta,\phi)$, you will need to numerically evaluate the integral

$$\int_0^\pi\int_0^{2\pi}f(\theta,\phi)\left[Y_n^{m}(\theta,\phi)\right]^*\sin\theta d\phi d\theta\, ,$$

to obtain the $n,m$th coefficient of your expansion. Hopefully your samples are at some convenient locations on the unit sphere, either uniformly sampled or at Gauss-Legendre nodes.

$\endgroup$
2
  • 1
    $\begingroup$ You probably want to Lebedev grid points instead of Gauss-Legendre nodes. $\endgroup$
    – nicoguaro
    Jun 16, 2017 at 17:13
  • $\begingroup$ Numerical evaluation this integral is poorly conditioned and painful. Which is why people usually just use a software package designed for this specific purpose. $\endgroup$
    – user20857
    Jun 16, 2017 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.