Changeset 24391 for trunk/extsrc/gpcsw/gpcsrc/fits/burntool
- Timestamp:
- Jun 12, 2009, 3:53:07 PM (17 years ago)
- Location:
- trunk/extsrc/gpcsw/gpcsrc/fits/burntool
- Files:
-
- 6 edited
-
Makefile (modified) (1 diff)
-
burnfix.c (modified) (1 diff)
-
burntool.c (modified) (14 diffs)
-
burntool.h (modified) (1 diff)
-
man/burntool.1 (modified) (3 diffs)
-
psfstamp.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/extsrc/gpcsw/gpcsrc/fits/burntool/Makefile
r24302 r24391 32 32 pscoords/pscoords.h 33 33 34 $(OBJ)/psfstats.o: psfstats.c burntool.h 34 $(OBJ)/psfstats.o: psfstats.c burntool.h psf/psf.h 35 35 36 36 $(OBJ)/sort.o: sort.c -
trunk/extsrc/gpcsw/gpcsrc/fits/burntool/burnfix.c
r23490 r24391 105 105 if(!cell->persist[k].fiterr) 106 106 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 */ 114 STATIC 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); 107 122 } 108 123 return(0); -
trunk/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.c
r23924 r24391 33 33 int otanum; 34 34 int nextend, cellxy, cell, cellcode; 35 int ext, update, restore, psfsize, psfavg;35 int ext, update, restore, apply, tableonly, psfsize, psfavg; 36 36 IMTYPE *buf; 37 37 const char *burnfile=NULL, *persistfile=NULL, *persistfitsfile=NULL; … … 102 102 /* Parse the args */ 103 103 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 */ 106 108 psfsize = 32; 107 109 psfavg = 0; … … 137 139 update = argv[i][7] == 'y' || argv[i][7] == '1' || argv[i][7] == 't'; 138 140 139 /* Modify the input MEF by subtractingfits? */141 /* Modify the input MEF by adding back fits? */ 140 142 } else if(strncmp(argv[i], "restore=", 8) == 0) { /* restore={t|f} */ 141 143 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'; 142 152 143 153 /* Output file for burn streaks */ … … 150 160 151 161 /* 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 */ 153 163 persistfile = argv[i] + 8; 154 164 155 165 /* 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 */ 157 167 persistfitsfile = argv[i] + 12; 158 168 … … 162 172 163 173 /* 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; 166 176 167 177 /* Output file for PSF gallery */ … … 322 332 /* If there is no other persistence info supplied, try getting 323 333 * 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; 326 336 } 327 337 … … 334 344 335 345 /* Read the persistence data for this OTA */ 336 if(persistfile != NULL) { 346 if(persistfile != NULL) { /* Text data file */ 337 347 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); 341 351 } 342 352 … … 369 379 "warning: Restoring old burns, but header indicates no burns previously corrected.\n"); 370 380 } 371 else if ( update&& (burn_applied == FH_TRUE)) {381 else if ((update||apply) && (burn_applied == FH_TRUE)) { 372 382 fprintf(stderr, 373 383 "warning: Applying burn correction, but header indicates burns previously corrected.\n"); … … 491 501 492 502 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", 494 504 naxis1, naxis2, prescan1, ovrscan1, ovrscan2, BZERO); 495 505 } … … 542 552 } 543 553 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 { 547 567 /* Fix up the burns */ 548 568 burn_fix(naxis1-ovrscan1, naxis2-ovrscan2, naxis1, naxis2, buf, … … 559 579 if(VERBOSE & VERB_NORM) burn_blab(OTA+cell); 560 580 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); 565 585 /* 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 } 572 588 } 573 589 574 590 /* Write the corrected data back to the FITS. */ 575 if( update) {591 if(!tableonly && update) { 576 592 fh_ehu(ehu, 0); /* Seek back to the start of data */ 577 593 if (fh_write_padded_image(ehu, fh_file_desc(ehu), buf, … … 590 606 591 607 /* Dump out the postage stamp file */ 592 if(psffile != NULL ) {608 if(psffile != NULL && !restore && !apply) { 593 609 psf_write(psfsize, psfsize, OTA, otanum, psffile); 594 610 } 595 611 596 612 /* Dump out the PSF stats */ 597 if(psfstatfile != NULL ) {613 if(psfstatfile != NULL && !restore && !apply) { 598 614 psf_write_stats(psfsize, psfsize, OTA, otanum, psfstatfile, psfavg); 599 615 } … … 601 617 /* Write burn info to FITS file. */ 602 618 if(update) persist_fits_write(OTA, ihu); 603 604 619 605 if(restore ) {620 if(restore || tableonly) { 606 621 /* 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); 610 630 } 611 631 … … 711 731 printf(" cell=N Work on just one cell? Cell count [0:63] mode.\n"); 712 732 printf(" mask=0101... 64 digits to work on cells 0:63.\n"); 713 printf(" update={t|f} Modify the input MEF bysubtracting fits?\n");733 printf(" update={t|f} Modify the input MEF writing table and subtracting fits?\n"); 714 734 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"); 715 737 printf(" in=fname Input file for previous burn persistence streaks\n"); 716 738 printf(" infits=fname Input FITS file for previous burn persistence streaks (stored\n"); -
trunk/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.h
r23924 r24391 173 173 MTYPE *mask, OBJBOX *box); 174 174 STATIC int burn_restore(int nx, int ny, int NX, IMTYPE *buf, CELL *cell); 175 STATIC int burn_apply(int nx, int ny, int NX, IMTYPE *buf, CELL *cell); 175 176 STATIC int persist_read(CELL *cell, const char *infile); 176 177 STATIC int persist_write(CELL *cell, const char *outfile); -
trunk/extsrc/gpcsw/gpcsrc/fits/burntool/man/burntool.1
r23924 r24391 66 66 inhibited from subtracting the fits by "update=f". 67 67 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 68 113 The identification of significant (but unsaturated) stars is an 69 114 important component of burntool's mask generation, and if requested 70 115 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. 71 118 72 119 Any star whose maximum exceeds PSF_THRESH above sky but is not deemed … … 125 172 qt=-5.201 Tangential quadrupole [pix^2] (-99.99 if fails) 126 173 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) 127 176 qpm=5.154 Plus quadrupole averaged over psfavg 128 177 qcm=0.560 Cross quadrupole averaged over psfavg 129 178 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) 130 186 131 187 Helpful utilities include: … … 151 207 152 208 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. 154 212 155 213 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) 157 223 158 224 in=fname -
trunk/extsrc/gpcsw/gpcsrc/fits/burntool/psfstamp.c
r23490 r24391 136 136 int i, k, l, nstar, fdout, otacx, otacy, xid, yid, ntot=0, sumax; 137 137 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); 139 139 IMTYPE *median_image; 140 140 CELL *cell; … … 203 203 qt = -q[1] * cos(2*phi) - q[2] * sin(2*phi); 204 204 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]); 207 208 208 209 if(CONCAT_FITS) { … … 258 259 double m2[MAXPSFMEDIAN], qp[MAXPSFMEDIAN], qc[MAXPSFMEDIAN]; 259 260 double qt[MAXPSFMEDIAN], fwavg[MAXPSFMEDIAN]; 261 double q3c[MAXPSFMEDIAN], q3s[MAXPSFMEDIAN]; 260 262 double qpavg[MAXPSFMEDIAN], qcavg[MAXPSFMEDIAN], qtavg[MAXPSFMEDIAN]; 263 double q3cavg[MAXPSFMEDIAN], q3savg[MAXPSFMEDIAN]; 261 264 int nstar[MAXCELL], nfw[MAXCELL]; 262 265 double fwmed[MAXCELL], m2med[MAXCELL]; 263 266 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; 265 269 FILE *fp; 266 270 CELL *cell; … … 304 308 qp[nstar[k]] = q[1]; 305 309 qc[nstar[k]] = q[2]; 310 q3c[nstar[k]] = q[3]; 311 q3s[nstar[k]] = q[4]; 306 312 /* Get the position in the focal plane and therefore the qt statistic */ 307 313 psc_cell_to_pixel(cellx, celly, 0.5*PSC_HCELL/PSC_PIXEL, … … 325 331 qcmed[k] = double_median(nstar[k], qc); 326 332 qtmed[k] = double_median(nstar[k], qt); 333 q3cmed[k] = double_median(nstar[k], q3c); 334 q3smed[k] = double_median(nstar[k], q3s); 327 335 } else { 328 336 m2med[k] = qpmed[k] = qcmed[k] = qtmed[k] = -99.99; 337 q3cmed[k] = q3smed[k] = -99.99; 329 338 } 330 339 /* Toss these results into the macrocell median hopper */ … … 337 346 qcavg[nqavg] = qc[l]; 338 347 qtavg[nqavg] = qt[l]; 348 q3cavg[nqavg] = q3c[l]; 349 q3savg[nqavg] = q3s[l]; 339 350 nqavg++; 340 351 } … … 346 357 qcmacro = double_median(nqavg, qcavg); 347 358 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; 349 362 fwmacro = double_median(nfwave, fwavg); 350 363 … … 357 370 cell = ota + k; 358 371 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 q pm=%.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", 360 373 cellx, celly, cell->bias, cell->sky, cell->rms, 361 374 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); 364 377 } 365 378 }
Note:
See TracChangeset
for help on using the changeset viewer.
