IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29851


Ignore:
Timestamp:
Nov 26, 2010, 10:47:07 AM (15 years ago)
Author:
eugene
Message:

updates from trunk (non-linearity correction)

Location:
branches/eam_branches/ipp-20101103/ppImage/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101103/ppImage/src/ppImage.h

    r28043 r29851  
    155155bool ppImageDetrendBias(pmReadout *inputReadout, pmReadout *bias, pmReadout *dark, ppImageOptions *options);
    156156
    157 bool ppImageDetrendNonLinear(pmReadout *input, ppImageOptions *options);
     157//bool ppImageDetrendNonLinear(pmReadout *input, ppImageOptions *options);
     158bool ppImageDetrendNonLinear(pmReadout *input, pmFPAview *linearity, pmConfig *config);
    158159bool ppImageDetrendNonLinearLookup(pmReadout *input, psMetadataItem *dataItem);
    159160bool ppImageDetrendNonLinearPolynomial(pmReadout *input, psMetadataItem *dataItem);
  • branches/eam_branches/ipp-20101103/ppImage/src/ppImageArguments.c

    r24485 r29851  
    2424    fprintf(stderr, "\t-mask/-masklist: Mask image.\n");
    2525    fprintf(stderr, "\t-fringe/-fringelist: Fringe image and data.\n");
     26    fprintf(stderr, "\t-linearity/-linearlist: linearity correction file.\n");
    2627    fprintf(stderr, "\n");
    2728    exit (2);
     
    120121    pmConfigFileSetsMD (config->arguments, &argc, argv, "MASK", "-mask", "-masklist");
    121122    pmConfigFileSetsMD (config->arguments, &argc, argv, "FRINGE", "-fringe", "-fringelist");
     123    pmConfigFileSetsMD (config->arguments, &argc, argv, "LINEARITY", "-linearity", "-linearlist");
    122124
    123125    // chip selection is used to limit chips to be processed
  • branches/eam_branches/ipp-20101103/ppImage/src/ppImageDefineFile.c

    r26494 r29851  
    1515        file = pmFPAfileDefineFromArgs(&status, config, filerule, argname);
    1616        if (!status) {
    17             psError(PS_ERR_UNKNOWN, false, "failed to load file definition");
     17            psError(PS_ERR_UNKNOWN, false, "failed to load file definition ARG LIST");
    1818            return false;
    1919        }
     
    2323        file = pmFPAfileDefineFromRun(&status, NULL, config, filerule);
    2424        if (!status) {
    25             psError(PS_ERR_UNKNOWN, false, "failed to load file definition");
     25            psError(PS_ERR_UNKNOWN, false, "failed to load file definition RUN");
    2626            return false;
    2727        }
     
    3131        file = pmFPAfileDefineFromConf(&status, config, filerule);
    3232        if (!status) {
    33             psError(PS_ERR_UNKNOWN, false, "failed to load file definition");
     33            psError(PS_ERR_UNKNOWN, false, "failed to load file definition CONFIG");
    3434            return false;
    3535        }
     
    3939        file = pmFPAfileDefineFromDetDB(&status, config, filerule, input, detrendType);
    4040        if (!status) {
    41             psError(PS_ERR_UNKNOWN, false, "failed to load file definition");
     41            psError(PS_ERR_UNKNOWN, false, "failed to load file definition DETREND");
    4242            return false;
    4343        }
  • branches/eam_branches/ipp-20101103/ppImage/src/ppImageDetrendFree.c

    r24485 r29851  
    1313    "PPIMAGE.FLAT",
    1414    "PPIMAGE.SHUTTER",
     15    "PPIMAGE.LINEARITY",
    1516    NULL
    1617};
     
    2324
    2425        pmFPAfile *file = psMetadataLookupPtr(&status, config->files, detrendTypes[i]); // File of interest
     26        psTrace("pmFPAfileFree",1,"Working on %s\n",detrendTypes[i]);
    2527        if (!file) continue; // not all detrends are used in any given run
    2628
  • branches/eam_branches/ipp-20101103/ppImage/src/ppImageDetrendNonLinear.c

    r11702 r29851  
    4444}
    4545
    46 bool ppImageDetrendNonLinear(pmReadout *input, ppImageOptions *options) {
     46
     47bool ppImageDetrendNonLinear(pmReadout *input, pmFPAview *detview, pmConfig  *config) {
     48    bool status;
     49
     50    pmFPAfile *linearity_file = psMetadataLookupPtr(&status,config->files,"PPIMAGE.LINEARITY");
     51    psFits *linearity_fits = linearity_file->fits;
     52
     53    char *extname = psMetadataLookupStr(&status,input->parent->concepts,"CELL.NAME");
     54    if (!extname) {
     55        psError(PS_ERR_IO, false, "missing CELL.NAME in concepts");
     56        return(false);
     57    }
     58
     59    if (!psFitsMoveExtName(linearity_fits,extname)) {
     60        psError(PS_ERR_IO, false, "Unable to move to non-linearity table %s", extname);
     61        return(false);
     62    }
     63 
     64    psArray *table = psFitsReadTable(linearity_fits);
     65    if (!table) {
     66        psError(PS_ERR_IO, false, "Unable to read non-linearity table.\n");
     67        return(false);
     68    }
     69
     70    // It might be better to pack lookup table here...
     71    // Why? I only use that lookup table once for the single cell it matches.
     72 
     73    if (!pmNonLinearityApply(input,table)) {
     74        psError(PS_ERR_UNKNOWN, false, "Unable to apply non-linearity corrections.\n");
     75        psFree (table);
     76        return(false);
     77    }       
     78    psFree (table);
     79
     80    return true;
     81}
     82
     83bool ppImageDetrendNonLinear_Original(pmReadout *input, ppImageOptions *options) {
    4784
    4885    psMetadataItem *concept;
     
    5996
    6097      case PS_DATA_METADATA:
    61         // XXX EAM: this is somewhat confusing : let's wrap in a function when i understand it
    62 
    6398        // Go looking for the value in the hierarchy
    6499        concept = psMetadataLookup(cell->concepts, options->nonLinearSource);
  • branches/eam_branches/ipp-20101103/ppImage/src/ppImageDetrendReadout.c

    r26653 r29851  
    5151    }
    5252
    53 
    54 # if 0
     53    // Subtract the overscan
     54    if (options->doOverscan) {
     55      if (!pmOverscanSubtract (input, options->overscan)) {
     56        psError(PS_ERR_UNKNOWN, false, "Unable to subtract overscan.");
     57        psFree(detview);
     58        return false;
     59      }
     60    }
     61
    5562    // Non-linearity correction
    5663    if (options->doNonLin) {
    57         ppImageDetrendNonLinear(detrend->input, input, options);
    58     }
    59 # endif
     64      if (!ppImageDetrendNonLinear(input,detview,config)) {
     65        psError(PS_ERR_UNKNOWN, false, "Unable to correct NonLinearity");
     66        psFree(detview);
     67        return(false);
     68      }
     69    }
    6070
    6171    // set up the dark and bias
     
    7787    }
    7888
    79     // Bias, dark and overscan subtraction are all merged.
    80     if (options->doBias || options->doOverscan) {
    81         if (!pmBiasSubtract(input, options->overscan, bias, oldDark, view)) {
     89    // Bias and temperature-independent-dark subtraction are merged.
     90    if (options->doBias) {
     91        if (!pmBiasSubtract(input, bias, oldDark, view)) {
    8292            psError(PS_ERR_UNKNOWN, false, "Unable to subtract bias.");
    8393            psFree(detview);
     
    8595        }
    8696    }
    87 
     97   
    8898    // Weight on the basis of pixel value needs to be done after the overscan has been subtracted
    8999    if (options->doVarianceBuild) {
  • branches/eam_branches/ipp-20101103/ppImage/src/ppImageLoop.c

    r28375 r29851  
    152152            ESCAPE("Unable to free detrend images");
    153153        }
    154 
     154   
    155155        // Apply the fringe correction
    156156        if (options->doFringe) {
  • branches/eam_branches/ipp-20101103/ppImage/src/ppImageOptions.c

    r29658 r29851  
    88{
    99    psFree(options->overscan);
    10     psFree(options->nonLinearData);
    11     psFree(options->nonLinearSource);
     10    // psFree(options->nonLinearData);
     11    // psFree(options->nonLinearSource);
    1212}
    1313
     
    130130        psMetadataItem *dataItem = psMetadataLookup(recipe, "NONLIN.DATA");
    131131        if (! dataItem) {
    132             psLogMsg(__func__, PS_LOG_ERROR, "Non-linearity correction desired, but unable to "
    133                      "find NONLIN.DATA in recipe %s.", RECIPE_NAME);
     132            psLogMsg("ppImage", PS_LOG_ERROR, "Non-linearity correction desired, but unable to find NONLIN.DATA in recipe %s.", RECIPE_NAME);
    134133            exit(EXIT_FAILURE);
    135134        }
     
    147146            // This is a menu; we need the key
    148147          case PS_DATA_METADATA:
    149             {
    150                 bool status;
    151                 options->nonLinearSource = psMetadataLookupStr(&status, recipe, "NONLIN.SOURCE");
    152                 if (! status || ! options->nonLinearSource) {
    153                     psLogMsg(__func__, PS_LOG_ERROR, "Non-linearity correction desired, but unable to "
    154                             "find NONLIN.SOURCE in recipe %s.", RECIPE_NAME);
    155                     exit(EXIT_FAILURE);
    156                 }
    157             }
     148            options->nonLinearSource = psMetadataLookupStr(&status, recipe, "NONLIN.SOURCE");
     149            if (! status || ! options->nonLinearSource) {
     150                psLogMsg("ppImage", PS_LOG_ERROR, "Non-linearity correction desired, but unable to find NONLIN.SOURCE in recipe %s.", RECIPE_NAME);
     151                exit(EXIT_FAILURE);
     152            }
    158153            break;
    159154          default:
    160             psLogMsg(__func__, PS_LOG_ERROR, "Non-linearity correction desired, but "
    161                     "NONLIN.DATA is of invalid type in recipe %s.", RECIPE_NAME);
     155            psLogMsg("ppImage", PS_LOG_ERROR, "Non-linearity correction desired, but NONLIN.DATA is of invalid type in recipe %s.", RECIPE_NAME);
    162156            exit(EXIT_FAILURE);
    163157        }
  • branches/eam_branches/ipp-20101103/ppImage/src/ppImageParseCamera.c

    r26895 r29851  
    7373            return NULL;
    7474        }
     75    }
     76
     77    if (options->doNonLin) {
     78      if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.LINEARITY", "LINEARITY",
     79                             PM_FPA_FILE_LINEARITY, PM_DETREND_TYPE_LINEARITY)) {
     80        psError(PS_ERR_IO, false, "Can't find a non-linearity correction source");
     81        psFree(options);
     82        return NULL;
     83      }
    7584    }
    7685
Note: See TracChangeset for help on using the changeset viewer.