Changeset 24391 for trunk/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.c
- Timestamp:
- Jun 12, 2009, 3:53:07 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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");
Note:
See TracChangeset
for help on using the changeset viewer.
