New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Confusing documentation for scipy.special.sph_harm
#6657
Comments
Sounds good to me. We should also 3) add tests for this to be sure, via manual evaluation of the equation and/or cross-checking with other packages. Do you have time to make a PR? |
Hey @EmperorDali note that the wiki page defines
whereas SciPy defines
If I flip the arguments in your example I get >>> sph_harm(1, 1, np.pi/2, 0)
(-0+0j) which matches the wiki expression. So I think everything defined correctly in the documentation. |
Oh great, the multiple definitions of spherical harmonics strike again... |
Given the amount of confusion this generates over the years, it'd probably be good to add an explicit form of the low-order harmonics (m=1, l=-1, 0, 1) and mention the Condon-Schockley phase. |
And while someone was working on that, they could also add a full definition of |
@person142 I don't agree with what you wrote. Note that when I copied Y_1^1 from the table to my first post I interchanged \theta and \phi, to match If you look at my post, you'll see I did |
Ah, I worked directly from the wiki page and missed that. Apologies. The function
|
The refguide for the Legendre functions could also use some improvements: https://scipy.github.io/devdocs/special.html#legendre-functions In particular it's difficult to figure out the differences between the functions at a glance. Also, given the names of the functions (consider Edit: aliases are a bit OT for this issue though; just something to think about. |
Yes it could be cleaned up a bit. I'll see if I can find some time to do it. |
Also add clearer one-sentence summaries for the Legendre functions. Closes scipygh-6657.
Also add clearer one-sentence summaries for the Legendre functions. Closes scipygh-6657.
The documentation for
scipy.special.sph_harm
states that this function computesI am not an expert in spherical harmonics, but to my eyes this notation imples that
scipy
is computing spherical harmonics without the Condon-Shortley phase factor.However,
scipy
is actually computing the spherical harmonics with CS phase:compare this to
which is a spherical harmonic with CS phase, see table here
Presumably this is because
scipy
includes the CS phase factor with the associated Legendre functionscipy.special.lpmv
. I believe this is another convention that is used, however the documentation forscipy.special.lpmv
doesn't state what exactly is being computed.We should 1) update the documentation for
lpmv
to indicate that the function computes the associated Legendre polynomials with CS phase 2) add a note to the documentation forsph_harm
indicating that the function returns spherical harmonics with CS phase.The text was updated successfully, but these errors were encountered: