Skip to content

added approximate routine for calculating position of the moon - #4963

Merged
astrofrog merged 20 commits into
astropy:masterfrom
StuartLittlefair:meeus
Jun 8, 2016
Merged

astrofrog merged 20 commits into
astropy:masterfrom
StuartLittlefair:meeus

Conversation

@StuartLittlefair

Copy link
Copy Markdown
Contributor

This PR fixes #4943.

I have coded up the algorithm in Jean Meeus', 'Astronomical Algorithms', second edition, 1998, Willmann-Bell for the approximate position of the Moon. Compared with JPL ephemerides this is only accurate to 15 arcsecs and 60 km over the range 1950-2050 (see below). However, it does not require any public downloads.

meeus

The function defined here has not been made part of the public API. I am thinking that the function can be used to add the moon to the approximate ephemeris added in #4920 once that PR is merged.

@mhvk mhvk mentioned this pull request May 25, 2016
@StuartLittlefair

Copy link
Copy Markdown
Contributor Author

@mhvk I guess now #4920 is in I should rebase this on astropy/master and make changes so the moon is available as part of the builtin ephemeris?

Comment thread astropy/coordinates/meeus.py Outdated

suml = sumr = 0.0
lrnum = len(_MOON_L_R)
for i in range(lrnum):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit more pythonic might be:

for moon_l_r in _MOON_L_R:
    DNum, MNum, McNum, FNum, LFac, RFac = moon_l_r
    corr = E ** abs(MNum)
    suml += LFac * corr * np.sin(...)
    sumr += RFac * corr * np.cos(...)

@eteq

eteq commented May 27, 2016 •

Copy link
Copy Markdown
Member

@StuartLittlefair - yep, rebase just as you said (and maybe address @mhvk's comments at the same time?)

Two larger scale thoughts (I'll do a more thorough review post-rebase):

  • I don't think there should be a meeus.py, because there's already some of those algorithms implemented elsewhere (either directly or indirectly via slightly different implementations of the same ideas). More generally, it's more consistent with the rest of the package to organize along "task" or "science area" lines, rather than "source". What you've done here should instead be orbital_elements.py or similar...?
  • Along related lines: you've implemented almost everything needed to get a location with arbitrary orbital elements. I think this is worth generalizing in that manner. That could be done here (if you like), or as a follow-on PR (which I'm happy to do myself if you'd rather not, @StuartLittlefair).

@StuartLittlefair

Copy link
Copy Markdown
Contributor Author

The commits I just pushed rebase this on @mhvk's changes made in #4920.

@eteq if these tests pass I guess this could do with a more thorough review. I thought about your suggestions for generalising to a location with arbitrary orbital elements but struggled to see how such a generalisation could be done. For example, the VSOP87 planetary theory uses different types of sum and even terms to the ELP2000-82 Lunar position model encoded here. If you think it can be done, however, feel free to make a PR and show me how!

Comment thread astropy/coordinates/orbital_elements.py Outdated
E = polyval(T, _coE)

suml = sumr = 0.0
for moon_l_r in _MOON_L_R:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this again, I think one can simply write

for DNum, MNum, McNum, FNum, LFac, RFac in _MOON_L_R:

(and same below)

Sorry that I didn't note that earlier!

@eteq

eteq commented Jun 7, 2016 •

Copy link
Copy Markdown
Member

I still think we might want to generalize the orbital elements machinery, but on reflection it's definitely a task for a future PR. So with that this looks good-to-go to me, right @StuartLittlefair?

@astrofrog and @taldcroft, are you OK with backporting this to 1.2 (as it's part of the solar system stuff that's new in 1.2)? If so, it doesn't need a changelog entry as it's an addition to an already-mentioned new feature.

@astrofrog

Copy link
Copy Markdown
Member

👍 to backporting

@astrofrog

Copy link
Copy Markdown
Member

@StuartLittlefair - can you confirm this is ready to go?

@taldcroft - do you agree with backporting this?

@StuartLittlefair

Copy link
Copy Markdown
Contributor Author

@mhvk - yes, ready to go from me.

@taldcroft

Copy link
Copy Markdown
Member

👍 on backporting to 1.2.

@astrofrog
astrofrog merged commit 59f1ea2 into astropy:master Jun 8, 2016
@astrofrog astrofrog added this to the v1.2.0 milestone Jun 8, 2016
astrofrog added a commit that referenced this pull request Jun 8, 2016
added approximate routine for calculating position of the moon
@StuartLittlefair
StuartLittlefair deleted the meeus branch June 10, 2016 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add approximate version of get_moon

6 participants