Changeset 42753
- Timestamp:
- Dec 6, 2024, 1:28:47 PM (20 months ago)
- Location:
- branches/eam_branches/ipp-20230313/extsrc/gpcsw/gpcsrc/fits/burntool
- Files:
-
- 6 edited
-
burnfix.c (modified) (14 diffs)
-
burntool.c (modified) (5 diffs)
-
burntool.h (modified) (3 diffs)
-
persistfix.c (modified) (2 diffs)
-
stardetect.c (modified) (2 diffs)
-
trailfit.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20230313/extsrc/gpcsw/gpcsrc/fits/burntool/burnfix.c
r42392 r42753 17 17 /* burn_fix(): Find and fix all the burned patches in a cell */ 18 18 STATIC int burn_fix(int nx, int ny, int NX, int NY, IMTYPE *buf, 19 CELL *cell, int cellnum )19 CELL *cell, int cellnum, char *camera) 20 20 { 21 21 int k, err; 22 22 23 23 /* Find all the burned patches and bright stars */ 24 err = star_detect(nx, ny, NX, NY, imbuf, mbuf, msbuf, cell, cellnum );25 26 err = burn_check(nx, ny, NX, NY, imbuf, mbuf, cell );24 err = star_detect(nx, ny, NX, NY, imbuf, mbuf, msbuf, cell, cellnum, camera); 25 26 err = burn_check(nx, ny, NX, NY, imbuf, mbuf, cell, camera); 27 27 28 28 // fprintf(stderr, "Got through burn_check\n"); 29 29 30 30 /* Expand the masks; burns asymmetrically, stars symmetrically */ 31 // err = grow_mask(nx, ny, NX, mbuf, YMASK_GROW, YMASK_GROW, cell->nstar, cell->star);32 // err = grow_mask(nx, ny, NX, mbuf, XMASK_GROW, YMASK_GROW, cell->nburn, cell->burn);33 31 err = grow_mask(nx, ny, NX, mbuf, BMASK_GROW, RMASK_GROW, 34 32 MASK_SAT_HALO, cell->nburn, cell->burn); … … 44 42 // fprintf(stderr, "Fitting trail %d\n", k); 45 43 fit_trail(nx, ny, NX, imbuf, mbuf, cell->burn+k, 1, 46 cell->sky+cell->bias, cell->rms, BURN_PWR );44 cell->sky+cell->bias, cell->rms, BURN_PWR, camera); 47 45 /* Subtract the fit from the image */ 48 46 // fprintf(stderr, "Subtracting trail %d\n", k); … … 54 52 for(k=0; k<NX*ny; k++) buf[k] = mbuf[k] - BZERO; 55 53 } 54 56 55 return(err); 57 56 } … … 106 105 /****************************************************************/ 107 106 /* burn_restore(): Restore the fitted trails back to the image */ 108 STATIC int burn_restore(int nx, int ny, int NX, IMTYPE *buf, CELL *cell )107 STATIC int burn_restore(int nx, int ny, int NX, IMTYPE *buf, CELL *cell, char *camera) 109 108 { 110 109 int k; … … 124 123 /****************************************************************/ 125 124 /* burn_apply(): Subtract the trail fits from the image */ 126 STATIC int burn_apply(int nx, int ny, int NX, IMTYPE *buf, CELL *cell )125 STATIC int burn_apply(int nx, int ny, int NX, IMTYPE *buf, CELL *cell, char *camera) 127 126 { 128 127 int k; … … 143 142 /* burn_check(): Find all the burned patches in a cell */ 144 143 STATIC int burn_check(int nx, int ny, int NX, int NY, DTYPE *data, 145 MTYPE *mask, CELL *cell )144 MTYPE *mask, CELL *cell, char *camera) 146 145 { 147 146 int err,k; … … 153 152 continue; 154 153 } 155 err = burn_test(nx, ny, NX, data, cell->rms, mask, cell->burn+k );154 err = burn_test(nx, ny, NX, data, cell->rms, mask, cell->burn+k, camera); 156 155 } 157 156 … … 240 239 */ 241 240 STATIC int burn_test(int nx, int ny, int NX, DTYPE *data, int rms, 242 MTYPE *mask, OBJBOX *box )241 MTYPE *mask, OBJBOX *box, char *camera) 243 242 { 244 243 int i, j, nburn, nref, nmed; 245 int y0, y1, ymid, xburn, xref, dx=0, dy=0;244 int y0, y1, x0, x1, xwidth, ymid, xburn, xref, dx=0, dy=0; 246 245 247 246 /*introduce a maximum to the burn contrast check, to avoid a very large number in crowded regions*/ … … 275 274 y0 = ymid + MAX(box->ey-ymid, FIT_EDGE); 276 275 y1 = MIN(y0+100, ny-1); 276 x0 = box->sx; 277 x1 = box->ex; 277 278 278 279 if(2*box->ex - box->sx + 1 < nx-1) { /* Work right? */ … … 294 295 dx = 0; 295 296 dy = MAX(ymid-box->sy, box->ey-ymid); 297 298 if(!strcmp(camera,"gpc2")) { 299 /*start right at the edge of the star box might not be the best*/ 300 /*add 20% of box size on top, with a maximum of ten pixels*/ 301 dy = dy + MIN((box->ey-box->sy)/5,10); 302 303 /*Use the inner third of the star width for this test. Should be brightest there*/ 304 xwidth = MAX((box->ex-box->sx)/3,10); 305 x0 = box->sx + (box->ex-box->sx)/2 - xwidth/2; 306 x1 = box->sx + (box->ex-box->sx)/2 + xwidth/2; 307 } else { 308 //regular gpc1 setup 309 x0 = box->sx; 310 x1 = box->ex; 311 } 312 296 313 if(dy < FIT_EDGE) dy = FIT_EDGE; 297 314 y0 = ymid + dy; 298 315 y1 = y0 + MIN(ny-1-y0, 2*ymid-y0-1); 299 316 if(y1-y0 > test_box) y1 = y0 + test_box; 317 318 } 319 if(VERBOSE & VERB_BOXGROW) { 320 printf("test input dx,dy,x0,x1, y0, y1, test_box, ymid: %8d %8d %8d %8d %8d %8d %8d %8d\n", dx,dy,x0,x1, y0, y1, test_box, ymid); 300 321 } 301 322 … … 305 326 xburn = xref = 0; 306 327 nburn = nref = 0; 307 for(i= box->sx; i<=box->ex; i++) {328 for(i=x0; i<=x1; i++) { 308 329 if(mask[i+j*NX] == MASK_NONE) { 309 330 xburn += data[i+j*NX]; … … 326 347 if(nref > 0 && nburn > 0) median_buf[nmed++] = xburn - xref; 327 348 if(VERBOSE & VERB_BOXGROW) { 328 printf("contrast: %8d %8d %8d %8d %8d\n", j, xburn, (2*ymid-j), xref, xburn - xref);349 printf("contrast: %8d %8d %8d %8d %8d %8d %8d\n", j, xburn,nburn, (2*ymid-j), xref,nref, xburn - xref); 329 350 } 330 351 … … 332 353 box->diff = int_median(nmed, median_buf); 333 354 box->burned = (box->diff > burn_contrast); 355 if(VERBOSE & VERB_BOXGROW) { 356 printf("test output: %8d %8d %8d\n", box->burned, burn_contrast, box->diff); 357 } 358 334 359 return(0); 335 360 } … … 344 369 /* burn_test() tests whether a box is burned or not */ 345 370 STATIC int burn_test(int nx, int ny, int NX, DTYPE *data, int rms, 346 MTYPE *mask, OBJBOX *box )371 MTYPE *mask, OBJBOX *box, char *camera) 347 372 { 348 373 int i, j, n, nrow, nmed; -
branches/eam_branches/ipp-20230313/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.c
r42392 r42753 29 29 HeaderUnit ehu; 30 30 const char* ifilename = "-"; 31 char extname[FH_MAX_STRLEN+1], otaposn[FH_MAX_STRLEN+1] ;31 char extname[FH_MAX_STRLEN+1], otaposn[FH_MAX_STRLEN+1], *camera="gpc1"; 32 32 int cellmask[MAXCELL]; 33 33 int otanum; … … 176 176 } else if(strncmp(argv[i], "infits=", 7) == 0) { /* infits=fname */ 177 177 persistfitsfile = argv[i] + 7; 178 179 /* Input camera keyword (optional) */ 180 } else if(strncmp(argv[i], "camera=", 7) == 0) { /* camera=fname */ 181 camera = argv[i] + 7; 178 182 179 183 /* Keep persistence streaks which had a bad slope? */ … … 577 581 /* Use the table-driven fits instead of calculating new ones */ 578 582 burn_apply(naxis1-ovrscan1, naxis2-ovrscan2, naxis1, 579 buf, OTA+cell );583 buf, OTA+cell,camera); 580 584 /* Tell us about it? */ 581 585 if(VERBOSE & VERB_NORM) burn_blab(OTA+cell); … … 584 588 /* Restore the old burns */ 585 589 burn_restore(naxis1-ovrscan1, naxis2-ovrscan2, naxis1, 586 buf, OTA+cell );590 buf, OTA+cell,camera); 587 591 588 592 } else { 589 593 /* Fix up the burns */ 590 594 burn_fix(naxis1-ovrscan1, naxis2-ovrscan2, naxis1, naxis2, buf, 591 OTA+cell, cell );595 OTA+cell, cell,camera); 592 596 593 597 /* Collect up a good star list */ … … 602 606 603 607 persist_fix(naxis1-ovrscan1, naxis2-ovrscan2, naxis1, buf, 604 OTA+cell );608 OTA+cell,camera); 605 609 /* Tell us about it? */ 606 610 if(VERBOSE & VERB_NORM) persist_blab(OTA+cell); -
branches/eam_branches/ipp-20230313/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.h
r42392 r42753 172 172 STATIC int mem_init(int nx, int ny, int NX, int NY); 173 173 STATIC int burn_fix(int nx, int ny, int stride, int NY, IMTYPE *buf, 174 CELL *cell, int cellnum );174 CELL *cell, int cellnum,char *camera); 175 175 STATIC int burn_test(int nx, int ny, int NX, DTYPE *data, int rms, 176 MTYPE *mask, OBJBOX *box );177 STATIC int burn_restore(int nx, int ny, int NX, IMTYPE *buf, CELL *cell );178 STATIC int burn_apply(int nx, int ny, int NX, IMTYPE *buf, CELL *cell );176 MTYPE *mask, OBJBOX *box,char *camera); 177 STATIC int burn_restore(int nx, int ny, int NX, IMTYPE *buf, CELL *cell,char *camera); 178 STATIC int burn_apply(int nx, int ny, int NX, IMTYPE *buf, CELL *cell,char *camera); 179 179 STATIC int persist_read(CELL *cell, const char *infile, int apply); 180 180 STATIC int persist_write(CELL *cell, const char *outfile); 181 STATIC int persist_fix(int nx, int ny, int stride, IMTYPE *buf, CELL *cell );181 STATIC int persist_fix(int nx, int ny, int stride, IMTYPE *buf, CELL *cell,char *camera); 182 182 STATIC int persist_merge(CELL *cell); 183 183 … … 187 187 188 188 STATIC int star_detect(int nx, int ny, int NX, int NY, DTYPE *data, 189 MTYPE *mask, MTYPE *veto, CELL *cell, int cellnum );189 MTYPE *mask, MTYPE *veto, CELL *cell, int cellnum,char *camera); 190 190 STATIC int burn_check(int nx, int ny, int stride, int NY, DTYPE *buf, 191 MTYPE *mask, CELL *cell );191 MTYPE *mask, CELL *cell,char *camera); 192 192 193 193 STATIC int cell_stats(int nx, int ny, int NX, int NY, DTYPE *data, CELL *cell); … … 197 197 198 198 STATIC int fit_trail(int nx, int ny, int NX, DTYPE *data, MTYPE *mask, 199 OBJBOX *box, int up, int sky, int rms, int fitfunc );199 OBJBOX *box, int up, int sky, int rms, int fitfunc,char *camera); 200 200 STATIC int sub_fit(int nx, int ny, int NX, IMTYPE *buf, OBJBOX *box, int sign); 201 201 -
branches/eam_branches/ipp-20230313/extsrc/gpcsw/gpcsrc/fits/burntool/persistfix.c
r42392 r42753 18 18 /* burn_fix must have been run first! */ 19 19 STATIC int persist_fix(int nx, int ny, int NX, IMTYPE *buf, 20 CELL *cell )20 CELL *cell, char *camera) 21 21 { 22 22 int k, err=0; … … 43 43 /* Fit the trail */ 44 44 err = fit_trail(nx, ny, NX, imbuf, mbuf, cell->persist+k, 0, 45 cell->sky+cell->bias, cell->rms, BURN_EXP );45 cell->sky+cell->bias, cell->rms, BURN_EXP, camera); 46 46 47 47 /* Subtract out the fit */ -
branches/eam_branches/ipp-20230313/extsrc/gpcsw/gpcsrc/fits/burntool/stardetect.c
r42392 r42753 17 17 /* star_detect(): Find all the stars and burned patches in a cell */ 18 18 STATIC int star_detect(int nx, int ny, int NX, int NY, DTYPE *data, 19 MTYPE *mask, MTYPE *veto, CELL *cell, int cellnum )19 MTYPE *mask, MTYPE *veto, CELL *cell, int cellnum, char *camera) 20 20 { 21 21 int i, j, k, l; … … 124 124 /* But take a hard look at stars with really bright centers... */ 125 125 if(!boxbuf[nbox].burned && boxbuf[nbox].max > MAX_THRESH) { 126 burn_test(nx, ny, NX, data, cell->rms, mask, boxbuf+nbox );126 burn_test(nx, ny, NX, data, cell->rms, mask, boxbuf+nbox, camera); 127 127 } 128 128 boxbuf[nbox].time = cell->time; -
branches/eam_branches/ipp-20230313/extsrc/gpcsw/gpcsrc/fits/burntool/trailfit.c
r42392 r42753 14 14 #include "burnparams.h" 15 15 16 STATIC double ybuf[MAXSIZE], zbuf[MAXSIZE], wbuf[MAXSIZE], wbuf0[MAXSIZE] ;16 STATIC double ybuf[MAXSIZE], zbuf[MAXSIZE], wbuf[MAXSIZE], wbuf0[MAXSIZE],xbuf[MAXSIZE]; 17 17 18 18 /****************************************************************/ … … 92 92 STATIC int fit_trail(int nx, int ny, int NX, 93 93 DTYPE *data, MTYPE *mask, OBJBOX *box, 94 int up, int bckgnd, int rms, int fitfunc )94 int up, int bckgnd, int rms, int fitfunc,char *camera) 95 95 { 96 int i, j, k, err, nfit,firstfitpix ;97 int xs, xe, y0, y1, y2, dy, yfit ;98 double slope, zero, zsum, wsum, trial,zfun ;96 int i, j, k, err, nfit,firstfitpix,secondfitpix, xwidth; 97 int xs, xe, y0, y1, y2, dy, yfit,x0,x1; 98 double slope, zero, zsum, wsum, trial,zfun,xsum,xmean,xstd; 99 99 char fooname[60]; 100 100 FILE *fp=stdout; … … 104 104 return(-1); 105 105 } 106 106 107 107 /*xs = box->sxfit; */ 108 108 /*xe = box->exfit; */ … … 110 110 xs = box->sx; 111 111 xe = box->ex; 112 112 113 113 114 if(up) { … … 119 120 yfit = box->sy; /* Start of validity, TBD later by col */ 120 121 firstfitpix = MAX((box->ey - box->sy)*2,20) ; /* Number of pixels to include in the initial fit*/ 122 secondfitpix = 200; /* Number of pixels to include in the second fit*/ 121 123 } else { 122 124 //y0 = (box->y0m + box->y1m + box->y0p + box->y1p + 2) / 4; … … 127 129 yfit = box->ey; /* Start of validity, TBD later by col */ 128 130 firstfitpix = 100; /* Number of pixels to include in the initial fit*/ 129 131 secondfitpix = 200; /* Number of pixels to include in the second fit*/ 132 } 133 134 if(!strcmp(camera,"gpc2")) { 135 /*Use the inner third of the star width for this test. Should be brightest there*/ 136 xwidth = MAX((box->ex-box->sx)/3,10); 137 x0 = box->sx + (box->ex-box->sx)/2 - xwidth/2; 138 x1 = box->sx + (box->ex-box->sx)/2 + xwidth/2; 139 /*when fitting a burn, do not want to include part of the star*/ 140 /*add 20% of box size on top, with a maximum of ten pixels*/ 141 if(up) y1 = box->ey + MIN((box->ey-box->sy)/5,10); 142 } else { 143 //regular gpc1 setup 144 x0 = box->sx; 145 x1 = box->ex; 130 146 } 131 147 132 148 if(VERBOSE & VERB_FIT) { 133 printf("Fit requested xs,xe,y0,y1,y2,dy,up,f =%d %d %d %d %d %d %d %d\n",134 xs, xe, y0, y1, y2, dy, up, fitfunc );149 printf("Fit requested xs,xe,y0,y1,y2,dy,up,f,x0,x1= %d %d %d %d %d %d %d %d %d %d\n", 150 xs, xe, y0, y1, y2, dy, up, fitfunc,x0,x1); 135 151 } 136 152 … … 184 200 ybuf[j] = Y_SCALE * dy * (j-y0); 185 201 zbuf[j]=0.0; 186 for(i=x s, k=0; i<=xe; i++) {202 for(i=x0, k=0; i<=x1; i++) { 187 203 if(data[i+j*NX] != NODATA && (mask[i+j*NX] == MASK_NONE || mask[i+j*NX] == MASK_SAT_HALO) ) { 188 204 zbuf[j] += data[i+j*NX]; … … 221 237 /* Trim away any really big positive deviations */ 222 238 for(j=y1; j<=y2; j++) { 223 // if(zbuf[j]-(ybuf[j]*slope+zero) > MAXDEV &&224 // zbuf[j] > log(MAXRMS*rms)) wbuf[j] = 0;225 239 if(abs(zbuf[j]-(ybuf[j]*slope+zero)) > MAXDEV) wbuf[j] = 0; 226 if(VERBOSE & VERB_FITPROF) { 227 fprintf(fp, "%9.4f %9.4f %9.4f %3d\n", ybuf[j], zbuf[j], wbuf[j], j); 240 if(j < (y2-secondfitpix) && !up) wbuf[j] = 0; 241 if(j > (y1+secondfitpix) && up) wbuf[j] = 0; 242 if(VERBOSE & VERB_FIT) { 243 printf("trim j : %d %9.4f %9.4f %9.4f %d %9.4f %9.4f\n", j,ybuf[j],zbuf[j],(ybuf[j]*slope+zero),abs(zbuf[j]-(ybuf[j]*slope+zero)), wbuf[j], wbuf0[j]); 228 244 } 229 245 } … … 237 253 238 254 if(VERBOSE & VERB_FITPROF) { 239 printf(" jt %d %.3f %.3f\n", xs, zero, slope);255 printf("2nd fit nfit, zero, slope: %d %.3f %.3f\n", nfit, zero, slope); 240 256 fclose(fp); 241 257 } … … 249 265 linearrms(nfit, ybuf+y1, zbuf+y1, slope, zero, &trial); 250 266 /* 100203 JT: bad idea: appears to be a bug in read/writing ABS(nfit) */ 267 251 268 // if(trial > 2*rms) box->nfit = -box->nfit; 252 269 if(trial > 2*rms) box->func = BURN_POSSLOPE; … … 256 273 } 257 274 258 /* Reconstruct the fit for comparison with the data col by col */ 259 for(j=y1; j<=y2; j++) zbuf[j] = exp(ybuf[j]*slope); 260 /* And tag on the extras to determine the end of the fit */ 261 for(j=yfit; dy*j<dy*(up?y1:y2); j+=dy) { 262 if(fitfunc == BURN_EXP) { 263 zbuf[j] = exp(Y_SCALE*dy*(j-y0)*slope); 275 /* find where the fitted function becomes less than half the rms and cut the trail there*/ 276 for(j=(up?y1:y2); dy*j<dy*(up?y2:y1); j+=dy) { 277 //for(j=y1; j<=y2; j++) { 278 zfun = exp((ybuf[j]*slope)+zero); 279 //printf("y zfun thresh : %d %9.4f %9.4f %9.4f\n",j,zfun,NEGLIGIBLE_TRAIL*rms,NEGLIGIBLE_TRAIL*rms*0.5); 280 if(up) { 281 if(zfun < NEGLIGIBLE_TRAIL*rms*0.5) break; 264 282 } else { 265 if(dy*(j-y0) <= 0) zbuf[j] = exp(log(Y_SCALE*1.0)*slope); 266 else zbuf[j] = exp(log(Y_SCALE*dy*(j-y0))*slope); 267 } 268 } 269 270 /* find where the fitted function becomes less than half the rms and cut the trail there*/ 271 for(j=y1; j<=y2; j++) { 272 zfun = exp((ybuf[j]*slope)+zero); 273 if(zfun > NEGLIGIBLE_TRAIL*rms) break; 283 if(zfun < NEGLIGIBLE_TRAIL*rms) break; 284 } 274 285 } 275 286 //For burns, just let it go to the top 276 if(j < y2 && !up) box->eyfit = j; 277 278 /* Determine good x-ranges and Save the fit information */ 279 box->slope = slope; 280 box->nfit = 0; 281 /* Save individual scaled versions for each column */ 282 for(i=xs; i<=xe; i++) { 283 zsum = wsum = 0.0; 284 for(j=y1; j<=y2; j++) { 287 //if(j < y2 && !up) box->eyfit = j; 288 box->eyfit = j; 289 290 291 if(!strcmp(camera,"gpc2")) { 292 293 /*Conpute the mean and standard deviation of the trail along x*/ 294 for(i=xs; i<=xe; i++) { 295 xbuf[i] = 0.0; 296 for(j=y1, k=0; j<=y2; j++) { 297 if(wbuf[j] > 0 && data[i+j*NX] != NODATA && 298 (mask[i+j*NX] == MASK_NONE || mask[i+j*NX] == MASK_SAT_HALO)) { 299 xbuf[i] += data[i+j*NX]; 300 k++; 301 } 302 } 303 xbuf[i] = xbuf[i] / MAX(1,k); 304 } 305 306 xsum = wsum = 0.; 307 for(i=xs; i<=xe; i++) { 308 xsum += i*xbuf[i]; 309 wsum += xbuf[i]; 310 } 311 xmean = xsum / wsum; 312 313 xsum = wsum = 0.; 314 for(i=xs; i<=xe; i++) { 315 xsum += xbuf[i]*pow(i-xmean,2); 316 wsum += xbuf[i]; 317 } 318 xstd = sqrt(xsum / (wsum-1.)); 319 if(VERBOSE & VERB_FIT) { 320 printf("x mean xstd : %9.4f %9.4f %9.4f %9.4f\n", xmean, xstd,xsum,wsum); 321 } 322 323 /* Update fit ranges */ 324 if(xstd > 1 && xstd < 50) { 325 box->sxfit = round(xmean-(xstd*1.1)); 326 box->exfit = round(xmean+(xstd*1.1)); 327 } else { 328 box->sxfit = xs; 329 box->exfit = xs - 1; 330 box->fiterr = FIT_ALL_GONE; 331 } 332 } else { 333 /* Reconstruct the fit for comparison with the data col by col */ 334 for(j=y1; j<=y2; j++) zbuf[j] = exp((ybuf[j]*slope)); 335 /* And tag on the extras to determine the end of the fit */ 336 for(j=yfit; dy*j<dy*(up?y1:y2); j+=dy) { 337 if(fitfunc == BURN_EXP) { 338 zbuf[j] = exp((Y_SCALE*dy*(j-y0)*slope)); 339 } else { 340 if(dy*(j-y0) <= 0) zbuf[j] = exp((log(Y_SCALE*1.0)*slope)); 341 else zbuf[j] = exp((log(Y_SCALE*dy*(j-y0))*slope)); 342 } 343 } 344 345 /* Determine good x-ranges and Save the fit information */ 346 box->slope = slope; 347 box->nfit = 0; 348 /* Save individual scaled versions for each column */ 349 for(i=xs; i<=xe; i++) { 350 zsum = wsum = 0.0; 351 for(j=y1; j<=y2; j++) { 285 352 if(wbuf[j] > 0 && data[i+j*NX] != NODATA && 286 353 (mask[i+j*NX] == MASK_NONE || mask[i+j*NX] == MASK_SAT_HALO)) { 287 // if(wbuf[j] > 0 && data[i+j*NX] != NODATA) {288 // wsum += wbuf[j];289 // zsum += wbuf[j] * (data[i+j*NX] - bckgnd) / zbuf[j];290 354 wsum += zbuf[j]; 291 355 zsum += data[i+j*NX] - bckgnd; 292 356 } 293 }294 if(zsum < 0 || wsum <= 0) {357 } 358 if(zsum < 0 || wsum <= 0) { 295 359 zsum = 0.0; 296 } else {360 } else { 297 361 zsum = zsum / wsum; 298 } 299 /* FIXME: what's a really good criterion for negligible fit? */ 300 /* 100 pixels up fit is zsum or ~zsum/e */ 301 // if(zsum > NEGLIGIBLE_TRAIL*rms) { 302 /* 100113: but also evaluate at the end of the fit for stubby trails */ 303 if(zsum > NEGLIGIBLE_TRAIL*rms || 362 } 363 /* FIXME: what's a really good criterion for negligible fit? */ 364 /* 100 pixels up fit is zsum or ~zsum/e */ 365 /* 100113: but also evaluate at the end of the fit for stubby trails */ 366 //printf("scaled fit comparison x zsum zbuf[y2]*zsum thresh: %d %9.4f %9.4f %9.4f %f %d %f\n", i, zsum, zbuf[y2], zbuf[y2]*zsum, NEGLIGIBLE_TRAIL, rms, NEGLIGIBLE_TRAIL*rms); 367 368 if(zsum > NEGLIGIBLE_TRAIL*rms || 304 369 zbuf[y2]*zsum > NEGLIGIBLE_TRAIL*rms) { 305 370 /* Ascertain the starting point of where the fit is good */ … … 314 379 box->zero[box->nfit] = zsum; 315 380 box->xfit[box->nfit] = i; 381 //printf("y comparison : %d %d %9.4f %9.4f %d %d\n", i, box->yfit[box->nfit], box->zero[box->nfit],zsum, box->xfit[box->nfit],box->nfit); 316 382 box->nfit += 1; 317 } 318 } 319 /* Update fit ranges */ 320 if(box->nfit > 0) { 321 box->sxfit = box->xfit[0]; 322 box->exfit = box->xfit[box->nfit-1]; 323 } else { 324 box->sxfit = xs; 325 box->exfit = xs - 1; 326 box->fiterr = FIT_ALL_GONE; 383 } 384 } 385 /* Update fit ranges */ 386 if(box->nfit > 0) { 387 box->sxfit = box->xfit[0]; 388 box->exfit = box->xfit[box->nfit-1]; 389 } else { 390 box->sxfit = xs; 391 box->exfit = xs - 1; 392 box->fiterr = FIT_ALL_GONE; 393 } 394 } 395 396 397 398 if(VERBOSE & VERB_FIT) { 399 printf("Final fit params xsfit,xefit,y1,y2, yfit,slope,nfit = %d %d %d %d %d %.3f %d\n", 400 box->sxfit, box->exfit, y1, y2,box->eyfit, box->slope, box->nfit); 327 401 } 328 402
Note:
See TracChangeset
for help on using the changeset viewer.
