IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 26, 2009, 4:56:14 PM (17 years ago)
Author:
watersc1
Message:

alterations to ppImage to allow masking of burntool remnants by ppImage.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/cleanup/ppImage/src/ppImageBurntoolMask.c

    r25159 r25210  
    33#endif
    44
     5#define PPIMAGE_BURNTOOL_DEBUG 1
     6
    57#include "ppImage.h"
    68
    7 bool ppImageBurntoolMask (pmConfig *config, ppImageOptions *options, pmFPAview *view) {
    8 
     9bool ppImageBurntoolMask (pmConfig *config, ppImageOptions *options, pmFPAview *view,pmReadout *mask) {
    910  bool status = true;
     11  int burntool_cell;
     12  /* Find input filename */
    1013  pmFPAfile *inputFile = psMetadataLookupPtr(&status , config->files, "PPIMAGE.INPUT");
    1114  if (!status) {
     
    1316    return(false);
    1417  }
    15 
    1618  psFits *fits = inputFile->fits;
    1719
     20  /* Read input header, and find the burntool data table. */
     21  psMetadata *phu = psFitsReadHeader(NULL, fits);
     22 
    1823  if (!psFitsMoveExtName(fits,"burntool_areas")) {
    1924    psError(PS_ERR_IO,false, "Unable to find extension burntool_areas");
     
    2126  }
    2227  long Nrows = psFitsTableSize(fits); 
     28
    2329  long row = 0;
    24  
    25   pmFPAview *detview = pmFPAviewAlloc(0);
    26   *detview = *view;
    27   detview->readout = 0;
    28   pmReadout *mask = pmFPAfileThisReadout(config->files,detview,"PPIMAGE.MASK");
     30
     31  psLogMsg ("ppImageBurntoolMask", 4, "Inside burntool mask %ld", Nrows);
     32
     33  /* Redirects and Memory juggling. */
     34  view->readout = 0;
    2935  psImage *image = mask->mask;
    3036
    31   psImageMaskType maskValue = psMetadataLookupS32(&status,config->files,"PPIMAGE.BURNTOOL_MASK");
    3237 
     38  /* Set the maskValue from the recipes. */
     39  psImageMaskType maskValue = options->burntoolMask;
     40#ifdef PPIMAGE_BURNTOOL_DEBUG
     41  psLogMsg("ppImageBurntoolMask", 4, "Status: %ld %d\n",Nrows,maskValue);
     42#endif
     43
     44  burntool_cell = view->cell;
     45  burntool_cell = (view->cell % 8) * 8 + (view->cell - (view->cell % 8)) / 8;
     46  psLogMsg("ppImageBurntoolMask", 4, "Cell mapping: %d %d %d\n",view->cell,burntool_cell,-1);
    3347  for (row = 0; row < Nrows; row++) {
    3448    psMetadata *rowMD = psFitsReadTableRow(fits,row);
    3549
    36     if (psMetadataLookupS32(&status,rowMD,"cell") == detview->cell) {
    37 
    38       if (psMetadataLookupS32(&status,rowMD,"func") != -1) { // This should be an actual check
    39 
     50    if (psMetadataLookupS32(&status,rowMD,"cell") == burntool_cell) {
     51      if (((options->burntoolTrails & 0x01)&&(psMetadataLookupS32(&status,rowMD,"nfit") == 0))||
     52          ((options->burntoolTrails & 0x02)&&(psMetadataLookupS32(&status,rowMD,"up") == 1))||
     53          ((options->burntoolTrails & 0x04)&&(psMetadataLookupS32(&status,rowMD,"up") == 0))) {
     54        /*       If the fit fails, burntool reports zero here.  This
     55                 signifies that it expected to see a trail (else why
     56                 fit) but did not find it when it attempted to
     57                 correct. */
     58#ifdef PPIMAGE_BURNTOOL_DEBUG
     59        psLogMsg ("ppImageBurntoolMask", 4, "Masking! %d (%d %d %d) %d %d",
     60                  psMetadataLookupS32(&status,rowMD,"cell"),
     61                  ((options->burntoolTrails & 0x0001)&&(psMetadataLookupS32(&status,rowMD,"nfit") == 0)),
     62                  ((options->burntoolTrails & 0x02)&&(psMetadataLookupS32(&status,rowMD,"up") == 1)),
     63                  ((options->burntoolTrails & 0x04)&&(psMetadataLookupS32(&status,rowMD,"up") == 0)),
     64                  options->burntoolTrails,
     65                  maskValue
     66                  );
     67#endif
    4068        for (int i = psMetadataLookupS32(&status,rowMD,"sxfit");
    4169             i <= psMetadataLookupS32(&status,rowMD,"exfit");
     
    4472          if (psMetadataLookupS32(&status,rowMD,"up") == 0) {
    4573            for (int j = 0; j <= psMetadataLookupS32(&status,rowMD,"y1p"); j++) {
     74/* #ifdef PPIMAGE_BURNTOOL_DEBUG */
     75/*            psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n", */
     76/*                     i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue); */
     77/* #endif */
    4678              image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue;
    4779            }
     
    4981          else {
    5082            for (int j = psMetadataLookupS32(&status,rowMD,"y1m"); j < image->numRows ; j++) {
     83/* #ifdef PPIMAGE_BURNTOOL_DEBUG */
     84/*            psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n", */
     85/*                     i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue); */
     86/* #endif */
    5187              image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue;
    5288            }
     
    5692      }
    5793    }
     94    psFree(rowMD);
    5895  }
    59 
     96  psFree(phu);
    6097  return(status);
    6198}
Note: See TracChangeset for help on using the changeset viewer.