Equinox, Solstice and the 24 Solar Terms

Asked by Jack

Hi all,

I am look for the calculation of Solar Terms
In short , they are used in Chinese and Japanese Calendar, they divide 1 year to 24 pieces as Solar Terms. Each term divide the ecliptic into 24 equal segments, with 15 degrees of the Sun's longitude between the terms.
Reference:
http://www2.gol.com/users/stever/calendar.htm#terms

While I can find functions in PyEphem to calculate 4 of the Solar Terms (next_vernal_equinox, next_summer_solstice, next_autumnal_equinox, next_winter_solstice).

#example from the code
def next_vernal_equinox(date):
    """Return the date of the next vernal equinox."""
    return holiday(date, twopi, 0)

def holiday(d0, motion, offset):
    """Function that assists the finding of equinoxes and solstices."""
    def f(d):
        _sun.compute(d)
        return (_sun.ra + eighthpi) % quarterpi - eighthpi
    d0 = Date(d0)
    _sun.compute(d0)
    angle_to_cover = motion - (_sun.ra + offset) % motion
    if abs(angle_to_cover) < tiny:
        angle_to_cover = motion
    d = d0 + 365.25 * angle_to_cover / twopi
    return date(newton(f, d, d + hour))

May be my lack of understanding of the whole things. I try to modify these functions to try to get other Solar Terms but I failed.

Can anyone get me out of this? A simple example of how I can get one of those other Solar Terms will be very helpful.

Thanks a lot

Question information

Language:
English Edit question
Status:
Answered
For:
PyEphem Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Brandon Rhodes (brandon-rhodes) said :
#1

The solar terms, it sounds like, would each be one-twenty-fourth of a year apart. So an approximate solution would be to find the vernal equinox, then step forward twenty-four times in steps of (365.25/24) days each, or 15.21875 days forward with each step.

But, of course, the sun does not move across the sky at exactly the same rate all year, so to find the actual moment that the sun crosses a 15° line you would want to run newton() with a small function that reaches zero each time the sun crosses a 15° mark. Here is a small program that can print the date and time of when the sun crosses a given longitude:

import ephem
from math import pi
twopi = 2 * pi

def when_is_sun_at_degrees_longitude(degrees):

    # Find out the sun's current longitude.

    sun = ephem.Sun(ephem.now())
    current_longitude = sun.hlong - pi

    # Find approximately the right time of year.

    target_longitude = degrees * ephem.degree
    difference = (target_longitude - current_longitude) % twopi
    t0 = ephem.now() + 365.25 * difference / twopi

    # Zero in on the exact moment.

    def f(t):
        sun.compute(t)
        longitude = sun.hlong - pi
        return ephem.degrees(target_longitude - longitude).znorm

    return ephem.Date(ephem.newton(f, t0, t0 + ephem.minute))

print when_is_sun_at_degrees_longitude(0)
print when_is_sun_at_degrees_longitude(15)
print when_is_sun_at_degrees_longitude(30)

Can you help with this problem?

Provide an answer of your own, or ask Jack for more information if necessary.

To post a message you must log in.