IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 12, 2009, 3:53:07 PM (17 years ago)
Author:
eugene
Message:

updates to burntool-and-related from camera svn

File:
1 edited

Legend:

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

    r23924 r24391  
    3333   int otanum;
    3434   int nextend, cellxy, cell, cellcode;
    35    int ext, update, restore, psfsize, psfavg;
     35   int ext, update, restore, apply, tableonly, psfsize, psfavg;
    3636   IMTYPE *buf;
    3737   const char *burnfile=NULL,  *persistfile=NULL, *persistfitsfile=NULL;
     
    102102/* Parse the args */
    103103   cellxy = -1;
    104    update = 1;
    105    restore = 0;
     104   update = 1;          /* Calc fits, apply fits, write img and table */
     105   restore = 0;         /* Restore previous fit only, write img */
     106   apply = 0;           /* Apply previous fit only, write img */
     107   tableonly = 0;       /* Calc fits (apply fits), write table only */
    106108   psfsize = 32;
    107109   psfavg = 0;
     
    137139         update = argv[i][7] == 'y' || argv[i][7] == '1' || argv[i][7] == 't';
    138140
    139 /* Modify the input MEF by subtracting fits? */
     141/* Modify the input MEF by adding back fits? */
    140142      } else if(strncmp(argv[i], "restore=", 8) == 0) { /* restore={t|f} */
    141143         restore = argv[i][8] == 'y' || argv[i][8] == '1' || argv[i][8] == 't';
     144
     145/* Modify the input MEF by subtracting previously calculated fits? */
     146      } else if(strncmp(argv[i], "apply=", 6) == 0) {   /* apply={t|f} */
     147         apply = argv[i][6] == 'y' || argv[i][6] == '1' || argv[i][6] == 't';
     148
     149/* Calculate and write tables only? */
     150      } else if(strncmp(argv[i], "tableonly=", 10) == 0) {/* tableonly={t|f} */
     151         tableonly = argv[i][10] == 'y' || argv[i][10] == '1' || argv[i][10] == 't';
    142152
    143153/* Output file for burn streaks */
     
    150160
    151161/* Input text file for previous burn persistence streaks */
    152       } else if(strncmp(argv[i], "infits=", 8) == 0) {  /* in=fname */
     162      } else if(strncmp(argv[i], "trailin=", 8) == 0) {/* trailin=fname */
    153163         persistfile = argv[i] + 8;
    154164
    155165/* Same thing, but information is stored in tables in a FITS file. */
    156       } else if(strncmp(argv[i], "trailinfits=", 8) == 0) { /* infits=fname */
     166      } else if(strncmp(argv[i], "trailinfits=", 12) == 0) { /* trailinfits=fname */
    157167         persistfitsfile = argv[i] + 12;
    158168
     
    162172
    163173/* Same thing, but information is stored in tables in a FITS file. */
    164       } else if(strncmp(argv[i], "trailinfits=", 8) == 0) { /* trailin=fname */
    165          persistfitsfile = argv[i] + 12;
     174      } else if(strncmp(argv[i], "infits=", 7) == 0) { /* infits=fname */
     175         persistfitsfile = argv[i] + 7;
    166176
    167177/* Output file for PSF gallery */
     
    322332   /* If there is no other persistence info supplied, try getting
    323333    * it from the input FITS file. */
    324    if(restore && persistfile == NULL) {
    325      if(persistfitsfile == NULL) persistfitsfile = ifilename;
     334   if((restore || apply) && persistfile == NULL) {
     335      if(persistfitsfile == NULL) persistfitsfile = ifilename;
    326336   }
    327337
     
    334344
    335345/* Read the persistence data for this OTA */
    336    if(persistfile != NULL) {
     346   if(persistfile != NULL) {                    /* Text data file */
    337347      if(persist_read(OTA, persistfile)) exit(EXIT_FAILURE);
    338    }
    339    else if(persistfitsfile != NULL) {
    340      if(persist_fits_read(OTA, persistfitsfile) != FH_SUCCESS) exit(EXIT_FAILURE);
     348   } else if(persistfitsfile != NULL) {         /* FITS table */
     349      if(persist_fits_read(OTA, persistfitsfile) != FH_SUCCESS)
     350        exit(EXIT_FAILURE);
    341351   }
    342352
     
    369379               "warning: Restoring old burns, but header indicates no burns previously corrected.\n");             
    370380     }
    371      else if (update && (burn_applied == FH_TRUE)) {
     381     else if ((update||apply) && (burn_applied == FH_TRUE)) {
    372382       fprintf(stderr,
    373383               "warning: Applying burn correction, but header indicates burns previously corrected.\n");             
     
    491501
    492502      if(VERBOSE & VERB_NORM) {
    493          printf("nx=%d ny=%d prex=%d postx=%d posty=%d BZERO=%.1f\n",
     503         printf("nx=%d ny=%d prex=%d postx=%d posty=%d BZERO=%d\n",
    494504                naxis1, naxis2, prescan1, ovrscan1, ovrscan2, BZERO);
    495505      }
     
    542552         }
    543553
    544 
    545          if(!restore) {
    546 
     554         if(apply) {
     555/* Use the table-driven fits instead of calculating new ones */
     556            burn_apply(naxis1-ovrscan1, naxis2-ovrscan2, naxis1,
     557                       buf, OTA+cell);
     558/* Tell us about it? */
     559            if(VERBOSE & VERB_NORM) burn_blab(OTA+cell);
     560
     561         } else if(restore) {
     562/* Restore the old burns */
     563            burn_restore(naxis1-ovrscan1, naxis2-ovrscan2, naxis1,
     564                         buf, OTA+cell);
     565
     566         } else {
    547567/* Fix up the burns */
    548568            burn_fix(naxis1-ovrscan1, naxis2-ovrscan2, naxis1, naxis2, buf,
     
    559579            if(VERBOSE & VERB_NORM) burn_blab(OTA+cell);
    560580
    561 /* Fix up the streaks */
    562             persist_fix(naxis1-ovrscan1, naxis2-ovrscan2, naxis1, buf,
    563                         OTA+cell);
    564 
     581/* Fix up the streaks (don't bother if table only) */
     582            if(!tableonly) {
     583               persist_fix(naxis1-ovrscan1, naxis2-ovrscan2, naxis1, buf,
     584                           OTA+cell);
    565585/* Tell us about it? */
    566             if(VERBOSE & VERB_NORM) persist_blab(OTA+cell);
    567 
    568          } else {
    569 /* Restore the old burns */
    570             burn_restore(naxis1-ovrscan1, naxis2-ovrscan2, naxis1,
    571                          buf, OTA+cell);
     586               if(VERBOSE & VERB_NORM) persist_blab(OTA+cell);
     587            }
    572588         }
    573589
    574590/* Write the corrected data back to the FITS. */
    575          if(update) {
     591         if(!tableonly && update) {
    576592            fh_ehu(ehu, 0);     /* Seek back to the start of data */
    577593            if (fh_write_padded_image(ehu, fh_file_desc(ehu), buf,
     
    590606
    591607/* Dump out the postage stamp file */
    592    if(psffile != NULL) {
     608   if(psffile != NULL && !restore && !apply) {
    593609      psf_write(psfsize, psfsize, OTA, otanum, psffile);
    594610   }
    595611
    596612/* Dump out the PSF stats */
    597    if(psfstatfile != NULL) {
     613   if(psfstatfile != NULL && !restore && !apply) {
    598614      psf_write_stats(psfsize, psfsize, OTA, otanum, psfstatfile, psfavg);
    599615   }
     
    601617/* Write burn info to FITS file. */
    602618   if(update) persist_fits_write(OTA, ihu);
    603 
    604619   
    605    if(restore) {   
     620   if(restore || tableonly) {   
    606621     /* Indicate in the header that the burns are not applied. */
    607      fh_set_bool(ihu, FH_AUTO, PHU_NAME_BURN_APPLIED,
    608                  FH_FALSE, PHU_COMMENT_BURN_APPLIED);
    609      fh_rewrite(ihu);
     622      fh_set_bool(ihu, FH_AUTO, PHU_NAME_BURN_APPLIED,
     623                  FH_FALSE, PHU_COMMENT_BURN_APPLIED);
     624      fh_rewrite(ihu);
     625   } else if(apply) {
     626     /* Indicate in the header that the burns have been applied. */
     627      fh_set_bool(ihu, FH_AUTO, PHU_NAME_BURN_APPLIED,
     628                  FH_TRUE, PHU_COMMENT_BURN_APPLIED);
     629      fh_rewrite(ihu);
    610630   }
    611631
     
    711731   printf(" cell=N         Work on just one cell? Cell count [0:63] mode.\n");
    712732   printf(" mask=0101...   64 digits to work on cells 0:63.\n");
    713    printf(" update={t|f}   Modify the input MEF by subtracting fits?\n");
     733   printf(" update={t|f}   Modify the input MEF writing table and subtracting fits?\n");
    714734   printf(" restore={t|f}  Restore the input MEF by adding input fits?\n");
     735   printf(" apply={t|f}    Modify the input MEF by subtracting previously calculated fits?\n");
     736   printf(" tableonly={t|f} Calculate fits but do *not* modify the input MEF images, only write tables\n");
    715737   printf(" in=fname       Input file for previous burn persistence streaks\n");
    716738   printf(" infits=fname   Input FITS file for previous burn persistence streaks (stored\n");
Note: See TracChangeset for help on using the changeset viewer.