IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25145


Ignore:
Timestamp:
Aug 20, 2009, 11:13:44 AM (17 years ago)
Author:
watersc1
Message:
 
Location:
branches/czw_branch/cleanup/extsrc/gpcsw/gpcsrc/fits/burntool
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/cleanup/extsrc/gpcsw/gpcsrc/fits/burntool/burnfix.c

    r24391 r25145  
    2525   err = burn_check(nx, ny, NX, NY, imbuf, mbuf, cell);
    2626
     27//   fprintf(stderr, "Got through burn_check\n");
     28
    2729/* Expand the masks; burns asymmetrically, stars symmetrically */
    2830//   err = grow_mask(nx, ny, NX, mbuf, YMASK_GROW, YMASK_GROW, cell->nstar, cell->star);
     
    3032   err = grow_mask(nx, ny, NX, mbuf, BMASK_GROW, RMASK_GROW,
    3133                   MASK_SAT_HALO, cell->nburn, cell->burn);
     34//   fprintf(stderr, "Got through grow mask for burns\n");
    3235   err = grow_mask(nx, ny, NX, mbuf, BMASK_GROW, RMASK_GROW,
    3336                   MASK_STAR_HALO, cell->nstar, cell->star);
     37//   fprintf(stderr, "Got through grow mask for stars\n");
    3438
    3539/* Fix up all the burns */
     
    3741      if(!cell->burn[k].burned) continue;
    3842/* Fit the trail */
     43//      fprintf(stderr, "Fitting trail %d\n", k);
    3944      fit_trail(nx, ny, NX, imbuf, mbuf, cell->burn+k, 1,
    4045             cell->sky+cell->bias, cell->rms, BURN_PWR);
    4146/* Subtract the fit from the image */
     47//      fprintf(stderr, "Subtracting trail %d\n", k);
    4248      if(!cell->burn[k].fiterr) sub_fit(nx, ny, NX, buf, cell->burn+k, 1);
    4349   }
     
    218224/****************************************************************/
    219225/* 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 */
    220232STATIC int burn_test(int nx, int ny, int NX, DTYPE *data, int rms,
    221233                       MTYPE *mask, OBJBOX *box)
    222234{
     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 */
     321STATIC int burn_test(int nx, int ny, int NX, DTYPE *data, int rms,
     322                       MTYPE *mask, OBJBOX *box)
     323{
    223324   int i, j, n, nrow, nmed;
    224325   int y0, y1, ymid, xsum, dx=0;
     
    229330/* Center line */
    230331   ymid = (box->y0m + box->y0p + box->y1m + box->y1p + 2) / 4;
     332
    231333/* Starting point offset */
    232334   y0 = MAX(ymid-box->sy, box->ey-ymid);
     
    259361      nrow = 0;
    260362      for(i=box->sx; i<=box->ex; i++) {
     363// IS THIS THE PROBLEM?
    261364         xsum += data[i+(ymid+y0+j)*NX]*(mask[i+(ymid+y0+j)*NX] == MASK_NONE);
    262365         if(y1 < ny) {
     
    279382   return(0);
    280383}
     384#endif
  • branches/czw_branch/cleanup/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.h

    r24391 r25145  
    9797#define FIT_TOP_ERROR  2        /* Saturation extends to top: no points */
    9898#define FIT_SLOPE_ERROR  3      /* Unreasonable fit */
     99#define FIT_ALL_GONE  4         /* No column survived as significant */
    99100#define FIT_EXPIRED 9           /* Don't carry any more as persistent */
    100101
  • branches/czw_branch/cleanup/extsrc/gpcsw/gpcsrc/fits/burntool/burnutils.c

    r23490 r25145  
    115115   if(VERBOSE & VERB_BOXGROW) {
    116116      printf("box: %d %d %d %d\n", box->sx, box->sy, box->ex, box->ey);
     117      fflush(stdout);
    117118   }
    118119
  • branches/czw_branch/cleanup/extsrc/gpcsw/gpcsrc/fits/burntool/stardetect.c

    r23490 r25145  
    9898                         boxbuf[nbox].ex, boxbuf[nbox].ey,
    9999                         boxbuf[nbox].max);
     100                  fflush(stdout);
    100101               }
    101102/* Mark the veto mask so as not to trigger on this one again */
     
    139140               printf("   %d %d %d %d\n",
    140141                      boxbuf[nbox].y0m, boxbuf[nbox].y0p,boxbuf[nbox].y1m, boxbuf[nbox].y1p);
     142               fflush(stdout);
    141143            }
    142144            xon = -1;
  • branches/czw_branch/cleanup/extsrc/gpcsw/gpcsrc/fits/burntool/trailfit.c

    r23924 r25145  
    283283   }
    284284/* 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");
    288294   return(0);
    289295}
Note: See TracChangeset for help on using the changeset viewer.