'
' This program by Roger W. Sinnott calculates the times of sunrise
' and sunset on any date, accurate to the minute within several
' centuries of the present. It correctly describes what happens in the
' arctic and antarctic regions, where the Sun may not rise or set on
' a given date. Enter north latitudes positive, west longitudes
' negative. For the time zone, enter the number of hours west of
' Greenwich (e.g., 5 for EST, 4 for EDT). The calculation is
' discussed in Sky & Telescope for August 1994, page 84.
' Sunrise-Sunset
' Constants
P1 = 3.14159265
P2 = 2 * P1
DR = P1 / 180
K1 = 15 * DR * 1.0027379
S1 = "Sunset at "
R1 = "Sunrise at "
M1 = "No sunrise this date"
M2 = "No sunset this date"
M3s = "Sun down all day"
M4 = "Sun up all day"
INPUT "Lat, Long (deg)"; B5
, L5
INPUT "Time zone (hrs)"; H
L5 = L5 / 360
Z0 = H / 24
'
' Calendar --> JD
Y = 2020
M = 12
D3 = 25 'INPUT "Year, Month, Day";Y,M,D3
G = 1
F = D3 - D1 - .5
J
= -INT(7 * (INT((M
+ 9) / 12) + Y
) / 4) J3
= -INT((INT(J3
/ 100) + 1) * 3 / 4)J
= J
+ INT(275 * M
/ 9) + D1
+ G
* J3
J = J + 1721027 + 2 * G + 367 * Y
F = F + 1
J = J - 1
T = (J - 2451545) + F
TT = T / 36525 + 1 ' TT = centuries
' from 1900.0
' LST at 0h zone time
T0 = T / 36525
S = 24110.5 + 8640184.813 * T0
S = S + 86636.6 * Z0 + 86400 * L5
S = S / 86400
T0 = S * 360 * DR
T = T + Z0
'
' Get Sun's Position
T = T + 1
IF A
(2) < A
(1) THEN A
(2) = A
(2) + P2
Z1 = DR * 90.833 ' Zenith dist.
M8 = 0
W8 = 0
A0 = A(1)
D0 = D(1)
DA = A(2) - A(1)
DD = D(2) - D(1)
P = (C0 + 1) / 24
A2 = A(1) + P * DA
D2 = D(1) + P * DD
'
' Test an hour for an event
L0 = T0 + C0 * K1
L2 = L0 + K1
H0 = L0 - A0
H2 = L2 - A2
H1 = (H2 + H0) / 2 ' Hour angle,
D1 = (D2 + D0) / 2 ' declination,
' at half hour
A1 = 2 * V2 - 4 * V1 + 2 * V0
B = 4 * V1 - 3 * V0 - V2
D3 = B * B - 4 * A1 * V0
E = (-B + D3) / (2 * A1)
IF E
> 1 OR E
< 0 THEN E
= (-B
- D3
) / (2 * A1
) T3 = C0 + E + 1 / 120: ' Round off
H7 = H0 + E * (H2 - H0)
IF AZ
> 360 THEN AZ
= AZ
- 360 A0 = A2
D0 = D2
V0 = V2
' Special msg?
'
' Special-message routine
'
' Fundamental arguments
' (Van Flandern &
' Pulkkinen, 1979)
P2 = 6.283185307179586
L = .779072 + .00273790931 * T
G = .993126 + .0027377785 * T
L
= L
- INT(L
): G
= G
- INT(G
) L = L * P2: G = G * P2
V
= V
- .01000 * SIN(L
- G
) V
= V
+ .00333 * SIN(L
+ G
) V
= V
- .00021 * TT
* SIN(L
) U
= U
- .00014 * COS(2 * L
) W
= -.00010 - .04129 * SIN(2 * L
) W
= W
+ .00104 * SIN(2 * L
- G
) W
= W
- .00035 * SIN(2 * L
+ G
) W
= W
- .00008 * TT
* SIN(G
) '
' Compute Sun's RA and Dec
A5
= L
+ ATN(S
/ SQR(1 - S
* S
))