IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26767


Ignore:
Timestamp:
Feb 3, 2010, 1:00:34 PM (17 years ago)
Author:
watersc1
Message:

New burntool, with trails retained even if they had a poor slope.

Location:
branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/burnfix.c

    r26764 r26767  
    7272      ymid = (cell->burn[k].y0m + cell->burn[k].y1m +
    7373              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;
    7575      printf("%3d %5d %3d %5d %5d %3d %5d %3d %5d %5d %2d %1d %1d %6.3f %8d\n",
    7676             k,
    … …  
    109109/* Restore all the burns */
    110110   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) ) {
    112114         sub_fit(nx, ny, NX, buf, &(cell->persist[k]), -1);
     115      }
    113116   }
    114117   return(0);
    … …  
    124127/* Restore all the burns */
    125128   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) ) {
    127132         sub_fit(nx, ny, NX, buf, &(cell->persist[k]), +1);
     133      }
    128134   }
    129135   return(0);
  • branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.c

    r26764 r26767  
    364364/* Read the persistence data for this OTA */
    365365   if(persistfile != NULL) {                    /* Text data file */
    366       if(persist_read(OTA, persistfile)) exit(-317);
     366      if(persist_read(OTA, persistfile, apply)) exit(-317);
    367367   } 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)
    369369         exit(-318);
    370370   }
    … …  
    770770   printf(" restore={t|f}  Restore the input MEF by adding input fits?\n");
    771771   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");
    773773   printf(" in=fname       Input file for previous burn persistence streaks\n");
    774774   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  
    9191#define BURN_EXP  2             /* Exponential */
    9292#define BURN_BLASTED 3          /* Blasted top to bottom: flag only for IPP */
     93#define BURN_POSSLOPE 4         /* Positive slope fit (bad) but significant */
    9394#define PSF_STAR  9             /* Unfitted: good psf star */
    9495
    … …  
    175176STATIC int burn_restore(int nx, int ny, int NX, IMTYPE *buf, CELL *cell);
    176177STATIC int burn_apply(int nx, int ny, int NX, IMTYPE *buf, CELL *cell);
    177 STATIC int persist_read(CELL *cell, const char *infile);
     178STATIC int persist_read(CELL *cell, const char *infile, int apply);
    178179STATIC int persist_write(CELL *cell, const char *outfile);
    179180STATIC int persist_fix(int nx, int ny, int stride, IMTYPE *buf, CELL *cell);
    180181STATIC 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);
    181186
    182187STATIC 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  
    6161        until they finally achieve a legal fit with negligible amplitude.
    6262        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.
    6466
    6567        Burntool also identifies really blasted areas which are saturated from
    … …  
    229231
    230232        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,
    232234                only write the fit data as a FITS and/or text table (default f)
    233235
  • branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/persist_fits.c

    r26764 r26767  
    5252   AREA_TABLE_COL_SXFIT,
    5353   AREA_TABLE_COL_EXFIT,
     54   AREA_TABLE_COL_FITERR,
    5455   
    5556   /* Add new columns above this line. */
    … …  
    8687   { "sxfit", "Starting column for fit",              "pixels",  FH_TABLE_FORMAT_INT,    3,     0 },
    8788   { "exfit", "Ending column for fit",                "pixels",  FH_TABLE_FORMAT_INT,    3,     0 },
     89   { "fiterr", "Error code of fit",                "",  FH_TABLE_FORMAT_INT,    3,     0 },
    8890};
    8991
    … …  
    237239         }
    238240         num_areas++;
    239          num_fits += ABS(cell[j].persist[k].nfit);
     241         num_fits += cell[j].persist[k].nfit;
    240242      }
    241243
    … …  
    257259         }
    258260         num_areas++;
    259          num_fits += ABS(cell[j].burn[k].nfit);
     261         num_fits += cell[j].burn[k].nfit;
    260262      }
    261263   }
    … …  
    310312      (fh_table_write_value(table, data, row, AREA_TABLE_COL_NFIT,  &(area->nfit))  != FH_SUCCESS) ||
    311313      (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))
    313316   {
    314317      fprintf(stderr, "\rerror: Error writing data to row %d of area table.\n", row);
    … …  
    480483            if(cell[j].persist[k].fiterr) continue;
    481484         }
    482          for(i=0; i<ABS(cell[j].persist[k].nfit); i++)
     485         for(i=0; i<cell[j].persist[k].nfit; i++)
    483486         {
    484487            result = write_fit_row(hu, data, table, row++,
    … …  
    505508         }
    506509
    507          for(i=0; i<ABS(cell[j].burn[k].nfit); i++)
     510         for(i=0; i<cell[j].burn[k].nfit; i++)
    508511         {
    509512            result = write_fit_row(hu, data, table, row++,
    … …  
    538541 */
    539542static fh_result
    540 read_area(fhTable * table, void * data, int row)
     543read_area(fhTable * table, void * data, int row, int apply)
    541544{
    542545   int cell_num;
    … …  
    585588      (fh_table_read_value(table, data, row, AREA_TABLE_COL_NFIT,  &(boxbuf[row].nfit)) != FH_SUCCESS) ||
    586589      (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))
    588592   {
    589593      fprintf(stderr,
    … …  
    595599   
    596600   /* Make space for fits (to be read later). */
    597    if(ABS(boxbuf[row].nfit) > 0)
     601   if(boxbuf[row].nfit > 0)
    598602   {
    599603      /* This shouldn't happen, but be nice and don't leak. */
    … …  
    602606      if(boxbuf[row].yfit) free(boxbuf[row].yfit);
    603607
    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));
    607611
    608612      if(boxbuf[row].zero == NULL ||
    … …  
    612616         exit(-671);
    613617      }
    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;
    615620   }
    616621
    … …  
    635640 */
    636641static fh_result
    637 read_area_table(HeaderUnit hu, fhTable * table)
     642read_area_table(HeaderUnit hu, fhTable * table, int apply)
    638643{
    639644   fh_result result = FH_INVALID;
    … …  
    688693   for(i = 0; i < num_rows; i++)
    689694   {
    690       if((result = read_area(table, data, i)) != FH_SUCCESS) break;
     695      if((result = read_area(table, data, i, apply)) != FH_SUCCESS) break;
    691696   }
    692697
    … …  
    840845   for(area = 0; area < num_areas; area++)
    841846   {
    842       for(i = 0; i < ABS(boxbuf[area].nfit); i++)
     847      for(i = 0; i < boxbuf[area].nfit; i++)
    843848      {
    844849         if((result = read_fit(hu, table, data, fit_table_row,
    … …  
    901906 */
    902907fh_result
    903 persist_fits_read(CELL *cell, const char * filename)
     908persist_fits_read(CELL *cell, const char * filename, int apply)
    904909{
    905910   HeaderUnit phu;
    … …  
    938943
    939944   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)
    941946   {
    942947      free(area_table.strbuf);
  • branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/persist_fits.h

    r23924 r26767  
    2424
    2525fh_result
    26 persist_fits_read(CELL *cell, const char * filename);
     26persist_fits_read(CELL *cell, const char * filename, int apply);
    2727
    2828fh_result
  • branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/persistfix.c

    r23924 r26767  
    3434         }
    3535         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... */
    3641      }
    3742
  • branches/eam_branches/20091201/extsrc/gpcsw/gpcsrc/fits/burntool/persistio.c

    r26764 r26767  
    1616/****************************************************************/
    1717/* persist_read(): Read all the persistence trails from a file */
    18 STATIC int persist_read(CELL *cell, const char *infile)
     18STATIC int persist_read(CELL *cell, const char *infile, int apply)
    1919{
    2020   int i, k, nbox=0;
    … …  
    3838   while(fgets(line, 1024, fp) != NULL) {
    3939      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",
    4141             &boxbuf[nbox].cell, &boxbuf[nbox].time,
    4242             &boxbuf[nbox].cx, &boxbuf[nbox].cy,
    … …  
    5050             &boxbuf[nbox].func, &boxbuf[nbox].up,
    5151             &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));
    5758         if(boxbuf[nbox].zero == NULL ||
    5859            boxbuf[nbox].xfit == NULL ||
    … …  
    6263         }
    6364
    64          for(i=0; i<ABS(boxbuf[nbox].nfit); i++) {
     65         for(i=0; i<boxbuf[nbox].nfit; i++) {
    6566            if(fgets(line, 1024, fp) == NULL) {
    6667               fprintf(stderr, "\rerror: short read of burn lines\n");
    … …  
    7172         }
    7273      }
    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;
    7476/* Augment counts */
    7577      k = boxbuf[nbox].cell;
    … …  
    159161         k = boxid[kp];
    160162         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];
    162164         for(jp=kp+1; jp<n; jp++) {
    163165            j = boxid[jp];
    164166            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];
    166168            if(ABS(yctr[jp]-yctr[kp]) > DIFFERENT_STREAK) {
    167169/* Trim back the feebler streak */
    … …  
    266268            if(cell[j].persist[k].nfit <= 0) continue;
    267269         }
    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",
    269271                 j, cell[j].persist[k].time,
    270272                 cell[j].persist[k].cx, cell[j].persist[k].cy,
    … …  
    278280                 cell[j].persist[k].func, cell[j].persist[k].up,
    279281                 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++) {
    282285            fprintf(fp, "%3d %3d %8.4f\n", cell[j].persist[k].xfit[i],
    283286                    cell[j].persist[k].yfit[i], cell[j].persist[k].zero[i]);
    … …  
    302305
    303306         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",
    305308                 j, cell[j].burn[k].time,
    306309                 cell[j].burn[k].cx, cell[j].burn[k].cy,
    … …  
    314317                 cell[j].burn[k].func, cell[j].burn[k].up,
    315318                 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++) {
    318322            fprintf(fp, "%3d %3d %8.4f\n", cell[j].burn[k].xfit[i],
    319323                    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  
    3030
    3131   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);
    3334      return(-1);
    3435   }
    … …  
    230231/* FIXME: sanity check fits */
    231232   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 */
    235237      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;
    240241      return(-1);
    241242   }
Note: See TracChangeset for help on using the changeset viewer.