IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42395 for trunk/ppImage


Ignore:
Timestamp:
Feb 14, 2023, 12:59:09 PM (3 years ago)
Author:
tdeboer
Message:

burntool running updates

Location:
trunk/ppImage/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppImage/src/burntool.h

    r35685 r42395  
    7070#define STAR_RADIUS  4          /* Radius over which a star ctr must be max */
    7171#define SKY_MARG 3              /* Horiz offset from burn area for sky */
    72 #define FIT_EDGE 10             /* How far beyond saturation to start fit? */
     72#define FIT_EDGE 5              /* How far beyond saturation to start fit? */
    7373#define Y_SCALE 0.01            /* Scale factor for y in fits */
    7474
     
    102102
    103103/* Fit parameters */
    104 #define FIT_MIN_SLOPE  -5.0     /* minimum slope which is a credible fit */
     104#define FIT_MIN_SLOPE -10.0     /* minimum slope which is a credible fit */
    105105#define FIT_MAX_SLOPE   0.0     /* maximum slope which is a credible fit */
    106106
     
    144144      int sxfit;        /* starting column for fits */
    145145      int exfit;        /* ending column for fits */
     146      int eyfit;        /* y-coord ending column for fits */
    146147      int nfit;         /* how many columns were corrected? */
    147148      IMTYPE *stamp;    /* postage stamp of this object */
     
    176177STATIC int burn_restore(int nx, int ny, int NX, IMTYPE *buf, CELL *cell);
    177178STATIC int burn_apply(int nx, int ny, int NX, IMTYPE *buf, CELL *cell);
    178 STATIC int persist_read(CELL *cell, const char *infile, int apply);
    179 STATIC int persist_write(CELL *cell, const char *outfile);
     179STATIC int persist_read(CELL *cell, const char *infile, int apply, int oldfile);
     180STATIC int persist_write(CELL *cell, const char *outfile, int oldfile);
    180181STATIC int persist_fix(int nx, int ny, int stride, IMTYPE *buf, CELL *cell);
    181182STATIC int persist_merge(CELL *cell);
  • trunk/ppImage/src/ppImageBurntoolApply.c

    r35685 r42395  
    4949    psF32 satVal = psMetadataLookupF32(NULL, readout->parent->concepts, "CELL.SATURATION");
    5050
     51    /* The new burntool tables and method coming into play in 2022 has a slightly different format (an extra column). Need to differentiate */
     52    psS16 BURNTOOL_STATE_GOOD = psMetadataLookupS16(NULL, config->camera, "BURNTOOL.STATE.GOOD");
     53
    5154    for (int p = 0; p < burntoolData->npersist; p++) {
    5255        OBJBOX *box = &(burntoolData->persist[p]);
     
    6164
    6265        y0 = box->y0;
    63         y1 = (box->up) ? ny-1 : 0;
    64         dy = (y0<y1) ? +1 : -1;
    65         if(box->up) {
    66             ys = box->sy;
     66        if (BURNTOOL_STATE_GOOD >= 15) {
     67          y1 = box->eyfit;
    6768        } else {
    68             ys = box->ey;
     69          y1 = (box->up) ? ny-1 : 0;
     70        }
     71        dy = (box->up) ? +1 : -1;
     72        if (BURNTOOL_STATE_GOOD >= 15) {
     73          ys = (box->up) ? box->sy : box->y0;
     74        } else {
     75          ys = (box->up) ? box->y1m : box->y1p;
    6976        }
    7077
     
    9198        for(k=0; k<box->nfit; k++) {
    9299            i = box->xfit[k];
    93             for(j=box->yfit[k]; dy*j<=dy*y1; j+=dy) {
     100            for(j=ys; dy*j<=dy*y1; j+=dy) {
    94101                psF32 inputPixel = image->data.F32[j][i];
    95102                if (false && inputPixel >= satVal) {
     
    150157            return NULL;
    151158        }
    152         if (persist_read(OTA, burntoolFileName, 1)) {
     159
     160        /* The new burntool tables and method coming into play in 2022 has a slightly different format (an extra column). Need to differentiate */
     161        psS16 BURNTOOL_STATE_GOOD = psMetadataLookupS16(NULL, config->camera, "BURNTOOL.STATE.GOOD");
     162        int oldfile = 1;
     163        if (BURNTOOL_STATE_GOOD >= 15) oldfile = 0;
     164
     165        if (persist_read(OTA, burntoolFileName, 1,oldfile)) {
    153166            psError(PS_ERR_UNKNOWN, "true", "failed to read burntool file");
    154167            return NULL;
     
    174187  /* Set the maskValue from the recipes. */
    175188  psImageMaskType maskValue = options->burntoolMask;
     189
     190  /* The new burntool tables and method coming into play in 2022 has a slightly different format (an extra column). Need to differentiate */
     191  psS16 BURNTOOL_STATE_GOOD = psMetadataLookupS16(NULL, config->camera, "BURNTOOL.STATE.GOOD");
    176192
    177193  burntool_cell = (view->cell % 8) * 8 + (view->cell - (view->cell % 8)) / 8;
     
    206222                  );
    207223#endif
     224
     225
     226        /* do separate masking strategy for old (14 and lower) and new burntool tables*/
     227        if (BURNTOOL_STATE_GOOD >= 15) {
     228         printf("DET: New burntool style %d\n",BURNTOOL_STATE_GOOD);
    208229          for (int i = box->sxfit; i<= box->exfit; i++) {
    209 
     230              if (box->up == 0) {
     231                  for (int j = box->eyfit; j <= box->y0; j++) {
     232                    #if PPIMAGE_BURNTOOL_DEBUG
     233                    psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n",
     234                         i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue);
     235                    #endif
     236                      image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue;
     237                  }
     238              } else {
     239                  for (int j = box->sy; j < box->eyfit ; j++) {
     240                    #if PPIMAGE_BURNTOOL_DEBUG
     241                      psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n",
     242                       i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue);
     243                    #endif
     244                      image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue;
     245                  }
     246              }
     247          }
     248
     249        } else {
     250         printf("DET: Old burntool style %d\n",BURNTOOL_STATE_GOOD);
     251          for (int i = box->sxfit; i<= box->exfit; i++) {
    210252              if (box->up == 0) {
    211253                  for (int j = 0; j <= box->y1p; j++) {
    212 #if PPIMAGE_BURNTOOL_DEBUG
     254                    #if PPIMAGE_BURNTOOL_DEBUG
    213255                    psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n",
    214256                         i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue);
    215 #endif
     257                    #endif
    216258                      image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue;
    217259                  }
    218260              } else {
    219261                  for (int j = box->y1m; j < image->numRows ; j++) {
    220 #if PPIMAGE_BURNTOOL_DEBUG
     262                    #if PPIMAGE_BURNTOOL_DEBUG
    221263                      psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n",
    222264                       i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue);
    223 #endif
     265                    #endif
    224266                      image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue;
    225                  }
    226              }
    227          }
     267                  }
     268              }
     269          }
     270        }
     271
     272
    228273      }
    229274  }
     
    235280/****************************************************************/
    236281/* persist_read(): Read all the persistence trails from a file */
    237 STATIC int persist_read(CELL *cell, const char *infile, int apply)
     282STATIC int persist_read(CELL *cell, const char *infile, int apply, int oldfile)
    238283{
    239284   int i, k, nbox=0;
     
    257302   while(fgets(line, 1024, fp) != NULL) {
    258303      if(line[0] == '#') continue;
    259       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",
     304
     305      /* read-in of new burntool tables (including the eyfit column)*/
     306      if(!oldfile) {
     307        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 %d",
     308             &boxbuf[nbox].cell, &boxbuf[nbox].time,
     309             &boxbuf[nbox].cx, &boxbuf[nbox].cy,
     310             &boxbuf[nbox].max, &boxbuf[nbox].y0,
     311             &boxbuf[nbox].sx, &boxbuf[nbox].sy,
     312             &boxbuf[nbox].ex, &boxbuf[nbox].ey,
     313             &boxbuf[nbox].y0m, &boxbuf[nbox].y0p,
     314             &boxbuf[nbox].y1m, &boxbuf[nbox].y1p,
     315             &boxbuf[nbox].x0m, &boxbuf[nbox].x0p,
     316             &boxbuf[nbox].x1m, &boxbuf[nbox].x1p,
     317             &boxbuf[nbox].func, &boxbuf[nbox].up,
     318             &boxbuf[nbox].slope, &boxbuf[nbox].nfit,
     319             &boxbuf[nbox].sxfit, &boxbuf[nbox].exfit,
     320             &boxbuf[nbox].fiterr,&boxbuf[nbox].eyfit);
     321
     322      } else {
     323        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",
    260324             &boxbuf[nbox].cell, &boxbuf[nbox].time,
    261325             &boxbuf[nbox].cx, &boxbuf[nbox].cy,
     
    271335             &boxbuf[nbox].sxfit, &boxbuf[nbox].exfit,
    272336             &boxbuf[nbox].fiterr);
     337      }
     338
    273339      if(boxbuf[nbox].nfit > 0) {
    274340         boxbuf[nbox].zero = (double *)calloc(boxbuf[nbox].nfit, sizeof(double));
     
    431497               box[j].sxfit = MIN(box[j].sxfit, box[k].sxfit);
    432498               box[j].exfit = MAX(box[j].exfit, box[k].exfit);
     499               box[j].eyfit = MIN(box[j].eyfit, box[k].eyfit);
    433500
    434501               box[k].exfit = box[k].sxfit - 1;
     
    459526/****************************************************************/
    460527/* persist_write(): Write all the persistence data for the next image */
    461 STATIC int persist_write(CELL *cell, const char *outfile)
     528STATIC int persist_write(CELL *cell, const char *outfile, int oldfile)
    462529{
    463530   int i, k, j, err=0;
     
    474541   fprintf(fp,  "# Cell: %d  sky= %d   rms= %d   bias= %d\n",
    475542           cell[0].cell, cell[0].sky, cell[0].rms, cell[0].bias);
    476    fprintf(fp, "#Cell time    cx  cy  max   y0   sx  sy   ex  ey  y0m y0p y1m y1p x0m x0p x1m x1p F up    slope nfit sxf exf\n");
     543
     544   /*write new burntool tables (including the eyfit column)*/
     545   if(!oldfile) {
     546     fprintf(fp, "#Cell time    cx  cy  max   y0   sx  sy   ex  ey  y0m y0p y1m y1p x0m x0p x1m x1p F up    slope nfit sxf exf fiterr eyf\n");
     547   } else {
     548     fprintf(fp, "#Cell time    cx  cy  max   y0   sx  sy   ex  ey  y0m y0p y1m y1p x0m x0p x1m x1p F up    slope nfit sxf exf fiterr\n");
     549   }
    477550
    478551   for(j=0; j<MAXCELL; j++) {
     
    494567            if(cell[j].persist[k].nfit <= 0) continue;
    495568         }
    496          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",
     569 
     570         /*write new burntool tables (including the eyfit column)*/
     571         if(!oldfile) {
     572           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 %3d\n",
     573                 j, cell[j].persist[k].time,
     574                 cell[j].persist[k].cx, cell[j].persist[k].cy,
     575                 cell[j].persist[k].max, cell[j].persist[k].y0,
     576                 cell[j].persist[k].sx, cell[j].persist[k].sy,
     577                 cell[j].persist[k].ex, cell[j].persist[k].ey,
     578                 cell[j].persist[k].y0m, cell[j].persist[k].y0p,
     579                 cell[j].persist[k].y1m, cell[j].persist[k].y1p,
     580                 cell[j].persist[k].x0m, cell[j].persist[k].x0p,
     581                 cell[j].persist[k].x1m, cell[j].persist[k].x1p,
     582                 cell[j].persist[k].func, cell[j].persist[k].up,
     583                 cell[j].persist[k].slope, cell[j].persist[k].nfit,
     584                 cell[j].persist[k].sxfit, cell[j].persist[k].exfit,
     585                 cell[j].persist[k].fiterr, cell[j].persist[k].eyfit);
     586         } else {
     587           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",
    497588                 j, cell[j].persist[k].time,
    498589                 cell[j].persist[k].cx, cell[j].persist[k].cy,
     
    508599                 cell[j].persist[k].sxfit, cell[j].persist[k].exfit,
    509600                 cell[j].persist[k].fiterr);
     601         }
     602
    510603         for(i=0; i<cell[j].persist[k].nfit; i++) {
    511604            fprintf(fp, "%3d %3d %8.4f\n", cell[j].persist[k].xfit[i],
     
    531624
    532625         i = (cell[j].burn[k].ex - cell[j].burn[k].sx + 1) / 2;
    533          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",
     626
     627         if(!oldfile) {
     628           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 %3d\n",
     629                 j, cell[j].burn[k].time,
     630                 cell[j].burn[k].cx, cell[j].burn[k].cy,
     631                 cell[j].burn[k].max, cell[j].burn[k].y0,
     632                 cell[j].burn[k].sx, cell[j].burn[k].sy,
     633                 cell[j].burn[k].ex, cell[j].burn[k].ey,
     634                 cell[j].burn[k].y0m, cell[j].burn[k].y0p,
     635                 cell[j].burn[k].y1m, cell[j].burn[k].y1p,
     636                 cell[j].burn[k].x0m, cell[j].burn[k].x0p,
     637                 cell[j].burn[k].x1m, cell[j].burn[k].x1p,
     638                 cell[j].burn[k].func, cell[j].burn[k].up,
     639                 cell[j].burn[k].slope, cell[j].burn[k].nfit,
     640                 cell[j].burn[k].sxfit, cell[j].burn[k].exfit,
     641                 cell[j].burn[k].fiterr, cell[j].burn[k].eyfit);
     642         } else {
     643           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",
    534644                 j, cell[j].burn[k].time,
    535645                 cell[j].burn[k].cx, cell[j].burn[k].cy,
     
    545655                 cell[j].burn[k].sxfit, cell[j].burn[k].exfit,
    546656                 cell[j].burn[k].fiterr);
     657         }
     658
    547659         for(i=0; i<cell[j].burn[k].nfit; i++) {
    548660            fprintf(fp, "%3d %3d %8.4f\n", cell[j].burn[k].xfit[i],
  • trunk/ppImage/src/ppImageBurntoolMask.c

    r26895 r42395  
    2424  }
    2525  long Nrows = psFitsTableSize(fits);
    26 
    2726  long row = 0;
    2827
    2928  psLogMsg ("ppImageBurntoolMask", 4, "Inside burntool mask %ld", Nrows);
    3029
     30  /* The new burntool tables and method coming into play in 2022 has a slightly different format (an extra column). Need to differentiate */
     31  psS16 BURNTOOL_STATE_GOOD = psMetadataLookupS16(NULL, config->camera, "BURNTOOL.STATE.GOOD");
     32
    3133  /* Redirects and Memory juggling. */
    3234  view->readout = 0;
    3335  psImage *image = mask->mask;
    34 
    3536
    3637  /* Set the maskValue from the recipes. */
     
    6465                  );
    6566#endif
    66         for (int i = psMetadataLookupS32(&status,rowMD,"sxfit");
     67
     68        /* do separate masking strategy for old (14 and lower) and new burntool tables*/
     69        if (BURNTOOL_STATE_GOOD >= 15) {
     70          for (int i = psMetadataLookupS32(&status,rowMD,"sxfit");
    6771             i <= psMetadataLookupS32(&status,rowMD,"exfit");
    6872             i++) {
    6973
    70           if (psMetadataLookupS32(&status,rowMD,"up") == 0) {
    71             for (int j = 0; j <= psMetadataLookupS32(&status,rowMD,"y1p"); j++) {
    72 #if PPIMAGE_BURNTOOL_DEBUG
    73               psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n",
     74            if (psMetadataLookupS32(&status,rowMD,"up") == 0) {
     75              for (int j = psMetadataLookupS32(&status,rowMD,"eyfit"); j <= psMetadataLookupS32(&status,rowMD,"y0"); j++) {
     76                #if PPIMAGE_BURNTOOL_DEBUG
     77                psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n",
    7478                       i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue);
    75 #endif
    76               image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue;
     79                #endif
     80                image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue;
     81              }
     82            } else {
     83              for (int j = psMetadataLookupS32(&status,rowMD,"sy"); j < psMetadataLookupS32(&status,rowMD,"eyfit") ; j++) {
     84                #if PPIMAGE_BURNTOOL_DEBUG
     85                psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n",
     86                       i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue);
     87                #endif
     88                image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue;
     89              }
    7790            }
    7891          }
    79           else {
    80             for (int j = psMetadataLookupS32(&status,rowMD,"y1m"); j < image->numRows ; j++) {
    81 #if PPIMAGE_BURNTOOL_DEBUG
    82               psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n",
     92        } else {
     93          for (int i = psMetadataLookupS32(&status,rowMD,"sxfit");
     94             i <= psMetadataLookupS32(&status,rowMD,"exfit");
     95             i++) {
     96
     97            if (psMetadataLookupS32(&status,rowMD,"up") == 0) {
     98              for (int j = 0; j <= psMetadataLookupS32(&status,rowMD,"y1p"); j++) {
     99                #if PPIMAGE_BURNTOOL_DEBUG
     100                psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n",
    83101                       i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue);
    84 #endif
    85               image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue;
     102                #endif
     103                image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue;
     104              }
     105            }
     106            else {
     107              for (int j = psMetadataLookupS32(&status,rowMD,"y1m"); j < image->numRows ; j++) {
     108                #if PPIMAGE_BURNTOOL_DEBUG
     109                psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n",
     110                       i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue);
     111                #endif
     112                image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue;
     113              }
    86114            }
    87115          }
     116
    88117        }
     118
    89119
    90120      }
Note: See TracChangeset for help on using the changeset viewer.