Calculation of sunrise and sunset: Difference between revisions

From WickyWiki
mNo edit summary
mNo edit summary
Line 9: Line 9:
A script to change settings with [[MotionEyeOS]] for day and night settings:
A script to change settings with [[MotionEyeOS]] for day and night settings:
* https://blog.ligos.net/2016-04-18/Day-Night-Cycle-For-MotionEye.html
* https://blog.ligos.net/2016-04-18/Day-Night-Cycle-For-MotionEye.html
= Approximation of solar noon, sunrise and sunset =


Input example:
Input example:
* Date --> vDayOfYear
* Date --> vDayOfYear
* Date --> vLeapyear
* Date --> vLeapyear
* ToRads(degs) = degs /360 * 2*Pi
* ToDegs(rads) = rads / (2*Pi) * 360


Fractional year (radians)
Fractional year (radians)
Line 28: Line 32:
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):
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):


   vHa = ACOS( COS( TO_RADIANS(90.833) ) / COS(vLat) * COS(vDecl) - TAN(vLat) * TAN(vDecl) )
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)


Sunrise UTC minutes
Sunrise UTC minutes


   vUtcMinsSunrise = 360 * 2 - 4 * (vLon + TO_DEGREES(vHa) ) - vEqtime
   vUtcMinsSunrise = 360 * 2 - 4 * (vLon + ToDegs(vHa) ) - vEqtime


Noon UTC minutes
Noon UTC minutes
Line 40: Line 50:
Sunset UTC minutes
Sunset UTC minutes


   vUtcMinsSunset = 360 * 2 - 4 * (vLon - TO_DEGREES(vHa) ) - vEqtime
   vUtcMinsSunset = 360 * 2 - 4 * (vLon - ToDegs(vHa) ) - vEqtime


Sunset local time in fractional day. For Europe/Amsterdam --> vTimezone=+1 or +2 (DST)
Sunset local time in fractional day. For Europe/Amsterdam --> vTimezone=+1 or +2 (DST)


   (vUtcMinsSunset / 60 + vTimezone) / 24
   (vUtcMinsSunset / 60 + vTimezone) / 24

Revision as of 15:07, 5 March 2019


Source:

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)

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