Jay Wen
Jay Wen

Reputation: 31

Calculate the end of sunrise/start of sunset

In PyEphem, I can calculate sunrise time. No problems. What I want is: when does the bottom of the sun appear to separate from the horizon? One obvious, but incorrect, method is when the center of the sun is at 1/2 * (sun size in degrees). Due to atmospheric effects, this is way off.

Same question for sunset. When does the bottom of the sun touch the horizon?

Is there a standard correction for this? The same as setting the horizon to -34 arcminutes for sunrise/set?

Upvotes: 1

Views: 250

Answers (2)

David K
David K

Reputation: 3132

The PyEphem page for Rising, Transit, Setting suggests that to match the USNO's almanac data for rising of the Sun, you can turn off refraction (by setting air pressure to zero) and put the horizon 34 minutes of arc lower than normal:

>>> import ephem
>>> atlanta = ephem.Observer()
>>> atlanta.pressure = 0
>>> atlanta.horizon = '-0:34'
>>> atlanta.lat, atlanta.lon = '33.8', '-84.4'
>>> atlanta.date = '2009/09/06 17:00' # noon EST
>>> print(atlanta.previous_rising(ephem.Sun()))

Now if you move the horizon up by the entire apparent diameter of the Sun, previous_rising will tell when the top limb of the Sun reaches this horizon (assuming no refraction), which will occur exactly when the bottom limb of the Sun reaches 34 minutes of arc below the normal horizon (again assuming no refraction), which (following the USNO's practice) is the predicted time when the bottom limb of the sun will be at the normal horizon when refraction is taken into account.

Note that, as explained under the heading Technical Definitions and Computational Details on this page at the USNO site, the USNO rise/set times for the Sun tell when the center of the sun is 50 minutes of arc below the horizon, regardless of the actual apparent diameter of the Sun at that time. In effect, they assume 16 minutes of arc for the radius of the Sun and 34 minutes of arc for refraction. Further, under the subheading Accuracy of rise/set computations, it is noted that "even under ideal conditions (e.g., a clear sky at sea) the times computed for rise or set may be in error by a minute or more" due to unpredictable atmospheric conditions. And the effect gets even worse if you are at a higher latitude.

In light of this, a reasonable procedure might be to assume 32 minutes of arc for the Sun's diameter; then to predict the end of sunrise rather than the beginning, you would change the line

>>> atlanta.horizon = '-0:34'

in the PyEphem sample code to

>>> atlanta.horizon = '-0:02'

Upvotes: 2

Jay Wen
Jay Wen

Reputation: 31

I have an approximate solution that seems to work. If anyone knows a more elegant solution. Please speak up.

At sunrise: The center of the sun is at approx. -34' - (sun dia)/2. The top of the sun appears to be at the horizon. Assume that the -34' correction is constant near the horizon. (A big assumption)

When the sun has moved up by 1 solar diameter, the bottom of the sun will be at the horizon.

For this morning:

    time_of_sunrise = obs.previous_rising(ephem.Sun(), ephem.now())
    obs.date = time_of_sunrise
    sun.compute(obs)
    angle_sun_center_sunrise = sun.alt / degree ( about -0.84' )
    sun_dia_at_sunrise = sun.size / 3600

Find the end of sunrise with a binary search. Pseudo code:

    adjTm = 6 minutes
    sunriseEnd = time_of_sunrise + adjTm
    obs.date = sunriseEnd
    sun.compute(obs)

Check to see if sun.alt is within X tolerance of (angle_sun_center_sunrise + sun_dia_at_sunrise)

If out of tol.:
    set adjTm = adjTm/2
    adjust obs.date by sunriseEnd +/- adjTm
repeat until within tolerance.

Sunset works the same way.

Upvotes: 1

Related Questions