ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/cal/sun.cal
Revision: 1.4
Committed: Fri Nov 8 22:48:08 2019 UTC (4 years, 6 months ago) by greg
Branch: MAIN
CVS Tags: rad5R4, rad5R3, HEAD
Changes since 1.3: +11 -7 lines
Log Message:
Added calculation of half-day (time before and after noon for sunrise/sunset)

File Contents

# Content
1 { RCSid $Id: sun.cal,v 1.3 2019/11/07 23:15:06 greg Exp $ }
2 {*
3 * SOLAR CALCULATIONS
4 *
5 * 7/25/84
6 * 10/10/86
7 *
8 *}
9
10 DEG : PI/180;
11
12 RLAT = 0.66; {* Site latitude (radians) *}
13
14 RLON = 2.13; {* Site longitude (radians) *}
15
16 RSM = 120 * DEG; {* Standard meridian (radians) *}
17
18
19 stadj(jd) {* solar time adjustment (hours) *}
20 { jd is days into year }
21 =
22 0.170 * sin( 4*PI/373 * (jd - 80) ) -
23 0.129 * sin( 2*PI/355 * (jd - 8 ) ) +
24 12*(RSM-RLON)/PI
25 ;
26
27
28 sdec(jd) {* solar declination angle (radians) *}
29 { jd is days into year }
30 =
31 0.4093 * sin( 2*PI/365 * (jd - 81) )
32 ;
33
34
35 salt(sd, st) {* solar altitude (radians) *}
36 { sd is solar declination, st is solar time (hours) }
37 =
38 asin( sin(RLAT) * sin(sd) - cos(RLAT) * cos(sd) *
39 cos(PI/12*st) )
40 ;
41
42
43 sazi(sd, st) {* the solar azimuth (radians) *}
44 { sd is solar declination, st is solar time (hours) }
45 =
46 -atan2( cos(sd) * sin(PI/12*st),
47 -cos(RLAT)*sin(sd) -
48 sin(RLAT)*cos(sd)*cos(PI/12*st) )
49 ;
50
51
52 SAZI = sazi(SDEC, STIME) / DEG;
53
54 SALT = salt(SDEC, STIME) / DEG;
55
56 SDEC = sdec(JDATE);
57
58 STIME = TIME + stadj(JDATE);
59
60 HALFDAY = acos(-tan(RLAT)*tan(SDEC)) * (12/PI);
61
62 JDATE = DAY + select(MONTH,0,31,59,90,120,151,181,212,243,273,304,334);