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

Location:
trunk/extsrc/gpcsw/gpcsrc/fits/burntool
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/extsrc/gpcsw/gpcsrc/fits/burntool/Makefile

    r24302 r24391  
    3232  pscoords/pscoords.h
    3333
    34 $(OBJ)/psfstats.o: psfstats.c burntool.h
     34$(OBJ)/psfstats.o: psfstats.c burntool.h psf/psf.h
    3535
    3636$(OBJ)/sort.o: sort.c
  • trunk/extsrc/gpcsw/gpcsrc/fits/burntool/burnfix.c

    r23490 r24391  
    105105      if(!cell->persist[k].fiterr)
    106106         sub_fit(nx, ny, NX, buf, &(cell->persist[k]), -1);
     107   }
     108   return(0);
     109}
     110
     111
     112/****************************************************************/
     113/* burn_apply(): Subtract the trail fits from the image */
     114STATIC int burn_apply(int nx, int ny, int NX, IMTYPE *buf, CELL *cell)
     115{
     116   int k;
     117
     118/* Restore all the burns */
     119   for(k=0; k<cell->npersist; k++) {
     120      if(!cell->persist[k].fiterr)
     121         sub_fit(nx, ny, NX, buf, &(cell->persist[k]), +1);
    107122   }
    108123   return(0);
  • 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");
  • trunk/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.h

    r23924 r24391  
    173173                     MTYPE *mask, OBJBOX *box);
    174174STATIC int burn_restore(int nx, int ny, int NX, IMTYPE *buf, CELL *cell);
     175STATIC int burn_apply(int nx, int ny, int NX, IMTYPE *buf, CELL *cell);
    175176STATIC int persist_read(CELL *cell, const char *infile);
    176177STATIC int persist_write(CELL *cell, const char *outfile);
  • trunk/extsrc/gpcsw/gpcsrc/fits/burntool/man/burntool.1

    r23924 r24391  
    6666        inhibited from subtracting the fits by "update=f".
    6767       
     68        Two other modes can be invoked using "tableonly=t" and "apply=t".
     69        The first mode is just like "update=t", except that it does not write
     70        the modified images, only the FITS table and/or tabulated fit data.
     71        The second mode is like "restore=t", except that it subtracts the
     72        tabulated fits instead of adding them back in.  Note that this requires
     73        slightly different specifications for the "in=" file:
     74
     75                update or tableonly:    in=previous_file_for_persistence
     76                restore or apply:       in=this_file_for_burn_and_persistence
     77
     78        Thus a sequence of images could be processed (leaving off usual
     79        arguments such as mask=, etc) to immediately fit and subtract:
     80
     81           burntool o4991g0001o24.fits \
     82                                   out=o4991g0001o24.burn \
     83             psfstat=o4991g0001o24.stat psf=o4991g0001o24.psf
     84
     85           burntool o4991g0002o24.fits \
     86             in=o4991g0001o24.burn out=o4991g0002o24.burn \
     87             psfstat=o4991g0002o24.stat psf=o4991g0002o24.psf
     88
     89           burntool o4991g0003o24.fits \
     90             in=o4991g0002o24.burn out=o4991g0003o24.burn \
     91             psfstat=o4991g0003o24.stat psf=o4991g0003o24.psf
     92
     93        or as a two step process of generating tables:
     94
     95           burntool o4991g0001o24.fits tableonly=t \
     96                                   out=o4991g0001o24.burn \
     97             psfstat=o4991g0001o24.stat psf=o4991g0001o24.psf
     98
     99           burntool o4991g0002o24.fits tableonly=t \
     100             in=o4991g0001o24.burn out=o4991g0002o24.burn \
     101             psfstat=o4991g0002o24.stat psf=o4991g0002o24.psf
     102
     103           burntool o4991g0003o24.fits tableonly=t \
     104             in=o4991g0002o24.burn out=o4991g0003o24.burn \
     105             psfstat=o4991g0003o24.stat psf=o4991g0003o24.psf
     106
     107        and then later on carrying out the subtractions of the fits:
     108
     109           burntool o4991g0001o24.fits apply=t
     110           burntool o4991g0002o24.fits apply=t
     111           burntool o4991g0003o24.fits apply=t
     112
    68113        The identification of significant (but unsaturated) stars is an
    69114        important component of burntool's mask generation, and if requested
    70115        burntool can assemble a gallery of postage stamps of suitable stars.
     116        This does not work with "restore=t" or "apply=t" of course, since
     117        these work only on previous tables and do not examine the images.
    71118       
    72119        Any star whose maximum exceeds PSF_THRESH above sky but is not deemed
     
    125172           qt=-5.201       Tangential quadrupole [pix^2] (-99.99 if fails)
    126173                                q+ * cos(2*phi) + qx * sin(2*phi)
     174           q3c=-1.193      Cosine trefoil measure [pix^2] (-99.99 if fails)
     175           q3s=-0.038      Sine trefoil measure [pix^2] (-99.99 if fails)
    127176           qpm=5.154       Plus quadrupole averaged over psfavg
    128177           qcm=0.560       Cross quadrupole averaged over psfavg
    129178           qtm=-5.201      Tangential averaged over psfavg
     179           q3cm=-1.230     Cosine trefoil averaged over psfavg
     180           q3sm=-0.079     Sine trefoil averaged over psfavg
     181
     182        The net, polar coordinate quadrupole can be assembled from
     183
     184           Qmagnitude = sqrt(qpm^2+qcm^2)
     185           Qtheta     = 0.5 * atan2(qcm, qpm)
    130186
    131187        Helpful utilities include:
     
    151207
    152208        update={t|f}   
    153                 Modify the input MEF by subtracting fits (default t)?
     209                Calculate fits and modify the input MEF images by subtracting
     210                the trail fits and writing a FITS table (default t).  If
     211                false the MEF is not altered, although PSF can be calculated.
    154212
    155213        restore={t|f} 
    156                 Restore the input MEF by adding input fits (default f)?
     214                Restore the input MEF by adding input fits (default f)
     215
     216        apply={t|f}
     217                Use previously calculated fits to modify the input MEF image
     218                by subtraction (default f)
     219
     220        tableonly={t|f}
     221                Calculate fits but do *not* modify the input MEF images,
     222                only write the fit data as a FITS and/or text table (default f)
    157223
    158224        in=fname       
  • trunk/extsrc/gpcsw/gpcsrc/fits/burntool/psfstamp.c

    r23490 r24391  
    136136   int i, k, l, nstar, fdout, otacx, otacy, xid, yid, ntot=0, sumax;
    137137   int cellcount, ota_xid, ota_yid;
    138    double scale, phi, fwhm[3], q[3], qt, xfp, yfp, pi=4*atan(1.0);
     138   double scale, phi, fwhm[3], q[5], qt, xfp, yfp, pi=4*atan(1.0);
    139139   IMTYPE *median_image;
    140140   CELL *cell;
     
    203203   qt = -q[1] * cos(2*phi) - q[2] * sin(2*phi);
    204204
    205    printf("N= %d PSFmaj= %.2f min= %.2f theta= %.1f m2= %.2f q+= %.3f qx= %.3f qt= %.3f\n",
    206           nstar, fwhm[0], fwhm[1], fwhm[2]*180/pi, q[0], q[1], q[2], qt);
     205   printf("N= %d PSFmaj= %.2f min= %.2f theta= %.1f m2= %.2f q+= %.3f qx= %.3f qt= %.3f q3c= %.3f q3s= %.3f\n",
     206          nstar, fwhm[0], fwhm[1], fwhm[2]*180/pi, q[0], q[1], q[2], qt,
     207          q[3], q[4]);
    207208
    208209   if(CONCAT_FITS) {
     
    258259   double m2[MAXPSFMEDIAN], qp[MAXPSFMEDIAN], qc[MAXPSFMEDIAN];
    259260   double qt[MAXPSFMEDIAN], fwavg[MAXPSFMEDIAN];
     261   double q3c[MAXPSFMEDIAN], q3s[MAXPSFMEDIAN];
    260262   double qpavg[MAXPSFMEDIAN], qcavg[MAXPSFMEDIAN], qtavg[MAXPSFMEDIAN];
     263   double q3cavg[MAXPSFMEDIAN], q3savg[MAXPSFMEDIAN];
    261264   int nstar[MAXCELL], nfw[MAXCELL];
    262265   double fwmed[MAXCELL], m2med[MAXCELL];
    263266   double qpmed[MAXCELL], qcmed[MAXCELL], qtmed[MAXCELL];
    264    double qpmacro, qcmacro, qtmacro, fwmacro;
     267   double q3cmed[MAXCELL], q3smed[MAXCELL];
     268   double qpmacro, qcmacro, qtmacro, fwmacro, q3cmacro, q3smacro;
    265269   FILE *fp;
    266270   CELL *cell;
     
    304308                     qp[nstar[k]] = q[1];
    305309                     qc[nstar[k]] = q[2];
     310                     q3c[nstar[k]] = q[3];
     311                     q3s[nstar[k]] = q[4];
    306312/* Get the position in the focal plane and therefore the qt statistic */
    307313                     psc_cell_to_pixel(cellx, celly, 0.5*PSC_HCELL/PSC_PIXEL,
     
    325331                  qcmed[k] = double_median(nstar[k], qc);
    326332                  qtmed[k] = double_median(nstar[k], qt);
     333                  q3cmed[k] = double_median(nstar[k], q3c);
     334                  q3smed[k] = double_median(nstar[k], q3s);
    327335               } else {
    328336                  m2med[k] = qpmed[k] = qcmed[k] = qtmed[k] = -99.99;
     337                  q3cmed[k] = q3smed[k] = -99.99;
    329338               }
    330339/* Toss these results into the macrocell median hopper */
     
    337346                     qcavg[nqavg] = qc[l];
    338347                     qtavg[nqavg] = qt[l];
     348                     q3cavg[nqavg] = q3c[l];
     349                     q3savg[nqavg] = q3s[l];
    339350                     nqavg++;
    340351                  }
     
    346357         qcmacro = double_median(nqavg, qcavg);
    347358         qtmacro = double_median(nqavg, qtavg);
    348          if(nqavg == 0) qpmacro = qcmacro = qtmacro = -99.99;
     359         q3cmacro = double_median(nqavg, q3cavg);
     360         q3smacro = double_median(nqavg, q3savg);
     361         if(nqavg == 0) qpmacro = qcmacro = qtmacro = q3cmacro = q3smacro = -99.99;
    349362         fwmacro = double_median(nfwave, fwavg);
    350363
     
    357370               cell = ota + k;
    358371
    359                fprintf(fp, "ext=xy%1d%1d bias=%d sky=%d rmssky=%d npsf=%d fwhm=%.2f fwmed=%.2f m2=%.2f qp=%.3f qc=%.3f qt=%.3f qpm=%.3f qcm=%.3f qtm=%.3f\n",
     372               fprintf(fp, "ext=xy%1d%1d bias=%d sky=%d rmssky=%d npsf=%d fwhm=%.2f fwmed=%.2f m2=%.2f qp=%.3f qc=%.3f qt=%.3f q3c=%.3f q3s=%.3f qpm=%.3f qcm=%.3f qtm=%.3f q3cm=%.3f q3sm=%.3f\n",
    360373                       cellx, celly, cell->bias, cell->sky, cell->rms,
    361374                       nstar[k], fwmed[k], fwmacro, m2med[k],
    362                        qpmed[k], qcmed[k], qtmed[k],
    363                        qpmacro, qcmacro, qtmacro);
     375                       qpmed[k], qcmed[k], qtmed[k], q3cmed[k], q3smed[k],
     376                       qpmacro, qcmacro, qtmacro, q3cmacro, q3smacro);
    364377            }
    365378         }
Note: See TracChangeset for help on using the changeset viewer.