mourner / suncalc

A tiny JavaScript library for calculating sun/moon positions and phases.
BSD 2-Clause "Simplified" License
3.07k stars 412 forks source link

What's the altitude of the sun at sunrise/sunset and why? #108

Open ianvonseggern1 opened 6 years ago

ianvonseggern1 commented 6 years ago

I'm trying to figure out some more specifics about the altitude of the sun at sunrise/set.

Some specific questions: a) Is the altitude of the sun the altitude of the center of the sun? b) What is the altitude at sunrise/set? c) What's the angular 'width' of the sun at sunrise/set?

Based on some exploration

SunCalc.getPosition(new Date(2017, 6, 10, 20, 29, 46), 40.7128, -74.0060).altitude * 180 / Math.PI -0.932926770103763 // At sunset

SunCalc.getPosition(new Date(2017, 6, 10, 20, 26, 30), 40.7128, -74.0060).altitude * 180 / Math.PI -0.3993281894769307 // At sunsetStart

I was a bit surprised to find that the altitude of sunsetStart isn't positive and of an equal magnitude to the sunset. Is sunset actually a bit below the horizon because of the curvature of the earth or because of the bending of light in the atmosphere or something?

I did find

[-0.833, 'sunrise', 'sunset' ], [ -0.3, 'sunriseEnd', 'sunsetStart' ],

In the code, but I couldn't figure out the units on these angles.

Thanks!!

lukes commented 6 years ago

I'm not an expert but have a read of https://en.wikipedia.org/wiki/Sunrise#Angle

The -0.833 measurement would appear to be degrees, as the article says sunrise happens when the sun is 90.83 below the zenith.

MenoData commented 6 years ago

0.833 = (50/60) ° = 50' (arc minutes). It is the sum of 16' arc minutes for the apparent radius of the sun (in the vertical) and 34' mean refraction angle (because the atmosphere bends the light depending on the temperature and the pressure so we can look a little bit "behind" the true horizon, i.e. the apparent horizone is a little bit further away than the true horizon)..

The radius correction is necessary in order to let the sunrise/sunset-event start when the upper limb and not the center of the sun crosses the horizon.