IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 31086


Ignore:
Timestamp:
Mar 30, 2011, 9:39:01 AM (15 years ago)
Author:
eugene
Message:

merging changes from trunk

Location:
branches/eam_branches/ipp-20110213/ppImage/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110213/ppImage/src

  • branches/eam_branches/ipp-20110213/ppImage/src/ppImageDetrendPattern.c

    r26922 r31086  
    2323    assert(inputView->readout == -1);
    2424
     25    // PATTERN.ROW is selected by the recipe.  If it is selected, we search for the table
     26    // PATTERN.ROW.SUBSET.  If this is found in our format file, we use that version;
     27    // otherwise, we use the table provided in the recipe file "ppImage.config".  Within that
     28    // table, we select the entry that matches our CHIP.NAME.  This will be either a boolean or
     29    // a string of bits.  If it is a boolean, it specified whether or not to correct the entire
     30    // chip; if it is a string, the bits specify which cells to correct (sequence is order of
     31    // CELLS in the format:CHIPS metadata table)
     32
     33    // We also check the chip header for the boolean 'PTRN_ROW' : if this is true, we have
     34    // already applied this correct to this data, so we simply skip the correction for this
     35    // chip.
     36
    2537    if (options->doPatternRow) {
    2638        bool status;
    27         pmFPAfile *input = psMetadataLookupPtr(&status, config->files, "PPIMAGE.INPUT");
    28         pmFPAview *view = pmFPAviewAlloc(0); // View for local processing
    29         *view = *inputView;
    30         while ((cell = pmFPAviewNextCell(view, input->fpa, 1)) != NULL) {
     39        pmHDU *hdu = pmHDUFromChip(chip);
     40        if (psMetadataLookupBool(NULL,hdu->header,"PTRN_ROW")) {
     41          psLogMsg("ppImage", PS_LOG_INFO, "Not performing row pattern correction as it has already been done.");
     42          goto pattern_cell;
     43        }
     44
     45        pmFPAfile *input = psMetadataLookupPtr(&status, config->files, "PPIMAGE.INPUT");
     46        pmFPAview *view = pmFPAviewAlloc(0); // View for local processing
     47        *view = *inputView;
     48        while ((cell = pmFPAviewNextCell(view, input->fpa, 1)) != NULL) {
    3149            if (!cell->process || !cell->file_exists) {
    32                 continue;
     50                continue;
    3351            }
    3452            if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
    35               ESCAPE(false, "load failure for Cell");
     53                ESCAPE(false, "load failure for Cell");
    3654            }
    37 
     55           
    3856            if (!cell->data_exists) {
    3957                continue;
     
    5169            if (!doPattern) continue;
    5270
     71            // A very detailed log message.
    5372            const char *chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME");
    5473            const char *cellName = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME");
    55             psLogMsg("ppImage", PS_LOG_INFO, "Performing row pattern correction for %s, %s\n",
    56                      chipName, cellName);
     74            psLogMsg("ppImage", PS_LOG_INFO, "Performing row pattern correction for %s, %s\n", chipName, cellName);
    5775
    5876            // process each of the readouts
     
    7492                }
    7593            }
    76         }
    77         psFree(view);
     94
     95        }
     96        psMetadataAddBool(hdu->header, PS_LIST_TAIL, "PTRN_ROW",PS_META_REPLACE,"PATTERN.ROW correction applied",true);
     97        psFree(view);
    7898    }
     99
     100 pattern_cell:
     101
     102    // see the comment for PATTERN.ROW; the same rules apply for PATTERN.CELL
    79103
    80104    if (options->doPatternCell) {
     
    83107        pmFPAview *view = pmFPAviewAlloc(0); // View for local processing
    84108        *view = *inputView;
    85         for (int i = 0; i < chip->cells->n; i++) {
     109
     110        pmHDU *hdu = pmHDUFromChip(chip);
     111        if (psMetadataLookupBool(NULL,hdu->header,"PTRN_CEL")) {
     112          psLogMsg("ppImage", PS_LOG_INFO, "Not performing cell pattern correction as it has already been done.");
     113          goto pattern_done;
     114        }
     115
     116        for (int i = 0; i < chip->cells->n; i++) {
    86117            view->cell = i;
    87118
    88119            pmCell *cell = chip->cells->data[i]; // Cell of interest
     120
    89121            if (cell->readouts->n > 1) {
    90122                psLogMsg("ppImage", PS_LOG_INFO, "Not performing cell pattern correction on video cell.");
     
    99131                tweak->data.U8[i] = 0xFF;
    100132            }
    101         }
    102133
    103         // Tweak the cells
    104         if (!pmPatternCell(chip, tweak, options->patternCellBG, options->patternCellMean,
    105                            options->maskValue, options->darkMask)) {
    106             psFree(tweak);
    107             psFree(view);
    108             return false;
    109         }
    110         psFree(tweak);
    111         psFree(view);
     134        }
     135
     136        // Tweak the cells
     137        if (!pmPatternCell(chip, tweak, options->patternCellBG, options->patternCellMean,
     138                           options->maskValue, options->darkMask)) {
     139            psFree(tweak);
     140            psFree(view);
     141            return false;
     142        }
     143        psFree(tweak);
     144        psFree(view);
     145
     146        psMetadataAddBool(hdu->header, PS_LIST_TAIL, "PTRN_CEL",PS_META_REPLACE,"PATTERN.CELL correction applied",true);
    112147    }
    113148
     149 pattern_done:
    114150    return(true);
    115151}
     
    119155    *doit = false;
    120156
    121     psMetadataItem *doPattern = pmConfigRecipeValueByView(config, recipeName, recipeValue, chip->parent, view);
     157    psMetadataItem *doPattern;
     158
     159    doPattern = pmConfigRecipeValueByView(config, recipeName, recipeValue, chip->parent, view);
     160   
    122161    if (!doPattern) {
    123162        psError(PS_ERR_UNKNOWN, false, "Unable to determine whether row pattern matching should be applied.");
  • branches/eam_branches/ipp-20110213/ppImage/src/ppImageOptions.c

    r30680 r31086  
    126126        exit(EXIT_FAILURE);
    127127    }
    128 
     128    psMetadata *format = config->format;
     129   
    129130    // Non-linearity recipe options
    130131    if (psMetadataLookupBool(NULL, recipe, "NONLIN")) {
     
    237238    options->doFringe = psMetadataLookupBool(NULL, recipe, "FRINGE");
    238239    options->doShutter = psMetadataLookupBool(NULL, recipe, "SHUTTER");
     240
     241    // PATTERN.ROW is selected by the recipe.  If it is selected, we search for the table
     242    // PATTERN.ROW.SUBSET.  If this is found in our format file, we use that version;
     243    // otherwise, we use the table provided in the recipe file "ppImage.config".  Within that
     244    // table, we select the entry that matches our CHIP.NAME.  This will be either a boolean or
     245    // a string of bits.  If it is a boolean, it specified whether or not to correct the entire
     246    // chip; if it is a string, the bits specify which cells to correct (sequence is order of
     247    // CELLS in the format:CHIPS metadata table)
     248
     249    // We also check the chip header for the boolean 'PTRN_ROW' : if this is true, we have
     250    // already applied this correct to this data, so we simply skip the correction for this
     251    // chip.
     252
    239253    options->doPatternRow = psMetadataLookupBool(NULL, recipe, "PATTERN.ROW");
    240254    options->doPatternCell = psMetadataLookupBool(NULL, recipe, "PATTERN.CELL");
     255
    241256    options->doMaskStats = psMetadataLookupBool(NULL, recipe, "MASK.STATS");
    242257    options->addNoise = psMetadataLookupBool(NULL, recipe, "ADDNOISE");
     
    344359
    345360    // Pattern correction
    346     options->patternRowOrder = psMetadataLookupS32(NULL, recipe, "PATTERN.ROW.ORDER");
    347     options->patternRowIter = psMetadataLookupS32(NULL, recipe, "PATTERN.ROW.ITER");
    348     options->patternRowRej = psMetadataLookupF32(NULL, recipe, "PATTERN.ROW.REJ");
    349     options->patternRowThresh = psMetadataLookupF32(NULL, recipe, "PATTERN.ROW.THRESH");
    350     options->patternRowMean = psStatsOptionFromString(psMetadataLookupStr(NULL, recipe, "PATTERN.ROW.MEAN"));
    351     options->patternRowStdev = psStatsOptionFromString(psMetadataLookupStr(NULL, recipe, "PATTERN.ROW.STDEV"));
    352     options->patternCellBG = psStatsOptionFromString(psMetadataLookupStr(NULL, recipe, "PATTERN.CELL.BG"));
    353     options->patternCellMean = psStatsOptionFromString(psMetadataLookupStr(NULL, recipe, "PATTERN.CELL.MEAN"));
     361    if (psMetadataLookup(format, "PATTERN.ROW.ORDER")) {
     362      options->patternRowOrder = psMetadataLookupS32(NULL, format, "PATTERN.ROW.ORDER");
     363    }
     364    else {
     365      options->patternRowOrder = psMetadataLookupS32(NULL, recipe, "PATTERN.ROW.ORDER");
     366    }
     367    if (psMetadataLookup(format, "PATTERN.ROW.ITER")) {
     368      options->patternRowIter = psMetadataLookupS32(NULL, format, "PATTERN.ROW.ITER");
     369    }
     370    else {
     371      options->patternRowIter = psMetadataLookupS32(NULL, recipe, "PATTERN.ROW.ITER");
     372    }
     373    if (psMetadataLookup(format, "PATTERN.ROW.REJ")) {
     374      options->patternRowRej = psMetadataLookupF32(NULL, format, "PATTERN.ROW.REJ");
     375    }
     376    else {
     377      options->patternRowRej = psMetadataLookupF32(NULL, recipe, "PATTERN.ROW.REJ");
     378    }
     379    if (psMetadataLookup(format, "PATTERN.ROW.THRESH")) {
     380      options->patternRowThresh = psMetadataLookupF32(NULL, format, "PATTERN.ROW.THRESH");
     381    }
     382    else {
     383      options->patternRowThresh = psMetadataLookupF32(NULL, recipe, "PATTERN.ROW.THRESH");
     384    }
     385    if (psMetadataLookup(format, "PATTERN.ROW.MEAN")) {
     386      options->patternRowMean = psStatsOptionFromString(psMetadataLookupStr(NULL, format, "PATTERN.ROW.MEAN"));
     387    }
     388    else {
     389      options->patternRowMean = psStatsOptionFromString(psMetadataLookupStr(NULL, recipe, "PATTERN.ROW.MEAN"));
     390    }
     391    if (psMetadataLookup(format, "PATTERN.ROW.STDEV")) {
     392      options->patternRowStdev = psStatsOptionFromString(psMetadataLookupStr(NULL, format, "PATTERN.ROW.STDEV"));
     393    }
     394    else {
     395      options->patternRowStdev = psStatsOptionFromString(psMetadataLookupStr(NULL, recipe, "PATTERN.ROW.STDEV"));
     396    }
     397    if (psMetadataLookup(format, "PATTERN.CELL.BG")) {
     398      options->patternCellBG = psStatsOptionFromString(psMetadataLookupStr(NULL, format, "PATTERN.CELL.BG"));
     399    }
     400    else {
     401      options->patternCellBG = psStatsOptionFromString(psMetadataLookupStr(NULL, recipe, "PATTERN.CELL.BG"));
     402    }
     403    if (psMetadataLookup(format, "PATTERN.CELL.MEAN")) {
     404      options->patternCellMean = psStatsOptionFromString(psMetadataLookupStr(NULL, format, "PATTERN.CELL.MEAN"));
     405    }
     406    else {
     407      options->patternCellMean = psStatsOptionFromString(psMetadataLookupStr(NULL, recipe, "PATTERN.CELL.MEAN"));
     408    }
     409
    354410
    355411    // Remnance options
Note: See TracChangeset for help on using the changeset viewer.