IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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:
2 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.");
Note: See TracChangeset for help on using the changeset viewer.