Changeset 25145
- Timestamp:
- Aug 20, 2009, 11:13:44 AM (17 years ago)
- Location:
- branches/czw_branch/cleanup/extsrc/gpcsw/gpcsrc/fits/burntool
- Files:
-
- 5 edited
-
burnfix.c (modified) (7 diffs)
-
burntool.h (modified) (1 diff)
-
burnutils.c (modified) (1 diff)
-
stardetect.c (modified) (2 diffs)
-
trailfit.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/cleanup/extsrc/gpcsw/gpcsrc/fits/burntool/burnfix.c
r24391 r25145 25 25 err = burn_check(nx, ny, NX, NY, imbuf, mbuf, cell); 26 26 27 // fprintf(stderr, "Got through burn_check\n"); 28 27 29 /* Expand the masks; burns asymmetrically, stars symmetrically */ 28 30 // err = grow_mask(nx, ny, NX, mbuf, YMASK_GROW, YMASK_GROW, cell->nstar, cell->star); … … 30 32 err = grow_mask(nx, ny, NX, mbuf, BMASK_GROW, RMASK_GROW, 31 33 MASK_SAT_HALO, cell->nburn, cell->burn); 34 // fprintf(stderr, "Got through grow mask for burns\n"); 32 35 err = grow_mask(nx, ny, NX, mbuf, BMASK_GROW, RMASK_GROW, 33 36 MASK_STAR_HALO, cell->nstar, cell->star); 37 // fprintf(stderr, "Got through grow mask for stars\n"); 34 38 35 39 /* Fix up all the burns */ … … 37 41 if(!cell->burn[k].burned) continue; 38 42 /* Fit the trail */ 43 // fprintf(stderr, "Fitting trail %d\n", k); 39 44 fit_trail(nx, ny, NX, imbuf, mbuf, cell->burn+k, 1, 40 45 cell->sky+cell->bias, cell->rms, BURN_PWR); 41 46 /* Subtract the fit from the image */ 47 // fprintf(stderr, "Subtracting trail %d\n", k); 42 48 if(!cell->burn[k].fiterr) sub_fit(nx, ny, NX, buf, cell->burn+k, 1); 43 49 } … … 218 224 /****************************************************************/ 219 225 /* burn_test() tests whether a box is burned or not */ 226 /* It's trying to balance the flux of above-below to see whether 227 * there's a net burn above. It has to cope with the case that the box is 228 * so low there is no above in which case it compares center-side. 229 * It's somewhat rudimentary as indicated by the FIXME's, and the original 230 * version had some real logical problems. 231 */ 220 232 STATIC int burn_test(int nx, int ny, int NX, DTYPE *data, int rms, 221 233 MTYPE *mask, OBJBOX *box) 222 234 { 235 int i, j, nburn, nref, nmed; 236 int y0, y1, ymid, xburn, xref, dx=0, dy=0; 237 238 /* FIXME: needs a test for flat-toppedness as well as trail... */ 239 /* FIXME: needs a test for pure, massive saturation */ 240 241 /* Center line */ 242 ymid = (box->y0m + box->y0p + box->y1m + box->y1p + 2) / 4; 243 244 /* Irrelevant, too near the top to detect a burn anyway */ 245 if(box->ey > ny-FIT_EDGE-3) { 246 box->diff = -1; 247 box->burned = -1; 248 /* But looks like a bad one which will leave behind persistence */ 249 if(box->ey-box->sy+1 > 4) box->burned = 1; 250 return(0); 251 252 /* Too near the bottom, do a side-side test */ 253 } else if(box->sy < FIT_EDGE+3) { 254 dy = 0; 255 y0 = ymid + MAX(box->ey-ymid, FIT_EDGE); 256 y1 = MIN(y0+100, ny-1); 257 258 if(2*box->ex - box->sx + 1 < nx-1) { /* Work right? */ 259 dx = box->ex - box->sx + 1; 260 261 } else if(2*box->sx - box->ex - 1 > 0) { /* Work left? */ 262 dx = -(box->ex - box->sx + 1); 263 264 } else { /* No room! Oh no! */ 265 box->diff = -1; 266 box->burned = -1; 267 /* But looks like a bad one which will leave behind persistence */ 268 if(box->ey-box->sy+1 > 4) box->burned = 1; 269 return(0); 270 } 271 272 /* Do a top-bottom test for excess flux */ 273 } else { 274 dx = 0; 275 dy = MAX(ymid-box->sy, box->ey-ymid); 276 if(dy < FIT_EDGE) dy = FIT_EDGE; 277 y0 = ymid + dy; 278 y1 = y0 + MIN(ny-1-y0, 2*ymid-y0-1); 279 if(y1-y0 > 100) y1 = y0 + 100; 280 } 281 282 /* Do the test; get the median of the averages across x */ 283 nmed = 0; 284 for(j=y0; j<y1; j++) { 285 xburn = xref = 0; 286 nburn = nref = 0; 287 for(i=box->sx; i<=box->ex; i++) { 288 if(mask[i+j*NX] == MASK_NONE) { 289 xburn += data[i+j*NX]; 290 nburn++; 291 } 292 if(dx != 0) { /* Side to side */ 293 if(mask[i+dx+j*NX] == MASK_NONE) { 294 xref += data[i+dx+j*NX]; 295 nref++; 296 } 297 } else { /* top-bottom */ 298 if(mask[i+(2*ymid-j)*NX] == MASK_NONE) { 299 xref += data[i+(2*ymid-j)*NX]; 300 nref++; 301 } 302 } 303 } 304 if(nburn > 0) xburn /= nburn; 305 if(nref > 0) xref /= nref; 306 if(nref > 0 && nburn > 0) median_buf[nmed++] = xburn - xref; 307 } 308 box->diff = int_median(nmed, median_buf); 309 box->burned = (box->diff > 0.3*rms); 310 return(0); 311 } 312 313 #ifdef ORIG_BURN_TEST 314 // This has a lot of problems -- chief among which is what happens with 315 // a huge kite-shaped bad region. It's fundamentally trying to balance 316 // the flux of above-below to see whether there's a net burn above. But 317 // it has to cope with the case that the box is so low there is no above 318 // in which case it compares center-side. 319 /****************************************************************/ 320 /* burn_test() tests whether a box is burned or not */ 321 STATIC int burn_test(int nx, int ny, int NX, DTYPE *data, int rms, 322 MTYPE *mask, OBJBOX *box) 323 { 223 324 int i, j, n, nrow, nmed; 224 325 int y0, y1, ymid, xsum, dx=0; … … 229 330 /* Center line */ 230 331 ymid = (box->y0m + box->y0p + box->y1m + box->y1p + 2) / 4; 332 231 333 /* Starting point offset */ 232 334 y0 = MAX(ymid-box->sy, box->ey-ymid); … … 259 361 nrow = 0; 260 362 for(i=box->sx; i<=box->ex; i++) { 363 // IS THIS THE PROBLEM? 261 364 xsum += data[i+(ymid+y0+j)*NX]*(mask[i+(ymid+y0+j)*NX] == MASK_NONE); 262 365 if(y1 < ny) { … … 279 382 return(0); 280 383 } 384 #endif -
branches/czw_branch/cleanup/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.h
r24391 r25145 97 97 #define FIT_TOP_ERROR 2 /* Saturation extends to top: no points */ 98 98 #define FIT_SLOPE_ERROR 3 /* Unreasonable fit */ 99 #define FIT_ALL_GONE 4 /* No column survived as significant */ 99 100 #define FIT_EXPIRED 9 /* Don't carry any more as persistent */ 100 101 -
branches/czw_branch/cleanup/extsrc/gpcsw/gpcsrc/fits/burntool/burnutils.c
r23490 r25145 115 115 if(VERBOSE & VERB_BOXGROW) { 116 116 printf("box: %d %d %d %d\n", box->sx, box->sy, box->ex, box->ey); 117 fflush(stdout); 117 118 } 118 119 -
branches/czw_branch/cleanup/extsrc/gpcsw/gpcsrc/fits/burntool/stardetect.c
r23490 r25145 98 98 boxbuf[nbox].ex, boxbuf[nbox].ey, 99 99 boxbuf[nbox].max); 100 fflush(stdout); 100 101 } 101 102 /* Mark the veto mask so as not to trigger on this one again */ … … 139 140 printf(" %d %d %d %d\n", 140 141 boxbuf[nbox].y0m, boxbuf[nbox].y0p,boxbuf[nbox].y1m, boxbuf[nbox].y1p); 142 fflush(stdout); 141 143 } 142 144 xon = -1; -
branches/czw_branch/cleanup/extsrc/gpcsw/gpcsrc/fits/burntool/trailfit.c
r23924 r25145 283 283 } 284 284 /* Update fit ranges */ 285 box->sxfit = box->xfit[0]; 286 box->exfit = box->xfit[box->nfit-1]; 287 285 if(box->nfit > 0) { 286 box->sxfit = box->xfit[0]; 287 box->exfit = box->xfit[box->nfit-1]; 288 } else { 289 box->sxfit = xs; 290 box->exfit = xs - 1; 291 box->fiterr = FIT_ALL_GONE; 292 } 293 // if(box->nfit <= 0) fprintf(stderr, "WHOA, got nfit = 0\n"); 288 294 return(0); 289 295 }
Note:
See TracChangeset
for help on using the changeset viewer.
