SphericalHarmonics
SphericalHarmonics copied to clipboard
`nan`s in calculation of the spherical harmonics
There are nans
when computing spherical harmonics with the number of degrees > 87 in dimension 3.
Steps to reproduce:
- Generate fundamental system cache for dim = 3 and the number of degrees > 87.
- Run the code:
import numpy as np
from spherical_harmonics import SphericalHarmonics
X = np.r_[1., 0., 0.].reshape(1, -1)
harmonics_86 = SphericalHarmonics(dimension=3, degrees=86)
hX = harmonics_86(X)
print(np.any(np.isnan(hX))) # False
harmonics_87 = SphericalHarmonics(dimension=3, degrees=87)
hX = harmonics_87(X)
print(np.any(np.isnan(hX))) # True
Expected behaviour:
No nans
The spherical harmonics are only defined on the sphere. I'm not surprised that the input X = np.r_[0., 0., 0.].reshape(1, -1)
leads to nan
s. Can you double-check that this isn't the issue, please?
I am sorry for the typo. The problem persists with X = np.r_[1., 0., 0.].reshape(1, -1)
and I updated the issue.