86 |
|
#include <string.h> |
87 |
|
#include <ctype.h> |
88 |
|
#include "rtmath.h" |
89 |
+ |
#include "platform.h" |
90 |
|
#include "color.h" |
91 |
|
|
92 |
|
char *progname; /* Program name */ |
293 |
|
extern float * resize_dmatrix(float *mtx_data, int nsteps, int npatch); |
294 |
|
extern void AddDirect(float *parr); |
295 |
|
|
296 |
+ |
|
297 |
+ |
static const char * |
298 |
+ |
getfmtname(int fmt) |
299 |
+ |
{ |
300 |
+ |
switch (fmt) { |
301 |
+ |
case 'a': |
302 |
+ |
return("ascii"); |
303 |
+ |
case 'f': |
304 |
+ |
return("float"); |
305 |
+ |
case 'd': |
306 |
+ |
return("double"); |
307 |
+ |
} |
308 |
+ |
return("unknown"); |
309 |
+ |
} |
310 |
+ |
|
311 |
+ |
|
312 |
|
int |
313 |
|
main(int argc, char *argv[]) |
314 |
|
{ |
315 |
|
char buf[256]; |
316 |
+ |
int doheader = 1; /* output header? */ |
317 |
|
double rotation = 0; /* site rotation (degrees) */ |
318 |
|
double elevation; /* site elevation (meters) */ |
319 |
|
int dir_is_horiz; /* direct is meas. on horizontal? */ |
338 |
|
case 'v': /* verbose progress reports */ |
339 |
|
verbose++; |
340 |
|
break; |
341 |
+ |
case 'h': /* turn off header */ |
342 |
+ |
doheader = 0; |
343 |
+ |
break; |
344 |
|
case 'o': /* output format */ |
345 |
|
switch (argv[i][2]) { |
346 |
|
case 'f': |
499 |
|
break; |
500 |
|
} |
501 |
|
/* write out matrix */ |
502 |
+ |
if (outfmt != 'a') |
503 |
+ |
SET_FILE_BINARY(stdout); |
504 |
|
#ifdef getc_unlocked |
505 |
|
flockfile(stdout); |
506 |
|
#endif |
507 |
|
if (verbose) |
508 |
|
fprintf(stderr, "%s: writing %smatrix with %d time steps...\n", |
509 |
|
progname, outfmt=='a' ? "" : "binary ", ntsteps); |
510 |
+ |
if (doheader) { |
511 |
+ |
newheader("RADIANCE", stdout); |
512 |
+ |
printargs(argc, argv, stdout); |
513 |
+ |
printf("LATLONG= %.8f %.8f\n", RadToDeg(s_latitude), |
514 |
+ |
-RadToDeg(s_longitude)); |
515 |
+ |
printf("NROWS=%d\n", nskypatch); |
516 |
+ |
printf("NCOLS=%d\n", ntsteps); |
517 |
+ |
printf("NCOMP=3\n"); |
518 |
+ |
fputformat(getfmtname(outfmt), stdout); |
519 |
+ |
putchar('\n'); |
520 |
+ |
} |
521 |
|
/* patches are rows (outer sort) */ |
522 |
|
for (i = 0; i < nskypatch; i++) { |
523 |
|
mtx_offset = 3*i; |
559 |
|
fprintf(stderr, "%s: done.\n", progname); |
560 |
|
exit(0); |
561 |
|
userr: |
562 |
< |
fprintf(stderr, "Usage: %s [-v][-d|-s][-r deg][-m N][-g r g b][-c r g b][-o{f|d}][-O{0|1}] [tape.wea]\n", |
562 |
> |
fprintf(stderr, "Usage: %s [-v][-h][-d|-s][-r deg][-m N][-g r g b][-c r g b][-o{f|d}][-O{0|1}] [tape.wea]\n", |
563 |
|
progname); |
564 |
|
exit(1); |
565 |
|
fmterr: |