| 4 |
|
* Centre de Valbonne, 500 route des Lucioles, 06565 Sophia Antipolis Cedex, France |
| 5 |
|
* *BOUYGUES |
| 6 |
|
* 1 Avenue Eugene Freyssinet, Saint-Quentin-Yvelines, France |
| 7 |
+ |
* print colored output if activated in command line (-C). Based on model from A. Diakite, TU-Berlin. Implemented by J. Wienold, August 26 2018 |
| 8 |
|
*/ |
| 9 |
|
|
| 10 |
+ |
#define _USE_MATH_DEFINES |
| 11 |
|
#include <stdio.h> |
| 12 |
|
#include <string.h> |
| 13 |
|
#include <math.h> |
| 18 |
|
#include "paths.h" |
| 19 |
|
|
| 20 |
|
#define DOT(v1,v2) (v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2]) |
| 19 |
– |
#define _USE_MATH_DEFINES |
| 21 |
|
|
| 22 |
|
double normsc(); |
| 23 |
|
|
| 54 |
|
90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300, 315, 330, 345, 0, 20, 40, 60, |
| 55 |
|
80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 0, 30, 60, 90, 120, 150, 180, 210, |
| 56 |
|
240, 270, 300, 330, 0, 60, 120, 180, 240, 300, 0}; |
| 57 |
+ |
/* default values for Berlin */ |
| 58 |
+ |
float locus[] = { |
| 59 |
+ |
-4.843e9,2.5568e6,0.24282e3,0.23258,-4.843e9,2.5568e6,0.24282e3,0.23258,-1.2848,1.7519,-0.093786}; |
| 60 |
|
|
| 61 |
|
|
| 62 |
|
|
| 104 |
|
|
| 105 |
|
double solar_sunset(int month, int day); |
| 106 |
|
double solar_sunrise(int month, int day); |
| 103 |
– |
double stadj(); |
| 104 |
– |
int jdate(int month, int day); |
| 107 |
|
|
| 106 |
– |
|
| 107 |
– |
/* sun calculation constants */ |
| 108 |
– |
extern double s_latitude; |
| 109 |
– |
extern double s_longitude; |
| 110 |
– |
extern double s_meridian; |
| 111 |
– |
|
| 108 |
|
const double AU = 149597890E3; |
| 109 |
|
const double solar_constant_e = 1367; /* solar constant W/m^2 */ |
| 110 |
|
const double solar_constant_l = 127500; /* solar constant lux */ |
| 120 |
|
|
| 121 |
|
|
| 122 |
|
/* required values */ |
| 123 |
+ |
int year = 0; /* year (optional) */ |
| 124 |
|
int month, day; /* date */ |
| 125 |
|
double hour; /* time */ |
| 126 |
|
int tsolar; /* 0=standard, 1=solar */ |
| 143 |
|
int output=0; /* define the unit of the output (sky luminance or radiance): */ |
| 144 |
|
/* visible watt=0, solar watt=1, lumen=2 */ |
| 145 |
|
int input=0; /* define the input for the calulation */ |
| 146 |
< |
|
| 146 |
> |
int color_output=0; |
| 147 |
|
int suppress_warnings=0; |
| 148 |
|
|
| 149 |
|
/* default values */ |
| 154 |
|
double gprefl = 0.2; |
| 155 |
|
int S_INTER=0; |
| 156 |
|
|
| 157 |
+ |
|
| 158 |
|
/* computed values */ |
| 159 |
|
double sundir[3]; |
| 160 |
|
double groundbr = 0; |
| 203 |
|
cloudy = 0; |
| 204 |
|
dosun = argv[i][0] == '+'; |
| 205 |
|
break; |
| 206 |
+ |
case 'y': |
| 207 |
+ |
year = atoi(argv[++i]); |
| 208 |
+ |
break; |
| 209 |
|
case 'R': |
| 210 |
|
u_solar = argv[i][1] == 'R' ? -1 : 1; |
| 211 |
|
solarbr = atof(argv[++i]); |
| 214 |
|
cloudy = argv[i][0] == '+' ? 2 : 1; |
| 215 |
|
dosun = 0; |
| 216 |
|
break; |
| 217 |
+ |
case 'C': |
| 218 |
+ |
if (argv[i][2] == 'I' && argv[i][3] == 'E' ) { |
| 219 |
+ |
locus[0] = -4.607e9; |
| 220 |
+ |
locus[1] = 2.9678e6; |
| 221 |
+ |
locus[2] = 0.09911e3; |
| 222 |
+ |
locus[3] = 0.244063; |
| 223 |
+ |
locus[4] = -2.0064e9; |
| 224 |
+ |
locus[5] = 1.9018e6; |
| 225 |
+ |
locus[6] = 0.24748e3; |
| 226 |
+ |
locus[7] = 0.23704; |
| 227 |
+ |
locus[8] = -3.0; |
| 228 |
+ |
locus[9] = 2.87; |
| 229 |
+ |
locus[10] = -0.275; |
| 230 |
+ |
}else{ color_output = 1; |
| 231 |
+ |
} |
| 232 |
+ |
break; |
| 233 |
+ |
case 'l': |
| 234 |
+ |
locus[0] = atof(argv[++i]); |
| 235 |
+ |
locus[1] = atof(argv[++i]); |
| 236 |
+ |
locus[2] = atof(argv[++i]); |
| 237 |
+ |
locus[3] = atof(argv[++i]); |
| 238 |
+ |
locus[4] = locus[0]; |
| 239 |
+ |
locus[5] = locus[1]; |
| 240 |
+ |
locus[6] = locus[2]; |
| 241 |
+ |
locus[7] = locus[3]; |
| 242 |
+ |
locus[8] = atof(argv[++i]); |
| 243 |
+ |
locus[9] = atof(argv[++i]); |
| 244 |
+ |
locus[10] = atof(argv[++i]); |
| 245 |
+ |
break; |
| 246 |
+ |
|
| 247 |
|
case 't': |
| 248 |
|
betaturbidity = atof(argv[++i]); |
| 249 |
|
break; |
| 349 |
|
/* compute solar direction */ |
| 350 |
|
|
| 351 |
|
if (month) { /* from date and time */ |
| 321 |
– |
int jd; |
| 352 |
|
double sd; |
| 353 |
|
|
| 354 |
< |
jd = jdate(month, day); /* Julian date */ |
| 355 |
< |
sd = sdec(jd); /* solar declination */ |
| 356 |
< |
if (tsolar) /* solar time */ |
| 357 |
< |
st = hour; |
| 358 |
< |
else |
| 359 |
< |
st = hour + stadj(jd); |
| 360 |
< |
|
| 361 |
< |
|
| 354 |
> |
st = hour; |
| 355 |
> |
if (year) { /* Michalsky algorithm? */ |
| 356 |
> |
double mjd = mjdate(year, month, day, hour); |
| 357 |
> |
if (tsolar) |
| 358 |
> |
sd = msdec(mjd, NULL); |
| 359 |
> |
else |
| 360 |
> |
sd = msdec(mjd, &st); |
| 361 |
> |
} else { |
| 362 |
> |
int jd = jdate(month, day); /* Julian date */ |
| 363 |
> |
sd = sdec(jd); /* solar declination */ |
| 364 |
> |
if (!tsolar) /* get solar time? */ |
| 365 |
> |
st = hour + stadj(jd); |
| 366 |
> |
} |
| 367 |
> |
|
| 368 |
|
if(timeinterval) { |
| 369 |
|
|
| 370 |
|
if(timeinterval<0) { |
| 718 |
|
printf("0\n0\n"); |
| 719 |
|
printf("4 %f %f %f %f\n", sundir[0], sundir[1], sundir[2], 2*half_sun_angle); |
| 720 |
|
} |
| 721 |
< |
|
| 722 |
< |
|
| 723 |
< |
printf("\nvoid brightfunc skyfunc\n"); |
| 724 |
< |
printf("2 skybright perezlum.cal\n"); |
| 721 |
> |
/* print colored output if activated in command line (-C). Based on model from A. Diakite, TU-Berlin. Implemented by J. Wienold, August 26 2018 */ |
| 722 |
> |
if (color_output==1 && skyclearness < 4.5 && skyclearness >1.065 ) |
| 723 |
> |
{ |
| 724 |
> |
fprintf(stderr, " warning: sky clearness(epsilon)= %f \n",skyclearness); |
| 725 |
> |
fprintf(stderr, " warning: intermediate sky!! \n"); |
| 726 |
> |
fprintf(stderr, " warning: color model for intermediate sky pending \n"); |
| 727 |
> |
fprintf(stderr, " warning: no color output ! \n"); |
| 728 |
> |
color_output=0; |
| 729 |
> |
} |
| 730 |
> |
if (color_output==1) |
| 731 |
> |
{ |
| 732 |
> |
printf("\nvoid colorfunc skyfunc\n"); |
| 733 |
> |
printf("4 skybright_r skybright_g skybright_b perezlum_c.cal\n"); |
| 734 |
|
printf("0\n"); |
| 735 |
< |
printf("10 %.3e %.3e %lf %lf %lf %lf %lf %f %f %f \n", diffnormalization, groundbr, |
| 735 |
> |
printf("22 %.3e %.3e %lf %lf %lf %lf %lf %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\n", diffnormalization, groundbr, |
| 736 |
|
*(c_perez+0),*(c_perez+1),*(c_perez+2),*(c_perez+3),*(c_perez+4), |
| 737 |
< |
sundir[0], sundir[1], sundir[2]); |
| 737 |
> |
sundir[0], sundir[1], sundir[2],skyclearness,locus[0],locus[1],locus[2],locus[3],locus[4],locus[5],locus[6],locus[7],locus[8],locus[9],locus[10]); |
| 738 |
> |
}else{ |
| 739 |
> |
printf("\nvoid brightfunc skyfunc\n"); |
| 740 |
> |
printf("2 skybright perezlum.cal\n"); |
| 741 |
> |
printf("0\n"); |
| 742 |
> |
printf("10 %.3e %.3e %lf %lf %lf %lf %lf %f %f %f \n", diffnormalization, groundbr, |
| 743 |
> |
*(c_perez+0),*(c_perez+1),*(c_perez+2),*(c_perez+3),*(c_perez+4), |
| 744 |
> |
sundir[0], sundir[1], sundir[2]); |
| 745 |
> |
} |
| 746 |
|
|
| 747 |
|
} |
| 748 |
|
|
| 788 |
|
{ |
| 789 |
|
if (msg != NULL) |
| 790 |
|
fprintf(stderr, "%s: Use error - %s\n\n", progname, msg); |
| 791 |
< |
fprintf(stderr, "Usage: %s month day hour [...]\n", progname); |
| 792 |
< |
fprintf(stderr, " or: %s -ang altitude azimuth [...]\n", progname); |
| 791 |
> |
fprintf(stderr, "Usage: %s month day hour [-y year] [...]\n", progname); |
| 792 |
> |
fprintf(stderr, " or: %s -ang altitude azimuth [...]\n", progname); |
| 793 |
|
fprintf(stderr, " followed by: -P epsilon delta [options]\n"); |
| 794 |
|
fprintf(stderr, " or: [-W|-L|-G] direct_value diffuse_value [options]\n"); |
| 795 |
< |
fprintf(stderr, " or: -E global_irradiance [options]\n\n"); |
| 796 |
< |
fprintf(stderr, " Description:\n"); |
| 795 |
> |
fprintf(stderr, " or: -E global_irradiance [options]\n\n"); |
| 796 |
> |
fprintf(stderr, " Description:\n"); |
| 797 |
|
fprintf(stderr, " -P epsilon delta (these are the Perez parameters) \n"); |
| 798 |
|
fprintf(stderr, " -W direct-normal-irradiance diffuse-horizontal-irradiance (W/m^2)\n"); |
| 799 |
|
fprintf(stderr, " -L direct-normal-illuminance diffuse-horizontal-illuminance (lux)\n"); |
| 801 |
|
fprintf(stderr, " -E global-horizontal-irradiance (W/m^2)\n\n"); |
| 802 |
|
fprintf(stderr, " Output specification with option:\n"); |
| 803 |
|
fprintf(stderr, " -O [0|1|2] (0=output in W/m^2/sr visible, 1=output in W/m^2/sr solar, 2=output in candela/m^2), default is 0 \n"); |
| 804 |
< |
fprintf(stderr, " gendaylit version 2.4 (2013/09/04) \n\n"); |
| 804 |
> |
fprintf(stderr, " gendaylit version 2.5 (2018/04/18) \n\n"); |
| 805 |
|
exit(1); |
| 806 |
|
} |
| 807 |
|
|