IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25027 for branches/pap/ppImage


Ignore:
Timestamp:
Aug 7, 2009, 4:08:25 PM (17 years ago)
Author:
Paul Price
Message:

Merging trunk (r25026) to get up-to-date on old branch.

Location:
branches/pap
Files:
17 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/pap

  • branches/pap/ppImage

    • Property svn:mergeinfo deleted
  • branches/pap/ppImage/notes.txt

    r14620 r25027  
    11
    2 ppImage pmFPAfiles:
     220090611 : adjusting things to allow the readnoise to be an image map for each cell
    33
    4     pmFPAfile *input = pmFPAfileDefineFromArgs (&status, config, "PPIMAGE.INPUT", "INPUT");
    5     pmFPAfile *inputMask = pmFPAfileBindFromArgs(&status, input, config, "PPIMAGE.INPUT.MASK", "INPUT.MASK");
    6     pmFPAfile *inputWeight = pmFPAfileBindFromArgs(&status, input, config, "PPIMAGE.INPUT.WEIGHT", "INPUT.WEIGHT");
    7     pmFPAfile *output = pmFPAfileDefineOutput(config, input->fpa, "PPIMAGE.OUTPUT");
    8     pmFPAfile *outMask = pmFPAfileDefineOutput(config, input->fpa, "PPIMAGE.OUTPUT.MASK");
    9     pmFPAfile *outWeight = pmFPAfileDefineOutput(config, input->fpa, "PPIMAGE.OUTPUT.WEIGHT");
    10     pmFPAfile *chipImage = pmFPAfileDefineChipMosaic(config, input->fpa, "PPIMAGE.CHIP");
    11     pmFPAfile *chipMask = pmFPAfileDefineOutput(config, chipImage->fpa, "PPIMAGE.CHIP.MASK");
    12     pmFPAfile *chipWeight = pmFPAfileDefineOutput(config, chipImage->fpa, "PPIMAGE.CHIP.WEIGHT");
    13     pmFPAfile *byFPA1 = pmFPAfileDefineFPAMosaic(config, input->fpa, "PPIMAGE.OUTPUT.FPA1");
    14     pmFPAfile *byFPA2 = pmFPAfileDefineFPAMosaic(config, input->fpa, "PPIMAGE.OUTPUT.FPA2");
     4  * pmReadoutSetVaraince : when variance is created, we are suppling a single CELL.READNOISE value -- change this to an optional image (carried through concepts?)
    155
    16         pmFPAfile *psphotInput = pmFPAfileDefineFromFPA (config, chipImage->fpa, 1, 1, "PSPHOT.INPUT");
    17         pmFPAfile *psphotOutput = psMetadataLookupPtr (&status, config->files, "PSPHOT.OUTPUT");
    18         pmFPAfile *psastroInput = pmFPAfileDefineInput (config, psphotOutput->fpa, "PSASTRO.INPUT");
     6  I need to:
    197
    20     pmFPAfile *bin1 = pmFPAfileDefineFromFPA (config, chipImage->fpa, options->xBin1, options->yBin1, "PPIMAGE.BIN1");
    21     pmFPAfile *bin2 = pmFPAfileDefineFromFPA (config, chipImage->fpa, options->xBin2, options->yBin2, "PPIMAGE.BIN2");
    22     pmFPAfile *jpg1 = pmFPAfileDefineOutput (config, byFPA1->fpa, "PPIMAGE.JPEG1");
    23     pmFPAfile *jpg2 = pmFPAfileDefineOutput (config, byFPA2->fpa, "PPIMAGE.JPEG2");
     8  * define a format for the readnoise map (image map in SPLIT/MEF format?)
     9  * load the readnoise map
     10
     11  * supply the map for each cell to the pmReadoutSetVariance (pointer to ppImageMap?)
     12    pmReadoutSetVariance -> add psImageMap to API (also pmReadoutGenerateVariance)
     13
     14  * add recipe information to define the source of the READNOISE info.
     15
  • branches/pap/ppImage/src/Makefile.am

    r23845 r25027  
    5454        ppImageDefineFile.c \
    5555        ppImageSetMaskBits.c \
     56        ppImageParityFlip.c \
    5657        ppImageCheckCTE.c \
    5758        ppImageFileCheck.c \
  • branches/pap/ppImage/src/ppImage.h

    r23845 r25027  
    3131    bool doNonLin;                      // Non-linearity correction
    3232    bool doOverscan;                    // Overscan subtraction
     33    bool doNoiseMap;                    // Bias subtraction
    3334    bool doBias;                        // Bias subtraction
    3435    bool doDark;                        // Dark subtraction
     
    3637    bool doShutter;                     // Shutter correction
    3738    bool doFlat;                        // Flat-field normalisation
     39    bool doPattern;                     // Pattern noise subtraction
    3840    bool doFringe;                      // Fringe subtraction
    3941    bool doPhotom;                      // Source identification and photometry
     
    4345    bool doStats;                       // call ppStats on the image
    4446    bool checkCTE;                      // measure pixel-based variance
    45 
    46     bool doCrosstalkMeasure;            // measure crosstalk signal
    47     bool doCrosstalkCorrect;            // apply crosstalk correction
     47    bool applyParity;                   // Apply Cell parities
     48
     49    bool doCrosstalkMeasure;            // measure crosstalk signal
     50    bool doCrosstalkCorrect;            // apply crosstalk correction
    4851
    4952    // output files requested
     
    6972    psImageMaskType lowMask;            // Mask value to give bad pixels
    7073    psImageMaskType flatMask;           // Mask value to give bad flat pixels
     74    psImageMaskType darkMask;           // Mask value to give bad dark pixels
    7175    psImageMaskType blankMask;          // Mask value to give blank pixels
    7276
     
    8993    int fringeIter;                     // Fringe iterations
    9094    float fringeKeep;                   // Fringe keep fraction
     95
     96    // Pattern noise subtraction
     97    int patternOrder;                   // Polynomial order
     98    int patternIter;                    // Clipping iterations
     99    float patternRej;                   // Clipping threshold
     100    float patternThresh;                // Ignore threshold
     101    psStatsOptions patternMean;         // Statistic for mean
     102    psStatsOptions patternStdev;        // Statistic for stdev
    91103
    92104    int remnanceSize;                   // Size for remnance detection
     
    117129bool ppImageSetMaskBits (pmConfig *config, ppImageOptions *options);
    118130
     131// apply the cell flips to the input data before analysis
     132bool ppImageParityFlip (pmConfig *config, const ppImageOptions *options, const pmFPAview *view);
     133
    119134// Loop over the input
    120135bool ppImageLoop(pmConfig *config, ppImageOptions *options);
  • branches/pap/ppImage/src/ppImageArguments.c

    r23268 r25027  
    1717    fprintf(stderr, "\n");
    1818    fprintf(stderr, "Input options (single file / file list):\n");
     19    fprintf(stderr, "\t-noisemap/-noisemaplist: Noise Map image.\n");
    1920    fprintf(stderr, "\t-bias/-biaslist: Bias image.\n");
    2021    fprintf(stderr, "\t-dark/-darklist: Dark image.\n");
     
    112113    // if these command-line options are supplied, load the file name lists into config->arguments
    113114    // override any configuration-specified source for these files
     115    pmConfigFileSetsMD (config->arguments, &argc, argv, "NOISEMAP", "-noisemap", "-noisemaplist");
    114116    pmConfigFileSetsMD (config->arguments, &argc, argv, "BIAS", "-bias", "-biaslist");
    115117    pmConfigFileSetsMD (config->arguments, &argc, argv, "DARK", "-dark", "-darklist");
  • branches/pap/ppImage/src/ppImageCheckCTE.c

    r23411 r25027  
    6060            fineRegion = psImageBinningSetFineRegion (binning, ruffRegion);
    6161            fineRegion = psRegionForImage (image, fineRegion);
    62             if (fineRegion.x0 >= image->numCols || fineRegion.x1 >= image->numCols ||
    63                 fineRegion.y0 >= image->numRows || fineRegion.y1 >= image->numRows) {
    64                 continue;
    65             }
     62            if (fineRegion.x0 >= image->numCols) continue;
     63            if (fineRegion.y0 >= image->numRows) continue;
    6664
    6765            psImage *subset  = psImageSubset (image, fineRegion);
     
    8583            float normVariance = PS_SQR(stats->robustStdev) / cellMedian;
    8684            // float normVariance = PS_SQR(stats->sampleStdev) / cellMedian;
     85            // if (!isfinite(normVariance)) fprintf (stderr, "** normVariance is nan **\n");
    8786
    8887            // apply resulting value to the input pixels
    8988            for (int jy = fineRegion.y0; jy < fineRegion.y1; jy++) {
     89              if (jy < 0) continue;
     90              if (jy >= image->numRows) continue;
    9091              for (int jx = fineRegion.x0; jx < fineRegion.x1; jx++) {
     92                if (jx < 0) continue;
     93                if (jx >= image->numCols) continue;
    9194                image->data.F32[jy][jx] = normVariance;
    9295              }
  • branches/pap/ppImage/src/ppImageDetrendFree.c

    r20774 r25027  
    88static char *detrendTypes[] = {
    99    "PPIMAGE.MASK",
     10    "PPIMAGE.NOISEMAP",
    1011    "PPIMAGE.BIAS",
    1112    "PPIMAGE.DARK",
  • branches/pap/ppImage/src/ppImageDetrendFringe.c

    r18969 r25027  
    1111    PS_ASSERT_PTR_NON_NULL(options, false);
    1212
    13     // Reference fringe measurements
    14     psArray *references = psMemIncrRefCounter(psMetadataLookupPtr(NULL, fringe->analysis,
    15                                                                   "FRINGE.MEASUREMENTS"));
     13    // Reference fringe measurements (stored on the reference cell->analysis)
     14    psArray *references = psMemIncrRefCounter(psMetadataLookupPtr(NULL, fringe->analysis, "FRINGE.MEASUREMENTS"));
    1615    if (!references) {
    17         references = pmFringesParse(fringe); // Reference fringes
    18         if (!references) {
    19             psError(PS_ERR_IO, false, "Unable to find fringe references.\n");
    20             return false;
    21         }
    22         psMetadataAdd(fringe->analysis, PS_LIST_TAIL, "FRINGE.MEASUREMENTS", PS_DATA_UNKNOWN,
    23                       "Fringe measurements", references);
     16        psError(PS_ERR_IO, false, "Unable to find fringe references.\n");
     17        return false;
    2418    }
    2519
     
    7569    }
    7670
    77     psMetadataAdd(readout->parent->analysis, PS_LIST_TAIL, scienceFringes,
    78                   PS_DATA_UNKNOWN | PS_META_REPLACE, "Fringe measurements", measurements);
     71    psMetadataAdd(readout->parent->analysis, PS_LIST_TAIL, scienceFringes, PS_DATA_UNKNOWN | PS_META_REPLACE, "Fringe measurements", measurements);
    7972    psFree(measurements);
    8073    psFree(scienceFringes);
     
    9285    psArray *fringes = psArrayAlloc(cells->n); // Fringes, to return
    9386    for (int i = 0; i < cells->n; i++) {
     87        fringes->data[i] = NULL;
     88
    9489        pmCell *cell = cells->data[i];  // Cell of interest
    9590
    9691        // XXX for now, skip the video cells (cell->readouts->n > 1)
    9792        if (cell->readouts->n > 1) {
    98           psWarning ("Skipping Video Cell for ppImageDetrendFringe.c:getFringes");
    99           continue;
     93            psWarning ("Skipping Video Cell (%d) for ppImageDetrendFringe.c:getFringes", i);
     94            continue;
    10095        }
    10196
     
    197192    }
    198193    assert(fringes->readouts->n == solution->nFringeFrames);
     194
     195    psImageMaskType maskVal = options->flatMask;
    199196
    200197    bool mdok;                          // Status of MD lookup
     
    262259        }
    263260
     261        // subtract fringe and update mask if fringe value is NAN
     262        for (int iy = 0; iy < readout->image->numRows; iy++) {
     263            for (int ix = 0; ix < readout->image->numCols; ix++) {
     264                readout->image->data.F32[iy][ix] -= sumFringe->data.F32[iy][ix];
     265                if (!isfinite(sumFringe->data.F32[iy][ix]) && readout->mask) {
     266                    readout->mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= maskVal;
     267                }
     268            }
     269        }
     270
    264271        // XXX: Make generic, so subregions may be subtracted as well
    265         if (!psBinaryOp(readout->image, readout->image, "-", sumFringe)) {
    266             psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to subtract fringe.\n");
    267             return false;
    268         }
     272        // if (!psBinaryOp(readout->image, readout->image, "-", sumFringe)) {
     273        //     psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to subtract fringe.\n");
     274        //     return false;
     275        // }
    269276
    270277        // measure residual fringe amplitude. results go to FRINGE.RESIDUALS
  • branches/pap/ppImage/src/ppImageDetrendReadout.c

    r23825 r25027  
    1717    // Masking on the basis of pixel value needs to be done before anything else, so the values are pristine.
    1818    if (options->doMaskBuild) {
    19         psImageMaskType satMask = options->doMaskSat ? options->satMask : 0;
    20         psImageMaskType lowMask = options->doMaskLow ? options->lowMask : 0;
     19        psImageMaskType satMask = options->doMaskSat ? options->satMask : 0;
     20        psImageMaskType lowMask = options->doMaskLow ? options->lowMask : 0;
    2121        pmReadoutGenerateMask(input, satMask, lowMask);
    2222    }
     
    5656        if (!pmBiasSubtract(input, options->overscan, bias, oldDark, view)) {
    5757            psError(PS_ERR_UNKNOWN, false, "Unable to subtract bias.");
    58             psFree(detview);
     58            psFree(detview);
    5959            return false;
    6060        }
     
    6464    if (options->doVarianceBuild) {
    6565        // create the target mask and variance images
    66         pmReadoutGenerateVariance(input, true);
     66        psImage *noiseImage = NULL;
     67        if (options->doNoiseMap) {
     68            // XXX convert the noiseMap image to a binned image
     69            pmReadout *noiseMap = NULL;
     70            noiseMap = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.NOISEMAP");
     71            noiseImage = psImageCopy (NULL, input->image, PS_TYPE_F32);
     72            psImageInit (noiseImage, 0.0);
     73
     74            // XXX this works, but is not really quite right: the model shoud include the
     75            // offset information, we are not really getting exactly the right mapping from the
     76            // original file.
     77            psImageBinning *binning = psImageBinningAlloc();
     78            binning->nXruff = noiseMap->image->numCols;
     79            binning->nYruff = noiseMap->image->numRows;
     80            binning->nXfine = input->image->numCols;
     81            binning->nYfine = input->image->numRows;
     82            psImageBinningSetScale(binning, PS_IMAGE_BINNING_LEFT);
     83
     84            psImageUnbin (noiseImage, noiseMap->image, binning);
     85            psFree (binning);
     86        }
     87        pmReadoutGenerateVariance(input, noiseImage, true);
     88        psFree (noiseImage);
    6789    }
    6890
    6991    if (options->doDark && dark) {
    70         if (!pmDarkApply(input, dark, options->maskValue)) {
     92        if (!pmDarkApply(input, dark, options->darkMask)) {
    7193            psError(PS_ERR_UNKNOWN, false, "Unable to subtract dark.");
    72             psFree(detview);
     94            psFree(detview);
    7395            return false;
    7496        }
     
    79101                        options->remnanceSize, options->remnanceThresh)) {
    80102            psError(PS_ERR_UNKNOWN, false, "Unable to mask remnance.");
    81             psFree(detview);
     103            psFree(detview);
    82104            return false;
    83105        }
     
    88110        pmReadout *shutter = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.SHUTTER");
    89111        if (!pmShutterCorrectionApply(input, shutter, pmConfigMaskGet("FLAT", config))) {
    90             psFree(detview);
     112            psFree(detview);
    91113            return false;
    92114        }
     
    97119        pmReadout *flat = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.FLAT");
    98120        if (!pmFlatField(input, flat, options->flatMask)) {
    99             psFree(detview);
     121            psFree(detview);
     122            return false;
     123        }
     124    }
     125
     126    // Pattern noise correction
     127    if (options->doPattern) {
     128        if (!pmPatternRow(input, options->patternOrder, options->patternIter, options->patternRej,
     129                          options->patternThresh, options->patternMean, options->patternStdev,
     130                          options->maskValue, options->darkMask)) {
     131            psFree(detview);
    100132            return false;
    101133        }
     
    119151    psMetadata *normlist = psMetadataLookupMetadata(&mdok, config->arguments, "NORMALIZATION.TABLE");
    120152    if (normlist) {
    121         pmFPAfile *inputFile = psMetadataLookupPtr(&mdok, config->files, "PPIMAGE.INPUT");
    122 
    123         // get the menu of class IDs
    124         psMetadata *menu = psMetadataLookupMetadata(&mdok, inputFile->camera, "CLASSID"); 
     153        pmFPAfile *inputFile = psMetadataLookupPtr(&mdok, config->files, "PPIMAGE.INPUT");
     154
     155        // get the menu of class IDs
     156        psMetadata *menu = psMetadataLookupMetadata(&mdok, inputFile->camera, "CLASSID");
    125157        if (!menu) {
    126158            psError(PS_ERR_IO, false, "Unable to find CLASSID metadata in camera configuration");
    127             psFree(detview);
    128             return false;
    129         }
    130         // get the rule for class_id for the desired class
    131         const char *rule = psMetadataLookupStr(&mdok, menu, options->normClass); 
     159            psFree(detview);
     160            return false;
     161        }
     162        // get the rule for class_id for the desired class
     163        const char *rule = psMetadataLookupStr(&mdok, menu, options->normClass);
    132164        if (!rule) {
    133165            psError(PS_ERR_IO, false, "Unable to find NORM.CLASS value %s in CLASSID in camera configuration", options->normClass);
    134             psFree(detview);
    135             return false;
    136         }
    137         // get the class_id from the rule
     166            psFree(detview);
     167            return false;
     168        }
     169        // get the class_id from the rule
    138170        char *classID = pmFPAfileNameFromRule(rule, inputFile, view);
    139171        if (!classID) {
    140172            psError(PS_ERR_IO, false, "error converting CLASSID rule %s to name\n", rule);
    141             psFree(detview);
    142             return false;
    143         }
    144 
    145         // get normalization from the class_id
    146         float norm = psMetadataLookupF32 (&mdok, normlist, classID);
    147         if (!mdok) {
    148             psError(PS_ERR_IO, false, "failed to find class ID %s in normalization table\n", classID);
    149             psFree(detview);
    150             return false;
    151         }
     173            psFree(detview);
     174            return false;
     175        }
     176
     177        // get normalization from the class_id
     178        float norm = psMetadataLookupF32 (&mdok, normlist, classID);
     179        if (!mdok) {
     180            psError(PS_ERR_IO, false, "failed to find class ID %s in normalization table\n", classID);
     181            psFree(detview);
     182            return false;
     183        }
    152184
    153185        pmHDU *hdu = pmHDUFromReadout(input); // HDU of interest
     
    157189        psFree(comment);
    158190
    159         // apply the normalization
     191        // apply the normalization
    160192        psBinaryOp(input->image, input->image, "*", psScalarAlloc(norm, PS_TYPE_F32));
    161193
    162         psFree (classID);
     194        psFree (classID);
    163195    }
    164196# endif
     
    167199        pmCell *fringe = pmFPAfileThisCell(config->files, detview, "PPIMAGE.FRINGE");
    168200        if (!ppImageDetrendFringeMeasure(input, fringe, false, options)) {
    169             psFree(detview);
     201            psFree(detview);
    170202            return false;
    171203        }
  • branches/pap/ppImage/src/ppImageDetrendRecord.c

    r20773 r25027  
    6767    psMetadataAddMetadata(cell->analysis, PS_LIST_TAIL, "DETREND", 0, "Detrend information", detrend);
    6868
    69     detrendRecord(options->doMask, detrend, config, view, "PPIMAGE.MASK", "DETREND.MASK", "Mask filename");
    70     detrendRecord(options->doBias, detrend, config, view, "PPIMAGE.BIAS", "DETREND.BIAS", "Bias filename");
    71     detrendRecord(options->doDark, detrend, config, view, "PPIMAGE.DARK", "DETREND.DARK", "Dark filename");
    72     detrendRecord(options->doShutter, detrend, config, view, "PPIMAGE.SHUTTER", "DETREND.SHUTTER",
    73                   "Shutter correction filename");
    74     detrendRecord(options->doFlat, detrend, config, view, "PPIMAGE.FLAT", "DETREND.FLAT", "Flat filename");
    75     detrendRecord(options->doFringe, detrend, config, view, "PPIMAGE.FRINGE", "DETREND.FRINGE",
    76                   "Fringe filename");
     69    detrendRecord(options->doMask,     detrend, config, view, "PPIMAGE.MASK",     "DETREND.MASK",     "Mask filename");
     70    detrendRecord(options->doNoiseMap, detrend, config, view, "PPIMAGE.NOISEMAP", "DETREND.NOISEMAP", "Noise Map filename");
     71    detrendRecord(options->doBias,     detrend, config, view, "PPIMAGE.BIAS",     "DETREND.BIAS",     "Bias filename");
     72    detrendRecord(options->doDark,     detrend, config, view, "PPIMAGE.DARK",     "DETREND.DARK",     "Dark filename");
     73    detrendRecord(options->doShutter,  detrend, config, view, "PPIMAGE.SHUTTER",  "DETREND.SHUTTER",  "Shutter correction filename");
     74    detrendRecord(options->doFlat,     detrend, config, view, "PPIMAGE.FLAT",     "DETREND.FLAT",     "Flat filename");
     75    detrendRecord(options->doFringe,   detrend, config, view, "PPIMAGE.FRINGE",   "DETREND.FRINGE",   "Fringe filename");
    7776
    7877    psFree (detrend);
  • branches/pap/ppImage/src/ppImageLoop.c

    r23845 r25027  
    9898                    continue;
    9999                }
     100
     101                // perform the detrend analysis
     102                if (!ppImageParityFlip(config, options, view)) {
     103                    ESCAPE("Unable to detrend readout");
     104                }
     105
     106                // XXX TEST:
     107                // psphotSaveImage (NULL, readout->image, "test.image.fits");
    100108
    101109                // XXX set the options->*Mask values here (after the mask images have been loaded
  • branches/pap/ppImage/src/ppImageMeasureCrosstalk.c

    r23903 r25027  
    149149
    150150                psStatsInit (stats);
    151                 psVectorStats (stats, vector, NULL, NULL, 0);
     151                if (!psVectorStats (stats, vector, NULL, NULL, 0)) {
     152                    psError(PS_ERR_UNKNOWN, false, "failure to measure stats");
     153                    return false;
     154                }
    152155                   
    153156                float background = psMetadataLookupF32 (&status, cell->analysis, "XTALK.REF");
  • branches/pap/ppImage/src/ppImageOptions.c

    r23845 r25027  
    2525    options->doNonLin        = false;   // Non-linearity correction
    2626    options->doOverscan      = false;   // Overscan subtraction
     27    options->doNoiseMap      = false;   // Apply Read Noise Map
    2728    options->doBias          = false;   // Bias subtraction
    2829    options->doDark          = false;   // Dark subtraction
     
    3031    options->doShutter       = false;   // Shutter correction
    3132    options->doFlat          = false;   // Flat-field normalisation
     33    options->doPattern       = false;   // Pattern noise subtraction
    3234    options->doFringe        = false;   // Fringe subtraction
    3335    options->doPhotom        = false;   // Source identification and photometry
     
    3638    options->doStats         = false;   // Measure and save image statistics
    3739    options->checkCTE        = false;   // Measure pixel-based variance
     40    options->applyParity     = false;   // Apply Cell parities
    3841
    3942    // output files requested
     
    5861    options->lowMask         = 0x00;    // out-of-bounds (low) pixels (supplied to pmReadoutGenerateMask)
    5962    options->flatMask        = 0x00;    // Bad flat pixels (supplied to pmFlatField)
     63    options->darkMask        = 0x00;    // Bad dark pixels (supplied to pmDarkApply)
    6064    options->blankMask       = 0x00;    // Blank (no data, cell gap) pixels (supplied to pmChipMosaic, pmFPAMosaic)
    6165    options->markValue       = 0x00;    // A safe bit for internal marking
     
    8387    options->fringeIter      = 0;       // Fringe iterations
    8488    options->fringeKeep      = 1.0;     // Fringe keep fraction
     89
     90    // Pattern noise values
     91
     92    options->patternOrder    = 0;       // Polynomial order
     93    options->patternIter     = 0;       // Clipping iterations
     94    options->patternRej      = NAN;     // Clipping rejection threshold
     95    options->patternThresh   = NAN;     // Threshold for ignoring pixels
     96    options->patternMean     = PS_STAT_NONE; // Statistic for mean
     97    options->patternStdev    = PS_STAT_NONE; // Statistic for standard deviation
    8598
    8699    // Remnance values
     
    215228    options->doCrosstalkCorrect = psMetadataLookupBool(NULL, recipe, "CROSSTALK.CORRECT");
    216229
     230    options->doNoiseMap = psMetadataLookupBool(NULL, recipe, "NOISEMAP");
    217231    options->doBias = psMetadataLookupBool(NULL, recipe, "BIAS");
    218232    options->doDark = psMetadataLookupBool(NULL, recipe, "DARK");
     
    221235    options->doFringe = psMetadataLookupBool(NULL, recipe, "FRINGE");
    222236    options->doShutter = psMetadataLookupBool(NULL, recipe, "SHUTTER");
     237    options->doPattern = psMetadataLookupBool(NULL, recipe, "PATTERN");
    223238
    224239    options->doStats = false;
     
    228243    }
    229244
     245    options->applyParity = psMetadataLookupBool(NULL, recipe, "APPLY.CELL.PARITY");
     246
    230247    // binned image options
    231248    options->xBin1 = psMetadataLookupS32(&status, recipe, "BIN1.XBIN");
     
    274291
    275292    // even if not requested explicitly, if any of these are set, build an internal mask and variance:
    276     if (options->doBias || options->doOverscan || options->doDark || options->doShutter || options->doFlat ||
     293    if (options->doNoiseMap || options->doBias || options->doOverscan || options->doDark || options->doShutter || options->doFlat ||
    277294        options->doPhotom) {
    278295        options->doMaskBuild = true;
     
    292309    options->fringeKeep = psMetadataLookupF32(NULL, recipe, "FRINGE.KEEP");
    293310
     311    // Pattern noise
     312    options->patternOrder = psMetadataLookupS32(NULL, recipe, "PATTERN.ORDER");
     313    options->patternIter = psMetadataLookupS32(NULL, recipe, "PATTERN.ITER");
     314    options->patternRej = psMetadataLookupF32(NULL, recipe, "PATTERN.REJ");
     315    options->patternThresh = psMetadataLookupF32(NULL, recipe, "PATTERN.THRESH");
     316    options->patternMean = psStatsOptionFromString(psMetadataLookupStr(NULL, recipe, "PATTERN.MEAN"));
     317    options->patternStdev = psStatsOptionFromString(psMetadataLookupStr(NULL, recipe, "PATTERN.STDEV"));
     318
    294319    // Remnance options
    295320    options->remnanceSize = psMetadataLookupF32(NULL, recipe, "REMNANCE.SIZE");
  • branches/pap/ppImage/src/ppImageParseCamera.c

    r23411 r25027  
    2525    // otherwise they revert to the config information
    2626    // not all input or output images are used in a given recipe
     27    if (options->doNoiseMap) {
     28        if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.NOISEMAP", "NOISEMAP",
     29                               PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_NOISEMAP)) {
     30            psError(PS_ERR_IO, false, "Can't find a noise map image source");
     31            psFree(options);
     32            return NULL;
     33        }
     34    }
    2735    if (options->doBias) {
    2836        if (!ppImageDefineFile(config, input->fpa, "PPIMAGE.BIAS", "BIAS",
     
    4856            return NULL;
    4957        }
    50 
    51 #if 0
    52         // I think this is now done automatically in the pmFPAfileDefine and pmFPAfileIOChecks -- PAP.
    53 
    54         // XXX have ppImageDefineFile return the pmFPAfile?
    55         pmFPAfile *mask = psMetadataLookupPtr(&status, config->files, "PPIMAGE.MASK");
    56         psAssert(mask, "Just defined the mask!");
    57 
    58         // Need to read the names of bit masks from the mask header and set them in the
    59         // recipe.  If we are loading this from the detrend db, this action will happen
    60         // when the file is resolved.
    61         if (!mask->detrend) {
    62             // XXX need to load the mask bit names from one of the headers
    63             // this grabs the first available hdu : no guarantee that it will be valid, though
    64             pmHDU *hdu = pmHDUGetFirst(mask->fpa);
    65             if (!hdu) {
    66                 psError(PS_ERR_IO, true, "no valid HDU for PPIMAGE.INPUT.MASK");
    67                 return NULL;
    68             }
    69             // XXX is this consistent with the pmConfigMaskReadHeader call above?
    70             if (!pmConfigMaskReadHeader(config, hdu->header)) {
    71                 psError(PS_ERR_IO, false, "error in mask bits");
    72                 return NULL;
    73             }
    74         }
    75 #endif
    7658    }
    7759    if (options->doShutter) {
  • branches/pap/ppImage/src/ppImageReplaceBackground.c

    r23825 r25027  
    144144    for (int y = 0; y < numRows; y++) {
    145145        for (int x = 0; x < numCols; x++) {
    146             float value = backData[y][x];
    147             if (!isfinite(value)) {
    148                 image->data.F32[y][x] = NAN;
    149                 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= options->lowMask;
     146            if (mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) {
     147                image->data.F32[y][x] = 0.0;
    150148            } else {
    151                 image->data.F32[y][x] -= value;
    152             }
     149                float value = backData[y][x];
     150                if (!isfinite(value)) {
     151                    image->data.F32[y][x] = NAN;
     152                    mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= options->lowMask;
     153                } else {
     154                    image->data.F32[y][x] -= value;
     155                }
     156            }
    153157        }
    154158    }
  • branches/pap/ppImage/src/ppImageSetMaskBits.c

    r23825 r25027  
    1414    // at this point we know we have valid values for required entries SAT, BAD, FLAT, BLANK:
    1515
    16     // mask for non-linear flat corrections
     16    // mask for bad flat corrections
    1717    options->flatMask = pmConfigMaskGet("FLAT", config);
    1818    psAssert (options->flatMask, "flat mask not set");
     19
     20    // mask for bad dark corrections
     21    options->darkMask = pmConfigMaskGet("DARK", config);
     22    psAssert (options->darkMask, "dark mask not set");
    1923
    2024    // mask for non-existent data  (default to DETECTOR if not defined)
Note: See TracChangeset for help on using the changeset viewer.