Changeset 26767
- Timestamp:
- Feb 3, 2010, 1:00:34 PM (16 years ago)
- Location:
- branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool
- Files:
-
- 9 edited
-
burnfix.c (modified) (3 diffs)
-
burntool.c (modified) (2 diffs)
-
burntool.h (modified) (2 diffs)
-
man/burntool.1 (modified) (2 diffs)
-
persist_fits.c (modified) (17 diffs)
-
persist_fits.h (modified) (1 diff)
-
persistfix.c (modified) (1 diff)
-
persistio.c (modified) (10 diffs)
-
trailfit.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/burnfix.c
r26764 r26767 72 72 ymid = (cell->burn[k].y0m + cell->burn[k].y1m + 73 73 cell->burn[k].y0p + cell->burn[k].y1p + 2) / 4; 74 i = ABS(cell->burn[k].nfit)/ 2;74 i = cell->burn[k].nfit / 2; 75 75 printf("%3d %5d %3d %5d %5d %3d %5d %3d %5d %5d %2d %1d %1d %6.3f %8d\n", 76 76 k, … … 109 109 /* Restore all the burns */ 110 110 for(k=0; k<cell->npersist; k++) { 111 if(!cell->persist[k].fiterr) 111 if(!cell->persist[k].fiterr && 112 (cell->persist[k].func == BURN_PWR || 113 cell->persist[k].func == BURN_EXP) ) { 112 114 sub_fit(nx, ny, NX, buf, &(cell->persist[k]), -1); 115 } 113 116 } 114 117 return(0); … … 124 127 /* Restore all the burns */ 125 128 for(k=0; k<cell->npersist; k++) { 126 if(!cell->persist[k].fiterr) 129 if(!cell->persist[k].fiterr && 130 (cell->persist[k].func == BURN_PWR || 131 cell->persist[k].func == BURN_EXP) ) { 127 132 sub_fit(nx, ny, NX, buf, &(cell->persist[k]), +1); 133 } 128 134 } 129 135 return(0); -
branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.c
r26764 r26767 364 364 /* Read the persistence data for this OTA */ 365 365 if(persistfile != NULL) { /* Text data file */ 366 if(persist_read(OTA, persistfile )) exit(-317);366 if(persist_read(OTA, persistfile, apply)) exit(-317); 367 367 } else if(persistfitsfile != NULL) { /* FITS table */ 368 if(persist_fits_read(OTA, persistfitsfile ) != FH_SUCCESS)368 if(persist_fits_read(OTA, persistfitsfile, apply) != FH_SUCCESS) 369 369 exit(-318); 370 370 } … … 770 770 printf(" restore={t|f} Restore the input MEF by adding input fits?\n"); 771 771 printf(" apply={t|f} Modify the input MEF by subtracting previously calculated fits?\n"); 772 printf(" tableonly={t|f} Calculate fits but do *not* modify the input MEF images, only write tables\n");772 printf(" tableonly={t|f} Calculate fits but do *not* modify the input MEF pixels, only write tables\n"); 773 773 printf(" in=fname Input file for previous burn persistence streaks\n"); 774 774 printf(" infits=fname Input FITS file for previous burn persistence streaks (stored\n"); -
branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.h
r26764 r26767 91 91 #define BURN_EXP 2 /* Exponential */ 92 92 #define BURN_BLASTED 3 /* Blasted top to bottom: flag only for IPP */ 93 #define BURN_POSSLOPE 4 /* Positive slope fit (bad) but significant */ 93 94 #define PSF_STAR 9 /* Unfitted: good psf star */ 94 95 … … 175 176 STATIC int burn_restore(int nx, int ny, int NX, IMTYPE *buf, CELL *cell); 176 177 STATIC int burn_apply(int nx, int ny, int NX, IMTYPE *buf, CELL *cell); 177 STATIC int persist_read(CELL *cell, const char *infile );178 STATIC int persist_read(CELL *cell, const char *infile, int apply); 178 179 STATIC int persist_write(CELL *cell, const char *outfile); 179 180 STATIC int persist_fix(int nx, int ny, int stride, IMTYPE *buf, CELL *cell); 180 181 STATIC int persist_merge(CELL *cell); 182 183 //fh_result persist_fits_read(CELL *cell, const char *filename, int apply); 184 //fh_result persist_fits_write(CELL *cell, HeaderUnit phu); 185 //fh_result persist_fits_remove_tables(HeaderUnit phu_in, const char *fileout); 181 186 182 187 STATIC int star_detect(int nx, int ny, int NX, int NY, DTYPE *data, -
branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/man/burntool.1
r26764 r26767 61 61 until they finally achieve a legal fit with negligible amplitude. 62 62 Note that if burntool decides that a fit had a bad slope but was 63 non-negligible it negates the "nfit" width parameter of the fit box. 63 non-negligible it writes a function type "BURN_POSSLOPE" = 4 so 64 the box is available for masking if desired, and can be refitted 65 on subsequent images. 64 66 65 67 Burntool also identifies really blasted areas which are saturated from … … 229 231 230 232 tableonly={t|f} 231 Calculate fits but do *not* modify the input MEF images,233 Calculate fits but do *not* modify the input MEF pixels, 232 234 only write the fit data as a FITS and/or text table (default f) 233 235 -
branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/persist_fits.c
r26764 r26767 52 52 AREA_TABLE_COL_SXFIT, 53 53 AREA_TABLE_COL_EXFIT, 54 AREA_TABLE_COL_FITERR, 54 55 55 56 /* Add new columns above this line. */ … … 86 87 { "sxfit", "Starting column for fit", "pixels", FH_TABLE_FORMAT_INT, 3, 0 }, 87 88 { "exfit", "Ending column for fit", "pixels", FH_TABLE_FORMAT_INT, 3, 0 }, 89 { "fiterr", "Error code of fit", "", FH_TABLE_FORMAT_INT, 3, 0 }, 88 90 }; 89 91 … … 237 239 } 238 240 num_areas++; 239 num_fits += ABS(cell[j].persist[k].nfit);241 num_fits += cell[j].persist[k].nfit; 240 242 } 241 243 … … 257 259 } 258 260 num_areas++; 259 num_fits += ABS(cell[j].burn[k].nfit);261 num_fits += cell[j].burn[k].nfit; 260 262 } 261 263 } … … 310 312 (fh_table_write_value(table, data, row, AREA_TABLE_COL_NFIT, &(area->nfit)) != FH_SUCCESS) || 311 313 (fh_table_write_value(table, data, row, AREA_TABLE_COL_SXFIT, &(area->sxfit)) != FH_SUCCESS) || 312 (fh_table_write_value(table, data, row, AREA_TABLE_COL_EXFIT, &(area->exfit)) != FH_SUCCESS)) 314 (fh_table_write_value(table, data, row, AREA_TABLE_COL_EXFIT, &(area->exfit)) != FH_SUCCESS) || 315 (fh_table_write_value(table, data, row, AREA_TABLE_COL_FITERR, &(area->fiterr)) != FH_SUCCESS)) 313 316 { 314 317 fprintf(stderr, "\rerror: Error writing data to row %d of area table.\n", row); … … 480 483 if(cell[j].persist[k].fiterr) continue; 481 484 } 482 for(i=0; i< ABS(cell[j].persist[k].nfit); i++)485 for(i=0; i<cell[j].persist[k].nfit; i++) 483 486 { 484 487 result = write_fit_row(hu, data, table, row++, … … 505 508 } 506 509 507 for(i=0; i< ABS(cell[j].burn[k].nfit); i++)510 for(i=0; i<cell[j].burn[k].nfit; i++) 508 511 { 509 512 result = write_fit_row(hu, data, table, row++, … … 538 541 */ 539 542 static fh_result 540 read_area(fhTable * table, void * data, int row )543 read_area(fhTable * table, void * data, int row, int apply) 541 544 { 542 545 int cell_num; … … 585 588 (fh_table_read_value(table, data, row, AREA_TABLE_COL_NFIT, &(boxbuf[row].nfit)) != FH_SUCCESS) || 586 589 (fh_table_read_value(table, data, row, AREA_TABLE_COL_SXFIT, &(boxbuf[row].sxfit)) != FH_SUCCESS) || 587 (fh_table_read_value(table, data, row, AREA_TABLE_COL_EXFIT, &(boxbuf[row].exfit)) != FH_SUCCESS)) 590 (fh_table_read_value(table, data, row, AREA_TABLE_COL_EXFIT, &(boxbuf[row].exfit)) != FH_SUCCESS) || 591 (fh_table_read_value(table, data, row, AREA_TABLE_COL_FITERR, &(boxbuf[row].fiterr)) != FH_SUCCESS)) 588 592 { 589 593 fprintf(stderr, … … 595 599 596 600 /* Make space for fits (to be read later). */ 597 if( ABS(boxbuf[row].nfit)> 0)601 if(boxbuf[row].nfit > 0) 598 602 { 599 603 /* This shouldn't happen, but be nice and don't leak. */ … … 602 606 if(boxbuf[row].yfit) free(boxbuf[row].yfit); 603 607 604 boxbuf[row].zero = (double *)calloc( ABS(boxbuf[row].nfit), sizeof(double));605 boxbuf[row].xfit = (int *)calloc( ABS(boxbuf[row].nfit), sizeof(int));606 boxbuf[row].yfit = (int *)calloc( ABS(boxbuf[row].nfit), sizeof(int));608 boxbuf[row].zero = (double *)calloc(boxbuf[row].nfit, sizeof(double)); 609 boxbuf[row].xfit = (int *)calloc(boxbuf[row].nfit, sizeof(int)); 610 boxbuf[row].yfit = (int *)calloc(boxbuf[row].nfit, sizeof(int)); 607 611 608 612 if(boxbuf[row].zero == NULL || … … 612 616 exit(-671); 613 617 } 614 boxbuf[row].fiterr = 0; 618 // 100203 JT: fiterr now saved and read, refit if not just an "apply" 619 if(!apply) boxbuf[row].fiterr = 0; 615 620 } 616 621 … … 635 640 */ 636 641 static fh_result 637 read_area_table(HeaderUnit hu, fhTable * table )642 read_area_table(HeaderUnit hu, fhTable * table, int apply) 638 643 { 639 644 fh_result result = FH_INVALID; … … 688 693 for(i = 0; i < num_rows; i++) 689 694 { 690 if((result = read_area(table, data, i )) != FH_SUCCESS) break;695 if((result = read_area(table, data, i, apply)) != FH_SUCCESS) break; 691 696 } 692 697 … … 840 845 for(area = 0; area < num_areas; area++) 841 846 { 842 for(i = 0; i < ABS(boxbuf[area].nfit); i++)847 for(i = 0; i < boxbuf[area].nfit; i++) 843 848 { 844 849 if((result = read_fit(hu, table, data, fit_table_row, … … 901 906 */ 902 907 fh_result 903 persist_fits_read(CELL *cell, const char * filename )908 persist_fits_read(CELL *cell, const char * filename, int apply) 904 909 { 905 910 HeaderUnit phu; … … 938 943 939 944 fh_ehu_by_extname(phu, DEFAULT_EXTNAME_AREA_TABLE); 940 if((result = read_area_table(area_hu, &area_table )) != FH_SUCCESS)945 if((result = read_area_table(area_hu, &area_table, apply)) != FH_SUCCESS) 941 946 { 942 947 free(area_table.strbuf); -
branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/persist_fits.h
r23924 r26767 24 24 25 25 fh_result 26 persist_fits_read(CELL *cell, const char * filename );26 persist_fits_read(CELL *cell, const char * filename, int apply); 27 27 28 28 fh_result -
branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/persistfix.c
r23924 r26767 34 34 } 35 35 continue; 36 } 37 38 /* This had a significant positive slope, what do we do now? */ 39 if( (cell->persist)[k].func == BURN_POSSLOPE) { 40 /* try again, so let it slide through... */ 36 41 } 37 42 -
branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/persistio.c
r26764 r26767 16 16 /****************************************************************/ 17 17 /* persist_read(): Read all the persistence trails from a file */ 18 STATIC int persist_read(CELL *cell, const char *infile )18 STATIC int persist_read(CELL *cell, const char *infile, int apply) 19 19 { 20 20 int i, k, nbox=0; … … 38 38 while(fgets(line, 1024, fp) != NULL) { 39 39 if(line[0] == '#') continue; 40 sscanf(line, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %lf %d %d %d ",40 sscanf(line, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %lf %d %d %d %d", 41 41 &boxbuf[nbox].cell, &boxbuf[nbox].time, 42 42 &boxbuf[nbox].cx, &boxbuf[nbox].cy, … … 50 50 &boxbuf[nbox].func, &boxbuf[nbox].up, 51 51 &boxbuf[nbox].slope, &boxbuf[nbox].nfit, 52 &boxbuf[nbox].sxfit, &boxbuf[nbox].exfit); 53 if(ABS(boxbuf[nbox].nfit) > 0) { 54 boxbuf[nbox].zero = (double *)calloc(ABS(boxbuf[nbox].nfit), sizeof(double)); 55 boxbuf[nbox].xfit = (int *)calloc(ABS(boxbuf[nbox].nfit), sizeof(int)); 56 boxbuf[nbox].yfit = (int *)calloc(ABS(boxbuf[nbox].nfit), sizeof(int)); 52 &boxbuf[nbox].sxfit, &boxbuf[nbox].exfit, 53 &boxbuf[nbox].fiterr); 54 if(boxbuf[nbox].nfit > 0) { 55 boxbuf[nbox].zero = (double *)calloc(boxbuf[nbox].nfit, sizeof(double)); 56 boxbuf[nbox].xfit = (int *)calloc(boxbuf[nbox].nfit, sizeof(int)); 57 boxbuf[nbox].yfit = (int *)calloc(boxbuf[nbox].nfit, sizeof(int)); 57 58 if(boxbuf[nbox].zero == NULL || 58 59 boxbuf[nbox].xfit == NULL || … … 62 63 } 63 64 64 for(i=0; i< ABS(boxbuf[nbox].nfit); i++) {65 for(i=0; i<boxbuf[nbox].nfit; i++) { 65 66 if(fgets(line, 1024, fp) == NULL) { 66 67 fprintf(stderr, "\rerror: short read of burn lines\n"); … … 71 72 } 72 73 } 73 boxbuf[nbox].fiterr = 0; 74 // 100203 JT: fiterr now saved and read, refit if not just an "apply" 75 if(!apply) boxbuf[nbox].fiterr = 0; 74 76 /* Augment counts */ 75 77 k = boxbuf[nbox].cell; … … 159 161 k = boxid[kp]; 160 162 zk = 0.0; 161 if( ABS(box[k].nfit) > 0) zk = box[k].zero[ABS(box[k].nfit)/2];163 if(box[k].nfit > 0) zk = box[k].zero[box[k].nfit/2]; 162 164 for(jp=kp+1; jp<n; jp++) { 163 165 j = boxid[jp]; 164 166 zj = 0.0; 165 if( ABS(box[j].nfit) > 0) zj = box[j].zero[ABS(box[j].nfit)/2];167 if(box[j].nfit > 0) zj = box[j].zero[box[j].nfit/2]; 166 168 if(ABS(yctr[jp]-yctr[kp]) > DIFFERENT_STREAK) { 167 169 /* Trim back the feebler streak */ … … 266 268 if(cell[j].persist[k].nfit <= 0) continue; 267 269 } 268 fprintf(fp, "%3d %7d %3d %3d %5d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %1d %1d %9.6f %3d %3d %3d \n",270 fprintf(fp, "%3d %7d %3d %3d %5d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %1d %1d %9.6f %3d %3d %3d %d\n", 269 271 j, cell[j].persist[k].time, 270 272 cell[j].persist[k].cx, cell[j].persist[k].cy, … … 278 280 cell[j].persist[k].func, cell[j].persist[k].up, 279 281 cell[j].persist[k].slope, cell[j].persist[k].nfit, 280 cell[j].persist[k].sxfit, cell[j].persist[k].exfit); 281 for(i=0; i<ABS(cell[j].persist[k].nfit); i++) { 282 cell[j].persist[k].sxfit, cell[j].persist[k].exfit, 283 cell[j].persist[k].fiterr); 284 for(i=0; i<cell[j].persist[k].nfit; i++) { 282 285 fprintf(fp, "%3d %3d %8.4f\n", cell[j].persist[k].xfit[i], 283 286 cell[j].persist[k].yfit[i], cell[j].persist[k].zero[i]); … … 302 305 303 306 i = (cell[j].burn[k].ex - cell[j].burn[k].sx + 1) / 2; 304 fprintf(fp, "%3d %7d %3d %3d %5d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %1d %1d %9.6f %3d %3d %3d \n",307 fprintf(fp, "%3d %7d %3d %3d %5d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %1d %1d %9.6f %3d %3d %3d %d\n", 305 308 j, cell[j].burn[k].time, 306 309 cell[j].burn[k].cx, cell[j].burn[k].cy, … … 314 317 cell[j].burn[k].func, cell[j].burn[k].up, 315 318 cell[j].burn[k].slope, cell[j].burn[k].nfit, 316 cell[j].burn[k].sxfit, cell[j].burn[k].exfit); 317 for(i=0; i<ABS(cell[j].burn[k].nfit); i++) { 319 cell[j].burn[k].sxfit, cell[j].burn[k].exfit, 320 cell[j].burn[k].fiterr); 321 for(i=0; i<cell[j].burn[k].nfit; i++) { 318 322 fprintf(fp, "%3d %3d %8.4f\n", cell[j].burn[k].xfit[i], 319 323 cell[j].burn[k].yfit[i], cell[j].burn[k].zero[i]); -
branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/trailfit.c
r26764 r26767 30 30 31 31 if(box->func != BURN_PWR && box->func != BURN_EXP) { 32 fprintf(stderr, "error: unimplemented fit function %d\n", box->func); 32 fprintf(stderr, "error: unimplemented fit function %d (err %d)\n", 33 box->func, box->fiterr); 33 34 return(-1); 34 35 } … … 230 231 /* FIXME: sanity check fits */ 231 232 if(slope >= FIT_MAX_SLOPE || slope < FIT_MIN_SLOPE) { 232 /* Check whether it's a significant trail (but with wrong slope) or just 233 * noise. In the former case negate box->nfit, 234 * in the latter case set it to zero. */ 233 box->slope = slope; 234 box->nfit = 0; 235 box->fiterr = FIT_SLOPE_ERROR; 236 /* Check whether it's a significant trail (but with pos slope) or just noise */ 235 237 linearrms(nfit, ybuf+y1, zbuf+y1, slope, zero, &trial); 236 box->slope = slope; 237 if(trial > 2*rms) box->nfit = -box->nfit; 238 else box->nfit = 0; 239 box->fiterr = FIT_SLOPE_ERROR; 238 /* 100203 JT: bad idea: appears to be a bug in read/writing ABS(nfit) */ 239 // if(trial > 2*rms) box->nfit = -box->nfit; 240 if(trial > 2*rms) box->func = BURN_POSSLOPE; 240 241 return(-1); 241 242 }
Note:
See TracChangeset
for help on using the changeset viewer.
