10000 REM June 10, 1998 ******* WS.rtn ******* wf 10001 REM This routine calculates the solar noon time (SNT) and its zenith 10020 REM angle(ZAMIN). It also calculates ZA1, ZA2 at 65 minutes off SNT, 10050 REM Delta equals a ZA the Sun moves in 4 minutes in the morning 10060 REM Variables ZA1, ZA2 and Delta are passed to WR.rtn to write daily 10070 REM schedule file 10080 CLS 10090 DATA WS 10110 rem PI= 3.141593: P0= PI/180: P3%=1000: LO=83.376: LA=33.948 10120 rem YE%=95: 'INPUT " The year (YY)is: ", YE% 10140 rem MO%=6: 'INPUT " The Month (MM) is: ", MO% 10150 rem DA=22: 'INPUT " The day (DD) is: ", DA% 10170 IF YE%=INT(YE%/4)*4 THEN LP%=1 ELSE LP%=0 10180 rem MO%=151: ' jd or may 31 10200 rem IF LP%=1 AND N>1 THEN MO%= MO%+1 10220 PRINT "Caculating solar zenith angles.........." 10300 zcold=zc: rem important to return the zc when exit the ws.rtn. 10400 rem *** determine approximately the local noon time. 10420 HL% = (LO/15) + 12: 10440 H1= HL% - 1.2: H2 = HL% + 1.2: rem 2.4 hours around local noon. 11040 Z=0.5: ZAMIN=90: SNT=0: rem step size = 0.5 minutes 11050 T0=H1*60:H3=H2*60: 11060 'GOSUB 17700 11120 GOSUB 17810: 11140 IF ZA < ZAMIN THEN ZAMIN = ZA: SNT=T0: 'MUMIN$=MS$ 11360 T0=T0+Z:IF T0>H3 THEN GOTO 11590 11380 GOTO 11120 11590 SY=INT(SNT/60): SX= SNT-60*SY 11610 PRINT " Mininum solar zenith angle for the day is "; ZAMIN 12000 rem *** calculate zenith 66 minutes before and after solar noon. 12050 T0= (SNT -66): GOSUB 17800 12100 ZA1=ZC: 12110 PRINT "ZA1=", ZA1 12150 T0=(SNT+63): GOSUB 17800 12200 ZA2=ZC: PRINT "ZA2=", ZA2 12300 'ZC=zcold: T0=timer/60 13000 rem +++ calculate Delta ZA in 4 minutes interval in the morning 13100 T0=SNT-180: rem 3 hours b4 solar noon 13120 GOSUB 17800: ZA3=ZC 13140 T0=T0+4: rem 4 minutes 13160 GOSUB 17800: ZA4=ZC 13180 Delta=ZA4 - ZA3: 13300 ZC=zcold: t0=timer/60 13400 'CLOSE#6: OPEN DD$ + "WTLOG." + NO$ FOR APPEND AS 6 13420 'PRINT#6, DATE$, SNT, ZAMIN, ZA1, ZA2, Delta 13440 'CLOSE#6: 14000 RETURN 17000 rem **************************************** 17700 REM -7799 calculate year # from 1965 17710 T=0:IF MO%<35 AND YE%/4=INT(YE%/4) THEN T=-1:REM take off day in leap year 17712 IF YE% < 50 THEN T=(T+25+DA%+INT(YE%/4)+(YE%+35)*365-16+MO%)/365.2422 17720 IF YE% >=50 THEN T=(T+DA%+INT(YE%/4)+(YE%-65)*365-16+MO%)/365.2422 17730 RETURN 17800 REM -7999 calculate solar angles 17810 EP=.999999999#: 17815 I=(279.4574+360*T+T0/1460.97)*P0 17820 E=4.2*SIN(3*I)-2*COS(2*I)+596.5*SIN(2*I) 17830 E=E-12.8*SIN(4*I)+19.3*COS(3*I) 17840 E=E-(102.5+.142*T)*SIN(I)+(.033*T-429.8)*COS(I):RA=(T0+E/60+720-LO*4)*P0/4 17850 A=ATN(.4336*SIN(I-E*P0/240)) 17860 E=COS(RA)*COS(A)*COS(LA*P0)+SIN(LA*P0)*SIN(A):IF E=>1 THEN E=EP 17865 IF E=<-1 THEN E=-EP 17877 IF E=0 THEN E=.0000001 17885 E=ATN(SQR(1-E*E)/E):IF E<0 THEN E=E+PI:REM ** ERROR ON CONVERSION ** 17890 RA=SIN(RA): 'IF AZ=<0 AND RA=<0 THEN AZ=180+AZ:GOTO 7930 17937 IF E>90.5*P0 THEN 17960 17939 C1=COS(E):D1=1/(.955+(20.267*C1))-.047121 17940 C1=C1+.0083*D1:IF C1>-EP AND C1