Calculation of sunrise and sunset: Difference between revisions
From WickyWiki
mNo edit summary |
mNo edit summary |
||
| Line 8: | Line 8: | ||
A script to change settings with [[MotionEyeOS]] for day and night settings: | A script to change settings with [[MotionEyeOS]] for day and night settings: | ||
* | * [[MotionEyeOS Day and Night Python script]] | ||
= Approximation of solar noon, sunrise and sunset = | = Approximation of solar noon, sunrise and sunset = | ||
Latest revision as of 15:12, 5 March 2019
Source:
- https://www.esrl.noaa.gov/gmd/grad/solcalc/
- https://en.wikipedia.org/wiki/Sunrise_equation
- http://www.srrb.noaa.gov/highlights/sunrise/calcdetails.html
A script to change settings with MotionEyeOS for day and night settings:
Approximation of solar noon, sunrise and sunset
Input example:
- Date --> vDayOfYear
- Date --> vLeapyear
- ToRads(degs) = degs /360 * 2*Pi
- ToDegs(rads) = rads / (2*Pi) * 360
Fractional year (radians)
vY = 2 * PI() / (365 + vLeapYear) * (vDayOfYear - 1 )
Equation of time (minutes)
vEqtime = 229.18 * (0.000075 + 0.001868 * COS( vY ) - 0.032077 * SIN( vY ) - 0.014615 * COS(2 * vY ) - 0.040849 * SIN(2 * vY )
Solar declination angle (radians).
vDecl = 0.006918 - 0.399912 * COS(vY) + 0.070257 * SIN(vY) - 0.006758 * COS(2 * vY) + 0.000907 * SIN(2 * vY) - 0.002697 * COS(3 * vY) + 0.00148 * SIN (3 * vY)
For sunrise or sunset, the zenith is set to 90.833 degrees (the approximate correction for atmospheric refraction at sunrise and sunset, and the size of the solar disk). Hours angle (radians):
Input:
- Latitude --> vLat (corresponds with distance from the equator)
vHa = ACOS( COS( ToRads(90.833) ) / COS(vLat) * COS(vDecl) - TAN(vLat) * TAN(vDecl) )
Input:
- Longitude --> vLon (corresponds with distance from UTC=0)
Sunrise UTC minutes
vUtcMinsSunrise = 360 * 2 - 4 * (vLon + ToDegs(vHa) ) - vEqtime
Noon UTC minutes
vUtcMinsNoon = 360 * 2 - 4 * vLon - vEqtime
Sunset UTC minutes
vUtcMinsSunset = 360 * 2 - 4 * (vLon - ToDegs(vHa) ) - vEqtime
Sunset local time in fractional day. For Europe/Amsterdam --> vTimezone=+1 or +2 (DST)
(vUtcMinsSunset / 60 + vTimezone) / 24