IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/pap

  • branches/pap/ppImage

    • Property svn:mergeinfo deleted
  • 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        }
Note: See TracChangeset for help on using the changeset viewer.