- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
extsrc/gpcsw/gpcsrc/fits/burntool/burnfix.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/extsrc/gpcsw/gpcsrc/fits/burntool/burnfix.c
r24391 r27840 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 } … … 103 109 /* Restore all the burns */ 104 110 for(k=0; k<cell->npersist; k++) { 105 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) ) { 106 114 sub_fit(nx, ny, NX, buf, &(cell->persist[k]), -1); 115 } 107 116 } 108 117 return(0); … … 118 127 /* Restore all the burns */ 119 128 for(k=0; k<cell->npersist; k++) { 120 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) ) { 121 132 sub_fit(nx, ny, NX, buf, &(cell->persist[k]), +1); 133 } 122 134 } 123 135 return(0); … … 218 230 /****************************************************************/ 219 231 /* burn_test() tests whether a box is burned or not */ 232 /* It's trying to balance the flux of above-below to see whether 233 * there's a net burn above. It has to cope with the case that the box is 234 * so low there is no above in which case it compares center-side. 235 * It's somewhat rudimentary as indicated by the FIXME's, and the original 236 * version had some real logical problems. 237 */ 220 238 STATIC int burn_test(int nx, int ny, int NX, DTYPE *data, int rms, 221 239 MTYPE *mask, OBJBOX *box) 222 240 { 241 int i, j, nburn, nref, nmed; 242 int y0, y1, ymid, xburn, xref, dx=0, dy=0; 243 244 /* FIXME: needs a test for flat-toppedness as well as trail... */ 245 /* FIXME: needs a test for pure, massive saturation */ 246 247 /* Center line */ 248 ymid = (box->y0m + box->y0p + box->y1m + box->y1p + 2) / 4; 249 250 /* Irrelevant, too near the top to detect a burn anyway */ 251 if(box->ey > ny-FIT_EDGE-3) { 252 box->diff = -1; 253 box->burned = -1; 254 /* But looks like a bad one which will leave behind persistence */ 255 if(box->ey-box->sy+1 > 4) box->burned = 1; 256 return(0); 257 258 /* Too near the bottom, do a side-side test */ 259 } else if(box->sy < FIT_EDGE+3) { 260 dy = 0; 261 y0 = ymid + MAX(box->ey-ymid, FIT_EDGE); 262 y1 = MIN(y0+100, ny-1); 263 264 if(2*box->ex - box->sx + 1 < nx-1) { /* Work right? */ 265 dx = box->ex - box->sx + 1; 266 267 } else if(2*box->sx - box->ex - 1 > 0) { /* Work left? */ 268 dx = -(box->ex - box->sx + 1); 269 270 } else { /* No room! Oh no! */ 271 box->diff = -1; 272 box->burned = -1; 273 /* But looks like a bad one which will leave behind persistence */ 274 if(box->ey-box->sy+1 > 4) box->burned = 1; 275 return(0); 276 } 277 278 /* Do a top-bottom test for excess flux */ 279 } else { 280 dx = 0; 281 dy = MAX(ymid-box->sy, box->ey-ymid); 282 if(dy < FIT_EDGE) dy = FIT_EDGE; 283 y0 = ymid + dy; 284 y1 = y0 + MIN(ny-1-y0, 2*ymid-y0-1); 285 if(y1-y0 > 100) y1 = y0 + 100; 286 } 287 288 /* Do the test; get the median of the averages across x */ 289 nmed = 0; 290 for(j=y0; j<y1; j++) { 291 xburn = xref = 0; 292 nburn = nref = 0; 293 for(i=box->sx; i<=box->ex; i++) { 294 if(mask[i+j*NX] == MASK_NONE) { 295 xburn += data[i+j*NX]; 296 nburn++; 297 } 298 if(dx != 0) { /* Side to side */ 299 if(mask[i+dx+j*NX] == MASK_NONE) { 300 xref += data[i+dx+j*NX]; 301 nref++; 302 } 303 } else { /* top-bottom */ 304 if(mask[i+(2*ymid-j)*NX] == MASK_NONE) { 305 xref += data[i+(2*ymid-j)*NX]; 306 nref++; 307 } 308 } 309 } 310 if(nburn > 0) xburn /= nburn; 311 if(nref > 0) xref /= nref; 312 if(nref > 0 && nburn > 0) median_buf[nmed++] = xburn - xref; 313 } 314 box->diff = int_median(nmed, median_buf); 315 box->burned = (box->diff > 0.3*rms); 316 return(0); 317 } 318 319 #ifdef ORIG_BURN_TEST 320 // This has a lot of problems -- chief among which is what happens with 321 // a huge kite-shaped bad region. It's fundamentally trying to balance 322 // the flux of above-below to see whether there's a net burn above. But 323 // it has to cope with the case that the box is so low there is no above 324 // in which case it compares center-side. 325 /****************************************************************/ 326 /* burn_test() tests whether a box is burned or not */ 327 STATIC int burn_test(int nx, int ny, int NX, DTYPE *data, int rms, 328 MTYPE *mask, OBJBOX *box) 329 { 223 330 int i, j, n, nrow, nmed; 224 331 int y0, y1, ymid, xsum, dx=0; … … 229 336 /* Center line */ 230 337 ymid = (box->y0m + box->y0p + box->y1m + box->y1p + 2) / 4; 338 231 339 /* Starting point offset */ 232 340 y0 = MAX(ymid-box->sy, box->ey-ymid); … … 259 367 nrow = 0; 260 368 for(i=box->sx; i<=box->ex; i++) { 369 // IS THIS THE PROBLEM? 261 370 xsum += data[i+(ymid+y0+j)*NX]*(mask[i+(ymid+y0+j)*NX] == MASK_NONE); 262 371 if(y1 < ny) { … … 279 388 return(0); 280 389 } 390 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
