The sun's declination (δ) is the angle of the sun relative to the earth's equatorial plane.
The solar declination is 0 ∘ at the vernal and autumnal equinoxes and rises to a maximum
of23.45∘ at the summer solstice. On any given day of the year (d), declination can be
calculated from the following formula:
δ= sin−^1 sin(23.45)sin
360
365
(d−81)
From the declination (δ) and the latitude (φ) we can calculate the sun's elevation (α) at
the current time.
α= sin−^1 sinδsinφ+cosδcosφcosω
Here ω is the hour angle, which is the number of degrees of rotation of the earth between
the current solar time and solar noon.
delta = asind(sind(23.45)sind(360(d - 81)/365)); % Declination
omega = 15(solarTime.Hour + solarTime.Minute/60 - 12); % Hour angle
alpha = asind(sind(delta)sind(phi) + ... % Elevation
cosd(delta)cosd(phi)cosd(omega));
disp(['Solar Declination = ' num2str(delta) ' Solar Elevation = ' num2str(alpha)])
Solar Declination = 21.9634 Solar Elevation = 69.2589
Knowing the sun's declination and the local latitude allows us to calculate the time of
sunrise and sunset. Sunrise and sunset are calculated in Standard Time.
sunrise= 12−
cos−^1 −tanφtanδ
15 ∘
−
TC
60
sunset= 12+
cos−^1 −tanφtanδ
15 ∘
−
TC
60
midnight = dateshift(localTime,'start','day');
sr = 12 - acosd(-tand(phi)tand(delta))/15 - solarCorr/60;
sunrise = timeofday(midnight + hours(sr));
ss = 12 + acosd(-tand(phi)tand(delta))/15 - solarCorr/60;
sunset = timeofday(midnight + hours(ss));
disp(['Sunrise = ' datestr(sunrise,'HH:MM:SS') ' Sunset = ' datestr(sunset,'HH:MM:ss') ])
Sunrise = 04:15:34 Sunset = 19:08:11
Create an Interactive Narrative with the Live Editor