IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 14, 2010, 4:24:34 PM (16 years ago)
Author:
eugene
Message:

modify to use updates psphot APIs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/magic/censorObjects/src/censorReadout.c

    r24714 r26952  
    1919    // if there is no mask file for this readout drop all sources
    2020    if (badMaskFile) {
    21       psMetadataRemoveKey (readout->analysis, "PSPHOT.SOURCES");
     21      psMetadataRemoveKey (readout->analysis, "PSPHOT.DETECTIONS");
    2222      return true;
    2323    }
     
    4141    }
    4242
    43     // XXX why not do this? 
     43    // XXX why not do this?
    4444    pmReadout *readoutMask = pmFPAviewThisReadout (view, inMask->fpa);
    4545    if (!readoutMask) {
    4646        psError(CENSOR_ERR_CONFIG, true, "Can't find mask for this readout");
    47         return false;
     47        return false;
    4848    }
    4949
    5050    // select the raw objects for this readout, flag is they fall in a mask
    51     psArray *inSources = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.SOURCES");
    52     if (inSources == NULL) {
    53         psError(CENSOR_ERR_CONFIG, true, "Can't find sources for this readout");
    54         return false;
     51    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
     52    if (detections == NULL) {
     53        psError(CENSOR_ERR_CONFIG, true, "Can't find detections for this readout");
     54        return false;
    5555    }
    56                
     56    psArray *inSources = detections->allSources;
     57    psAssert (inSources, "missing sources?");
     58
    5759    // create a replacement output array:
    5860    psArray *outSources = psArrayAllocEmpty(100);
     
    6062    // only keep sources that do not match the specified mask bit
    6163    for (int i = 0; i < inSources->n; i++) {
    62         pmSource *source = inSources->data[i];
     64        pmSource *source = inSources->data[i];
    6365
    64         int xChip = source->peak->x;
    65         int yChip = source->peak->y;
     66        int xChip = source->peak->x;
     67        int yChip = source->peak->y;
    6668
    67         bool onChip = true;
    68         onChip &= (xChip >= 0);
    69         onChip &= (xChip < readoutMask->mask->numCols);
    70         onChip &= (yChip >= 0);
    71         onChip &= (yChip < readoutMask->mask->numRows);
     69        bool onChip = true;
     70        onChip &= (xChip >= 0);
     71        onChip &= (xChip < readoutMask->mask->numCols);
     72        onChip &= (yChip >= 0);
     73        onChip &= (yChip < readoutMask->mask->numRows);
    7274
    73         if (onChip) {
    74             psImageMaskType value = readoutMask->mask->data.PS_TYPE_IMAGE_MASK_DATA[yChip][xChip];
    75             if (value & streakMaskValue) {
    76                 // skip sources on streak masks
    77                 continue;
    78             }
    79         }
    80         psArrayAdd (outSources, 100, source);
     75        if (onChip) {
     76            psImageMaskType value = readoutMask->mask->data.PS_TYPE_IMAGE_MASK_DATA[yChip][xChip];
     77            if (value & streakMaskValue) {
     78                // skip sources on streak masks
     79                continue;
     80            }
     81        }
     82        psArrayAdd (outSources, 100, source);
    8183    }
    8284
    8385    psLogMsg ("censor", PS_LOG_INFO, "keeping %ld of %ld sources", outSources->n, inSources->n);
    8486
     87    psFree (detections->allSources);
     88    detections->allSources = outSources;
     89
     90#ifdef notdef
     91    // XXX: this is not necessary (and incorrect) as we are re-using the pmDetections object that is in readout->analysis
    8592    // remove the inSources and replace with the outSources
    86     psMetadataRemoveKey (readout->analysis, "PSPHOT.SOURCES");
    87     psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, "sources", outSources);
    88     psFree (outSources);
    89 
     93    psMetadataRemoveKey (readout->analysis, "PSPHOT.DETECTIONS");
     94    psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_DATA_ARRAY, "sources", detections);
     95    psFree (detections);
     96#endif
    9097    return true;
    9198}
Note: See TracChangeset for help on using the changeset viewer.