IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26780


Ignore:
Timestamp:
Feb 5, 2010, 1:12:28 PM (16 years ago)
Author:
eugene
Message:

add option to use short or long form description of PATTERN options

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/ppImage/src/ppImageDetrendPattern.c

    r26776 r26780  
    55#include "ppImage.h"
    66
    7 #define ESCAPE(MESSAGE) {                               \
    8         psError(PS_ERR_UNKNOWN, false, MESSAGE);        \
     7#define ESCAPE(STATUS,...) {                    \
     8        psError(PS_ERR_UNKNOWN, STATUS, __VA_ARGS__);   \
    99        psFree(view);                                   \
    1010        return false;                                   \
    1111    }
     12
     13static bool doPatternForView (bool *doit, const pmConfig *config, const pmChip *chip, const pmFPAview *view, const char *recipename, const char *recipevalue);
    1214
    1315bool ppImageDetrendPatternApply(pmConfig *config, pmChip *chip, const pmFPAview *inputView,
     
    3133            }
    3234            if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
    33                 ESCAPE("load failure for Cell");
     35              ESCAPE(false, "load failure for Cell");
    3436            }
    3537
     
    4345            }
    4446
    45             psMetadataItem *doPattern = pmConfigRecipeValueByView(config, RECIPE_NAME, "PATTERN.ROW.SUBSET",
    46                                                                   chip->parent, view); // Do pattern corr?
    47             if (!doPattern || doPattern->type != PS_DATA_BOOL) {
    48                 ESCAPE("Unable to determine whether row pattern correction should be applied.");
    49             }
    50             if (!doPattern->data.B) {
    51                 continue;
    52             }
     47            bool doPattern = false;
     48            if (!doPatternForView(&doPattern, config, chip, view, RECIPE_NAME, "PATTERN.ROW.SUBSET")) {
     49                ESCAPE(false, "Unable to determine whether row pattern matching should be applied.");
     50            }
     51            if (!doPattern) continue;
    5352
    5453            psLogMsg("ppImage", PS_LOG_INFO, "Performing row pattern correction for %d,%d\n",
     
    5958            while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
    6059                if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
    61                     ESCAPE("load failure for Readout");
     60                    ESCAPE(false, "load failure for Readout");
    6261                }
    6362                if (!readout->data_exists) {
     
    8483        for (int i = 0; i < chip->cells->n; i++) {
    8584            view->cell = i;
    86             psMetadataItem *doPattern = pmConfigRecipeValueByView(config, RECIPE_NAME, "PATTERN.CELL.SUBSET",
    87                                                                   chip->parent, view); // Do pattern sub?
    88             if (!doPattern || doPattern->type != PS_DATA_BOOL) {
    89                 ESCAPE("Unable to determine whether cell pattern correction should be applied.");
    90             }
    91             if (doPattern->data.B) {
    92                 tweak->data.U8[i] = 0xFF;
    93             }
     85
     86            bool doPattern = false;
     87            if (!doPatternForView(&doPattern, config, chip, view, RECIPE_NAME, "PATTERN.CELL.SUBSET")) {
     88                ESCAPE(false, "Unable to determine whether row pattern matching should be applied.");
     89            }
     90            if (doPattern) {
     91                tweak->data.U8[i] = 0xFF;
     92            }
    9493        }
    9594
     
    108107}
    109108
     109static bool doPatternForView (bool *doit, const pmConfig *config, const pmChip *chip, const pmFPAview *view, const char *recipeName, const char *recipeValue) {
    110110
     111    *doit = false;
     112
     113    psMetadataItem *doPattern = pmConfigRecipeValueByView(config, recipeName, recipeValue, chip->parent, view);
     114    if (!doPattern) {
     115        psError(PS_ERR_UNKNOWN, false, "Unable to determine whether row pattern matching should be applied.");
     116        return false;
     117    }
     118    if (doPattern->type == PS_DATA_BOOL) {
     119        *doit = doPattern->data.B;
     120        return true;
     121    }
     122    if (doPattern->type == PS_DATA_STRING) {
     123        // expect a string of the form "000110001001" with at least view->cell entries
     124        char *string = doPattern->data.str;
     125        if (strlen(string) < view->cell) {
     126            psError(PS_ERR_UNKNOWN, true, "error in PATTERN.ROW.SUBSET chip string (too few elements %d)", (int) strlen(string));
     127            return false;
     128        }
     129        switch (string[view->cell]) {
     130          case '0':
     131          case 'f':
     132          case 'F':
     133          case 'n':
     134          case 'N':
     135            *doit = false;
     136            return true;
     137          case '1':
     138          case 't':
     139          case 'T':
     140          case 'y':
     141          case 'Y':
     142            *doit = true;
     143            return true;
     144          default:
     145            psError(PS_ERR_UNKNOWN, true, "error in PATTERN.ROW.SUBSET chip string %s (unknown value %c))", string, string[view->cell]);
     146            return false;
     147        }
     148        psAbort("imposible to reach here");
     149    }
     150    psError(PS_ERR_UNKNOWN, true, "error in PATTERN.ROW.SUBSET : invalid data type");
     151    return false;
     152}
Note: See TracChangeset for help on using the changeset viewer.