13

What algorithms or formulas are available for computing the equinoxes and solstices? I found one of these a few years ago and implemented it, but the precision was not great: the time of day seemed to be assumed at 00:00, 06:00, 12:00, and 18:00 UTC depending on which equinox or solstice was computed. Wikipedia gives these computed out to the minute, so something more exact must be possible. Libraries for my favorite programming language also come out to those hardcoded times, so I assume they are using the same or a similar algorithm as the one I implemented.

I also once tried using a library that gave me the solar longitude and implementing a search routine to zero in on the exact moments of 0, 90, 180, and 270 degrees; this worked down to the second but did not agree with the times in Wikipedia, so I assume there was something wrong with this approach. I am, however, pleasantly surprised to discover that Maimonides (medieval Jewish scholar) proposed an algorithm using the exact same idea a millenium ago.

skiphoppy
  • 97,646
  • 72
  • 174
  • 218

4 Answers4

6

A great source for the (complex!) underlying formulas and algorithms is Astronomical Algorithms by Jean Meeus.

Using the PyMeeus implementation of those algorithms, and the code below, you can get the following values for the 2018 winter solstice (where "winter" refers to the northern hemisphere).

winter solstice for 2018 in Terrestrial Time is at:
 (2018, 12, 21, 22, 23, 52.493725419044495)

winter solstice for 2018 in UTC, if last leap second was (2016, 12):
 (2018, 12, 21, 22, 22, 43.30972542127711)

winter solstice for 2018 in local time, if last leap second was (2016, 12)
 and local time offset is -7.00 hours:
 (2018, 12, 21, 15, 22, 43.30973883232218)

i.e. 2018-12-21T15:22:43.309725-07:00

Of course, the answer is not accurate down to microseconds, but I also wanted to show how to do high-precision conversions with arrow.

Code:

from pymeeus.Sun import Sun
from pymeeus.Epoch import Epoch

year = 2018  # datetime.datetime.now().year
target="winter"

# Get terrestrial time of given solstice for given year
solstice_epoch = Sun.get_equinox_solstice(year, target=target)

print("%s solstice for %d in Terrestrial Time is at:\n %s" %
      (target, year, solstice_epoch.get_full_date()))

print("%s solstice for %d in UTC, if last leap second was %s:\n %s" %
 (target, year, Epoch.get_last_leap_second()[:2], solstice_epoch.get_full_date(utc=True)))

solstice_local = (solstice_epoch + Epoch.utc2local()/(24*60*60))
print("%s solstice for %d in local time, if last leap second was %s\n"
 " and local time offset is %.2f hours:\n %s" %
 (target, year, Epoch.get_last_leap_second()[:2],
  Epoch.utc2local() / 3600., solstice_local.get_full_date(utc=True)))

Using the very cool more ISO and TZ aware module Arrow: better dates and times for Python, that can be printed more nicely:

import arrow
import math

slutc = solstice_epoch.get_full_date(utc=True)
frac, whole = math.modf(slutc[5])

print("i.e. %s" % arrow.get(*slutc[:5], int(whole), round(frac * 1e6)).to('local'))
pjpscriv
  • 866
  • 11
  • 20
nealmcb
  • 12,479
  • 7
  • 66
  • 91
  • very cool for a python programmer. Unfortunately not applicable for everyone else. The OP asked for the algorithm. I'm also looking for the formula(s) or a source for those. – Steffen Roller Dec 30 '20 at 02:05
  • 1
    True enough. I added a reference to Meeus' book. But the algorithms or formulas are perhaps more appropriate for http://astronomy.stackexchange.com/ – nealmcb Dec 31 '20 at 04:01
  • 1
    Hmm... "winter". I suppose this applies to winter in the northern hemisphere... – marisano May 21 '21 at 07:38
1

I'm not sure if this is an accurate enough solution for you, but I found a NASA website that has some code snippets for calculating the vernal equinox as well as some other astronomical-type information. I've also found some references to a book called Astronomical Algorithms which may have the answers you need if the info somehow isn't available online.

Neil Williams
  • 12,318
  • 4
  • 43
  • 40
  • I've seen that book mentioned before; I was hoping to use SO as an opportunity to get some of that information online if it's not already. :) – skiphoppy Apr 01 '09 at 05:03
  • 1
    It'd certainly be nice to have it somewhere! It seems the algorithms are rather complicated and specialized. – Neil Williams Apr 01 '09 at 05:05
  • 7
    Link is dead. That's why they tell you not to just drop links in here. – Rob May 06 '15 at 03:54
1

I know you're looking for something that'll paste into an answer here, but I have to mention SPICE, a toolkit produced by NAIF at JPL, funded by NASA. It might be overkill for Farmer's Almanac stuff, but you mentioned interest in precision and this toolkit is routinely used in planetary science.

dwc
  • 24,196
  • 7
  • 44
  • 55
-2

I have implemented Jean Meeus' (the author of the Astronomical Algorithms referenced above) equinox and solstice algorithm in C and Java, if you're interested.

Gary Chambers
  • 1,257
  • 1
  • 10
  • 10
  • I need your implementation in Java of above mentioned topics. Could u share the same. My email id is astroshoav.dev@gmail.com Thanks – Kumar Apr 02 '14 at 06:07
  • 4
    Please follow standard StackOverflow conventions and put the relevant details in your answer: code to calculate the answer, perhaps using specifically referenced software libraries etc. – nealmcb Dec 22 '18 at 20:48