21 |
|
#include <string.h> |
22 |
|
#include <math.h> |
23 |
|
#include <stdlib.h> |
24 |
+ |
#include <ctype.h> |
25 |
|
|
26 |
|
#include "rtio.h" |
27 |
|
#include "fvect.h" |
43 |
|
/* Perez sky parametrization : epsilon and delta calculations from the direct and diffuse irradiances */ |
44 |
|
double sky_brightness(); |
45 |
|
double sky_clearness(); |
46 |
+ |
void computesky(); |
47 |
|
|
48 |
|
/* calculation of the direct and diffuse components from the Perez parametrization */ |
49 |
|
double diffus_irradiance_from_sky_brightness(); |
73 |
|
double integ_lv(float *lv,float *theta); |
74 |
|
float *theta_ordered(char *filename); |
75 |
|
float *phi_ordered(char *filename); |
76 |
+ |
void skip_comments(FILE *fp); |
77 |
|
|
78 |
|
|
79 |
|
|
274 |
|
} |
275 |
|
|
276 |
|
|
277 |
+ |
void |
278 |
|
computesky() /* compute sky parameters */ |
279 |
|
{ |
280 |
|
|
474 |
|
/* Compute the ground radiance */ |
475 |
|
zenithbr=calc_rel_lum_perez(0.0,radians(sunzenith),radians(sunzenith),skyclearness,skybrightness,coeff_perez); |
476 |
|
zenithbr*=diffnormalization; |
477 |
+ |
/* |
478 |
|
fprintf(stderr, "gendaylit : the actual zenith radiance(W/m^2/sr) or luminance(cd/m^2) is : %.0lf\n", zenithbr); |
479 |
< |
|
479 |
> |
*/ |
480 |
> |
|
481 |
|
if (skyclearness==1) |
482 |
|
normfactor = 0.777778; |
483 |
|
|
614 |
|
|
615 |
|
|
616 |
|
|
617 |
+ |
void |
618 |
+ |
skip_comments(FILE *fp) /* skip comments in file */ |
619 |
+ |
{ |
620 |
+ |
int c; |
621 |
+ |
|
622 |
+ |
while ((c = getc(fp)) != EOF) |
623 |
+ |
if (c == '#') { |
624 |
+ |
while ((c = getc(fp)) != EOF) |
625 |
+ |
if (c == '\n') |
626 |
+ |
break; |
627 |
+ |
} else if (!isspace(c)) { |
628 |
+ |
ungetc(c, fp); |
629 |
+ |
break; |
630 |
+ |
} |
631 |
+ |
} |
632 |
|
|
633 |
|
|
634 |
|
|
614 |
– |
|
615 |
– |
|
616 |
– |
|
617 |
– |
|
618 |
– |
|
635 |
|
/* Perez models */ |
636 |
|
|
637 |
|
/* Perez global horizontal luminous efficacy model */ |
1014 |
|
{ |
1015 |
|
/*printf("file %s open\n", filename);*/ |
1016 |
|
} |
1017 |
+ |
|
1018 |
+ |
skip_comments(fcoeff_perez); |
1019 |
|
|
1002 |
– |
rewind(fcoeff_perez); /* on se place en debut de fichier */ |
1003 |
– |
|
1020 |
|
for (i=0;i<8;i++) |
1021 |
|
for (j=0;j<20;j++) |
1022 |
|
{ |
1199 |
|
fprintf(stderr,"Cannot open file %s in function theta_ordered\n",filename); |
1200 |
|
exit(1); |
1201 |
|
} |
1202 |
+ |
|
1203 |
+ |
skip_comments(file_in); |
1204 |
|
|
1187 |
– |
rewind(file_in); |
1188 |
– |
|
1205 |
|
if ( (ptr = malloc(145*sizeof(float))) == NULL ) |
1206 |
|
{ |
1207 |
|
fprintf(stderr,"Out of memory in function theta_ordered\n"); |
1245 |
|
fprintf(stderr,"Cannot open file %s in function phi_ordered\n",filename); |
1246 |
|
exit(1); |
1247 |
|
} |
1248 |
< |
|
1249 |
< |
rewind(file_in); |
1248 |
> |
|
1249 |
> |
skip_comments(file_in); |
1250 |
|
|
1251 |
|
if ( (ptr = malloc(145*sizeof(float))) == NULL ) |
1252 |
|
{ |