--- ray/src/gen/gendaymtx.c 2014/06/17 18:51:47 2.15 +++ ray/src/gen/gendaymtx.c 2016/08/19 15:13:40 2.24 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: gendaymtx.c,v 2.15 2014/06/17 18:51:47 greg Exp $"; +static const char RCSid[] = "$Id: gendaymtx.c,v 2.24 2016/08/19 15:13:40 greg Exp $"; #endif /* * gendaymtx.c @@ -86,8 +86,11 @@ static const char RCSid[] = "$Id: gendaymtx.c,v 2.15 2 #include #include #include "rtmath.h" +#include "rtio.h" +#include "resolu.h" #include "platform.h" #include "color.h" +#include "resolu.h" char *progname; /* Program name */ char errmsg[128]; /* Error message buffer */ @@ -319,7 +322,9 @@ main(int argc, char *argv[]) int dir_is_horiz; /* direct is meas. on horizontal? */ float *mtx_data = NULL; /* our matrix data */ int ntsteps = 0; /* number of rows in matrix */ + int step_alloc = 0; int last_monthly = 0; /* month of last report */ + int inconsistent = 0; /* inconsistent options set? */ int mo, da; /* month (1-12) and day (1-31) */ double hr; /* hour (local standard time) */ double dir, dif; /* direct and diffuse values */ @@ -370,19 +375,24 @@ main(int argc, char *argv[]) rhsubdiv = atoi(argv[++i]); break; case 'c': /* sky color */ + inconsistent |= (skycolor[1] <= 1e-4); skycolor[0] = atof(argv[++i]); skycolor[1] = atof(argv[++i]); skycolor[2] = atof(argv[++i]); break; case 'd': /* solar (direct) only */ skycolor[0] = skycolor[1] = skycolor[2] = 0; - if (suncolor[1] <= 1e-4) + if (suncolor[1] <= 1e-4) { + inconsistent = 1; suncolor[0] = suncolor[1] = suncolor[2] = 1; + } break; case 's': /* sky only (no direct) */ suncolor[0] = suncolor[1] = suncolor[2] = 0; - if (skycolor[1] <= 1e-4) + if (skycolor[1] <= 1e-4) { + inconsistent = 1; skycolor[0] = skycolor[1] = skycolor[2] = 1; + } break; case 'r': /* rotate distribution */ if (argv[i][2] && argv[i][2] != 'z') @@ -391,13 +401,22 @@ main(int argc, char *argv[]) break; case '5': /* 5-phase calculation */ nsuns = 1; - fixed_sun_sa = 6.797e-05; + fixed_sun_sa = PI/360.*atof(argv[++i]); + if (fixed_sun_sa <= 0) { + fprintf(stderr, "%s: missing solar disk size argument for '-5' option\n", + argv[0]); + exit(1); + } + fixed_sun_sa *= fixed_sun_sa*PI; break; default: goto userr; } if (i < argc-1) goto userr; + if (inconsistent) + fprintf(stderr, "%s: WARNING: inconsistent -s, -d, -c options!\n", + progname); if (i == argc-1 && freopen(argv[i], "r", stdin) == NULL) { fprintf(stderr, "%s: cannot open '%s' for input\n", progname, argv[i]); @@ -457,12 +476,11 @@ main(int argc, char *argv[]) s_meridian = DegToRad(s_meridian); /* process each time step in tape */ while (scanf("%d %d %lf %lf %lf\n", &mo, &da, &hr, &dir, &dif) == 5) { - static int step_alloc = 0; double sda, sta; /* make space for next time step */ mtx_offset = 3*nskypatch*ntsteps++; if (ntsteps > step_alloc) { - step_alloc += step_alloc>>1 + 8; + step_alloc += (step_alloc>>1) + ntsteps + 7; mtx_data = resize_dmatrix(mtx_data, step_alloc, nskypatch); } if (dif <= 1e-4) { @@ -519,7 +537,7 @@ main(int argc, char *argv[]) printf("NROWS=%d\n", nskypatch); printf("NCOLS=%d\n", ntsteps); printf("NCOMP=3\n"); - fputformat(getfmtname(outfmt), stdout); + fputformat((char *)getfmtname(outfmt), stdout); putchar('\n'); } /* patches are rows (outer sort) */ @@ -538,7 +556,7 @@ main(int argc, char *argv[]) break; case 'f': for (j = 0; j < ntsteps; j++) { - fwrite(mtx_data+mtx_offset, sizeof(float), 3, + putbinary(mtx_data+mtx_offset, sizeof(float), 3, stdout); mtx_offset += 3*nskypatch; } @@ -549,7 +567,7 @@ main(int argc, char *argv[]) ment[0] = mtx_data[mtx_offset]; ment[1] = mtx_data[mtx_offset+1]; ment[2] = mtx_data[mtx_offset+2]; - fwrite(ment, sizeof(double), 3, stdout); + putbinary(ment, sizeof(double), 3, stdout); mtx_offset += 3*nskypatch; } break; @@ -1110,6 +1128,8 @@ void CalcSkyPatchLumin( float *parr ) double aas; /* Sun-sky point azimuthal angle */ double sspa; /* Sun-sky point angle */ double zsa; /* Zenithal sun angle */ + + perez_param[0], perez_param[1], perez_param[2], perez_param[3], perez_param[4]); for (i = 1; i < nskypatch; i++) {