2

Skyfield has the functionality to compute the phases of the moon. but What if I wanted to know when would the moon be 20 degrees from the sun or 25 degrees from the sun.

How can I get the exact date and time when the sun and moon would be at a certain degree longitude?

Edit(for clarification): Is it possible to know the next (or previous) date and time the sun or moon would be at a certain position? Like skyfield provides a function to find when sun and moon are at 0 degrees or 180 degrees (new moon, full moon).

AviD1511
  • 133
  • 7
  • There isn't a single date and time when the sun or the moon would be at a certain position in the sky. There are either multiple answers or none, depending on the position. – usernumber Nov 06 '19 at 14:48
  • You used the tag skyfield, so this is a bit off-topic, but stellarium has quite a few addons for calculating reversed ephemerids – usernumber Nov 06 '19 at 14:49
  • sorry for not clarifying it in the question. I wanted to know if given a date can i find when (next date and time) the moon or any other planet will be at a certain longitude next. And I would be using skyfield for my program so would like a solution in skyfield (or pyephem if required) – AviD1511 Nov 06 '19 at 19:32

1 Answers1

1

Yes, Skyfield supports a possible approach. Look at its almanac.py module and you will find there are two steps:

  1. Create a function that, given a date, returns 0 if the Moon is <20° from the Sun or 1 if the Moon is ≥20°. You can either create this function directly and simply, or be more complicated like Skyfield is, and return a function from inside another function that holds the references to things like the ephemeris that the function will need to generate its answer.

  2. Pass that function to the find_discrete() routine to tell you the moments at which the function flips from 0 to 1 or back again during a particular time period.

Hopefully the examples there will help you get started!

Brandon Rhodes
  • 83,755
  • 16
  • 106
  • 147
  • 1
    Thanks for taking the time to reply and also for writing the code so beautifully. What I wanted was very similar to `moon_phases()`. I created a function to return each degree of change and get dates using `find_discrete()`. Thanks again!! – AviD1511 Nov 14 '19 at 06:10