Changeset 23493
- Timestamp:
- Mar 23, 2009, 4:22:05 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.c
r23490 r23493 25 25 { 26 26 int i, j, k, nx, ny, err; 27 HeaderUnit ohu = fh_create(); 27 28 HeaderUnit ihu = fh_create(); 28 29 HeaderUnit ehu; 29 30 const char* ifilename = "-"; 31 const char* ofilename = NULL; 30 32 char extname[FH_MAX_STRLEN+1], otaposn[FH_MAX_STRLEN+1]; 31 33 int cellmask[MAXCELL]; … … 33 35 int nextend, cellxy, cell, cellcode; 34 36 int ext, update, restore, psfsize, psfavg; 37 int outfd; 35 38 IMTYPE *buf; 36 39 const char *burnfile=NULL, *persistfile=NULL; … … 142 145 burnfile = argv[i] + 4; 143 146 147 /* Alternate Output file for deburned image */ 148 } else if(strncmp(argv[i], "outimage=", 9) == 0) { /* outimage=fname */ 149 ofilename = argv[i] + 9; 150 144 151 /* Input file for previous burn persistence streaks */ 145 152 } else if(strncmp(argv[i], "trailin=", 8) == 0) { /* trailin=fname */ … … 307 314 } else { 308 315 otanum = (otaposn[2] - '0') + 8*(otaposn[3] - '0'); 316 } 317 318 if (ofilename) { 319 outfd = creat (ofilename, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); 320 if (outfd == -1) { 321 fprintf(stderr, "\rerror: Cannot open %s for output\n", ofilename); 322 exit(EXIT_FAILURE); 323 } 324 325 if (!fh_write(ihu, outfd)) { 326 fprintf(stderr, "\rerror: Trouble writing PHU to %s\n", ofilename); 327 exit(EXIT_FAILURE); 328 } 309 329 } 310 330 … … 477 497 /* Write the corrected data back to the FITS. */ 478 498 if(update) { 479 fh_ehu(ehu, 0); /* Seek back to the start of data */ 480 if (fh_write_padded_image(ehu, fh_file_desc(ehu), buf, 481 naxis1*naxis2*naxis3*sizeof(short), 482 FH_TYPESIZE_16) != FH_SUCCESS) { 499 if (ofilename) { 500 if (!fh_write(ehu, outfd)) { 501 fprintf(stderr, "\rerror: Trouble writing EXT %d to %s\n", ext, ofilename); 502 exit(EXIT_FAILURE); 503 } 504 505 if (fh_write_padded_image(ehu, outfd, buf, 506 naxis1*naxis2*naxis3*sizeof(short), 507 FH_TYPESIZE_16) != FH_SUCCESS) { 483 508 fprintf(stderr, "\rerror: failed to re-write image data for extension `%s'.\n", 484 509 extname); 485 510 free(buf); 486 511 exit(EXIT_FAILURE); 487 } 488 } 489 } 490 512 } 513 } else { 514 fh_ehu(ehu, 0); /* Seek back to the start of data */ 515 if (fh_write_padded_image(ehu, fh_file_desc(ehu), buf, 516 naxis1*naxis2*naxis3*sizeof(short), 517 FH_TYPESIZE_16) != FH_SUCCESS) { 518 fprintf(stderr, "\rerror: failed to re-write image data for extension `%s'.\n", 519 extname); 520 free(buf); 521 exit(EXIT_FAILURE); 522 } 523 } 524 } 525 } 526 491 527 free(buf); 492 528 } 493 529 530 if (ofilename) { 531 if (close(outfd)) { 532 fprintf(stderr, "\rerror: trouble writing data to output file %s\n", ofilename); 533 exit(EXIT_FAILURE); 534 } 535 } 536 494 537 /* Dump out the postage stamp file */ 495 538 if(psffile != NULL) { … … 595 638 printf(" in=fname Input file for previous burn persistence streaks\n"); 596 639 printf(" out=fname Output file for burn streaks\n"); 640 printf(" outimage=imname Output file for MEF image\n"); 597 641 // printf(" trailin=fname Input file for previous burn persistence streaks\n"); 598 642 // printf(" trailout=fname Output file for burn streaks\n");
Note:
See TracChangeset
for help on using the changeset viewer.
