IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 1, 2009, 11:43:05 AM (17 years ago)
Author:
eugene
Message:

merging Doxygen templates added by Bill G

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppMerge/src/ppMergeMask.c

    r21183 r21244  
     1/** @file ppMergeMask.c
     2 *
     3 *  @brief
     4 *
     5 *  @ingroup ppMerge
     6 *
     7 *  @author IfA
     8 *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-02-01 21:43:05 $
     10 *  Copyright 2009 Institute for Astronomy, University of Hawaii
     11 */
     12
    113#include "ppMerge.h"
    214
    3 static bool mergeMask(pmConfig *config, // Configuration
    4                       const pmFPAview *view, // View to chip
    5                       bool writeOut,     // Write output?
    6                       psRandom *rng,    // Random number generator
    7                       psMetadata *stats // Statistics output
     15static bool mergeMask(pmConfig *config, ///< Configuration
     16                      const pmFPAview *view, ///< View to chip
     17                      bool writeOut,     ///< Write output?
     18                      psRandom *rng,    ///< Random number generator
     19                      psMetadata *stats ///< Statistics output
    820    )
    921{
     
    1224    assert(view->chip != -1 && view->cell == -1 && view->readout == -1);
    1325
    14     bool mdok;                          // Status of MD lookup
    15     int numFiles = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); // Number of input files
    16     psStatsOptions meanStat = psMetadataLookupS32(NULL, config->arguments, "MEAN"); // Statistic for mean
    17     psStatsOptions stdevStat = psMetadataLookupS32(NULL, config->arguments, "STDEV"); // Statistic for stdev
    18     int sample = psMetadataLookupS32(NULL, config->arguments, "SAMPLE"); // Size of sample for statistics
    19     bool chipStats = psMetadataLookupBool(&mdok, config->arguments, "MASK.CHIPSTATS"); // Statistics on chip?
    20     float maskSuspect = psMetadataLookupF32(NULL, config->arguments, "MASK.SUSPECT"); // Threshold for suspect pixels
    21     float maskBad = psMetadataLookupF32(NULL, config->arguments, "MASK.BAD"); // Threshold for bad pixels
    22     pmMaskIdentifyMode maskMode = psMetadataLookupS32(NULL, config->arguments, "MASK.MODE"); // Mode for identifying bad pixels
    23     int maskGrow = psMetadataLookupS32(NULL, config->arguments, "MASK.GROW"); // Radius to grow mask
    24 
    25     bool smoothSuspect = psMetadataLookupBool(&mdok, config->arguments, "MASK.SMOOTH.SUSPECT"); // Radius to grow mask
    26     float smoothScale = psMetadataLookupF32(&mdok, config->arguments, "MASK.SMOOTH.SCALE"); // Radius to grow mask
     26    bool mdok;                          ///< Status of MD lookup
     27    int numFiles = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); ///< Number of input files
     28    psStatsOptions meanStat = psMetadataLookupS32(NULL, config->arguments, "MEAN"); ///< Statistic for mean
     29    psStatsOptions stdevStat = psMetadataLookupS32(NULL, config->arguments, "STDEV"); ///< Statistic for stdev
     30    int sample = psMetadataLookupS32(NULL, config->arguments, "SAMPLE"); ///< Size of sample for statistics
     31    bool chipStats = psMetadataLookupBool(&mdok, config->arguments, "MASK.CHIPSTATS"); ///< Statistics on chip?
     32    float maskSuspect = psMetadataLookupF32(NULL, config->arguments, "MASK.SUSPECT"); ///< Threshold for suspect pixels
     33    float maskBad = psMetadataLookupF32(NULL, config->arguments, "MASK.BAD"); ///< Threshold for bad pixels
     34    pmMaskIdentifyMode maskMode = psMetadataLookupS32(NULL, config->arguments, "MASK.MODE"); ///< Mode for identifying bad pixels
     35    int maskGrow = psMetadataLookupS32(NULL, config->arguments, "MASK.GROW"); ///< Radius to grow mask
     36
     37    bool smoothSuspect = psMetadataLookupBool(&mdok, config->arguments, "MASK.SMOOTH.SUSPECT"); ///< Radius to grow mask
     38    float smoothScale = psMetadataLookupF32(&mdok, config->arguments, "MASK.SMOOTH.SCALE"); ///< Radius to grow mask
    2739
    2840    psImageMaskType markVal;
     
    4052    }
    4153   
    42     psStats *statistics = psStatsAlloc(meanStat | stdevStat); // Statistics for background
    43 
    44     psString outName = ppMergeOutputFile(config); // Name of output file
    45     pmChip *outChip = pmFPAfileThisChip(config->files, view, outName); // Output chip
     54    psStats *statistics = psStatsAlloc(meanStat | stdevStat); ///< Statistics for background
     55
     56    psString outName = ppMergeOutputFile(config); ///< Name of output file
     57    pmChip *outChip = pmFPAfileThisChip(config->files, view, outName); ///< Output chip
    4658    psFree(outName);
    4759   
     
    5870
    5971    // For each input file, get the statistics, which can be calculated at the chip or cell levels
    60     psVector *values = psVectorAlloc(sample, PS_TYPE_F32); // Pixel values for statistics
    61     pmFPAview *inView = pmFPAviewAlloc(0); // View for input
     72    psVector *values = psVectorAlloc(sample, PS_TYPE_F32); ///< Pixel values for statistics
     73    pmFPAview *inView = pmFPAviewAlloc(0); ///< View for input
    6274    for (int i = 0; i < numFiles; i++) {
    6375        pmFPAfileActivate(config->files, false, NULL);
    64         psArray *files = ppMergeFileActivateSingle(config, PPMERGE_FILES_INPUT, true, i); // Input files
    65         pmFPAfile *input = files->data[0]; // Input file
     76        psArray *files = ppMergeFileActivateSingle(config, PPMERGE_FILES_INPUT, true, i); ///< Input files
     77        pmFPAfile *input = files->data[0]; ///< Input file
    6678        psFree(files);
    67         pmFPA *inFPA = input->fpa;  // Input FPA
     79        pmFPA *inFPA = input->fpa;  ///< Input FPA
    6880        *inView = *view;
    6981
    70         int valueIndex = 0;             // Index for vector of pixel values
    71 
    72         pmCell *inCell;                 // Input cell
     82        int valueIndex = 0;             ///< Index for vector of pixel values
     83
     84        pmCell *inCell;                 ///< Input cell
    7385        while ((inCell = pmFPAviewNextCell(inView, inFPA, 1))) {
    7486
    7587            // the output FPA structure carries the information about which cells to process
    76             pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell
     88            pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); ///< Output cell
    7789            if (!outCell->process) continue;
    7890
    79             pmHDU *hdu = pmHDUFromCell(inCell); // HDU for cell
     91            pmHDU *hdu = pmHDUFromCell(inCell); ///< HDU for cell
    8092            if (!hdu || hdu->blankPHU) {
    8193                // No data here
     
    106118            pmReadout *readout;
    107119            if (inCell->readouts && inCell->readouts->n == 1) {
    108                 readout = psMemIncrRefCounter(inCell->readouts->data[0]); // Input readout
     120                readout = psMemIncrRefCounter(inCell->readouts->data[0]); ///< Input readout
    109121            } else {
    110122                readout = pmReadoutAlloc(inCell);
     
    118130            }
    119131
    120             pmReadout *outRO = NULL;    // Output readout
     132            pmReadout *outRO = NULL;    ///< Output readout
    121133            if (outCell->readouts && outCell->readouts->n == 1) {
    122134                outRO = psMemIncrRefCounter(outCell->readouts->data[0]);
     
    124136                outRO = pmReadoutAlloc(outCell);
    125137            }
    126             psImage *outMask = outRO->mask;    // Output mask image (for iterative generation of mask)
    127 
    128             psImage *image = readout->image, *mask = readout->mask; // Image and mask
    129             int numCols = readout->image->numCols, numRows = readout->image->numRows; // Image size
    130             int numPix = numCols * numRows; // Number of pixels
    131             int num = PS_MIN(numPix, sample / numCells); // Number of values to add
     138            psImage *outMask = outRO->mask;    ///< Output mask image (for iterative generation of mask)
     139
     140            psImage *image = readout->image, *mask = readout->mask; ///< Image and mask
     141            int numCols = readout->image->numCols, numRows = readout->image->numRows; ///< Image size
     142            int numPix = numCols * numRows; ///< Number of pixels
     143            int num = PS_MIN(numPix, sample / numCells); ///< Number of values to add
    132144            if (!chipStats) {
    133145                valueIndex = 0;
     
    187199
    188200                // the output FPA structure carries the information about which cells to process
    189                 pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell
     201                pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); ///< Output cell
    190202                if (!outCell->process) continue;
    191203
    192                 pmHDU *hdu = pmHDUFromCell(inCell); // HDU for cell
     204                pmHDU *hdu = pmHDUFromCell(inCell); ///< HDU for cell
    193205                if (!hdu || hdu->blankPHU) continue;
    194206
    195                 pmReadout *readout = inCell->readouts->data[0]; // Readout of interest
     207                pmReadout *readout = inCell->readouts->data[0]; ///< Readout of interest
    196208
    197209                inView->readout = 0;
     
    225237        ppMergeFileActivate(config, PPMERGE_FILES_OUTPUT, true);
    226238    }
    227     pmFPA *outFPA = outChip->parent;    // Output FPA
    228     pmCell *outCell;                    // Output cell
    229     pmFPAview *outView = pmFPAviewAlloc(0); // View into output FPA
     239    pmFPA *outFPA = outChip->parent;    ///< Output FPA
     240    pmCell *outCell;                    ///< Output cell
     241    pmFPAview *outView = pmFPAviewAlloc(0); ///< View into output FPA
    230242    *outView = *view;
    231243    while ((outCell = pmFPAviewNextCell(outView, outFPA, 1))) {
     
    234246        if (!outCell->process) continue;
    235247
    236         pmHDU *hdu = pmHDUFromCell(outCell); // HDU for cell
     248        pmHDU *hdu = pmHDUFromCell(outCell); ///< HDU for cell
    237249        if (!hdu || hdu->blankPHU) continue;
    238250
     
    240252
    241253        assert(outCell->readouts && outCell->readouts->n == 1);
    242         pmReadout *outRO = outCell->readouts->data[0]; // Output readout
     254        pmReadout *outRO = outCell->readouts->data[0]; ///< Output readout
    243255
    244256        if (smoothSuspect) {
    245257            // XXX test output of suspect pixel image
    246             psImage *suspects = psMetadataLookupPtr(NULL, outRO->analysis, PM_MASK_ANALYSIS_SUSPECT); // Suspect img
     258            psImage *suspects = psMetadataLookupPtr(NULL, outRO->analysis, PM_MASK_ANALYSIS_SUSPECT); ///< Suspect img
    247259            assert (suspects);
    248             psImageSmooth (suspects, smoothScale, 3); // extend smoothing region to 3-sigma
     260            psImageSmooth (suspects, smoothScale, 3); ///< extend smoothing region to 3-sigma
    249261        }
    250262
     
    259271            // The counts image is fairly useless, but it preserves the model
    260272            pmCell *countsCell = pmFPAfileThisCell(config->files, outView, "PPMERGE.OUTPUT.COUNT");
    261             pmReadout *countsRO = pmReadoutAlloc(countsCell); // Readout with count of inputs per pixel
     273            pmReadout *countsRO = pmReadoutAlloc(countsCell); ///< Readout with count of inputs per pixel
    262274            countsRO->image = psImageAlloc(outRO->mask->numCols, outRO->mask->numRows, PS_TYPE_F32);
    263275            psImageInit(countsRO->image, numFiles);
     
    266278
    267279            pmCell *sigmaCell = pmFPAfileThisCell(config->files, outView, "PPMERGE.OUTPUT.SIGMA");
    268             pmReadout *sigmaRO = pmReadoutAlloc(sigmaCell); // Readout with suspect image
     280            pmReadout *sigmaRO = pmReadoutAlloc(sigmaCell); ///< Readout with suspect image
    269281            psImage *suspect = psMetadataLookupPtr(NULL, outRO->analysis, PM_MASK_ANALYSIS_SUSPECT);
    270282            sigmaRO->image = psImageCopy(sigmaRO->image, suspect, PS_TYPE_F32);
     
    275287
    276288        if (maskGrow > 0) {
    277             psImage *grown = psImageGrowMask(NULL, outRO->mask, maskValOut, maskGrow, maskValOut); // Grown mask
     289            psImage *grown = psImageGrowMask(NULL, outRO->mask, maskValOut, maskGrow, maskValOut); ///< Grown mask
    278290            psFree(outRO->mask);
    279291            outRO->mask = grown;
     
    289301
    290302            // Average concepts
    291             psList *cells = psListAlloc(NULL); // List of cells, for concept averaging
     303            psList *cells = psListAlloc(NULL); ///< List of cells, for concept averaging
    292304            for (int i = 0; i < numFiles; i++) {
    293                 pmFPAfile *inFile = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i); // Input file
    294                 pmCell *inCell = pmFPAviewThisCell(outView, inFile->fpa); // Input cell
     305                pmFPAfile *inFile = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i); ///< Input file
     306                pmCell *inCell = pmFPAviewThisCell(outView, inFile->fpa); ///< Input cell
    295307                psListAdd(cells, PS_LIST_TAIL, inCell);
    296308            }
     
    340352    assert(config);
    341353
    342     bool mdok;                          // Status of MD lookup
    343     int numFiles = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); // Number of inputs
    344     bool haveMasks = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.MASKS"); // Do we have masks?
    345     bool haveWeights = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.WEIGHTS"); // Do we have weights?
    346     int iter = psMetadataLookupS32(NULL, config->arguments, "ITER"); // Number of rejection iterations
     354    bool mdok;                          ///< Status of MD lookup
     355    int numFiles = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); ///< Number of inputs
     356    bool haveMasks = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.MASKS"); ///< Do we have masks?
     357    bool haveWeights = psMetadataLookupBool(&mdok, config->arguments, "INPUTS.WEIGHTS"); ///< Do we have weights?
     358    int iter = psMetadataLookupS32(NULL, config->arguments, "ITER"); ///< Number of rejection iterations
    347359
    348360    PS_ASSERT_INT_POSITIVE(iter, false);
    349361
    350     pmFPAview *view = pmFPAviewAlloc(0); // View to component of interest
    351     psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0); // Random number generator
    352 
    353     psMetadata *stats = NULL;           // Statistics for output
     362    pmFPAview *view = pmFPAviewAlloc(0); ///< View to component of interest
     363    psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0); ///< Random number generator
     364
     365    psMetadata *stats = NULL;           ///< Statistics for output
    354366    if (psMetadataLookup(config->arguments, "STATS.NAME")) {
    355367        stats = psMetadataAlloc();
     
    357369    }
    358370
    359     psArray *inputs = ppMergeFileDataLevel(config, "PPMERGE.INPUT", PM_FPA_LEVEL_READOUT); // Input images
     371    psArray *inputs = ppMergeFileDataLevel(config, "PPMERGE.INPUT", PM_FPA_LEVEL_READOUT); ///< Input images
    360372    psFree(inputs);
    361373    if (haveMasks) {
     
    380392    // for the input masks.
    381393
    382     psString outName = ppMergeOutputFile(config); // Name of output file
    383     pmFPAfile *output = psMetadataLookupPtr(NULL, config->files, outName); // Output file
     394    psString outName = ppMergeOutputFile(config); ///< Name of output file
     395    pmFPAfile *output = psMetadataLookupPtr(NULL, config->files, outName); ///< Output file
    384396    psFree(outName);
    385397    assert(output && output->fpa);
    386     pmFPA *outFPA = output->fpa;        // Output FPA
     398    pmFPA *outFPA = output->fpa;        ///< Output FPA
    387399
    388400    if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
    389401        goto PPMERGE_MASK_ERROR;
    390402    }
    391     pmChip *outChip;                    // Chip of interest
     403    pmChip *outChip;                    ///< Chip of interest
    392404    while ((outChip = pmFPAviewNextChip(view, outFPA, 1))) {
    393405
     
    408420            psList *inChips = psListAlloc(NULL);
    409421            for (int i=0; i < numFiles; i++) {
    410                 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i); // Input file
     422                pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i); ///< Input file
    411423                pmChip *chip = pmFPAviewThisChip(view, file->fpa);
    412424                psListAdd(inChips, PS_LIST_TAIL, chip);
     
    427439    }
    428440
    429     psList *fpaList = psListAlloc(NULL);// List of FPAs for concept averaging
     441    psList *fpaList = psListAlloc(NULL);///< List of FPAs for concept averaging
    430442    for (int i = 0; i < numFiles; i++) {
    431         pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i); // Input file
     443        pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPMERGE.INPUT", i); ///< Input file
    432444        psListAdd(fpaList, PS_LIST_TAIL, file->fpa);
    433445    }
Note: See TracChangeset for help on using the changeset viewer.