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

# User Rev Content
1 greg 1.4 { RCSid $Id: sun.cal,v 1.3 2019/11/07 23:15:06 greg Exp $ }
2 greg 1.1 {*
3     * SOLAR CALCULATIONS
4     *
5     * 7/25/84
6     * 10/10/86
7     *
8     *}
9    
10 greg 1.4 DEG : PI/180;
11    
12 greg 1.1 RLAT = 0.66; {* Site latitude (radians) *}
13    
14     RLON = 2.13; {* Site longitude (radians) *}
15    
16 greg 1.4 RSM = 120 * DEG; {* Standard meridian (radians) *}
17 greg 1.1
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 greg 1.3 0.4093 * sin( 2*PI/365 * (jd - 81) )
32 greg 1.1 ;
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 greg 1.4 cos(PI/12*st) )
40 greg 1.1 ;
41    
42    
43     sazi(sd, st) {* the solar azimuth (radians) *}
44     { sd is solar declination, st is solar time (hours) }
45     =
46 greg 1.4 -atan2( cos(sd) * sin(PI/12*st),
47 greg 1.1 -cos(RLAT)*sin(sd) -
48 greg 1.4 sin(RLAT)*cos(sd)*cos(PI/12*st) )
49 greg 1.1 ;
50    
51    
52 greg 1.4 SAZI = sazi(SDEC, STIME) / DEG;
53 greg 1.1
54 greg 1.4 SALT = salt(SDEC, STIME) / DEG;
55 greg 1.1
56     SDEC = sdec(JDATE);
57    
58     STIME = TIME + stadj(JDATE);
59    
60 greg 1.4 HALFDAY = acos(-tan(RLAT)*tan(SDEC)) * (12/PI);
61    
62 greg 1.1 JDATE = DAY + select(MONTH,0,31,59,90,120,151,181,212,243,273,304,334);