| 39 |
|
/* default values */ |
| 40 |
|
int cloudy = 0; /* 1=standard, 2=uniform */ |
| 41 |
|
int dosun = 1; |
| 42 |
< |
double zenithbr = -1.0; |
| 42 |
> |
double zenithbr = 0.0; |
| 43 |
> |
int u_zenith = 0; /* -1=irradiance, 1=radiance */ |
| 44 |
|
double turbidity = 2.75; |
| 45 |
|
double gprefl = 0.2; |
| 46 |
|
/* computed values */ |
| 47 |
|
double sundir[3]; |
| 48 |
|
double groundbr; |
| 49 |
|
double F2; |
| 50 |
< |
double solarbr = -1.0; |
| 50 |
> |
double solarbr = 0.0; |
| 51 |
> |
int u_solar = 0; /* -1=irradiance, 1=radiance */ |
| 52 |
|
|
| 53 |
|
char *progname; |
| 54 |
|
char errmsg[128]; |
| 91 |
|
dosun = argv[i][0] == '+'; |
| 92 |
|
break; |
| 93 |
|
case 'r': |
| 94 |
+ |
case 'R': |
| 95 |
+ |
u_solar = argv[i][1]=='R' ? -1 : 1; |
| 96 |
|
solarbr = atof(argv[++i]); |
| 97 |
|
break; |
| 98 |
|
case 'c': |
| 103 |
|
turbidity = atof(argv[++i]); |
| 104 |
|
break; |
| 105 |
|
case 'b': |
| 106 |
+ |
case 'B': |
| 107 |
+ |
u_zenith = argv[i][1]=='B' ? -1 : 1; |
| 108 |
|
zenithbr = atof(argv[++i]); |
| 109 |
|
break; |
| 110 |
|
case 'g': |
| 140 |
|
|
| 141 |
|
computesky() /* compute sky parameters */ |
| 142 |
|
{ |
| 143 |
+ |
double normfactor; |
| 144 |
|
/* compute solar direction */ |
| 145 |
|
if (month) { /* from date and time */ |
| 146 |
|
int jd; |
| 154 |
|
st = hour + stadj(jd); |
| 155 |
|
altitude = salt(sd, st); |
| 156 |
|
azimuth = sazi(sd, st); |
| 157 |
+ |
printf("# Solar altitude and azimuth: %f %f\n", |
| 158 |
+ |
180./PI*altitude, 180./PI*azimuth); |
| 159 |
|
} |
| 160 |
|
if (!cloudy && altitude > 87.*PI/180.) { |
| 161 |
|
fprintf(stderr, |
| 169 |
|
sundir[1] = -cos(azimuth)*cos(altitude); |
| 170 |
|
sundir[2] = sin(altitude); |
| 171 |
|
|
| 172 |
+ |
/* Compute normalization factor */ |
| 173 |
+ |
if (cloudy == 2) |
| 174 |
+ |
normfactor = 1.0; |
| 175 |
+ |
else if (cloudy == 1) |
| 176 |
+ |
normfactor = 0.777778; |
| 177 |
+ |
else { |
| 178 |
+ |
F2 = 0.274*(0.91 + 10.0*exp(-3.0*(PI/2.0-altitude)) + |
| 179 |
+ |
0.45*sundir[2]*sundir[2]); |
| 180 |
+ |
normfactor = normsc(altitude)/F2/PI; |
| 181 |
+ |
} |
| 182 |
|
/* Compute zenith brightness */ |
| 183 |
< |
if (zenithbr <= 0.0) |
| 184 |
< |
if (cloudy) { |
| 183 |
> |
if (u_zenith == -1) |
| 184 |
> |
zenithbr /= normfactor*PI; |
| 185 |
> |
else if (u_zenith == 0) { |
| 186 |
> |
if (cloudy) |
| 187 |
|
zenithbr = 8.6*sundir[2] + .123; |
| 188 |
< |
zenithbr *= 1000.0/WHTEFFICACY; |
| 168 |
< |
} else { |
| 188 |
> |
else |
| 189 |
|
zenithbr = (1.376*turbidity-1.81)*tan(altitude)+0.38; |
| 190 |
< |
zenithbr *= 1000.0/SKYEFFICACY; |
| 191 |
< |
} |
| 172 |
< |
if (zenithbr < 0.0) |
| 173 |
< |
zenithbr = 0.0; |
| 174 |
< |
/* Compute horizontal radiance */ |
| 175 |
< |
if (cloudy) { |
| 176 |
< |
if (cloudy == 2) |
| 177 |
< |
groundbr = zenithbr; |
| 190 |
> |
if (zenithbr < 0.0) |
| 191 |
> |
zenithbr = 0.0; |
| 192 |
|
else |
| 193 |
< |
groundbr = zenithbr*0.777778; |
| 180 |
< |
printf("# Ground ambient level: %f\n", groundbr); |
| 181 |
< |
} else { |
| 182 |
< |
F2 = 0.274*(0.91 + 10.0*exp(-3.0*(PI/2.0-altitude)) + |
| 183 |
< |
0.45*sundir[2]*sundir[2]); |
| 184 |
< |
groundbr = zenithbr*normsc(altitude)/F2/PI; |
| 185 |
< |
printf("# Ground ambient level: %f\n", groundbr); |
| 186 |
< |
if (sundir[2] > 0.0 && solarbr != 0.0) { |
| 187 |
< |
if (solarbr < 0.0) |
| 188 |
< |
solarbr = 1.5e9/SUNEFFICACY * |
| 189 |
< |
(1.147 - .147/(sundir[2]>.16?sundir[2]:.16)); |
| 190 |
< |
groundbr += solarbr*6e-5*sundir[2]/PI; |
| 191 |
< |
} else |
| 192 |
< |
dosun = 0; |
| 193 |
> |
zenithbr *= 1000.0/SKYEFFICACY; |
| 194 |
|
} |
| 195 |
+ |
/* Compute horizontal radiance */ |
| 196 |
+ |
groundbr = zenithbr*normfactor; |
| 197 |
+ |
printf("# Ground ambient level: %f\n", groundbr); |
| 198 |
+ |
if (sundir[2] > 0.0 && (!u_solar || solarbr > 0.0)) { |
| 199 |
+ |
if (u_solar == -1) |
| 200 |
+ |
solarbr /= 6e-5*sundir[2]; |
| 201 |
+ |
else if (u_solar == 0) |
| 202 |
+ |
solarbr = 1.5e9/SUNEFFICACY * |
| 203 |
+ |
(1.147 - .147/(sundir[2]>.16?sundir[2]:.16)); |
| 204 |
+ |
groundbr += 6e-5/PI*solarbr*sundir[2]; |
| 205 |
+ |
} else |
| 206 |
+ |
dosun = 0; |
| 207 |
|
groundbr *= gprefl; |
| 208 |
|
} |
| 209 |
|
|