Skip to content
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

Add associated Legendre function calculations #505

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Conversation

leouieda
Copy link
Member

@leouieda leouieda commented May 10, 2024

The numba-based functions calculate the associated Legendre functions (unnormalized, Schmidt normalized, and fully normalized) and their derivatives $\dfrac{\partial P_n^m}{\partial \theta}(\cos\theta)$. The derivatives functions can be used to calculate higher order derivatives as well. Values are tested against analytical solutions for the first 4 degrees as well as an identity for the Schmidt functions and the Legendre equation for the Schmidt and fully normalized functions. The values are returned as 2D numpy arrays. This is a bit of a waste of memory but it's much easier to use than storing these in sparse matrices or 1D arrays. But it should be acceptable since we're unlikely to ever go over ~2700 degree so the waste is in the order of a few Mb at worse.

Relevant issues/PRs:

Related to #504

Allocate the output array out of the loop. This way we can do it once
only when evaluating the spherical harmonics. Pre-compute the square
roots of integers that we use in the loops. Doesn't work well if the
square roots are calculated at the module level (probably a numba
thing).
@leouieda leouieda mentioned this pull request May 14, 2024
@leouieda leouieda marked this pull request as ready for review May 23, 2024 22:43
@leouieda
Copy link
Member Author

leouieda commented May 23, 2024

@santisoler and @MarkWieczorek this is ready now. I added the Holmes and Featherstone scaling and tested until degree 2800. I was surprised that calculating the derivatives on rescaled functions works well. That's nice because it means we can keep them separate and use the derivative functions to calculate higher order derivatives (which would appear in gravity gradients).

If you could both have a quick look I'd really appreciate it. And thanks for all the information and code examples @MarkWieczorek! It really helped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant