IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19172


Ignore:
Timestamp:
Aug 22, 2008, 2:05:48 PM (18 years ago)
Author:
Paul Price
Message:

Fixing mask values: making a bit more flexible, updating to new pmSubtractionMatch API.

Location:
trunk/ppStack/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack/src/ppStackArguments.c

    r19123 r19172  
    145145    psMetadataAddF32(arguments, PS_LIST_TAIL, "-combine-rej", 0,
    146146                     "Combination rejection thresold (sigma)", NAN);
    147     psMetadataAddU8(arguments,  PS_LIST_TAIL, "-mask-bad", 0, "Mask value for bad pixels", 0);
    148     psMetadataAddU8(arguments,  PS_LIST_TAIL, "-mask-blank", 0, "Mask value for blank region", 0);
     147    psMetadataAddStr(arguments,  PS_LIST_TAIL, "-mask-val", 0, "Mask value of input bad pixels", NULL);
     148    psMetadataAddStr(arguments,  PS_LIST_TAIL, "-mask-bad", 0, "Mask value to give bad pixels", NULL);
     149    psMetadataAddStr(arguments,  PS_LIST_TAIL, "-mask-poor", 0, "Mask value to give poor pixels", NULL);
    149150    psMetadataAddF32(arguments, PS_LIST_TAIL, "-threshold-mask", 0, "Threshold for mask deconvolution", NAN);
    150151    psMetadataAddF32(arguments, PS_LIST_TAIL, "-image-rej", 0,
     
    219220    VALUE_ARG_RECIPE_INT("-iter",             "ITER",           S32, 0);
    220221    VALUE_ARG_RECIPE_FLOAT("-combine-rej",    "COMBINE.REJ",    F32);
    221     VALUE_ARG_RECIPE_MASK("-mask-bad",        "MASK.BAD");
    222     VALUE_ARG_RECIPE_MASK("-mask-blank",      "MASK.BLANK");
    223222    VALUE_ARG_RECIPE_FLOAT("-threshold-mask", "THRESHOLD.MASK", F32);
    224223    VALUE_ARG_RECIPE_FLOAT("-image-rej",      "IMAGE.REJ",      F32);
    225224    VALUE_ARG_RECIPE_INT("-rows",             "ROWS",           S32, 0);
     225
     226    valueArgRecipeStr(arguments, recipe, "-mask-val",  "MASK.VAL",  recipe);
     227    valueArgRecipeStr(arguments, recipe, "-mask-bad",  "MASK.BAD",  recipe);
     228    valueArgRecipeStr(arguments, recipe, "-mask-poor", "MASK.POOR", recipe);
    226229
    227230    VALUE_ARG_RECIPE_FLOAT("-source-radius", "SOURCE.RADIUS", F32);
  • trunk/ppStack/src/ppStackLoop.c

    r19072 r19172  
    803803        if (stats) {
    804804            psTrace("ppStack", 1, "Gathering statistics on stacked image....\n");
    805             ppStatsFPA(stats, outCell->parent->parent, view, pmConfigMaskGet("BLANK", config), config);
     805            psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits for bad
     806            psMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
     807
     808            ppStatsFPA(stats, outCell->parent->parent, view, maskBad, config);
    806809        }
    807810
  • trunk/ppStack/src/ppStackMatch.c

    r19123 r19172  
    3434    int size = psMetadataLookupS32(NULL, ppsub, "KERNEL.SIZE"); // Kernel half-size
    3535
    36     psMaskType maskIn = pmConfigMaskGet("MASK.VALUE", config); // Bits to mask going in to pmSubtractionMatch
    37     psMaskType maskOut = pmConfigMaskGet("BLANK", config); // Bits to mask after pmSubtractionMatch
     36    psString maskValStr = psMetadataLookupStr(NULL, recipe, "MASK.VAL"); // Name of bits to mask going in
     37    psMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch
     38    psString maskPoorStr = psMetadataLookupStr(NULL, recipe, "MASK.POOR"); // Name of bits to mask for poor
     39    psMaskType maskPoor = pmConfigMaskGet(maskPoorStr, config); // Bits to mask for poor pixels
     40    psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits to mask for bad
     41    psMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
    3842
    3943    bool mdok;                          // Status of MD lookup
     
    4549    int threads = psMetadataLookupS32(NULL, config->arguments, "-threads"); // Number of threads
    4650
    47     if (!pmReadoutMaskNonfinite(readout, maskIn)) {
     51    if (!pmReadoutMaskNonfinite(readout, maskVal)) {
    4852        psError(PS_ERR_UNKNOWN, false, "Unable to mask non-finite pixels in readout.");
    4953        return false;
     
    7579        float optThresh = psMetadataLookupF32(&mdok, ppsub, "OPTIMUM.TOL"); // Tolerance for search
    7680        int optOrder = psMetadataLookupS32(&mdok, ppsub, "OPTIMUM.ORDER"); // Order for search
     81        float poorFrac = psMetadataLookupF32(&mdok, ppsub, "POOR.FRACTION"); // Fraction for "poor"
    7782
    7883        // These values are specified specifically for stacking
     
    8792        {
    8893            psStats *bg = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics for bg
    89             if (!psImageBackground(bg, NULL, readout->image, readout->mask, maskIn, rng)) {
     94            if (!psImageBackground(bg, NULL, readout->image, readout->mask, maskVal, rng)) {
    9095                psWarning("Can't measure background for image.");
    9196                psErrorClear();
     
    136141                                sources, stampsName, type, size, order, widths, orders, inner, ringsOrder,
    137142                                binning, penalty, optimum, optWidths, optOrder, optThresh, iter, rej,
    138                                 maskIn, maskOut, badFrac, PM_SUBTRACTION_MODE_1)) {
     143                                maskVal, maskBad, maskPoor, poorFrac, badFrac, PM_SUBTRACTION_MODE_1)) {
    139144            psError(PS_ERR_UNKNOWN, false, "Unable to match images.");
    140145            psFree(fake);
     
    226231    if (renorm) {
    227232        psLogMsg("ppStack", PS_LOG_INFO, "Renormalising variance map.");
    228         if (!pmReadoutWeightRenorm(readout, maskOut, renormMean, renormStdev, renormWidth, rng)) {
     233        if (!pmReadoutWeightRenorm(readout, maskBad, renormMean, renormStdev, renormWidth, rng)) {
    229234            psError(PS_ERR_UNKNOWN, false, "Unable to renormalise variances.");
    230235            psFree(output);
     
    235240    // Ensure the background value is zero
    236241    psStats *bg = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics for background
    237     if (!psImageBackground(bg, NULL, readout->image, readout->mask, maskOut, rng)) {
     242    if (!psImageBackground(bg, NULL, readout->image, readout->mask, maskVal | maskBad, rng)) {
    238243        psWarning("Can't measure background for image.");
    239244        psErrorClear();
  • trunk/ppStack/src/ppStackReadout.c

    r18918 r19172  
    1010#include "ppStack.h"
    1111
    12 //#define REJECTION_FILES                 // Write rejection mask?
    13 //#define INSPECTION_FILES                // Write inspection mask?
    14 //#define COMBINED_FILES                  // Write combined images?
     12#define REJECTION_FILES                 // Write rejection mask?
     13#define INSPECTION_FILES                // Write inspection mask?
     14#define COMBINED_FILES                  // Write combined images?
    1515
    1616
     
    3434    int iter = psMetadataLookupS32(NULL, recipe, "ITER"); // Rejection iterations
    3535    float combineRej = psMetadataLookupF32(NULL, recipe, "COMBINE.REJ"); // Combination threshold
    36     psMaskType maskVal = pmConfigMaskGet("BLANK", config); // Value to mask
    3736    bool useVariance = psMetadataLookupBool(&mdok, recipe, "VARIANCE"); // Use variance for rejection?
    3837    bool safe = psMetadataLookupBool(&mdok, recipe, "SAFE"); // Be safe when combining small numbers of pixels
     
    4039    psMetadata *ppsub = psMetadataLookupMetadata(NULL, config->recipes, "PPSUB"); // PPSUB recipe
    4140    int kernelSize = psMetadataLookupS32(NULL, ppsub, "KERNEL.SIZE"); // Kernel half-size
     41
     42    psString maskValStr = psMetadataLookupStr(NULL, recipe, "MASK.VAL"); // Name of bits to mask going in
     43    psMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch
     44    psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits to mask for bad
     45    psMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
    4246
    4347    int num = readouts->n;              // Number of inputs
     
    6771    }
    6872
    69     if (!pmStackCombine(outRO, stack, maskVal, maskVal, kernelSize, iter, combineRej, true,
     73    if (!pmStackCombine(outRO, stack, maskVal | maskBad, maskBad, kernelSize, iter, combineRej, true,
    7074                        useVariance, safe)) {
    7175        psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts with rejection.");
     
    9397                                            psRegionSet(0, outRO->image->numCols - 1,
    9498                                                        0, outRO->image->numRows - 1),
    95                                             maskVal);
     99                                            maskBad);
    96100        psString name = NULL;           // Name of image
    97101        psStringAppend(&name, "inspect_%03d_%03d.fits", sectionNum, i);
     
    143147
    144148    bool mdok;                          // Status of MD lookup
    145     psMaskType maskVal = pmConfigMaskGet("BLANK", config); // Value to mask
    146149    bool useVariance = psMetadataLookupBool(&mdok, recipe, "VARIANCE"); // Use variance for rejection?
     150
     151    psString maskValStr = psMetadataLookupStr(NULL, recipe, "MASK.VAL"); // Name of bits to mask going in
     152    psMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch
     153    psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits to mask for bad
     154    psMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
    147155
    148156    int num = readouts->n;              // Number of inputs
     
    210218                                             psRegionSet(0, outRO->image->numCols - 1,
    211219                                                         0, outRO->image->numRows - 1),
    212                                              maskVal);
     220                                             maskBad);
    213221            psString name = NULL;           // Name of image
    214222            psStringAppend(&name, "reject_%03d.fits", i);
     
    222230#endif
    223231
    224     if (!pmStackCombine(outRO, stack, maskVal, maskVal, 0, 0, NAN, numGood != num, useVariance, false)) {
     232    if (!pmStackCombine(outRO, stack, maskVal | maskBad, maskBad, 0, 0, NAN,
     233                        numGood != num, useVariance, false)) {
    225234        psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts.");
    226235        psFree(fpaList);
Note: See TracChangeset for help on using the changeset viewer.