home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HAM Radio 1
/
HamRadio.cdr
/
tech
/
david4
/
sunset.bas
< prev
next >
Wrap
BASIC Source File
|
1986-11-21
|
3KB
|
86 lines
10 REM One note regarding azimuth angles: In the SOUTHERN hemisphere,
20 REM this program assumes that the South Pole is zero degrees, and
30 REM the azimuth angle is measured COUNTER-clockwise through East.
40 REM Therefore, an azimuth angle of 108 degrees is NORTH of East.
50 REM When Lat and Long are input, use a negative value for Southern
60 REM Latitudes and for Eastern Longitudes.
70 REM ----------------- Program Begins ---------------------------
80 CLS
90 PRINT"This program finds the declination of the sun, the equation"
100 PRINT"of time, the azimuth angles of sunrise and sunset, and the"
110 PRINT"times of sunrise and sunset for any point on earth."
120 PRINT
130 PRINT"Input eastern longitudes and southern latitudes as NEGATIVE."
140 PRINT
150 PRINT
160 REM
170 REM
180 DIM N(12)
190 PL=3.14159/26:J=57.2958
200 INPUT"ENTER LATITUDE (FORMAT DD.MM)";D1
210 INPUT"ENTER LONGITUDE (FORMAT DD.MM)";D2
220 GOSUB 780
230 LA = D1
240 IF LA < 0 THEN LA = LA + 180
250 IF D2 < 0 THEN D2 = D2 + 360
260 LO = FIX(D2/15)*15 :REM finds time zone beginning
270 TD=(D2-LO)/15
280 INPUT"ENTER MONTH,DAY (11,25)";M,DA
290 FOR I=1 TO 12: READ N(I):NEXT I
300 DATA 0,31,59,90,120,151
310 DATA 181,212,243,273,304,334
320 X=(N(M)+DA)/7
330 REM
340 D=.4560001-22.195*COS(PL*X)-.43*COS(2*PL*X)-.156*COS(3*PL*X)+3.83*SIN(PL*X)+.06*SIN(2*PL*X)-.082*SIN(3*PL*X)
350 REM
360 PRINT
370 PRINT"DECLINATION OF SUN:";
380 PRINT USING"###.#";D;
390 PRINT" DEGREES"
400 E=8.000001E-03+.51*COS(PL*X)-3.197*COS(2*PL*X)-.106*COS(3*PL*X)-.15*COS(4*PL*X)-7.317001*SIN(PL*X)-9.471001*SIN(2*PL*X)-.391*SIN(3*PL*X)
410 REM
420 PRINT"EQUATION OF TIME:";
430 PRINT USING"###.#";E;
440 PRINT" MINUTES"
450 CL=COS(LA/J):SD=SIN(D/J):CD=COS(D/J):Y=SD/CL
460 IF ABS(Y)=>1 THEN PRINT"NO SUNRISE OR SUNSET":END
470 Z = 90 - J*ATN(Y/SQR(1-Y*Y))
480 PRINT"AZIMUTH OF SUNRISE:";
490 PRINT USING"####.#";ABS(Z);
500 PRINT" DEGREES"
510 PRINT"AZIMUTH OF SUNSET: ";
520 PRINT USING"####.#";360-ABS(Z);
530 PRINT" DEGREES"
540 ST=SIN(Z/J)/CD
550 IF ABS(ST)>=1 THEN T=6:TT=6:GOTO 590
560 CT=SQR(1-ST*ST)
570 T=J/15*ATN(ST/CT)
580 TT=T
590 IF D<0 AND LA<90 THEN T=12-T:TT=T
600 IF D>0 AND LA>90 THEN T=12-T: TT=T
610 T=T+TD-E/60-.04
620 GOSUB 690
630 PRINT"TIME OF SUNRISE:";T1$;":";T2$;" ";T$;"L.T. ";GM$;":";T2$;" GM"
640 T=12-TT:T=T+TD-E/60+.04
650 CNT=1
660 GOSUB 690
670 PRINT"TIME OF SUNSET: ";T1$;":";T2$;" ";T$;"L.T. ";GM$;":";T2$;" GM"
680 END
690 T1=INT(T):T2=T-T1:T1$=STR$(T1):T2=INT((T2*600+5)/10)
700 T2$=STR$(T2):T2$=RIGHT$(T2$,LEN(T2$)-1)
710 IF INT(T2)<10 THEN T2$="0"+T2$
720 GM = FIX(D2/15) :REM calculate difference between GM and local time
730 IF CNT = 0 THEN GM = VAL(T1$)+GM :REM GMT for sunrise
740 IF CNT > 0 THEN GM = VAL(T1$)+12+GM :REM GMT for sunset
750 IF GM +(VAL(T2$)/60)> 24 THEN GM = GM - 24
760 GM$ = STR$(GM) :GM$ = RIGHT$("0"+GM$,2)
770 RETURN
780 REM This subroutine converts DD.MM input to DD.DD
790 DEGTMP = (ABS(D1)-ABS(FIX(D1))) *100/60
800 D1 = (FIX(ABS(D1))+DEGTMP)*SGN(D1)
810 DEGTMP = (ABS(D2)-ABS(FIX(D2))) *100/60
820 D2 = (FIX(ABS(D2))+DEGTMP)*SGN(D2)
830 RETURN
840 END