IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23493


Ignore:
Timestamp:
Mar 23, 2009, 4:22:05 PM (17 years ago)
Author:
eugene
Message:

adding output file to burntool

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.c

    r23490 r23493  
    2525{
    2626   int i, j, k, nx, ny, err;
     27   HeaderUnit ohu = fh_create();
    2728   HeaderUnit ihu = fh_create();
    2829   HeaderUnit ehu;
    2930   const char* ifilename = "-";
     31   const char* ofilename = NULL;
    3032   char extname[FH_MAX_STRLEN+1], otaposn[FH_MAX_STRLEN+1];
    3133   int cellmask[MAXCELL];
     
    3335   int nextend, cellxy, cell, cellcode;
    3436   int ext, update, restore, psfsize, psfavg;
     37   int outfd;
    3538   IMTYPE *buf;
    3639   const char *burnfile=NULL,  *persistfile=NULL;
     
    142145         burnfile = argv[i] + 4;
    143146
     147/* Alternate Output file for deburned image */
     148      } else if(strncmp(argv[i], "outimage=", 9) == 0) {        /* outimage=fname */
     149        ofilename = argv[i] + 9;
     150
    144151/* Input file for previous burn persistence streaks */
    145152      } else if(strncmp(argv[i], "trailin=", 8) == 0) { /* trailin=fname */
     
    307314   } else {
    308315      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      }
    309329   }
    310330
     
    477497/* Write the corrected data back to the FITS. */
    478498         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) {
    483508               fprintf(stderr, "\rerror: failed to re-write image data for extension `%s'.\n",
    484509                       extname);
    485510               free(buf);
    486511               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     
    491527      free(buf);
    492528   }
    493529
     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     
    494537/* Dump out the postage stamp file */
    495538   if(psffile != NULL) {
     
    595638   printf(" in=fname       Input file for previous burn persistence streaks\n");
    596639   printf(" out=fname      Output file for burn streaks\n");
     640   printf(" outimage=imname Output file for MEF image\n");
    597641//   printf(" trailin=fname  Input file for previous burn persistence streaks\n");
    598642//   printf(" trailout=fname Output file for burn streaks\n");
Note: See TracChangeset for help on using the changeset viewer.