IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21183


Ignore:
Timestamp:
Jan 26, 2009, 8:40:07 PM (17 years ago)
Author:
eugene
Message:

incorporating changes from 16bit mask upgrades (eam_branch_20081230)

Location:
trunk
Files:
1 added
211 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppArith/src/ppArithReadout.c

    r15597 r21183  
    2626        outImage = output->mask;
    2727        if (!outImage) {
    28             output->mask = outImage = psImageAlloc(inImage1->numCols, inImage1->numRows, PS_TYPE_MASK);
     28            output->mask = outImage = psImageAlloc(inImage1->numCols, inImage1->numRows, PS_TYPE_IMAGE_MASK);
    2929        }
    3030        if (!output->image) {
     
    3737        outImage = output->image;
    3838        if (!outImage) {
    39             output->mask = outImage = psImageAlloc(inImage1->numCols, inImage1->numRows, PS_TYPE_MASK);
     39            output->mask = outImage = psImageAlloc(inImage1->numCols, inImage1->numRows, PS_TYPE_IMAGE_MASK);
    4040        }
    4141    }
  • trunk/ppImage/src/ppImage.h

    r20774 r21183  
    5858
    5959    // make values for abstract concepts of masking
    60     psMaskType maskValue;               // apply this bit-mask to choose masked bits
    61     psMaskType markValue;               // apply this bit-mask to choose masked bits
    62     psMaskType satMask;                 // Mask value to give saturated pixels
    63     psMaskType badMask;                 // Mask value to give bad pixels
    64     psMaskType flatMask;                // Mask value to give bad flat pixels
    65     psMaskType blankMask;               // Mask value to give blank pixels
     60    psImageMaskType maskValue;               // apply this bit-mask to choose masked bits
     61    psImageMaskType markValue;               // apply this bit-mask to choose masked bits
     62    psImageMaskType satMask;                 // Mask value to give saturated pixels
     63    psImageMaskType badMask;                 // Mask value to give bad pixels
     64    psImageMaskType flatMask;                // Mask value to give bad flat pixels
     65    psImageMaskType blankMask;               // Mask value to give blank pixels
    6666
    6767    // non-linear correction parameters
  • trunk/ppImage/src/ppImageCleanup.c

    r19928 r21183  
    2323    // fprintf (stderr, "Found %d leaks at %s\n", Nleaks, "ppImage");
    2424
    25     fprintf(stderr, "Found %d leaks at %s\n", psMemCheckLeaks (0, NULL, NULL, false), "ppImage");
     25    // fprintf(stderr, "Found %d leaks at %s\n", psMemCheckLeaks (0, NULL, NULL, false), "ppImage");
     26    fprintf(stderr, "Found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "ppImage");
    2627
    2728    return;
  • trunk/ppImage/src/ppImageLoop.c

    r20771 r21183  
    126126        }
    127127
    128         // measure various statistics for this image
     128        // measure various pixel-based statistics for this image
    129129        if (!ppImagePixelStats(config, stats, options, view)) {
    130             ESCAPE("Unable to measures stats for image");
     130            ESCAPE("Unable to measures pixel stats for image");
    131131        }
    132132        if (!ppImageMosaicChip(config, options, view, "PPIMAGE.CHIP", "PPIMAGE.OUTPUT")) {
     
    209209    }
    210210
    211     // Write out summary statistics
     211    // Calculate summary statistics from FPA Metadata
    212212    if (!ppImageMetadataStats(config, stats, options)) {
    213         ESCAPE("Unable to write statistics file.");
     213        ESCAPE("Unable to determine FPA-level metadata statistics.");
    214214    }
    215215
     
    218218        ESCAPE("save failure for FPA");
    219219    }
    220 
    221220    psFree(view);
    222221
     
    230229        }
    231230    }
     231    psFree (stats);
    232232
    233233    return true;
  • trunk/ppImage/src/ppImageReplaceBackground.c

    r20863 r21183  
    3030    // XXX Should this be options->maskValue or options->maskValue & ~options->satMask?
    3131    //     The latter will leave saturated pixels high
    32     psMaskType maskVal = options->maskValue;
     32    psImageMaskType maskVal = options->maskValue;
    3333
    3434    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    35     psMetadataAddU8(psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskVal);
     35    psMetadataAddImageMask(psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskVal);
    3636
    3737    // Since we are working on a chip-mosaicked image, there should only be a single cell and readout
     
    146146            if (!isfinite(value)) {
    147147                image->data.F32[y][x] = NAN;
    148                 mask->data.PS_TYPE_MASK_DATA[y][x] |= options->badMask;
     148                mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= options->badMask;
    149149            } else {
    150150                image->data.F32[y][x] -= value;
     
    157157    for (int y = 0; y < numRows; y++) {
    158158        for (int x = 0; x < numCols; x++) {
    159             if (mask && mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
     159            if (mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) {
    160160                image->data.F32[y][x] = 0.0;
    161161            } else {
     
    163163                if (!isfinite(value)) {
    164164                    image->data.F32[y][x] = NAN;
    165                     mask->data.PS_TYPE_MASK_DATA[y][x] |= options->badMask;
     165                    mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= options->badMask;
    166166                } else {
    167167                    image->data.F32[y][x] -= value;
  • trunk/ppImage/src/ppImageSetMaskBits.c

    r18556 r21183  
    3838
    3939    // set maskValue and markValue in the psphot recipe
    40     psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", options->maskValue);
    41     psMetadataAddU8 (recipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "user-defined mask", options->markValue);
     40    psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", options->maskValue);
     41    psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "user-defined mask", options->markValue);
    4242
    4343    return true;
  • trunk/ppMerge/src/ppMergeArguments.c

    r21138 r21183  
    9494        } \
    9595    } \
    96     psMaskType mask = pmConfigMask(str, config); \
    97     psMetadataAddU8(config->arguments, PS_LIST_TAIL, RECIPENAME, 0, NULL, mask); \
     96    psImageMaskType mask = pmConfigMask(str, config); \
     97    psMetadataAddImageMask(config->arguments, PS_LIST_TAIL, RECIPENAME, 0, NULL, mask); \
    9898}
    9999
  • trunk/ppMerge/src/ppMergeLoop.c

    r21139 r21183  
    3838
    3939    // set the mask and mark bit values based on the named masks
    40     psMaskType maskVal;
    41     psMaskType markVal;
     40    psImageMaskType maskVal;
     41    psImageMaskType markVal;
    4242    if (!pmConfigMaskSetBits (&maskVal, &markVal, config)) {
    4343        psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values");
  • trunk/ppMerge/src/ppMergeLoop_Threaded.c

    r21139 r21183  
    5454
    5555    // set the mask and mark bit values based on the named masks
    56     psMaskType maskVal;
    57     psMaskType markVal;
     56    psImageMaskType maskVal;
     57    psImageMaskType markVal;
    5858    if (!pmConfigMaskSetBits (&maskVal, &markVal, config)) {
    5959        psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values");
     
    257257                      psArrayAdd(job->args, 1, psScalarAlloc(iter, PS_TYPE_S32));
    258258                      psArrayAdd(job->args, 1, psScalarAlloc(rej, PS_TYPE_F32));
    259                       psArrayAdd(job->args, 1, psScalarAlloc(maskVal, PS_TYPE_U8));
     259                      psArrayAdd(job->args, 1, psScalarAlloc(maskVal, PS_TYPE_IMAGE_MASK));
    260260
    261261                      // call: pmDarkCombine(outCell, fileGroup->readouts, iter, rej, maskVal);
     
    276276                      psArrayAdd(job->args, 1, psScalarAlloc(iter, PS_TYPE_S32));
    277277                      psArrayAdd(job->args, 1, psScalarAlloc(rej, PS_TYPE_F32));
    278                       psArrayAdd(job->args, 1, psScalarAlloc(maskVal, PS_TYPE_U8));
     278                      psArrayAdd(job->args, 1, psScalarAlloc(maskVal, PS_TYPE_IMAGE_MASK));
    279279
    280280                      // call: pmShutterCorrectionGenerate(outRO, pattern, fileGroup->readouts, shutterRef,
  • trunk/ppMerge/src/ppMergeMask.c

    r18756 r21183  
    2626    float smoothScale = psMetadataLookupF32(&mdok, config->arguments, "MASK.SMOOTH.SCALE"); // Radius to grow mask
    2727
    28     psMaskType markVal;
    29     psMaskType maskValRaw;
     28    psImageMaskType markVal;
     29    psImageMaskType maskValRaw;
    3030    if (!pmConfigMaskSetBits (&maskValRaw, &markVal, config)) {
    3131        psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values");
     
    3434
    3535    char *maskOutName = psMetadataLookupStr (&mdok, config->arguments, "MASK.SET.VALUE");
    36     psMaskType maskValOut = pmConfigMaskGet (maskOutName, config);
     36    psImageMaskType maskValOut = pmConfigMaskGet (maskOutName, config);
    3737    if (!maskValOut) {
    3838        psError (PS_ERR_UNKNOWN, true, "Undefined output mask bit value");
     
    137137                int x = pixel % numCols;
    138138                int y = pixel / numCols;
    139                 if (mask && (mask->data.PS_TYPE_MASK_DATA[y][x] & maskValRaw)) continue;
    140                 if (outMask && (outMask->data.PS_TYPE_MASK_DATA[y][x] & maskValOut)) continue;
     139                if (mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValRaw)) continue;
     140                if (outMask && (outMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValOut)) continue;
    141141                if (!isfinite(image->data.F32[y][x])) continue;
    142142
  • trunk/ppMerge/src/ppMergeScaleZero.c

    r18930 r21183  
    8080                pmReadout *readout = cell->readouts->data[0]; // Readout of interest
    8181
    82                 psMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask
     82                psImageMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask
    8383
    8484                switch (type) {
  • trunk/ppMerge/src/ppMergeSetThreads.c

    r19299 r21183  
    2929    psScalar *maskVal           = job->args->data[4];
    3030
    31     bool status = pmDarkCombine(outCell, fileGroup->readouts, iter->data.S32, rej->data.F32, maskVal->data.U8);
     31    bool status = pmDarkCombine(outCell, fileGroup->readouts, iter->data.S32, rej->data.F32, maskVal->data.PS_TYPE_IMAGE_MASK_DATA);
    3232
    3333    // after we are done, tell the I/O system that this file group is done
     
    4949    psScalar *maskVal             = job->args->data[7];
    5050
    51     bool status = pmShutterCorrectionGenerate(output, pattern, fileGroup->readouts, shutterRef->data.F32, data, iter->data.S32, rej->data.F32, maskVal->data.U8);
     51    bool status = pmShutterCorrectionGenerate(output, pattern, fileGroup->readouts, shutterRef->data.F32, data, iter->data.S32, rej->data.F32, maskVal->data.PS_TYPE_IMAGE_MASK_DATA);
    5252
    5353    // after we are done, tell the I/O system that this file group is done
  • trunk/ppMerge/src/ppMergeThreadLauncher.c

    r18839 r21183  
    6060            psScalar *maskVal           = job->args->data[6];
    6161
    62             bool status = pmDarkCombine(outCell, fileGroup->readouts, darkOrdinates, darkNorm, iter->data.S32, rej->data.F32, maskVal->data.U8);
     62            bool status = pmDarkCombine(outCell, fileGroup->readouts, darkOrdinates, darkNorm, iter->data.S32, rej->data.F32, maskVal->data.PS_TYPE_IMAGE_MASK_DATA);
    6363            if (!status) {
    6464                self->fault = true;
     
    8282            psScalar *maskVal             = job->args->data[6];
    8383
    84             bool status = pmShutterCorrectionGenerate(output, NULL, fileGroup->readouts, shutterRef->data.F32, data, iter->data.S32, rej->data.F32, maskVal->data.U8);
     84            bool status = pmShutterCorrectionGenerate(output, NULL, fileGroup->readouts, shutterRef->data.F32, data, iter->data.S32, rej->data.F32, maskVal->data.PS_TYPE_IMAGE_MASK_DATA);
    8585            if (!status) {
    8686                self->fault = true;
  • trunk/ppSim/src/ppSim.h

    r18011 r21183  
    130130bool ppSimInsertGalaxies (pmReadout *readout, psImage *expCorr, psArray *galaxies, pmConfig *config);
    131131
    132 bool ppSimMosaicChip(pmConfig *config, const psMaskType blankMask, const pmFPAview *view,
    133                      const char *outFile, const char *inFile);
     132bool ppSimMosaicChip(pmConfig *config, const psImageMaskType blankMask, const pmFPAview *view, const char *outFile, const char *inFile);
    134133
    135134bool ppSimPhotom (pmConfig *config, pmFPAview *view);
  • trunk/ppSim/src/ppSimMosaicChip.c

    r18712 r21183  
    22
    33// XXX this is essentially identical to ppImageMosaicChip
    4 bool ppSimMosaicChip(pmConfig *config, const psMaskType blankMask, const pmFPAview *view,
     4bool ppSimMosaicChip(pmConfig *config, const psImageMaskType blankMask, const pmFPAview *view,
    55                       const char *outFile, const char *inFile)
    66{
  • trunk/ppSim/src/ppSimPhotom.c

    r20410 r21183  
    1515    psphotInit ();
    1616
    17     int blankMask = 0;          // XXX not sure what this should be set to...
     17    psImageMaskType blankMask = 1;              // XXX not sure what this should be set to...
    1818    ppSimMosaicChip(config, blankMask, view, "PPSIM.FORCE.CHIP", "PPSIM.INPUT");
    1919    ppSimMosaicChip(config, blankMask, view, "PPSIM.FAKE.CHIP", "PPSIM.OUTPUT");
  • trunk/ppSim/src/ppSimPhotomReadout.c

    r21170 r21183  
    9696
    9797    // XXX fake sources should measure peak->x,y, force sources should not
    98     psMaskType maskVal = 0xff;
     98    psImageMaskType maskVal = 0xff;
    9999    psImage *significance = psphotSignificanceImage (readout, recipe, 1, maskVal);
    100100    ppSimDetections (significance, recipe, fakeSources);
  • trunk/ppSim/src/ppSimPhotomReadoutFake.c

    r21170 r21183  
    7676
    7777    // XXX fake sources should measure peak->x,y, force sources should not
    78     psMaskType maskVal = 0xff;
     78    psImageMaskType maskVal = 0xff;
    7979    psImage *significance = psphotSignificanceImage (readout, recipe, 1, maskVal);
    8080    ppSimDetections (significance, recipe, fakeSources);
  • trunk/ppSim/src/ppSimPhotomReadoutForce.c

    r21170 r21183  
    6969
    7070    // XXX fake sources should measure peak->x,y, force sources should not
    71     psMaskType maskVal = 0xff;
     71    psImageMaskType maskVal = 0xff;
    7272    psImage *significance = psphotSignificanceImage (readout, recipe, 1, maskVal);
    7373    ppSimDetections (significance, recipe, forceSources);
  • trunk/ppStack/src/ppStackArguments.c

    r20995 r21183  
    7979        } \
    8080    } \
    81     psMaskType value = pmConfigMaskGet(name, config); \
    82     psMetadataAddU8(recipe, PS_LIST_TAIL, RECIPENAME, PS_META_REPLACE, NULL, value); \
     81    psImageMaskType value = pmConfigMaskGet(name, config); \
     82    psMetadataAddImageMask(recipe, PS_LIST_TAIL, RECIPENAME, PS_META_REPLACE, NULL, value); \
    8383}
    8484
  • trunk/ppStack/src/ppStackLoop.c

    r21092 r21183  
    403403    int numGood = 0;                    // Number of good frames
    404404    int numCols = 0, numRows = 0;       // Size of image
    405     psVector *inputMask = psVectorAlloc(num, PS_TYPE_U8); // Mask for inputs
     405    psVector *inputMask = psVectorAlloc(num, PS_TYPE_VECTOR_MASK); // Mask for inputs
    406406    psVectorInit(inputMask, 0);
    407407    psVector *matchChi2 = psVectorAlloc(num, PS_TYPE_F32); // chi^2 for stamps when matching
     
    449449                          sourceLists->data[i], targetPSF, rng, config)) {
    450450            psErrorStackPrint(stderr, "Unable to match image %d --- ignoring.", i);
    451             inputMask->data.U8[i] = PPSTACK_MASK_MATCH;
     451            inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PPSTACK_MASK_MATCH;
    452452            psErrorClear();
    453453            continue;
     
    536536        psVector *values = psVectorAllocEmpty(num, PS_TYPE_F32); // Values to sort
    537537        for (int i = 0; i < num; i++) {
    538             if (inputMask->data.PS_TYPE_MASK_DATA[i] & PPSTACK_MASK_ALL) {
     538            if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PPSTACK_MASK_ALL) {
    539539                continue;
    540540            }
     
    569569            numGood = 0;                    // Number of good images
    570570            for (int i = 0; i < num; i++) {
    571                 if (inputMask->data.PS_TYPE_MASK_DATA[i] & PPSTACK_MASK_ALL) {
     571              if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PPSTACK_MASK_ALL) {
    572572                    continue;
    573573                }
    574574                if (matchChi2->data.F32[i] > thresh) {
    575575                    numRej++;
    576                     inputMask->data.PS_TYPE_MASK_DATA[i] |= PPSTACK_MASK_CHI2;
     576                    inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= PPSTACK_MASK_CHI2;
    577577                    psLogMsg("ppStack", PS_LOG_INFO, "Rejecting image %d because of large matching chi^2: %f",
    578578                             i, matchChi2->data.F32[i]);
     
    647647
    648648        psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits to mask for bad
    649         psMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
     649        psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
    650650        if (!pmReadoutStackDefineOutput(outRO, col0, row0, numCols, numRows, true, true, maskBad)) {
    651651            psError(PS_ERR_UNKNOWN, false, "Unable to prepare output.");
     
    728728        inspect = psArrayAlloc(num);
    729729        for (int i = 0; i < num; i++) {
    730             if (inputMask->data.U8[i]) {
     730            if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    731731                continue;
    732732            }
     
    739739            psArray *results = job->results; // Results of job
    740740            for (int i = 0; i < num; i++) {
    741                 if (inputMask->data.U8[i]) {
     741                if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    742742                    continue;
    743743                }
     
    765765        // Count images rejected out of hand
    766766        for (int i = 0; i < num; i++) {
    767             if (inputMask->data.U8[i]) {
     767            if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    768768                numRejected++;
    769769            }
     
    771771
    772772        for (int i = 0; i < num; i++) {
    773             if (inputMask->data.U8[i]) {
     773            if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    774774                continue;
    775775            }
     
    816816        // Reject bad pixels
    817817        for (int i = 0; i < num; i++) {
    818             if (inputMask->data.U8[i]) {
     818            if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    819819                continue;
    820820            }
     
    859859                psWarning("Rejection on image %d didn't work --- reject entire image.", i);
    860860                numRejected++;
    861                 inputMask->data.U8[i] = PPSTACK_MASK_REJECT;
     861                inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PPSTACK_MASK_REJECT;
    862862            } else {
    863863                float frac = reject->n / (float)(numCols * numRows); // Pixel fraction
     
    870870                    // reject == NULL means reject image completely
    871871                    reject = NULL;
    872                     inputMask->data.U8[i] = PPSTACK_MASK_BAD;
     872                    inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PPSTACK_MASK_BAD;
    873873                    numRejected++;
    874874                }
     
    982982    {
    983983        psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits for bad
    984         psMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
     984        psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
    985985        if (!pmReadoutMaskApply(outRO, maskBad)) {
    986986            psWarning("Unable to apply mask");
     
    992992    bool wcsDone = false;           // Have we done the WCS?
    993993    for (int i = 0; i < num; i++) {
    994         if (inputMask->data.U8[i]) {
     994        if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    995995            continue;
    996996        }
     
    10561056        pmCell *cell1 = pmFPAfileThisCell(config->files, view, "PPSTACK.OUTPUT.JPEG1");
    10571057        pmCell *cell2 = pmFPAfileThisCell(config->files, view, "PPSTACK.OUTPUT.JPEG2");
    1058         psMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask
     1058        psImageMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask
    10591059
    10601060        pmReadout *ro1 = pmReadoutAlloc(cell1), *ro2 = pmReadoutAlloc(cell2); // Binned readouts
     
    10781078        int renormNum = psMetadataLookupS32(&mdok, recipe, "RENORM.NUM"); // Number of samples
    10791079        float renormWidth = psMetadataLookupS32(&mdok, recipe, "RENORM.WIDTH"); // Width of Gaussian phot
    1080         psMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask
     1080        psImageMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask
    10811081        if (!pmReadoutWeightRenormPhot(outRO, maskValue, renormNum, renormWidth,
    10821082                                       renormMean, renormStdev, NULL)) {
     
    11241124        psTrace("ppStack", 1, "Gathering statistics on stacked image....\n");
    11251125        psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits for bad
    1126         psMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
     1126        psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
    11271127
    11281128        ppStatsFPA(stats, outRO->parent->parent->parent, view, maskBad, config);
  • trunk/ppStack/src/ppStackMatch.c

    r21021 r21183  
    104104
    105105// Generate a background model of the readout we're matching
    106 psImage *stackBackgroundModel(pmReadout *ro, psMaskType maskVal, const psArray *sources, int size)
     106psImage *stackBackgroundModel(pmReadout *ro, psImageMaskType maskVal, const psArray *sources, int size)
    107107{
    108108    psImage *image = ro->image, *mask = ro->mask; // Image and mask of readout
     
    169169
    170170    psString maskValStr = psMetadataLookupStr(NULL, recipe, "MASK.VAL"); // Name of bits to mask going in
    171     psMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch
     171    psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch
    172172    psString maskPoorStr = psMetadataLookupStr(NULL, recipe, "MASK.POOR"); // Name of bits to mask for poor
    173     psMaskType maskPoor = pmConfigMaskGet(maskPoorStr, config); // Bits to mask for poor pixels
     173    psImageMaskType maskPoor = pmConfigMaskGet(maskPoorStr, config); // Bits to mask for poor pixels
    174174    psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits to mask for bad
    175     psMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
     175    psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
    176176
    177177    bool mdok;                          // Status of MD lookup
  • trunk/ppStack/src/ppStackPhotometry.c

    r20995 r21183  
    4545        return false;
    4646    }
    47     psMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask
     47    psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask
    4848
    4949    psImage *image = ro->image, *mask = ro->mask; // Image and mask from readout
     
    8585            float dy2 = PS_SQR(y - v); // Distance from centroid
    8686            for (int u = xMin; u <= xMax; u++) {
    87                 if (mask->data.PS_TYPE_MASK_DATA[v][u] & maskVal) {
     87                if (mask->data.PS_TYPE_IMAGE_MASK_DATA[v][u] & maskVal) {
    8888                    numBadPix++;
    8989                    continue;
     
    133133
    134134    // set maskValue and markValue in the psphot recipe
    135     psMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask
    136     psMaskType markValue = pmConfigMaskGet("MARK.VALUE", config); // Bits to use for marking
    137     psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "Bits to mask", maskValue);
    138     psMetadataAddU8 (recipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "Bits to use for mark", markValue);
     135    psImageMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask
     136    psImageMaskType markValue = pmConfigMaskGet("MARK.VALUE", config); // Bits to use for marking
     137    psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "Bits to mask", maskValue);
     138    psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "Bits to use for mark", markValue);
    139139
    140140    if (!psphotReadout(config, view)) {
  • trunk/ppStack/src/ppStackReadout.c

    r20884 r21183  
    114114
    115115    psString maskValStr = psMetadataLookupStr(NULL, recipe, "MASK.VAL"); // Name of bits to mask going in
    116     psMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch
     116    psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch
    117117    psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits to mask for bad
    118     psMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
     118    psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
    119119
    120120    int num = readouts->n;              // Number of inputs
     
    141141        // Ensure there is a mask, or pmStackCombine will complain
    142142        if (!ro->mask) {
    143             ro->mask = psImageAlloc(ro->image->numCols, ro->image->numRows, PS_TYPE_MASK);
     143            ro->mask = psImageAlloc(ro->image->numCols, ro->image->numRows, PS_TYPE_IMAGE_MASK);
    144144            psImageInit(ro->mask, 0);
    145145        }
     
    208208
    209209    psString maskValStr = psMetadataLookupStr(NULL, recipe, "MASK.VAL"); // Name of bits to mask going in
    210     psMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch
     210    psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch
    211211    psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits to mask for bad
    212     psMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
     212    psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
    213213
    214214    int num = readouts->n;              // Number of inputs
     
    238238        // Ensure there is a mask, or pmStackCombine will complain
    239239        if (!ro->mask) {
    240             ro->mask = psImageAlloc(ro->image->numCols, ro->image->numRows, PS_TYPE_MASK);
     240            ro->mask = psImageAlloc(ro->image->numCols, ro->image->numRows, PS_TYPE_IMAGE_MASK);
    241241            psImageInit(ro->mask, 0);
    242242        }
  • trunk/ppStack/src/ppStackSources.c

    r21092 r21183  
    109109            psVectorInit(mag, NAN);
    110110            for (int j = 0; j < match->num; j++) {
    111                 if (match->mask->data.PS_TYPE_MASK_DATA[j]) {
     111                if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) {
    112112                    continue;
    113113                }
  • trunk/ppStats/src/ppStats.h

    r19626 r21183  
    2424    bool doFirstReadout3D;              // for 3D data, use the first readout?
    2525    float sample;                       // Fraction of cell to sample for statistics
    26     psMaskType maskVal;                 // Mask value for images
     26    psImageMaskType maskVal;            // Mask value for images
    2727    psList *chips;                      // Chips to look at
    2828    psList *cells;                      // Cells to look at
     
    4545                       pmFPA *fpa,         // FPA for which to get statistics
    4646                       pmFPAview *view,    // View for analysis
    47                        psMaskType maskVal, // Value to mask
     47                       psImageMaskType maskVal, // Value to mask
    4848                       pmConfig *config    // Configuration
    4949    );
     
    7777                          pmFPA *fpa,         // FPA for which to get statistics
    7878                          pmFPAview *view,    // View for analysis
    79                           psMaskType maskVal, // Value to mask
     79                          psImageMaskType maskVal, // Value to mask
    8080                          pmConfig *config    // Configuration
    8181    );
     
    8585                            pmFPA *fpa,         // FPA for which to get statistics
    8686                            pmFPAview *view,    // View for analysis
    87                             psMaskType maskVal, // Value to mask
     87                            psImageMaskType maskVal, // Value to mask
    8888                            pmConfig *config    // Configuration
    8989    );
  • trunk/ppStats/src/ppStatsFPA.c

    r18558 r21183  
    44                       pmFPA *fpa,         // FPA for which to get statistics
    55                       pmFPAview *view,    // View for analysis
    6                        psMaskType maskVal, // Value to mask
     6                       psImageMaskType maskVal, // Value to mask
    77                       pmConfig *config    // Configuration
    88    )
  • trunk/ppStats/src/ppStatsMetadata.c

    r18558 r21183  
    55                            pmFPA *fpa,         // FPA for which to get statistics
    66                            pmFPAview *view,    // View for analysis
    7                             psMaskType maskVal, // Value to mask
     7                            psImageMaskType maskVal, // Value to mask
    88                            pmConfig *config    // Configuration
    99    )
  • trunk/ppStats/src/ppStatsPixels.c

    r18558 r21183  
    55                          pmFPA *fpa,         // FPA for which to get statistics
    66                          pmFPAview *view,    // View for analysis
    7                           psMaskType maskVal, // Value to mask
     7                          psImageMaskType maskVal, // Value to mask
    88                          pmConfig *config    // Configuration
    99    )
  • trunk/ppStats/src/ppStatsReadout.c

    r19355 r21183  
    6363        int sampleSpace = 1.0 / data->sample; // Space between samples
    6464        psVector *sampleValues = psVectorAlloc(numSamples, PS_TYPE_F32); // Vector of samples
    65         psVector *sampleMask = psVectorAlloc(numSamples, PS_TYPE_MASK);  // Corresponding mask
    66         if (!mask) {
    67             psVectorInit(sampleMask, 0);
    68         }
     65        psVector *sampleMask = psVectorAlloc(numSamples, PS_TYPE_VECTOR_MASK);  // Corresponding mask
     66        psVectorInit(sampleMask, 0);
     67
    6968        for (int i = 0; i < numSamples; i++) {
    7069            int j = i * sampleSpace;
     
    7271            int x = j % image->numCols;
    7372            sampleValues->data.F32[i] = image->data.F32[y][x];
    74             if ((!mask || !(mask->data.PS_TYPE_MASK_DATA[y][x] & data->maskVal)) &&
    75                 !isfinite(sampleValues->data.F32[i])) {
    76                 if (!warnNonFinite) {
    77                     psWarning("Unmasked non-finite value detected at %d,%d; suppressing further warnings",
    78                               x, y);
    79                     warnNonFinite = true;
    80                 }
    81                 sampleMask->data.PS_TYPE_MASK_DATA[i] = data->maskVal;
    82             } else if (mask) {
    83                 sampleMask->data.PS_TYPE_MASK_DATA[i] = mask->data.PS_TYPE_MASK_DATA[y][x];
    84             }
    85         }
    86         if (!psVectorStats(data->stats, sampleValues, NULL, sampleMask, data->maskVal)) {
     73
     74            // ignore the sampleMask if there is no input mask
     75            if (!mask) continue;
     76
     77            // if this pixel is masked, set the sample mask
     78            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & data->maskVal) {
     79                sampleMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;
     80                continue;
     81            }
     82
     83            // mask any unmasked NAN/INF values
     84            if (!isfinite(sampleValues->data.F32[i])) {
     85                // warn for the first unmasked NAN/INF value
     86                if (!warnNonFinite) {
     87                    psWarning("Unmasked non-finite value detected at %d,%d; suppressing further warnings", x, y);
     88                    warnNonFinite = true;
     89                }
     90                sampleMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;
     91            }
     92        }
     93        if (!psVectorStats(data->stats, sampleValues, NULL, sampleMask, 1)) {
    8794            psWarning("Unable to perform statistics on readout %s.\n", readoutName);
    8895            psErrorClear();
     
    179186                for (int j = 0; j < readout->mask->numRows; j++) {
    180187                    for (int i = 0; i < readout->mask->numCols; i++) {
    181                         if (readout->mask->data.PS_TYPE_MASK_DATA[j][i] & data->maskVal) {
     188                        if (readout->mask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] & data->maskVal) {
    182189                            numBad++;
    183190                        }
  • trunk/ppSub/src/ppSubArguments.c

    r20568 r21183  
    216216    psMetadataAddF32(arguments, PS_LIST_TAIL, "-rej", 0, "Rejection thresold (sigma)", NAN);
    217217    psMetadataAddF32(arguments, PS_LIST_TAIL, "-sys", 0, "Relative systematic error in kernel", NAN);
    218     psMetadataAddU8(arguments,  PS_LIST_TAIL, "-mask-bad", 0, "Mask value for bad pixels", 0);
    219     psMetadataAddU8(arguments,  PS_LIST_TAIL, "-mask-poor", 0, "Mask value for poor pixels", 0);
     218    psMetadataAddImageMask(arguments,  PS_LIST_TAIL, "-mask-bad", 0, "Mask value for bad pixels", 0);
     219    psMetadataAddImageMask(arguments,  PS_LIST_TAIL, "-mask-poor", 0, "Mask value for poor pixels", 0);
    220220    psMetadataAddF32(arguments,  PS_LIST_TAIL, "-poor-frac", 0, "Fraction of weight for poor pixels", NAN);
    221221    psMetadataAddF32(arguments, PS_LIST_TAIL, "-badfrac", 0, "Maximum fraction of bad pixels to accept", 1.0);
  • trunk/ppSub/src/ppSubBackground.c

    r20775 r21183  
    3030
    3131    psString maskBadStr = psMetadataLookupStr(NULL, ppSubRecipe, "MASK.BAD"); // Name of bits to mask for bad
    32     psMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
     32    psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
    3333
    3434    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    35     psMetadataAddU8(psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskBad);
     35    psMetadataAddImageMask(psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskBad);
    3636
    3737    psImage *image = ro->image, *mask = ro->mask; // Image and mask of interest
     
    5959    for (int y = 0; y < numRows; y++) {
    6060        for (int x = 0; x < numCols; x++) {
    61             if (mask && mask->data.PS_TYPE_MASK_DATA[y][x] & maskBad) {
     61            if (mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskBad) {
    6262                image->data.F32[y][x] = 0.0;
    6363            } else {
     
    6565                if (!isfinite(value)) {
    6666                    image->data.F32[y][x] = NAN;
    67                     mask->data.PS_TYPE_MASK_DATA[y][x] |= maskBad;
     67                    mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= maskBad;
    6868                } else {
    6969                    image->data.F32[y][x] -= value;
  • trunk/ppSub/src/ppSubReadout.c

    r21024 r21183  
    103103    float penalty = psMetadataLookupF32(NULL, recipe, "PENALTY"); // Penalty for wideness
    104104    psString maskValStr = psMetadataLookupStr(NULL, recipe, "MASK.IN"); // Name of bits to mask going in
    105     psMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch
     105    psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask going in to pmSubtractionMatch
    106106    psString maskPoorStr = psMetadataLookupStr(NULL, recipe, "MASK.POOR"); // Name of bits to mask for poor
    107     psMaskType maskPoor = pmConfigMaskGet(maskPoorStr, config); // Bits to mask for poor pixels
     107    psImageMaskType maskPoor = pmConfigMaskGet(maskPoorStr, config); // Bits to mask for poor pixels
    108108    psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits to mask for bad
    109     psMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
     109    psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
    110110    float badFrac = psMetadataLookupF32(NULL, recipe, "BADFRAC"); // Maximum bad fraction
    111111    const char *stampsName = psMetadataLookupStr(&mdok, config->arguments, "STAMPS"); // Filename for stamps
     
    146146            pmReadoutSetMask(inRO, pmConfigMaskGet("SAT", config), pmConfigMaskGet("BAD", config));
    147147        } else {
    148             inRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
     148            inRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
    149149            psImageInit(inRO->mask, 0);
    150150        }
     
    154154            pmReadoutSetMask(refRO, pmConfigMaskGet("SAT", config), pmConfigMaskGet("BAD", config));
    155155        } else {
    156             refRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
     156            refRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
    157157            psImageInit(refRO->mask, 0);
    158158        }
     
    363363        }
    364364        if (minuend->mask) {
    365             outRO->mask = psImageCopy(outRO->mask, minuend->mask, PS_TYPE_MASK);
     365            outRO->mask = psImageCopy(outRO->mask, minuend->mask, PS_TYPE_IMAGE_MASK);
    366366        }
    367367        outRO->data_exists = outCell->data_exists = outCell->parent->data_exists = true;
    368368
    369369        if (psMetadataLookupBool(&mdok, recipe, "RENORM")) {
    370             psMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask
     370            psImageMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask
    371371            if (!pmReadoutWeightRenormPhot(outRO, maskValue, renormNum, renormWidth,
    372372                                           renormMean, renormStdev, NULL)) {
     
    399399
    400400        // set maskValue and markValue in the psphot recipe
    401         psMaskType maskValue = maskVal;
    402         psMaskType markValue = pmConfigMaskGet("MARK.VALUE", config); // Bits to use for marking
    403         psMetadataAddU8(psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "Bits to mask", maskValue);
    404         psMetadataAddU8(psphotRecipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "Bits to use for marking",
     401        psImageMaskType maskValue = maskVal;
     402        psImageMaskType markValue = pmConfigMaskGet("MARK.VALUE", config); // Bits to use for marking
     403        psMetadataAddImageMask(psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "Bits to mask", maskValue);
     404        psMetadataAddImageMask(psphotRecipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "Bits to use for marking",
    405405                        markValue);
    406406
     
    477477    for (int y = 0; y < outRO->image->numRows; y++) {
    478478        for (int x = 0; x < outRO->image->numCols; x++) {
    479             if (isnan(outRO->image->data.F32[y][x]) && !(outRO->mask->data.U8[y][x] & maskVal)) {
    480                 printf("Unmasked NAN at %d %d --> %d\n", x, y, outRO->mask->data.U8[y][x]);
     479            if (isnan(outRO->image->data.F32[y][x]) && !(outRO->mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal)) {
     480                printf("Unmasked NAN at %d %d --> %d\n", x, y, outRO->mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x]);
    481481            }
    482482        }
     
    568568
    569569        if (psMetadataLookupBool(&mdok, recipe, "RENORM")) {
    570             psMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask
     570            psImageMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask
    571571            if (!pmReadoutWeightRenormPhot(outRO, maskValue, renormNum, renormWidth,
    572572                                           renormMean, renormStdev, NULL)) {
     
    669669    // Renormalising for pixels, because that's what magic desires
    670670    if (psMetadataLookupBool(&mdok, recipe, "RENORM")) {
    671         psMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask
     671        psImageMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask
    672672        if (!pmReadoutWeightRenormPixels(outRO, maskValue, renormMean, renormStdev, NULL)) {
    673673            psError(PS_ERR_UNKNOWN, false, "Unable to renormalise variances.");
  • trunk/psLib/src/fft/psImageFFT.c

    r20566 r21183  
    66/// @author Robert DeSonia, MHPCC
    77///
    8 /// @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
    9 /// @date $Date: 2008-11-06 23:36:20 $
     8/// @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
     9/// @date $Date: 2009-01-27 06:39:37 $
    1010///
    1111/// Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    318318
    319319
    320 psImage *psImageConvolveFFT(psImage *out, const psImage *in, const psImage *mask, psMaskType maskVal,
     320psImage *psImageConvolveFFT(psImage *out, const psImage *in, const psImage *mask, psImageMaskType maskVal,
    321321                            const psKernel *kernel)
    322322{
     
    326326    if (mask) {
    327327        PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
    328         PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
     328        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
    329329        PS_ASSERT_IMAGES_SIZE_EQUAL(mask, in, NULL);
    330330    }
     
    464464        for (int y = 0; y < numRows; y++) {
    465465            for (int x = 0; x < numCols; x++) {
    466                 if (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
     466                if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) {
    467467                    data[x + paddedCols * y] = 0;
    468468                }
  • trunk/psLib/src/fft/psImageFFT.h

    r17320 r21183  
    55/// @author Robert DeSonia, MHPCC
    66///
    7 /// @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    8 /// @date $Date: 2008-04-04 22:44:56 $
     7/// @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     8/// @date $Date: 2009-01-27 06:39:37 $
    99/// Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1010///
     
    7070    const psImage *in,                  ///< Image to convolve
    7171    const psImage *mask,                ///< Corresponding mask
    72     psMaskType maskVal,                 ///< Value to mask
     72    psImageMaskType maskVal,            ///< Value to mask
    7373    const psKernel *kernel              ///< kernel to colvolve with
    7474);
  • trunk/psLib/src/fits/psFitsImage.c

    r19384 r21183  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.40 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2008-09-05 08:08:33 $
     9 *  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2009-01-27 06:39:37 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    251251                                          const psImage *image, // Image to convert
    252252                                          const psImage *mask, // Mask image, or NULL
    253                                           psMaskType maskVal, // Value to mask
     253                                          psImageMaskType maskVal, // Value to mask
    254254                                          psRandom *rng, // Random number generator
    255255                                          bool newScaleZero // Determine a new BSCALE and BZERO?
     
    506506
    507507bool psFitsWriteImageWithMask(psFits *fits, psMetadata *header, const psImage *input,
    508                               const psImage *mask, psMaskType maskVal, int numZPlanes,
     508                              const psImage *mask, psImageMaskType maskVal, int numZPlanes,
    509509                              const char *extname)
    510510{
     
    525525
    526526bool psFitsInsertImageWithMask(psFits *fits, psMetadata *header, const psImage *image,
    527                                const psImage *mask, psMaskType maskVal, int numZPlanes,
     527                               const psImage *mask, psImageMaskType maskVal, int numZPlanes,
    528528                               const char *extname, bool after)
    529529{
     
    532532    PS_ASSERT_IMAGE_NON_NULL(image, false);
    533533    if (mask) {
    534         PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, false);
     534        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false);
    535535        PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, false);
    536536    }
     
    706706}
    707707
    708 bool psFitsUpdateImageWithMask(psFits *fits, const psImage *input, const psImage *mask, psMaskType maskVal,
     708bool psFitsUpdateImageWithMask(psFits *fits, const psImage *input, const psImage *mask, psImageMaskType maskVal,
    709709                               int x0, int y0, int z)
    710710{
     
    713713    PS_ASSERT_IMAGE_NON_NULL(input, false);
    714714    if (mask) {
    715         PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, false);
     715        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false);
    716716        PS_ASSERT_IMAGES_SIZE_EQUAL(mask, input, false);
    717717    }
     
    896896
    897897bool psFitsWriteImageCubeWithMask(psFits *fits, psMetadata *header, const psArray *input,
    898                                   const psArray *masks, psMaskType maskVal, const char *extname)
     898                                  const psArray *masks, psImageMaskType maskVal, const char *extname)
    899899{
    900900    PS_ASSERT_FITS_NON_NULL(fits, false);
     
    976976
    977977bool psFitsUpdateImageCubeWithMask(psFits *fits, const psArray *input,
    978                                    const psArray *masks, psMaskType maskVal, int x0, int y0)
     978                                   const psArray *masks, psImageMaskType maskVal, int x0, int y0)
    979979{
    980980    PS_ASSERT_FITS_NON_NULL(fits, false);
  • trunk/psLib/src/fits/psFitsImage.h

    r19384 r21183  
    44 * @author Robert DeSonia, MHPCC
    55 *
    6  * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2008-09-05 08:08:33 $
     6 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2009-01-27 06:39:37 $
    88 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    99 */
     
    7474    const psImage *input,               ///< the image to output
    7575    const psImage *mask,                ///< the mask image
    76     psMaskType maskVal,                 ///< value to mask
     76    psImageMaskType maskVal,            ///< value to mask
    7777    int depth,                          ///< the number of z-planes of the FITS image data cube
    7878    const char *extname                 ///< FITS extension name
     
    101101    const psImage *input,               ///< the image to output
    102102    const psImage *mask,                ///< the mask image
    103     psMaskType maskVal,                 ///< value to mask
     103    psImageMaskType maskVal,            ///< value to mask
    104104    int depth,                          ///< the number of z-planes of the FITS image data cube
    105105    const char *extname,                ///< FITS extension name
     
    128128    const psImage *input,               ///< the image to output
    129129    const psImage *mask,                ///< the mask image
    130     psMaskType maskVal,                 ///< value to mask
     130    psImageMaskType maskVal,            ///< value to mask
    131131    int x0,                             ///< psImage's x-axis origin in FITS image coordinates
    132132    int y0,                             ///< psImage's y-axis origin in FITS image coordinates
     
    157157    const psArray *input,               ///< Array of images
    158158    const psArray *masks,               ///< Array of masks
    159     psMaskType maskVal,                 ///< Value to mask
     159    psImageMaskType maskVal,            ///< Value to mask
    160160    const char *extname                 ///< Name of extension
    161161    );
     
    175175    const psArray *input,               ///< Array of images
    176176    const psArray *masks,               ///< Array of masks
    177     psMaskType maskVal,                 ///< Value to mask
     177    psImageMaskType maskVal,            ///< Value to mask
    178178    int x0,                             ///< x origin of images in FITS image coordinates
    179179    int y0                              ///< y origin of images in FITS image coordinates
  • trunk/psLib/src/fits/psFitsScale.c

    r19383 r21183  
    100100                       const psImage *image, // Image to scale
    101101                       const psImage *mask, // Mask image
    102                        psMaskType maskVal, // Value to mask
     102                       psImageMaskType maskVal, // Value to mask
    103103                       const psFitsOptions *options // FITS options
    104104    )
     
    167167
    168168bool psFitsScaleDetermine(double *bscale, double *bzero, long *blank, const psImage *image,
    169                           const psImage *mask, psMaskType maskVal, const psFits *fits)
     169                          const psImage *mask, psImageMaskType maskVal, const psFits *fits)
    170170{
    171171    PS_ASSERT_PTR_NON_NULL(bscale, false);
     
    174174    PS_ASSERT_IMAGE_NON_NULL(image, false);
    175175    if (mask) {
    176         PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, false);
     176        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false);
    177177        PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, false);
    178178    }
  • trunk/psLib/src/fits/psFitsScale.h

    r19383 r21183  
    1313                          const psImage *image, ///< Image to scale
    1414                          const psImage *mask, ///< Mask image
    15                           psMaskType maskVal, ///< Value to mask
     15                          psImageMaskType maskVal, ///< Value to mask
    1616                          const psFits *fits ///< FITS options
    1717    );
  • trunk/psLib/src/imageops/psImageBackground.c

    r20216 r21183  
    1818// XXX allow the user to choose the stats method?
    1919// (SAMPLE_MEAN, CLIPPED_MEAN, ROBUST_MEDIAN, FITTED_MEAN)
    20 bool psImageBackground(psStats *stats, psVector **sample, const psImage *image, const psImage *mask, psMaskType maskValue, psRandom *rng)
     20bool psImageBackground(psStats *stats, psVector **sample, const psImage *image, const psImage *mask, psImageMaskType maskValue, psRandom *rng)
    2121{
    2222    PS_ASSERT_IMAGE_NON_NULL(image, NULL);
    2323    if (mask) {
    2424        PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
    25         PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_U8, NULL);
     25        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
    2626        PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, NULL);
    2727    }
     
    6363        int iy = pixel / nx;
    6464
    65         if (!isfinite(image->data.F32[iy][ix]) || (mask && mask->data.U8[iy][ix] & maskValue)) {
     65        if (!isfinite(image->data.F32[iy][ix]) || (mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskValue)) {
    6666            continue;
    6767        }
  • trunk/psLib/src/imageops/psImageBackground.h

    r16115 r21183  
    55 *  @author EAM, IfA
    66 *
    7  *  $Revision: 1.6 $ $Name: not supported by cvs2svn $
    8  *  $Date: 2008-01-17 22:07:33 $
     7 *  $Revision: 1.7 $ $Name: not supported by cvs2svn $
     8 *  $Date: 2009-01-27 06:39:37 $
    99 *  Copyright 2004-2005 IfA, University of Hawaii
    1010 */
     
    2727                       const psImage *image, // Image for which to get the background
    2828                       const psImage *mask, // Mask image
    29                        psMaskType maskValue, // Mask pixels which this mask value
     29                       psImageMaskType maskValue, // Mask pixels which this mask value
    3030                       psRandom *rng // Random number generator (for pixel selection)
    3131                      );
  • trunk/psLib/src/imageops/psImageConvolve.c

    r20830 r21183  
    77/// @author Eugene Magnier, IfA
    88///
    9 /// @version $Revision: 1.81 $ $Name: not supported by cvs2svn $
    10 /// @date $Date: 2008-11-26 00:43:12 $
     9/// @version $Revision: 1.82 $ $Name: not supported by cvs2svn $
     10/// @date $Date: 2009-01-27 06:39:37 $
    1111///
    1212/// Copyright 2004-2007 Institute for Astronomy, University of Hawaii
     
    319319}
    320320
    321 psImage *psImageConvolveMaskDirect(psImage *out, const psImage *mask, psMaskType maskVal,
    322                                    psMaskType setVal, int xMin, int xMax, int yMin, int yMax)
     321psImage *psImageConvolveMaskDirect(psImage *out, const psImage *mask, psImageMaskType maskVal,
     322                                   psImageMaskType setVal, int xMin, int xMax, int yMin, int yMax)
    323323{
    324324    PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
    325     PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
     325    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
    326326    if (out == mask && ((maskVal & setVal) || !setVal)) {
    327327        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     
    352352    if (!out) {
    353353        // Propagate the non-masked values
    354         out = (psImage*)psBinaryOp(NULL, (const psPtr)mask, "&", psScalarAlloc(~maskVal, PS_TYPE_MASK));
     354        out = (psImage*)psBinaryOp(NULL, (const psPtr)mask, "&", psScalarAlloc(~maskVal, PS_TYPE_IMAGE_MASK));
    355355    }
    356356
    357357    // Dereference mask images
    358     psMaskType **maskData = mask->data.PS_TYPE_MASK_DATA;
    359     psMaskType **outData = out->data.PS_TYPE_MASK_DATA;
     358    psImageMaskType **maskData = mask->data.PS_TYPE_IMAGE_MASK_DATA;
     359    psImageMaskType **outData = out->data.PS_TYPE_IMAGE_MASK_DATA;
    360360
    361361    if (setVal) {
     
    376376        for (int row = 0; row < numRows; row++) {
    377377            for (int col = 0; col < numCols; col++) {
    378                 psMaskType pixel = outData[row][col]; // Pixel value to set
     378                psImageMaskType pixel = outData[row][col]; // Pixel value to set
    379379                if (pixel & maskVal) {
    380380                    // Already done this one
     
    395395
    396396
    397 psImage *psImageConvolveMaskFFT(psImage *out, const psImage *mask, psMaskType maskVal,
    398                                 psMaskType setVal, int xMin, int xMax, int yMin, int yMax, float thresh)
     397psImage *psImageConvolveMaskFFT(psImage *out, const psImage *mask, psImageMaskType maskVal,
     398                                psImageMaskType setVal, int xMin, int xMax, int yMin, int yMax, float thresh)
    399399{
    400400    PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
    401     PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
     401    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
    402402    PS_ASSERT_FLOAT_LARGER_THAN(thresh, 0.0, NULL);
    403403    PS_ASSERT_FLOAT_LESS_THAN(thresh, 1.0, NULL);
     
    431431    for (int y = 0; y < numRows; y++) {
    432432        for (int x = 0; x < numCols; x++) {
    433             if (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
     433            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) {
    434434                onoff->data.F32[y][x] = 1.0;
    435435            }
     
    452452
    453453    if (!out) {
    454         out = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
     454        out = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
    455455    }
    456456    for (int y = 0; y < numRows; y++) {
    457457        for (int x = 0; x < numCols; x++) {
    458             out->data.PS_TYPE_MASK_DATA[y][x] = (convolved->data.F32[y][x] >= thresh) ?
    459                 (mask->data.PS_TYPE_MASK_DATA[y][x] | setVal) : mask->data.PS_TYPE_MASK_DATA[y][x];
     458            out->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = (convolved->data.F32[y][x] >= thresh) ?
     459                (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] | setVal) : mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x];
    460460        }
    461461    }
     
    651651case PS_TYPE_##TYPE: { \
    652652    psImage *calculation = psImageAlloc(numRows, numCols, PS_TYPE_##TYPE); /* Calculation image; BW */ \
    653     psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_MASK); /* Mask for calculation image; BW */ \
     653    psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_IMAGE_MASK); /* Mask for calculation image; BW */ \
    654654    \
    655655    /** Smooth in X direction **/ \
     
    658658            int xMin = PS_MAX(i - size, 0); \
    659659            int xMax = PS_MIN(i + size, xLast); \
    660             const psMaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[j][xMin]; \
     660            const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[j][xMin]; \
    661661            const ps##TYPE *imageData = &image->data.TYPE[j][xMin]; \
    662662            int uMin = - PS_MIN(i, size); /* Minimum kernel index */ \
     
    673673                /* BW */ \
    674674                calculation->data.TYPE[i][j] = sumIG / sumG; \
    675                 calcMask->data.PS_TYPE_MASK_DATA[i][j] = 0; \
     675                calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0; \
    676676            } else { \
    677677                /* BW */ \
    678                 calcMask->data.PS_TYPE_MASK_DATA[i][j] = 0xFF; \
     678                calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0xFF; \
    679679            } \
    680680        } \
     
    688688            int yMin = PS_MAX(j - size, 0); \
    689689            int yMax = PS_MIN(j + size, yLast); \
    690             const psMaskType *maskData = &calcMask->data.PS_TYPE_MASK_DATA[i][yMin]; /* BW */ \
     690            const psImageMaskType *maskData = &calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][yMin]; /* BW */ \
    691691            const ps##TYPE *imageData = &calculation->data.TYPE[i][yMin]; /* BW */ \
    692692            int vMin = - PS_MIN(j, size); /* Minimum kernel index */ \
     
    714714                           const psImage *image,
    715715                           const psImage *mask,
    716                            psMaskType maskVal,
     716                           psImageMaskType maskVal,
    717717                           float sigma,
    718718                           float numSigma,
     
    721721    PS_ASSERT_IMAGE_NON_NULL(image, NULL);
    722722    PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
    723     PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
     723    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
    724724    PS_ASSERT_IMAGES_SIZE_EQUAL(image, mask, NULL);
    725725
     
    751751      case PS_TYPE_F32: {
    752752          psImage *calculation = psImageAlloc(numRows, numCols, PS_TYPE_F32); /* Calculation image; BW */
    753           psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_MASK); /* Mask for calculation image; BW */
     753          psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_IMAGE_MASK); /* Mask for calculation image; BW */
    754754
    755755          /** Smooth in X direction **/
     
    758758                  int xMin = PS_MAX(i - size, 0);
    759759                  int xMax = PS_MIN(i + size, xLast);
    760                   const psMaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[j][xMin];
     760                  const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[j][xMin];
    761761                  const psF32 *imageData = &image->data.F32[j][xMin];
    762762                  int uMin = - PS_MIN(i, size); /* Minimum kernel index */
     
    776776                      /* BW */
    777777                      calculation->data.F32[i][j] = sumIG / sumG;
    778                       calcMask->data.PS_TYPE_MASK_DATA[i][j] = 0;
     778                      calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0;
    779779                  } else {
    780780                      /* BW */
    781                       calcMask->data.PS_TYPE_MASK_DATA[i][j] = 0xFF;
     781                      calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0xFF;
    782782                  }
    783783              }
     
    791791                  int yMin = PS_MAX(j - size, 0);
    792792                  int yMax = PS_MIN(j + size, yLast);
    793                   const psMaskType *maskData = &calcMask->data.PS_TYPE_MASK_DATA[i][yMin]; /* BW */
     793                  const psImageMaskType *maskData = &calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][yMin]; /* BW */
    794794                  const psF32 *imageData = &calculation->data.F32[i][yMin]; /* BW */
    795795                  int vMin = - PS_MIN(j, size); /* Minimum kernel index */
     
    832832                                     const psImage *image,
    833833                                     const psImage *mask,
    834                                      psMaskType maskVal,
     834                                     psImageMaskType maskVal,
    835835                                     psVector *gaussNorm,
    836836                                     float minGauss,
     
    848848            int xMin = PS_MAX(i - size, 0);
    849849            int xMax = PS_MIN(i + size, xLast);
    850             const psMaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[j][xMin];
     850            const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[j][xMin];
    851851            const psF32 *imageData = &image->data.F32[j][xMin];
    852852            int uMin = - PS_MIN(i, size); /* Minimum kernel index */
     
    863863                /* BW */
    864864                calculation->data.F32[i][j] = sumIG / sumG;
    865                 calcMask->data.PS_TYPE_MASK_DATA[i][j] = 0;
     865                calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0;
    866866            } else {
    867867                /* BW */
    868                 calcMask->data.PS_TYPE_MASK_DATA[i][j] = 0xFF;
     868                calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] = 0xFF;
    869869            }
    870870        }
     
    876876                                     psImage *calculation,
    877877                                     psImage *calcMask,
    878                                      psMaskType maskVal,
     878                                     psImageMaskType maskVal,
    879879                                     psVector *gaussNorm,
    880880                                     float minGauss,
     
    892892            int yMin = PS_MAX(j - size, 0);
    893893            int yMax = PS_MIN(j + size, yLast);
    894             const psMaskType *maskData = &calcMask->data.PS_TYPE_MASK_DATA[i][yMin]; /* BW */
     894            const psImageMaskType *maskData = &calcMask->data.PS_TYPE_IMAGE_MASK_DATA[i][yMin]; /* BW */
    895895            const psF32 *imageData = &calculation->data.F32[i][yMin]; /* BW */
    896896            int vMin = - PS_MIN(j, size); /* Minimum kernel index */
     
    921921    const psImage *mask   = job->args->data[3]; // input mask
    922922
    923     psMaskType maskVal    = PS_SCALAR_VALUE(job->args->data[4],U8);
     923    psImageMaskType maskVal    = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA);
    924924    psVector *gaussNorm   = job->args->data[5]; // gauss kernel
    925925    float minGauss        = PS_SCALAR_VALUE(job->args->data[6],F32);
     
    941941    psImage *calculation  = job->args->data[1]; // calculation image
    942942    psImage *calcMask     = job->args->data[2]; // calculation mask
    943     psMaskType maskVal    = PS_SCALAR_VALUE(job->args->data[3],U8);
     943    psImageMaskType maskVal    = PS_SCALAR_VALUE(job->args->data[3],PS_TYPE_IMAGE_MASK_DATA);
    944944
    945945    psVector *gaussNorm   = job->args->data[4]; // gauss kernel
     
    956956                                    const psImage *image,
    957957                                    const psImage *mask,
    958                                     psMaskType maskVal,
     958                                    psImageMaskType maskVal,
    959959                                    float sigma,
    960960                                    float numSigma,
     
    963963    PS_ASSERT_IMAGE_NON_NULL(image, NULL);
    964964    PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
    965     PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
     965    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
    966966    PS_ASSERT_IMAGES_SIZE_EQUAL(image, mask, NULL);
    967967
     
    999999      case PS_TYPE_F32: {
    10001000          psImage *calculation = psImageAlloc(numRows, numCols, PS_TYPE_F32); /* Calculation image; BW */
    1001           psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_MASK); /* Mask for calculation image; BW */
     1001          psImage *calcMask = psImageAlloc(numRows, numCols, PS_TYPE_IMAGE_MASK); /* Mask for calculation image; BW */
    10021002
    10031003          /** Smooth in X direction **/
     
    10111011              psArrayAdd(job->args, 1, (psImage *) image); // cast away const
    10121012              psArrayAdd(job->args, 1, (psImage *) mask); // cast away const
    1013               PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_U8);
     1013              PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_IMAGE_MASK);
    10141014              psArrayAdd(job->args, 1, gaussNorm);
    10151015              PS_ARRAY_ADD_SCALAR(job->args, minGauss, PS_TYPE_F32);
     
    10461046              psArrayAdd(job->args, 1, calculation);
    10471047              psArrayAdd(job->args, 1, calcMask);
    1048               PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_U8);
     1048              PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_IMAGE_MASK);
    10491049              psArrayAdd(job->args, 1, gaussNorm);
    10501050              PS_ARRAY_ADD_SCALAR(job->args, minGauss, PS_TYPE_F32);
     
    10911091bool psImageSmoothMaskF32 (psImage *image,
    10921092                           psImage *mask,
    1093                            psMaskType maskVal,
     1093                           psImageMaskType maskVal,
    10941094                           double  sigma,
    10951095                           double  Nsigma)
     
    11221122    psVector *calculation = psVectorAlloc(Nx, PS_TYPE_F32);
    11231123    for (int j = 0; j < Ny; j++) {
    1124         psU8  *vm = mask->data.U8[j];
     1124        psImageMaskType  *vm = mask->data.PS_TYPE_IMAGE_MASK_DATA[j];
    11251125        psF32 *vi = image->data.F32[j];
    11261126        psF32 *vo = calculation->data.F32;
     
    11281128        for (int i = 0; i < Nx; i++, vi++, vo++, vm++) {
    11291129            int offset = PS_MIN (i, Nrange);
    1130             psU8  *sm = vm - offset;
     1130            psImageMaskType  *sm = vm - offset;
    11311131            psF32 *si = vi - offset;
    11321132            psF32 *sg = gauss - offset;
     
    11711171        int yMax = PS_MIN (j + Nrange + 1, Ny);
    11721172        for (int n = yMin; n < yMax; n++) {
    1173             psU8  *vm = mask->data.U8[n];
     1173            psImageMaskType  *vm = mask->data.PS_TYPE_IMAGE_MASK_DATA[n];
    11741174            psF32 *vi = image->data.F32[n];
    11751175            psF32 *vo = output->data.F32;
     
    12141214                                     const psImage *input, // Input image
    12151215                                     int start, int stop, // Range of rows
    1216                                      psMaskType maskVal, // Value to mask; NOTE subtle difference!
     1216                                     psImageMaskType maskVal, // Value to mask; NOTE subtle difference!
    12171217                                     int xMin, int xMax // Range in x for kernel
    12181218                                     )
    12191219{
    12201220    // Dereference mask images
    1221     psMaskType **inputData = input->data.PS_TYPE_MASK_DATA;
    1222     psMaskType **targetData = target->data.PS_TYPE_MASK_DATA;
     1221    psImageMaskType **inputData = input->data.PS_TYPE_IMAGE_MASK_DATA;
     1222    psImageMaskType **targetData = target->data.PS_TYPE_IMAGE_MASK_DATA;
    12231223
    12241224    int numCols = input->numCols;       // Number of columns
     
    12411241                min = PS_MAX(0, min);
    12421242                max = PS_MIN(numCols - 1, max);
    1243                 memset(&targetData[y][min], 0xff, (max - min + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_MASK));
     1243                memset(&targetData[y][min], 0xff, (max - min + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK));
    12441244            }
    12451245        }
     
    12471247            // Mask from the minimum to the end of the row
    12481248            min = PS_MAX(0, min);
    1249             memset(&targetData[y][min], 0xff, (numCols - min) * PSELEMTYPE_SIZEOF(PS_TYPE_MASK));
     1249            memset(&targetData[y][min], 0xff, (numCols - min) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK));
    12501250        }
    12511251    }
     
    12561256                                     const psImage *input, // Input image
    12571257                                     int start, int stop, // Range of rows
    1258                                      psMaskType setVal, // Value to set; NOTE subtle difference!
     1258                                     psImageMaskType setVal, // Value to set; NOTE subtle difference!
    12591259                                     int yMin, int yMax // Range in y for kernel
    12601260                                     )
    12611261{
    12621262    // Dereference mask images
    1263     psMaskType **inputData = input->data.PS_TYPE_MASK_DATA;
    1264     psMaskType **targetData = target->data.PS_TYPE_MASK_DATA;
     1263    psImageMaskType **inputData = input->data.PS_TYPE_IMAGE_MASK_DATA;
     1264    psImageMaskType **targetData = target->data.PS_TYPE_IMAGE_MASK_DATA;
    12651265
    12661266    int numRows = input->numRows;       // Number of rows
     
    13081308    int start = PS_SCALAR_VALUE(args->data[2], S32); // Row/col to start at
    13091309    int stop = PS_SCALAR_VALUE(args->data[3], S32); // Row/col to stop at
    1310     psMaskType maskVal = PS_SCALAR_VALUE(args->data[4], U8); // Value to mask/set
     1310    psImageMaskType maskVal = PS_SCALAR_VALUE(args->data[4], PS_TYPE_IMAGE_MASK_DATA); // Value to mask/set
    13111311    int kernelMin = PS_SCALAR_VALUE(args->data[5], S32); // Minimum range for kernel
    13121312    int kernelMax = PS_SCALAR_VALUE(args->data[6], S32); // Maximum range for kernel
     
    13171317}
    13181318
    1319 psImage *psImageConvolveMask(psImage *out, const psImage *mask, psMaskType maskVal,
    1320                              psMaskType setVal, int xMin, int xMax, int yMin, int yMax)
     1319psImage *psImageConvolveMask(psImage *out, const psImage *mask, psImageMaskType maskVal,
     1320                             psImageMaskType setVal, int xMin, int xMax, int yMin, int yMax)
    13211321{
    13221322    PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
    1323     PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
     1323    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
    13241324    if (out) {
    13251325        PS_ASSERT_IMAGE_NON_NULL(out, NULL);
    1326         PS_ASSERT_IMAGE_TYPE(out, PS_TYPE_MASK, NULL);
     1326        PS_ASSERT_IMAGE_TYPE(out, PS_TYPE_IMAGE_MASK, NULL);
    13271327        PS_ASSERT_IMAGES_SIZE_EQUAL(out, mask, NULL);
    13281328        if (out == mask && ((maskVal & setVal) || !setVal)) {
     
    13541354
    13551355    // Propagate the non-masked values
    1356     out = (psImage*)psBinaryOp(out, (const psPtr)mask, "&", psScalarAlloc(~setVal, PS_TYPE_MASK));
     1356    out = (psImage*)psBinaryOp(out, (const psPtr)mask, "&", psScalarAlloc(~setVal, PS_TYPE_IMAGE_MASK));
    13571357
    13581358    if (!setVal) {
     
    13601360    }
    13611361
    1362     psImage *conv = psImageAlloc(numCols, numRows, PS_TYPE_MASK); // Temporary convolved image
     1362    psImage *conv = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); // Temporary convolved image
    13631363    psImageInit(conv, 0);
    13641364
     
    13771377            PS_ARRAY_ADD_SCALAR(job->args, start, PS_TYPE_S32);
    13781378            PS_ARRAY_ADD_SCALAR(job->args, stop, PS_TYPE_S32);
    1379             PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_MASK);
     1379            PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK);
    13801380            PS_ARRAY_ADD_SCALAR(job->args, xMin, PS_TYPE_S32);
    13811381            PS_ARRAY_ADD_SCALAR(job->args, xMax, PS_TYPE_S32);
     
    14151415            PS_ARRAY_ADD_SCALAR(job->args, start, PS_TYPE_S32);
    14161416            PS_ARRAY_ADD_SCALAR(job->args, stop, PS_TYPE_S32);
    1417             PS_ARRAY_ADD_SCALAR(job->args, setVal, PS_TYPE_MASK);
     1417            PS_ARRAY_ADD_SCALAR(job->args, setVal, PS_TYPE_IMAGE_MASK);
    14181418            PS_ARRAY_ADD_SCALAR(job->args, yMin, PS_TYPE_S32);
    14191419            PS_ARRAY_ADD_SCALAR(job->args, yMax, PS_TYPE_S32);
     
    14601460                min = PS_MAX(0, min);
    14611461                max = PS_MIN(numCols - 1, max);
    1462                 memset(&convData[y][min], 0xff, (max - min + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_MASK));
     1462                memset(&convData[y][min], 0xff, (max - min + 1) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK));
    14631463            }
    14641464        }
     
    14661466            // Mask from the minimum to the end of the row
    14671467            min = PS_MAX(0, min);
    1468             memset(&convData[y][min], 0xff, (numCols - min) * PSELEMTYPE_SIZEOF(PS_TYPE_MASK));
     1468            memset(&convData[y][min], 0xff, (numCols - min) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK));
    14691469        }
    14701470    }
  • trunk/psLib/src/imageops/psImageConvolve.h

    r20830 r21183  
    55 * @author Robert DeSonia, MHPCC
    66 *
    7  * @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2008-11-26 00:43:12 $
     7 * @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2009-01-27 06:39:37 $
    99 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1010 */
     
    148148psImage *psImageConvolveMask(psImage *out, ///< Output image, or NULL
    149149                             const psImage *mask, ///< Mask to convolve
    150                              psMaskType maskVal, ///< Mask value to convolve
    151                              psMaskType setVal, ///< Mask value to set; 0 to propagate maskVal
     150                             psImageMaskType maskVal, ///< Mask value to convolve
     151                             psImageMaskType setVal, ///< Mask value to set; 0 to propagate maskVal
    152152                             int xMin, int xMax, int yMin, int yMax ///< Convolution bounds
    153153    );
     
    160160psImage *psImageConvolveMaskDirect(psImage *out, ///< Output image, or NULL
    161161                                   const psImage *mask, ///< Mask to convolve
    162                                    psMaskType maskVal, ///< Mask value to convolve
    163                                    psMaskType setVal, ///< Mask value to set; 0 to propagate maskVal
     162                                   psImageMaskType maskVal, ///< Mask value to convolve
     163                                   psImageMaskType setVal, ///< Mask value to set; 0 to propagate maskVal
    164164                                   int xMin, int xMax, int yMin, int yMax ///< Convolution bounds
    165165    );
     
    174174psImage *psImageConvolveMaskFFT(psImage *out, ///< Output image, or NULL
    175175                                const psImage *mask, ///< Mask to convolve
    176                                 psMaskType maskVal, ///< Mask value to convolve
    177                                 psMaskType setVal, ///< Mask value to set; 0 to use maskVal
     176                                psImageMaskType maskVal, ///< Mask value to convolve
     177                                psImageMaskType setVal, ///< Mask value to set; 0 to use maskVal
    178178                                int xMin, int xMax, int yMin, int yMax, ///< Convolution bounds
    179179                                float thresh ///< Threshold (0..1) for convolved floating-point image
     
    201201    const psImage *image,               ///< Input image (F32 or F64)
    202202    const psImage *mask,                ///< Mask image
    203     psMaskType maskVal,                 ///< Mask value
     203    psImageMaskType maskVal,            ///< Mask value
    204204    float sigma,                        ///< Width of the smoothing kernel (pixels)
    205205    float numSigma,                     ///< Size of the smoothing box (sigma)
     
    211211                                    const psImage *image,
    212212                                    const psImage *mask,
    213                                     psMaskType maskVal,
     213                                    psImageMaskType maskVal,
    214214                                    float sigma,
    215215                                    float numSigma,
     
    219219    psImage *image,                    ///< the image to be smoothed
    220220    psImage *mask,                     ///< optional mask
    221     psMaskType maskVal,
     221    psImageMaskType maskVal,            ///< masked bits
    222222    double  sigma,                     ///< the width of the smoothing kernel in pixels
    223223    double  Nsigma                     ///< the size of the smoothing box in sigmas
  • trunk/psLib/src/imageops/psImageGeomManip.c

    r20299 r21183  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2008-10-21 22:10:53 $
     12 *  @version $Revision: 1.45 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2009-01-27 06:39:37 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3939                      const psImage* in,
    4040                      const psImage* mask,
    41                       psMaskType maskVal,
     41                      psImageMaskType maskVal,
    4242                      int scale,
    4343                      const psStats* stats)
     
    4747    psS32 outRows;
    4848    psS32 outCols;
    49     psVector* vec;                     // vector to hold the values of a single bin.
    50     psVector* maskVec = NULL;          // vector to hold the mask of a single bin.
    51     psMaskType* maskData = NULL;
    52     psStats* myStats;
     49    psVector *vec;                     // vector to hold the values of a single bin.
     50    psVector *maskVec = NULL;          // vector to hold the mask of a single bin.
     51    psVectorMaskType *maskData = NULL;
     52    psStats *myStats;
    5353
    5454    if (in == NULL) {
     
    8686
    8787    if (mask != NULL) {
    88         if (mask->type.type != PS_TYPE_MASK) {
     88        if (mask->type.type != PS_TYPE_IMAGE_MASK) {
    8989            char* typeStr;
    9090            PS_TYPE_NAME(typeStr,mask->type.type);
    9191            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    9292                    _("Input psImage mask type, %s, is not the supported mask datatype of %s."),
    93                     typeStr, PS_TYPE_MASK_NAME);
     93                    typeStr, PS_TYPE_IMAGE_MASK_NAME);
    9494            psFree(out);
    9595            psFree(vec);
    9696            return NULL;
    9797        }
    98         maskVec = psVectorAllocEmpty(scale * scale, PS_TYPE_MASK);
    99         maskData = maskVec->data.PS_TYPE_MASK_DATA;
     98        maskVec = psVectorAllocEmpty(scale * scale, PS_TYPE_VECTOR_MASK);
     99        maskData = maskVec->data.PS_TYPE_VECTOR_MASK_DATA;
    100100    }
    101101
     
    114114        ps##TYPE *outRowData; \
    115115        ps##TYPE *vecData = vec->data.TYPE; \
    116         psMaskType *inRowMask = NULL; \
     116        psImageMaskType *inRowMask = NULL; \
    117117        for (psS32 row = 0; row < outRows; row++) { \
    118118            outRowData = out->data.TYPE[row]; \
     
    126126                    ps##TYPE* inRowData = in->data.TYPE[inRow]; \
    127127                    if (mask != NULL) { \
    128                         inRowMask = mask->data.PS_TYPE_MASK_DATA[inRow]; \
     128                        inRowMask = mask->data.PS_TYPE_IMAGE_MASK_DATA[inRow]; \
    129129                    } \
    130130                    for (psS32 inCol = inCurrentCol; inCol < inNextCol && inCol < inCols; inCol++) { \
    131131                        if (maskData != NULL) { \
    132                             maskData[n] = inRowMask[inCol]; \
     132                            maskData[n] = (inRowMask[inCol] & maskVal); \
    133133                        } \
    134134                        vecData[n++] = inRowData[inCol]; \
     
    139139                    maskVec->n = n; \
    140140                } \
    141                 psVectorStats(myStats, vec, NULL, maskVec, maskVal); \
     141                 psVectorStats(myStats, vec, NULL, maskVec, 0xff); /* the mask vector has only 0 or 1 */ \
    142142                outRowData[col] = (ps##TYPE)psStatsGetValue(myStats, statistic); \
    143143            } \
     
    659659
    660660bool psImageShiftMask(psImage **out, psImage **outMask, const psImage* in, const psImage *inMask,
    661                       psMaskType maskVal, float dx, float dy, double exposed, psMaskType blank,
     661                      psImageMaskType maskVal, float dx, float dy, double exposed, psImageMaskType blank,
    662662                      psImageInterpolateMode mode)
    663663{
     
    667667        PS_ASSERT_IMAGE_NON_NULL(inMask, false);
    668668        PS_ASSERT_IMAGES_SIZE_EQUAL(in, inMask, false);
    669         PS_ASSERT_IMAGE_TYPE(inMask, PS_TYPE_MASK, false);
     669        PS_ASSERT_IMAGE_TYPE(inMask, PS_TYPE_IMAGE_MASK, false);
    670670    }
    671671
     
    675675    *out = psImageRecycle(*out, numCols, numRows, type);
    676676    if (outMask) {
    677         *outMask = psImageRecycle(*outMask, numCols, numRows, PS_TYPE_MASK);
     677        *outMask = psImageRecycle(*outMask, numCols, numRows, PS_TYPE_IMAGE_MASK);
    678678    }
    679679
     
    702702    for (int row = 0; row < numRows; row++) { \
    703703        ps##TYPE* outRow = (*out)->data.TYPE[row]; \
    704         psMaskType *outMaskRow = (outMask ? (*outMask)->data.PS_TYPE_MASK_DATA[row] : NULL); \
     704        psImageMaskType *outMaskRow = (outMask ? (*outMask)->data.PS_TYPE_IMAGE_MASK_DATA[row] : NULL); \
    705705        float y = row + 0.5 - dy; \
    706706        for (int col = 0; col < numCols; col++) { \
    707707            float x = col + 0.5 - dx; \
    708708            double value; \
    709             psMaskType valueMask = 0; \
     709            psImageMaskType valueMask = 0; \
    710710            if (!psImageInterpolate(&value, NULL, &valueMask, x, y, interp)) { \
    711711                psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); \
     
    750750                          const psImage *input,
    751751                          const psImage *inputMask,
    752                           psMaskType inputMaskVal,
     752                          psImageMaskType inputMaskVal,
    753753                          const psPlaneTransform *outToIn,
    754754                          psRegion region,
     
    778778            return NULL;
    779779        }
    780         if (inputMask->type.type != PS_TYPE_MASK) {
     780        if (inputMask->type.type != PS_TYPE_IMAGE_MASK) {
    781781            char* typeStr;
    782782            PS_TYPE_NAME(typeStr,inputMask->type.type);
    783783            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    784784                    _("Input psImage mask type, %s, is not the supported mask datatype of %s."),
    785                     typeStr, PS_TYPE_MASK_NAME);
     785                    typeStr, PS_TYPE_IMAGE_MASK_NAME);
    786786            psFree(output);
    787787            return NULL;
  • trunk/psLib/src/imageops/psImageGeomManip.h

    r16910 r21183  
    66 * @author Robert DeSonia, MHPCC
    77 *
    8  * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
    9  * @date $Date: 2008-03-11 00:41:30 $
     8 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
     9 * @date $Date: 2009-01-27 06:39:37 $
    1010 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1111 */
     
    3636    const psImage* in,                 ///< input image
    3737    const psImage* mask,               ///< mask for input image.  If NULL, no masking is done.
    38     psMaskType maskVal,                ///< the bits to check in mask.
     38    psImageMaskType maskVal,            ///< the bits to check in mask.
    3939    int scale,                         ///< the scale to rebin for each dimension
    4040    const psStats* stats
     
    106106    const psImage* in,                  ///< Input image
    107107    const psImage *inMask,              ///< Input mask, or NULL
    108     psMaskType maskVal,                 ///< Value to mask
     108    psImageMaskType maskVal,            ///< Value to mask
    109109    float dx, float dy,                 ///< Shift to apply
    110110    double exposed,                     ///< Value to give exposed pixels
    111     psMaskType blank,                   ///< Mask value for exposed pixels
     111    psImageMaskType blank,              ///< Mask value for exposed pixels
    112112    psImageInterpolateMode mode         ///< Interpolation mode
    113113    );
     
    159159    const psImage *input,              ///< psImage to apply transform to
    160160    const psImage *inputMask,          ///< if not NULL, mask of input psImage
    161     psMaskType inputMaskVal,           ///< masking value for inputMask
     161    psImageMaskType inputMaskVal,       ///< masking value for inputMask
    162162    const psPlaneTransform *outToIn,   ///< the transform to apply
    163163    psRegion region,                   ///< the size of the transformed image
  • trunk/psLib/src/imageops/psImageInterpolate.c

    r20758 r21183  
    77 *  @author Paul Price, IfA
    88 *
    9  *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2008-11-15 03:09:34 $
     9 *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2009-01-27 06:39:37 $
    1111 *
    1212 *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
     
    205205psImageInterpolation *psImageInterpolationAlloc(psImageInterpolateMode mode,
    206206                                                const psImage *image, const psImage *variance,
    207                                                 const psImage *mask, psMaskType maskVal,
     207                                                const psImage *mask, psImageMaskType maskVal,
    208208                                                double badImage, double badVariance,
    209                                                 psMaskType badMask, psMaskType poorMask,
     209                                                psImageMaskType badMask, psImageMaskType poorMask,
    210210                                                float poorFrac, int numKernels)
    211211{
     
    274274// Interpolation engine for flat mode (nearest pixel)
    275275static inline psImageInterpolateStatus interpolateFlat(double *imageValue, double *varianceValue,
    276                                                        psMaskType *maskValue, float x, float y,
     276                                                       psImageMaskType *maskValue, float x, float y,
    277277                                                       const psImageInterpolation *interp)
    278278{
     
    331331        if (maskValue) {
    332332            if (interp->mask) {
    333                 *maskValue = interp->mask->data.PS_TYPE_MASK_DATA[yInt][xInt];
     333                *maskValue = interp->mask->data.PS_TYPE_IMAGE_MASK_DATA[yInt][xInt];
    334334            } else {
    335335                *maskValue = 0;
     
    456456// Interpolation engine for separable interpolation kernels
    457457static psImageInterpolateStatus interpolateSeparable(double *imageValue, double *varianceValue,
    458                                                      psMaskType *maskValue, float x, float y,
     458                                                     psImageMaskType *maskValue, float x, float y,
    459459                                                     const psImageInterpolation *interp)
    460460{
     
    465465    const psImage *mask = interp->mask; // Image mask
    466466    const psImage *variance = interp->variance; // Image variance
    467     psMaskType maskVal = interp->maskVal; // Value to mask
     467    psImageMaskType maskVal = interp->maskVal; // Value to mask
    468468    bool wantVariance = variance && varianceValue; // Does the user want the variance value?
    469469    bool haveMask = mask && maskVal; // Does the user want the variance value?
     
    582582                  const ps##TYPE *imageData = &image->data.TYPE[yPix][xMin]; \
    583583                  const ps##TYPE *varianceData = &variance->data.TYPE[yPix][xMin]; \
    584                   const psMaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[yPix][xMin]; \
     584                  const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[yPix][xMin]; \
    585585                  const psF32 *xKernelData = xKernel; \
    586586                  const psF32 *xKernel2Data = xKernel2; \
     
    642642              /* Dereferenced versions of inputs */ \
    643643              const ps##TYPE *imageData = &image->data.TYPE[yPix][xMin]; \
    644               const psMaskType *maskData = &mask->data.PS_TYPE_MASK_DATA[yPix][xMin]; \
     644              const psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[yPix][xMin]; \
    645645              const psF32 *xKernelData = xKernel; \
    646646              const psF32 *xKernel2Data = xKernel2; \
     
    713713// Interpolation engine for (separable) interpolation kernels
    714714static psImageInterpolateStatus interpolateKernel(double *imageValue, double *varianceValue,
    715                                                   psMaskType *maskValue, float x, float y,
     715                                                  psImageMaskType *maskValue, float x, float y,
    716716                                                  const psImageInterpolation *interp)
    717717{
     
    722722    const psImage *mask = interp->mask; // Image mask
    723723    const psImage *variance = interp->variance; // Image variance
    724     psMaskType maskVal = interp->maskVal; // Value to mask
     724    psImageMaskType maskVal = interp->maskVal; // Value to mask
    725725    bool wantVariance = variance && varianceValue; // Does the user want the variance value?
    726726    bool haveMask = mask && maskVal; // Does the user want the variance value?
     
    790790                      float kernelValue = kernel[j][i]; /* Value of kernel */ \
    791791                      float kernelValue2 = PS_SQR(kernelValue); /* Square of kernel */ \
    792                       if (mask->data.PS_TYPE_MASK_DATA[yPix][xPix] & maskVal) { \
     792                      if (mask->data.PS_TYPE_IMAGE_MASK_DATA[yPix][xPix] & maskVal) { \
    793793                          sumBad += kernelValue2; \
    794794                      } else { \
     
    820820                  float kernelValue = kernel[j][i]; /* Value of kernel */ \
    821821                  float kernelValue2 = PS_SQR(kernelValue); /* Square of kernel */ \
    822                   if (mask->data.PS_TYPE_MASK_DATA[yPix][xPix] & maskVal) { \
     822                  if (mask->data.PS_TYPE_IMAGE_MASK_DATA[yPix][xPix] & maskVal) { \
    823823                      sumBad += kernelValue2; \
    824824                  } else { \
     
    866866
    867867
    868 psImageInterpolateStatus psImageInterpolate(double *imageValue, double *varianceValue, psMaskType *maskValue,
     868psImageInterpolateStatus psImageInterpolate(double *imageValue, double *varianceValue, psImageMaskType *maskValue,
    869869                                            float x, float y, const psImageInterpolation *interp)
    870870{
     
    885885    if (maskValue && mask) {
    886886        PS_ASSERT_IMAGE_NON_NULL(mask, PS_INTERPOLATE_STATUS_ERROR);
    887         PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, PS_INTERPOLATE_STATUS_ERROR);
     887        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, PS_INTERPOLATE_STATUS_ERROR);
    888888        psAssert(image->numCols == mask->numCols && image->numRows == mask->numRows, "Image and mask sizes");
    889889    }
  • trunk/psLib/src/imageops/psImageInterpolate.h

    r20327 r21183  
    77 * @author Paul Price, Institute for Astronomy
    88 *
    9  * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    10  * @date $Date: 2008-10-22 19:21:06 $
     9 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     10 * @date $Date: 2009-01-27 06:39:37 $
    1111 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii
    1212 */
     
    5050    const psImage *variance;            ///< Variance image for interpolation
    5151    const psImage *mask;                ///< Mask image for interpolation
    52     psMaskType maskVal;                 ///< Value to mask
     52    psImageMaskType maskVal;            ///< Value to mask
    5353    double badImage;                    ///< Image value if x,y location is not good
    5454    double badVariance;                 ///< Variance value if x,y location is not good
    55     psMaskType badMask;                 ///< Mask value to give bad pixels
    56     psMaskType poorMask;                ///< Mask value to give poor pixels
     55    psImageMaskType badMask;            ///< Mask value to give bad pixels
     56    psImageMaskType poorMask;           ///< Mask value to give poor pixels
    5757    float poorFrac;                     ///< Fraction of flux in bad pixels before output is marked bad
    5858    bool shifting;                      ///< Shifting images? Don't interpolate if the shift is exact.
     
    6969    const psImage *variance,            // Variance image
    7070    const psImage *mask,                // Mask image
    71     psMaskType maskVal,                 // Value to mask
     71    psImageMaskType maskVal,                 // Value to mask
    7272    double badImage,                    // Value for image if bad
    7373    double badVariance,                 // Value for variance if bad
    74     psMaskType badMask,                 // Mask value for bad pixels
    75     psMaskType poorMask,                // Mask value for poor pixels
     74    psImageMaskType badMask,                 // Mask value for bad pixels
     75    psImageMaskType poorMask,                // Mask value for poor pixels
    7676    float poorFrac,                     // Fraction of flux for question
    7777    int numKernels                      // Number of interpolation kernels to pre-calculate
     
    8383    double *imageValue,                 ///< Return value for image
    8484    double *varianceValue,              ///< Return value for variance
    85     psMaskType *maskValue,              ///< Return value for mask
     85    psImageMaskType *maskValue,              ///< Return value for mask
    8686    float x, float y,                   ///< Location to which to interpolate
    8787    const psImageInterpolation *options ///< Options
  • trunk/psLib/src/imageops/psImageMap.c

    r21172 r21183  
    77 *  @author Eugene Magnier, IfA
    88 *
    9  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2009-01-27 00:00:21 $
     9 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2009-01-27 06:39:37 $
    1111 *
    1212 *  Copyright 2007 Institute for Astronomy, University of Hawaii
     
    145145    }
    146146
    147     psImage *mask = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_MASK);
     147    psImage *mask = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_IMAGE_MASK);
    148148    psImage *xCoord = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_F32);
    149149    psImage *yCoord = psImageAlloc (map->map->numCols, map->map->numRows, PS_TYPE_F32);
     
    212212            // this will not in general be properly weighted...
    213213            if (psVectorStats (map->stats, fCell, dfCell, NULL, 0)) {
    214                 mask->data.U8[iy][ix] = 0;
     214                mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] = 0;
    215215                // XXX ensure only one option is selected, or save both position and width
    216216                map->map->data.F32[iy][ix] = psStatsGetValue (map->stats, map->stats->options);
     
    224224                yCoord->data.F32[iy][ix] = psStatsGetValue (meanStat, meanStat->options);
    225225            } else {
    226                 mask->data.U8[iy][ix] = 1;
     226                mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] = 1;
    227227            }
    228228
     
    353353}
    354354
    355 psVector *psImageMapEvalVector(const psImageMap *map, const psVector *mask, psMaskType maskValue, const psVector *x, const psVector *y)
     355psVector *psImageMapEvalVector(const psImageMap *map, const psVector *mask, psVectorMaskType maskValue, const psVector *x, const psVector *y)
    356356{
    357357    PS_ASSERT_IMAGE_MAP_NON_NULL(map, NULL);
     
    365365
    366366    for (int i = 0; i < x->n; i++) {
    367       if (mask && (mask->data.U8[i] & maskValue)) {
     367      if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) {
    368368        result->data.F32[i] = 0.0;
    369369      } else { 
  • trunk/psLib/src/imageops/psImageMapFit.c

    r21172 r21183  
    77 *  @author Eugene Magnier, IfA
    88 *
    9  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2009-01-27 00:00:21 $
     9 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2009-01-27 06:39:37 $
    1111 *
    1212 *  Copyright 2007 Institute for Astronomy, University of Hawaii
     
    4747
    4848// map defines the output image dimensions and scaling.
    49 bool psImageMapFit(psImageMap *map, const psVector *mask, psMaskType maskValue,
     49bool psImageMapFit(psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
    5050                   const psVector *x, const psVector *y, const psVector *f, const psVector *df)
    5151{
     
    145145            for (int i = 0; i < x->n; i++) {
    146146
    147                 if (mask && (mask->data.U8[i] & maskValue)) continue;
     147                if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) continue;
    148148
    149149                // base coordinate offset for this point (x,y) relative to this map element (n,m)
     
    338338
    339339// measure residuals on each pass and clip outliers based on stats
    340 bool psImageMapClipFit(psImageMap *map, psStats *stats, psVector *inMask, psMaskType maskValue,
     340bool psImageMapClipFit(psImageMap *map, psStats *stats, psVector *inMask, psVectorMaskType maskValue,
    341341                       const psVector *x, const psVector *y, const psVector *f, const psVector *df)
    342342{
     
    377377    psVector *mask = inMask;
    378378    if (!inMask) {
    379         mask = psVectorAlloc (x->n, PS_TYPE_U8);
     379        mask = psVectorAlloc (x->n, PS_TYPE_VECTOR_MASK);
    380380        psVectorInit (mask, 0);
    381381    }
     
    429429        for (psS32 i = 0; i < resid->n; i++) {
    430430            // XXX this prevents recovery of previously masked values
    431             if (mask->data.U8[i] & maskValue) {
     431            if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue) {
    432432                continue;
    433433            }
     
    435435            if ((resid->data.F32[i] - meanValue > maxClipValue) || (resid->data.F32[i] - meanValue < minClipValue)) {
    436436                psTrace("psLib.imageops", 6, "Masking element %d  : %f vs %f : resid is %f\n", i, f->data.F32[i], fit->data.F32[i], resid->data.F32[i]);
    437                 mask->data.U8[i] |= 0x01;
     437                mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01;
    438438                continue;
    439439            }
     
    455455
    456456// map defines the output image dimensions and scaling.
    457 bool psImageMapFit1DinY(psImageMap *map, const psVector *mask, psMaskType maskValue,
     457bool psImageMapFit1DinY(psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
    458458                        const psVector *x, const psVector *y, const psVector *f, const psVector *df)
    459459{
     
    490490        for (int i = 0; i < y->n; i++) {
    491491
    492             if (mask && (mask->data.U8[i] & maskValue)) continue;
     492            if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) continue;
    493493
    494494            float dy = psImageBinningGetRuffY (map->binning, y->data.F32[i]) - (m + 0.5);
     
    603603
    604604// map defines the output image dimensions and scaling.
    605 bool psImageMapFit1DinX(psImageMap *map, const psVector *mask, psMaskType maskValue,
     605bool psImageMapFit1DinX(psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
    606606                        const psVector *x, const psVector *y, const psVector *f, const psVector *df)
    607607{
     
    638638        for (int i = 0; i < x->n; i++) {
    639639
    640             if (mask && (mask->data.U8[i] & maskValue)) continue;
     640            if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) continue;
    641641
    642642            float dx = psImageBinningGetRuffX (map->binning, x->data.F32[i]) - (m + 0.5);
  • trunk/psLib/src/imageops/psImageMapFit.h

    r15841 r21183  
    1010bool psImageMapFit(psImageMap *map,
    1111                   const psVector *mask,
    12                    psMaskType maskValue,
     12                   psVectorMaskType maskValue, //
    1313                   const psVector *x,
    1414                   const psVector *y,
     
    2121                       psStats *stats,
    2222                       psVector *mask,  // WARNING: Mask is modified!
    23                        psMaskType maskValue,
     23                       psVectorMaskType maskValue,
    2424                       const psVector *x,
    2525                       const psVector *y,
     
    3030bool psImageMapFit1DinY(psImageMap *map,
    3131                        const psVector *mask,
    32                         psMaskType maskValue,
     32                        psVectorMaskType maskValue,
    3333                        const psVector *x,
    3434                        const psVector *y,
     
    3939bool psImageMapFit1DinX(psImageMap *map,
    4040                        const psVector *mask,
    41                         psMaskType maskValue,
     41                        psVectorMaskType maskValue,
    4242                        const psVector *x,
    4343                        const psVector *y,
  • trunk/psLib/src/imageops/psImageMaskOps.c

    r18494 r21183  
    88 *  @author David Robbins, MHPCC
    99 *
    10  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2008-07-12 21:08:33 $
     10 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2009-01-27 06:39:37 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3737                       psRegion region,
    3838                       const char *op,
    39                        psMaskType maskValue)
     39                       psImageMaskType maskValue)
    4040{
    4141    if (image == NULL) {
     
    5353          if ((i + image->col0) < region.x0) continue; \
    5454          if ((i + image->col0) > region.x1) continue; /* is this correct (not >= ?) */ \
    55           image->data.PS_TYPE_MASK_DATA[j][i] OP maskValue; \
     55          image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] OP maskValue; \
    5656        } \
    5757      }
     
    8484                       psRegion region,
    8585                       const char *op,
    86                        psMaskType maskValue)
     86                       psImageMaskType maskValue)
    8787{
    8888    if (image == NULL) {
     
    100100            (i + image->col0) < region.x0 || \
    101101            (i + image->col0) > region.x1 ) { \
    102           image->data.PS_TYPE_MASK_DATA[j][i] OP maskValue; \
     102          image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] OP maskValue; \
    103103        } } }
    104104
     
    131131                       double radius,
    132132                       const char *op,
    133                        psMaskType maskValue)
     133                       psImageMaskType maskValue)
    134134{
    135135    if (image == NULL) {
     
    150150            r2 = PS_SQR(dx) + PS_SQR(dy); \
    151151            if (r2 <= R2) { \
    152               image->data.PS_TYPE_MASK_DATA[iy][ix] OP maskValue; \
     152              image->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] OP maskValue; \
    153153            } } }
    154154
     
    182182                       double radius,
    183183                       const char *op,
    184                        psMaskType maskValue)
     184                       psImageMaskType maskValue)
    185185{
    186186
     
    201201            r2 = PS_SQR(dx) + PS_SQR(dy); \
    202202            if (r2 > R2) { \
    203               image->data.PS_TYPE_MASK_DATA[iy][ix] OP maskValue; \
     203              image->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] OP maskValue; \
    204204            } } }
    205205
     
    228228psImage *psImageGrowMask(psImage *out,
    229229                         const psImage *in,
    230                          psMaskType maskVal,
     230                         psImageMaskType maskVal,
    231231                         unsigned int growSize,
    232                          psMaskType growVal)
     232                         psImageMaskType growVal)
    233233{
    234234    if (in == NULL) {
     
    237237        return NULL;
    238238    }
    239     if (in->type.type != PS_TYPE_MASK) {
     239    if (in->type.type != PS_TYPE_IMAGE_MASK) {
    240240        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    241                 "Invalid input image.  Input image type must match psMaskType.\n");
     241                "Invalid input image.  Input image type must match psImageMaskType.\n");
    242242        return NULL;
    243243    }
     
    261261    for (k = 0; k < in->numRows; k++) {
    262262        for (l = 0; l < in->numCols; l++) {
    263             out->data.PS_TYPE_MASK_DATA[k][l] = in->data.PS_TYPE_MASK_DATA[k][l];
    264             changed->data.PS_TYPE_MASK_DATA[k][l] = 0;
     263            out->data.PS_TYPE_IMAGE_MASK_DATA[k][l] = in->data.PS_TYPE_IMAGE_MASK_DATA[k][l];
     264            changed->data.PS_TYPE_IMAGE_MASK_DATA[k][l] = 0;
    265265        }
    266266    }
     
    268268    for (int i = 0; i < in->numRows; i++) {
    269269        for (int j = 0; j < in->numCols; j++) {
    270             if ( (in->data.PS_TYPE_MASK_DATA[i][j] & maskVal) != 0 &&
    271                     changed->data.PS_TYPE_MASK_DATA[i][j] == 0) {
     270            if ( (in->data.PS_TYPE_IMAGE_MASK_DATA[i][j] & maskVal) != 0 &&
     271                    changed->data.PS_TYPE_IMAGE_MASK_DATA[i][j] == 0) {
    272272                m = i - growSize;
    273273                if (m < 0) {
     
    281281                    for (l = n; l <= (j + growSize) && l < in->numCols; l++) {
    282282                        if (((k-i)*(k-i) + (l-j)*(l-j)) <= (growSize*growSize)) {
    283                             out->data.PS_TYPE_MASK_DATA[k][l] |= growVal;
    284                             if ( (in->data.PS_TYPE_MASK_DATA[i][j] & maskVal) == 0 ) {
    285                                 changed->data.PS_TYPE_MASK_DATA[k][l] = 1;
     283                            out->data.PS_TYPE_IMAGE_MASK_DATA[k][l] |= growVal;
     284                            if ( (in->data.PS_TYPE_IMAGE_MASK_DATA[i][j] & maskVal) == 0 ) {
     285                                changed->data.PS_TYPE_IMAGE_MASK_DATA[k][l] = 1;
    286286                            }
    287287                        }
  • trunk/psLib/src/imageops/psImageMaskOps.h

    r11248 r21183  
    66 * @author David Robbins, MHPCC
    77 *
    8  * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9  * @date $Date: 2007-01-23 22:47:23 $
     8 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9 * @date $Date: 2009-01-27 06:39:37 $
    1010 *
    1111 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3232    psRegion region,                   ///< the specified region
    3333    const char *op,                    ///< the logical operation
    34     psMaskType maskValue               ///< the specified bits
     34    psImageMaskType maskValue           ///< the specified bits
    3535);
    3636
     
    4444    psRegion region,                   ///< the specified region
    4545    const char *op,                    ///< the logical operation
    46     psMaskType maskValue               ///< the specified bits
     46    psImageMaskType maskValue           ///< the specified bits
    4747);
    4848
     
    5858    double radius,                     ///< the radius of the specified circle
    5959    const char *op,                    ///< the logical operation
    60     psMaskType maskValue               ///< the specified bits
     60    psImageMaskType maskValue           ///< the specified bits
    6161);
    6262
     
    7272    double radius,                     ///< the radius of the specified circle
    7373    const char *op,                    ///< the logical operation
    74     psMaskType maskValue               ///< the specified bits
     74    psImageMaskType maskValue           ///< the specified bits
    7575);
    7676
     
    8989    psImage *out,                      ///< the image to set and return
    9090    const psImage *in,                 ///< the input to image
    91     psMaskType maskVal,                ///< the specified mask value
     91    psImageMaskType maskVal,            ///< the specified mask value
    9292    unsigned int growSize,             ///< the range of values from maskVal
    93     psMaskType growVal                 ///< the output value to set
     93    psImageMaskType growVal             ///< the output value to set
    9494);
    9595
  • trunk/psLib/src/imageops/psImagePixelExtract.c

    r20306 r21183  
    88 *  @author Robert DeSonia, MHPCC
    99 *
    10  *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2008-10-22 02:10:37 $
     10 *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2009-01-27 06:39:37 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    206206                       const psImage* input,
    207207                       const psImage* mask,
    208                        psMaskType maskVal,
     208                       psImageMaskType maskVal,
    209209                       psRegion region,
    210210                       psImageCutDirection direction,
     
    357357            return NULL;
    358358        }
    359         if (mask->type.type != PS_TYPE_MASK) {
     359        if (mask->type.type != PS_TYPE_IMAGE_MASK) {
    360360            char* typeStr;
    361361            PS_TYPE_NAME(typeStr,mask->type.type);
    362362            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    363363                    _("Input psImage mask type, %s, is not the supported mask datatype of %s."),
    364                     typeStr, PS_TYPE_MASK_NAME);
     364                    typeStr, PS_TYPE_IMAGE_MASK_NAME);
    365365            psFree(out);
    366366            return NULL;
     
    394394        psVector* imgVec = psVectorAlloc(numRows, type);
    395395        psVector* maskVec = NULL;
    396         psMaskType* maskData = NULL;
     396        psImageMaskType* maskData = NULL;
    397397        psPixelCoord* outPosition = NULL;
    398398
     
    416416
    417417        if (mask != NULL) {
    418             maskVec = psVectorAlloc(numRows, mask->type.type);
    419         }
    420         #define PSIMAGE_CUT_VERTICAL(TYPE) \
     418            maskVec = psVectorAlloc(numRows, PS_TYPE_VECTOR_MASK);
     419        }
     420
     421#define PSIMAGE_CUT_VERTICAL(TYPE) \
    421422    case PS_TYPE_##TYPE: { \
    422             psMaskType* maskVecData = NULL; \
    423             for (psS32 c=col0;c<col1;c++) { \
     423            psVectorMaskType* maskVecData = NULL; \
     424            for (psS32 c = col0; c < col1; c++) { \
    424425                ps##TYPE *imgData = input->data.TYPE[row0] + c; \
    425426                ps##TYPE *imgVecData = imgVec->data.TYPE; \
    426427                if (maskVec != NULL) { \
    427                     maskVecData = maskVec->data.U8; \
    428                     maskData = (psMaskType* )(mask->data.U8[row0]) + c; \
     428                    maskVecData = maskVec->data.PS_TYPE_VECTOR_MASK_DATA; \
     429                    maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[row0][c]; /* XXX double check this... */ \
     430                    /** old entry: maskData = (psMaskType* )(mask->data.PS_TYPE_IMAGE_MASK_DATA[row0]) + c; */ \
    429431                } \
    430                 for (psS32 r=row0;r<row1;r++) { \
    431                     *(imgVecData++) = *imgData; \
     432                for (psS32 r = row0; r < row1; r++) { \
     433                   *imgVecData = *imgData; \
     434                    imgVecData ++; \
    432435                    imgData += inCols; \
    433436                    if (maskVecData != NULL) { \
    434                         *(maskVecData++) = *maskData; \
     437                        *maskVecData = (*maskData & maskVal); \
     438                        maskVecData ++; \
    435439                        maskData += inCols; \
    436440                    } \
    437441                } \
    438                 psVectorStats(myStats,imgVec,NULL,maskVec,maskVal); \
     442                psVectorStats(myStats, imgVec, NULL, maskVec, 0xff); \
    439443                *outData = psStatsGetValue(myStats, statistic); \
    440444                if (outPosition != NULL) { \
     
    471475        psFree(imgVec);
    472476        psFree(maskVec);
     477
    473478    } else if (direction == PS_CUT_Y_POS || direction == PS_CUT_Y_NEG) {
    474479        // Cut in Y direction
     480        // XXX use this if we drop the hackish stuff below: psVector* imgVec = psVectorAlloc(numCols, type);
    475481        psVector* imgVec = NULL;
    476482        psVector* maskVec = NULL;
     
    479485
    480486        // fill in psVector to fake out the statistics functions.
     487        // XXX EAM : this seems rather hackish: just use the needed psVectorAlloc (like above)?
    481488        imgVec = psAlloc(sizeof(psVector));
    482489        imgVec->type = input->type;
    483490        P_PSVECTOR_SET_NALLOC(imgVec,numCols);
    484         if (mask != NULL) {
    485             maskVec = psAlloc(sizeof(psVector));
    486             maskVec->type = mask->type;
    487             P_PSVECTOR_SET_NALLOC(maskVec,numCols);
    488         }
     491        imgVec->n = imgVec->nalloc;
     492
    489493        // recycle output to make a proper sized/type output structure
    490494        // n.b. type is double as that is the type given for all stats in
     
    492496        out = psVectorRecycle(out, numRows, PS_TYPE_F64);
    493497        out->n = numRows;
    494         imgVec->n = imgVec->nalloc;
    495         maskVec->n = maskVec->nalloc;
    496498        if (coords != NULL) {
    497499            coords = psPixelsRealloc(coords, numRows);
     
    507509        }
    508510
     511        if (mask != NULL) {
     512            maskVec = psVectorAlloc(numRows, PS_TYPE_VECTOR_MASK);
     513            // XXX the old code (below) faked out the mask vector
     514            // maskVec = psAlloc(sizeof(psVector));
     515            // maskVec->type = mask->type;
     516            // P_PSVECTOR_SET_NALLOC(maskVec,numCols);
     517            // maskVec->n = maskVec->nalloc;
     518        }
     519
    509520        for (psS32 r = row0; r < row1; r++) {
    510521            // point the vector struct to the
    511522            // data to calculate the stats
    512523            imgVec->data.U8 = (psPtr )(input->data.U8[r] + col0 * elementSize);
     524
     525            // set the vector mask pixels based on the image pixels
    513526            if (maskVec != NULL) {
    514                 maskVec->data.U8 = (psPtr )(mask->data.U8[r] + col0 * sizeof(psMaskType));
    515             }
    516             psVectorStats(myStats, imgVec, NULL, maskVec, maskVal);
     527                psVectorMaskType *maskVecData = maskVec->data.PS_TYPE_VECTOR_MASK_DATA;
     528                psImageMaskType *maskData = &mask->data.PS_TYPE_IMAGE_MASK_DATA[r][col0];
     529                for (psS32 c = col0; c < col1; c++) {
     530                    *maskVecData = (*maskData & maskVal);
     531                    maskVecData ++;
     532                    maskData ++;
     533                }
     534            }
     535
     536            psVectorStats(myStats, imgVec, NULL, maskVec, 0xff);
    517537            *outData = psStatsGetValue(myStats, statistic);
    518538            if (outPosition != NULL) {
     
    544564                     const psImage* input,
    545565                     const psImage* mask,
    546                      psMaskType maskVal,
     566                     psImageMaskType maskVal,
    547567                     psRegion region,
    548568                     unsigned int nSamples,
     
    651671            return NULL;
    652672        }
    653         if (mask->type.type != PS_TYPE_MASK) {
     673        if (mask->type.type != PS_TYPE_IMAGE_MASK) {
    654674            char* typeStr;
    655675            PS_TYPE_NAME(typeStr,mask->type.type);
    656676            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    657677                    _("Input psImage mask type, %s, is not the supported mask datatype of %s."),
    658                     typeStr, PS_TYPE_MASK_NAME);
     678                    typeStr, PS_TYPE_IMAGE_MASK_NAME);
    659679            psFree(out);
    660680            return NULL;
     
    739759                           const psImage* input,
    740760                           const psImage* mask,
    741                            psMaskType maskVal,
     761                           psImageMaskType maskVal,
    742762                           float x,
    743763                           float y,
     
    765785            return NULL;
    766786        }
    767         if (mask->type.type != PS_TYPE_MASK) {
     787        if (mask->type.type != PS_TYPE_IMAGE_MASK) {
    768788            char* typeStr;
    769789            PS_TYPE_NAME(typeStr,mask->type.type);
    770790            psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    771791                    _("Input psImage mask type, %s, is not the supported mask datatype of %s."),
    772                     typeStr, PS_TYPE_MASK_NAME);
     792                    typeStr, PS_TYPE_IMAGE_MASK_NAME);
    773793            psFree(out);
    774794            return NULL;
     
    868888        if (mask != NULL) {
    869889            bufferMask[lcv] = psVectorAllocEmpty(1+4*(rSq[lcv+1]-rSq[lcv]),
    870                                                  PS_TYPE_MASK);
     890                                                 PS_TYPE_VECTOR_MASK);
    871891        }
    872892    }
     
    877897    for (psS32 row=startRow; row <= endRow; row++) {
    878898        psF32* inRow = input->data.F32[row];
    879         psMaskType* maskRow = NULL;
     899        psImageMaskType* maskRow = NULL;
    880900        if (mask != NULL) {
    881             maskRow = mask->data.PS_TYPE_MASK_DATA[row];
     901            maskRow = mask->data.PS_TYPE_IMAGE_MASK_DATA[row];
    882902        }
    883903        for (psS32 col=startCol; col <= endCol; col++) {
     
    899919
    900920                    if (maskRow != NULL) {
    901                         bufferMask[r]->data.PS_TYPE_MASK_DATA[n] = maskRow[col];
     921                        bufferMask[r]->data.PS_TYPE_VECTOR_MASK_DATA[n] = (maskRow[col] & maskVal);
    902922                        bufferMask[r]->n = n+1;
    903923                    }
     
    913933
    914934    for (psS32 r = 0; r < numOut; r++) {
    915         psVectorStats(myStats,buffer[r], NULL, bufferMask[r],maskVal);
     935        psVectorStats(myStats, buffer[r], NULL, bufferMask[r], 0xff);
    916936        outData[r] = psStatsGetValue(myStats, statistic);
    917937    }
  • trunk/psLib/src/imageops/psImagePixelExtract.h

    r11248 r21183  
    55 * @author Robert DeSonia, MHPCC
    66 *
    7  * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2007-01-23 22:47:23 $
     7 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2009-01-27 06:39:37 $
    99 *
    1010 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    8484    const psImage* input,              ///< the input image in which to perform the slice
    8585    const psImage* mask,               ///< the mask for the input image.
    86     psMaskType maskVal,                ///< the mask value to apply to the mask
     86    psImageMaskType maskVal,            ///< the mask value to apply to the mask
    8787    psRegion region,                   ///< the slice region
    8888    psImageCutDirection direction,     ///< the slice dimension and direction
     
    112112    const psImage* input,              ///< the input image in which to perform the cut
    113113    const psImage* mask,               ///< the mask for the input image.
    114     psMaskType maskVal,                ///< the mask value to apply to the mask
     114    psImageMaskType maskVal,            ///< the mask value to apply to the mask
    115115    psRegion region,                   ///< the start and end points to cut along
    116116    unsigned int nSamples,             ///< the number of samples along the cut
     
    135135    const psImage* input,              ///< the input image in which to perform the cut
    136136    const psImage* mask,               ///< the mask for the input image.
    137     psMaskType maskVal,                ///< the mask value to apply to the mask
     137    psImageMaskType maskVal,            ///< the mask value to apply to the mask
    138138    float x,                           ///< the column of the center of the cut circle
    139139    float y,                           ///< the row of the center of the cut circle
  • trunk/psLib/src/imageops/psImagePixelInterpolate.c

    r15254 r21183  
    1111 *  @author Eugene Magnier, IfA
    1212 *
    13  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2007-10-09 19:25:44 $
     13 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2009-01-27 06:39:37 $
    1515 *
    1616 *  Copyright 2007 Institute for Astronomy, University of Hawaii
     
    5454                    /* do not test self */ \
    5555                    if (!jx && !jy) { continue; } \
    56                     if (mask->data.PS_TYPE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } \
     56                    if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; } \
    5757                    nGood ++; \
    5858                } \
     
    6767// just the mask, the output image contains enum values which define the type of interpolation which
    6868// can be performed
    69 psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, psMaskType maskVal) {
     69psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, psImageMaskType maskVal) {
    7070
    7171    psImage *result = psImageAlloc (mask->numCols, mask->numRows, PS_TYPE_S32);
     
    7979
    8080            // state of the good pixels (unmasked)
    81             if (!(mask->data.PS_TYPE_MASK_DATA[iy][ix] & maskVal)) {
     81            if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskVal)) {
    8282                // count good neighbor pixels (+ self)
    8383                int nGood = 0;
     
    9494                        if (jx + ix < 0) { continue; }
    9595                        if (jx + ix >= mask->numCols) { continue; }
    96                         if (mask->data.PS_TYPE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
     96                        if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
    9797                        nGood ++;
    9898                        minX = PS_MIN (minX, jx);
     
    137137
    138138// interpolate the poor pixels using the available options
    139 bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, psMaskType maskVal) {
     139bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, psImageMaskType maskVal) {
    140140
    141141    assert (image->numCols == state->numCols);
     
    185185                          if (!jx && !jy) { continue; }
    186186                          // skip masked pixels
    187                           if (mask->data.PS_TYPE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
     187                          if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
    188188                          x->data.F32[n] = jx;
    189189                          y->data.F32[n] = jy;
     
    241241   
    242242// interpolate the good pixels to their true centers
    243 bool psImagePixelInterpolateCenter (psImage *value, psImage *xCoord, psImage *yCoord, psImage *state, psImage *mask, psMaskType maskVal) {
     243bool psImagePixelInterpolateCenter (psImage *value, psImage *xCoord, psImage *yCoord, psImage *state, psImage *mask, psImageMaskType maskVal) {
    244244
    245245    assert (value->numCols == state->numCols);
     
    299299                          if (jx + ix >= value->numCols) { continue; }
    300300                          // skip masked pixels
    301                           if (mask->data.PS_TYPE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
     301                          if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
    302302                          x->data.F32[n] = xCoord->data.F32[iy+jy][ix+jx];
    303303                          y->data.F32[n] = yCoord->data.F32[iy+jy][ix+jx];
     
    331331                          if (jx + ix >= value->numCols) { continue; }
    332332                          // skip masked pixels
    333                           if (mask->data.PS_TYPE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
     333                          if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+jy][ix+jx] & maskVal) { continue; }
    334334                          x->data.F32[n] = xCoord->data.F32[iy+jy][ix+jx];
    335335                          y->data.F32[n] = yCoord->data.F32[iy+jy][ix+jx];
     
    363363    for (int iy = 0; iy < value->numRows; iy++) {
    364364        for (int ix = 0; ix < value->numCols; ix++) {
    365           if (mask->data.PS_TYPE_MASK_DATA[iy][ix] & maskVal) { continue; }
     365          if (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskVal) { continue; }
    366366          value->data.F32[iy][ix] = output->data.F32[iy][ix];
    367367        }
  • trunk/psLib/src/imageops/psImagePixelInterpolate.h

    r14924 r21183  
    77 *  @author Eugene Magnier, IfA
    88 *
    9  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2007-09-20 23:54:25 $
     9 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2009-01-27 06:39:37 $
    1111 *
    1212 *  Copyright 2007 Institute for Astronomy, University of Hawaii
     
    3434} psImagePixelInterpolateType;
    3535
    36 psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, psMaskType maskVal);
    37 bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, psMaskType maskVal);
    38 bool psImagePixelInterpolateCenter (psImage *value, psImage *xCoord, psImage *yCoord, psImage *state, psImage *mask, psMaskType maskVal);
     36psImage *psImagePixelInterpolateState (int *nBad, int *nPoor, psImage *mask, psImageMaskType maskVal);
     37bool psImagePixelInterpolatePoor (psImage *image, psImage *state, psImage *mask, psImageMaskType maskVal);
     38bool psImagePixelInterpolateCenter (psImage *value, psImage *xCoord, psImage *yCoord, psImage *state, psImage *mask, psImageMaskType maskVal);
    3939
    4040/// @}
  • trunk/psLib/src/imageops/psImageStats.c

    r12431 r21183  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.106 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2007-03-14 00:39:50 $
     11 *  @version $Revision: 1.107 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2009-01-27 06:39:37 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5353                      const psImage* in,
    5454                      const psImage* mask,
    55                       psMaskType maskVal)
     55                      psImageMaskType maskVal)
    5656{
    5757    psVector *junkData = NULL;
     
    6262    PS_ASSERT_IMAGE_NON_NULL(in, false)
    6363    if (mask != NULL) {
    64         PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_U8, false);
     64        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false);
    6565        PS_ASSERT_IMAGES_SIZE_EQUAL(in, mask, false);
    6666    }
     67
     68    if (in->parent == NULL) {
     69        // stuff the image data into a psVector struct.
     70        // XXX this is a bit hackish: does it save much time? (avoids a Nx*Ny alloc)
     71        junkData = (psVector *) psAlloc(sizeof(psVector));
     72        junkData->type = in->type;
     73        P_PSVECTOR_SET_NALLOC(junkData,in->numRows * in->numCols);
     74        junkData->n = junkData->nalloc;
     75        junkData->data.U8 = in->data.V[0];      // since psImage data is contiguous...
     76    } else {
     77        // image not necessarily contiguous
     78        int numRows = in->numRows;
     79        int numCols = in->numCols;
     80        int rowSize = numCols * (PSELEMTYPE_SIZEOF(in->type.type));
     81
     82        junkData = psVectorAlloc(numRows*numCols, in->type.type);
     83
     84        psU8* data = junkData->data.U8;
     85        for (int row = 0; row < numRows; row++) {
     86            memcpy(data, in->data.V[row], rowSize);
     87            data += rowSize;
     88        }
     89    }
     90
     91    if (mask != NULL) {
     92        // image not necessarily contiguous, generate a temp vector to hold the full image
     93        int numRows = mask->numRows;
     94        int numCols = mask->numCols;
     95
     96        junkMask = psVectorAlloc(numRows*numCols, PS_TYPE_VECTOR_MASK);
     97
     98        psVectorMaskType *data = junkMask->data.PS_TYPE_VECTOR_MASK_DATA;
     99        for (int row = 0, nVect = 0; row < numRows; row++) {
     100            for (int col = 0; col < numCols; col++, nVect++) {
     101                data[nVect] = (mask->data.PS_TYPE_IMAGE_MASK_DATA[row][col] & maskVal);
     102            }
     103        }
     104    }
     105
     106    psVectorStats(stats, junkData, NULL, junkMask, 0xff);
     107
     108    psFree(junkMask);
     109    psFree(junkData);
     110    return true;
     111}
     112
     113/*****************************************************************************
     114NOTE: We assume that the psHistogram structure out has already been allocated
     115and initialized.
     116 *****************************************************************************/
     117bool psImageHistogram(psHistogram* out,
     118                              const psImage* in,
     119                              const psImage* mask,
     120                              psImageMaskType maskVal)
     121{
     122    PS_ASSERT_PTR_NON_NULL(out, false);
     123    PS_ASSERT_PTR_NON_NULL(in, false);
     124    if (mask != NULL) {
     125        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false);
     126        PS_ASSERT_IMAGES_SIZE_EQUAL(in, mask, false);
     127    }
     128    psVector* junkData = NULL;
     129    psVector* junkMask = NULL;
    67130
    68131    if (in->parent == NULL) {
     
    89152
    90153    if (mask != NULL) {
    91         if (mask->parent == NULL) {
    92             // stuff the mask data into a psVector struct.
    93             junkMask = psAlloc(sizeof(psVector));
    94             junkMask->type = mask->type;
    95             P_PSVECTOR_SET_NALLOC(junkMask,mask->numRows * mask->numCols);
    96             junkMask->n = junkMask->nalloc;
    97             junkMask->data.U8 = mask->data.V[0];
    98         } else {
    99             // image not necessarily contiguous
    100             int numRows = mask->numRows;
    101             int numCols = mask->numCols;
    102             int rowSize = numCols * (PSELEMTYPE_SIZEOF(mask->type.type));
    103 
    104             junkMask = psVectorAlloc(numRows*numCols, mask->type.type);
    105 
    106             psU8* data = junkMask->data.U8;
    107             for (int row = 0; row < numRows; row++) {
    108                 memcpy(data, mask->data.V[row], rowSize);
    109                 data += rowSize;
    110             }
    111         }
    112     }
    113 
    114     psVectorStats(stats, junkData, NULL, junkMask, maskVal);
    115 
    116     psFree(junkMask);
    117     psFree(junkData);
    118     return true;
    119 }
    120 
    121 /*****************************************************************************
    122 NOTE: We assume that the psHistogram structure out has already been allocated
    123 and initialized.
    124  *****************************************************************************/
    125 bool psImageHistogram(psHistogram* out,
    126                               const psImage* in,
    127                               const psImage* mask,
    128                               psMaskType maskVal)
    129 {
    130     PS_ASSERT_PTR_NON_NULL(out, false);
    131     PS_ASSERT_PTR_NON_NULL(in, false);
    132     if (mask != NULL) {
    133         PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_U8, false);
    134         PS_ASSERT_IMAGES_SIZE_EQUAL(in, mask, false);
    135     }
    136     psVector* junkData = NULL;
    137     psVector* junkMask = NULL;
    138 
    139     if (in->parent == NULL) {
    140         // stuff the image data into a psVector struct.
    141         junkData = (psVector *) psAlloc(sizeof(psVector));
    142         junkData->type = in->type;
    143         P_PSVECTOR_SET_NALLOC(junkData,in->numRows * in->numCols);
    144         junkData->n = junkData->nalloc;
    145         junkData->data.U8 = in->data.V[0];      // since psImage data is contiguous...
    146     } else {
    147         // image not necessarily contiguous
    148         int numRows = in->numRows;
    149         int numCols = in->numCols;
    150         int rowSize = numCols * (PSELEMTYPE_SIZEOF(in->type.type));
    151 
    152         junkData = psVectorAlloc(numRows*numCols, in->type.type);
    153 
    154         psU8* data = junkData->data.U8;
    155         for (int row = 0; row < numRows; row++) {
    156             memcpy(data, in->data.V[row], rowSize);
    157             data += rowSize;
    158         }
    159     }
    160 
    161     if (mask != NULL) {
    162         if (mask->parent == NULL) {
    163             // stuff the mask data into a psVector struct.
    164             junkMask = psAlloc(sizeof(psVector));
    165             junkMask->type = mask->type;
    166             P_PSVECTOR_SET_NALLOC(junkMask,mask->numRows * mask->numCols);
    167             junkMask->n = junkMask->nalloc;
    168             junkMask->data.U8 = mask->data.V[0];
    169         } else {
    170             // image not necessarily contiguous
    171             int numRows = mask->numRows;
    172             int numCols = mask->numCols;
    173             int rowSize = numCols * (PSELEMTYPE_SIZEOF(mask->type.type));
    174 
    175             junkMask = psVectorAlloc(numRows*numCols, mask->type.type);
    176 
    177             psU8* data = junkMask->data.U8;
    178             for (int row = 0; row < numRows; row++) {
    179                 memcpy(data, mask->data.V[row], rowSize);
    180                 data += rowSize;
    181             }
    182         }
     154        // image not necessarily contiguous; vector & image mask types do not match
     155        int numRows = mask->numRows;
     156        int numCols = mask->numCols;
     157
     158        junkMask = psVectorAlloc(numRows*numCols, PS_TYPE_VECTOR_MASK);
     159
     160        psVectorMaskType *data = junkMask->data.PS_TYPE_VECTOR_MASK_DATA;
     161        for (int row = 0, nVect = 0; row < numRows; row++) {
     162            for (int col = 0; col < numCols; col++, nVect++) {
     163                data[nVect] = (mask->data.PS_TYPE_IMAGE_MASK_DATA[row][col] & maskVal);
     164            }
     165        }
    183166    }
    184167
     
    472455long psImageCountPixelMask (psImage *mask,
    473456                            psRegion region,
    474                             psMaskType value)
     457                            psImageMaskType value)
    475458{
    476459    long Npixels = 0;
     
    479462    int x1 = 0;
    480463    int y1 = 0;
    481     psElemType type;
    482464
    483465    // this is not a valid error: a psRegion with ranges outside the valid pixels
     
    608590    y1 = row1;
    609591
    610     type = mask->type.type;
    611     if (type != PS_TYPE_MASK) {
    612         psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    613                 "psImage type does not match the specified psMaskType!\n");
    614         return -1;
    615     }
    616 
     592# define PS_IMAGE_COUNT_PIXEL_MASK(NAME,TYPE) \
     593    case PS_TYPE_##NAME: \
     594        for (long j = y0; j < y1; j++) { \
     595            for (long i = x0; i < x1; i++) { \
     596                if (mask->data.TYPE[j][i] & value) { \
     597                    Npixels ++; \
     598                } \
     599            } \
     600        } \
     601        break;
     602
     603    psElemType type = mask->type.type;
    617604    switch (type) {
    618     case PS_TYPE_U8:
    619     case PS_TYPE_U16:
    620         for (long j = y0; j < y1; j++) {
    621             for (long i = x0; i < x1; i++) {
    622                 if (mask->data.PS_TYPE_MASK_DATA[j][i] & value) {
    623                     Npixels ++;
    624                 }
    625             }
    626         }
    627         break;
    628     case PS_TYPE_S8:
    629     case PS_TYPE_S16:
    630     case PS_TYPE_S32:
    631     case PS_TYPE_S64:
    632     case PS_TYPE_U32:
    633     case PS_TYPE_U64:
    634     case PS_TYPE_F32:
    635     case PS_TYPE_F64:
     605        PS_IMAGE_COUNT_PIXEL_MASK(U8, U8);
     606        PS_IMAGE_COUNT_PIXEL_MASK(U16,U16);
     607        PS_IMAGE_COUNT_PIXEL_MASK(U32,U32);
     608        PS_IMAGE_COUNT_PIXEL_MASK(U64,U64);
     609        PS_IMAGE_COUNT_PIXEL_MASK(S8, S8);
     610        PS_IMAGE_COUNT_PIXEL_MASK(S16,S16);
     611        PS_IMAGE_COUNT_PIXEL_MASK(S32,S32);
     612        PS_IMAGE_COUNT_PIXEL_MASK(S64,S64);
     613
    636614    default:
    637615        // XXX this should include the mask type (as a string)
    638616        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    639                 _("Input psImage mask type is not a supported mask datatype"));
     617                _("Input psImage is an unsupported datatype"));
    640618
    641619        return -1;
  • trunk/psLib/src/imageops/psImageStats.h

    r11759 r21183  
    99 * @author GLG, MHPCC
    1010 *
    11  * @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
    12  * @date $Date: 2007-02-13 03:01:23 $
     11 * @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
     12 * @date $Date: 2009-01-27 06:39:37 $
    1313 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1414 */
     
    4242    const psImage* in,                 ///< image (or subimage) to calculate stats
    4343    const psImage* mask,               ///< mask data for image (NULL ok)
    44     psMaskType maskVal                 ///< mask value for mask
     44    psImageMaskType maskVal             ///< mask value for mask
    4545);
    4646
     
    5757    const psImage* in,                 ///< Image data to be histogramed.
    5858    const psImage* mask,               ///< mask data for image (NULL ok)
    59     psMaskType maskVal                 ///< mask Mask for mask
     59    psImageMaskType maskVal             ///< mask Mask for mask
    6060);
    6161
     
    9797    psImage *mask,                     ///< input image to count
    9898    psRegion region,                   ///< input region of image
    99     psMaskType value                   ///< the mask value to satisfy
     99    psImageMaskType value               ///< the mask value to satisfy
    100100);
    101101
  • trunk/psLib/src/math/psClip.c

    r11756 r21183  
    2222
    2323psClipParams *psClipParamsAlloc(psStatsOptions meanStat, psStatsOptions stdevStat,
    24                                 psMaskType masked, psMaskType clipped)
     24                                psVectorMaskType masked, psVectorMaskType clipped)
    2525{
    2626    psClipParams *params = psAlloc(sizeof(psClipParams)); // Clip parameters
     
    4848    PS_ASSERT_VECTOR_NON_NULL(values, -1);
    4949    PS_ASSERT_VECTOR_NON_NULL(mask, -1);
    50     PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_MASK, -1);
     50    PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, -1);
    5151    PS_ASSERT_PTR(params, -1);
    5252    PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, -1);
     
    6262    }
    6363
    64     psMaskType masked = params->masked; // Indicates masked values
    65     psMaskType clipped = params->clipped; // Indicates clipped values
     64    psVectorMaskType masked = params->masked; // Indicates masked values
     65    psVectorMaskType clipped = params->clipped; // Indicates clipped values
    6666    masked |= clipped;                  // Make sure we're also masking clipped values
    67     psMaskType *maskData = mask->data.PS_TYPE_MASK_DATA; // Dereference mask
     67    psVectorMaskType *maskData = mask->data.PS_TYPE_VECTOR_MASK_DATA; // Dereference mask
    6868    long totalMasked = 0;               // Total number of pixels masked
    6969
     
    120120    PS_ASSERT_VECTOR_NON_NULL(values, -1);
    121121    PS_ASSERT_VECTOR_NON_NULL(mask, -1);
    122     PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_MASK, -1);
     122    PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, -1);
    123123    PS_ASSERT_PTR(params, -1);
    124124    PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, -1);
     
    141141    }
    142142
    143     psMaskType masked = params->masked; // Indicates masked values
    144     psMaskType clipped = params->clipped; // Indicates clipped values
     143    psVectorMaskType masked = params->masked; // Indicates masked values
     144    psVectorMaskType clipped = params->clipped; // Indicates clipped values
    145145    masked |= clipped;                  // Make sure we're also masking clipped values
    146146
     
    158158case PS_TYPE_##TYPE: { \
    159159        ps##TYPE *valuesData = values->data.TYPE; /* Dereference for speed */ \
    160         psMaskType *maskData = mask->data.PS_TYPE_MASK_DATA; /* Dereference mask for speed */ \
     160        psVectorMaskType *maskData = mask->data.PS_TYPE_VECTOR_MASK_DATA; /* Dereference mask for speed */ \
    161161        if (errors) { \
    162162            ps##TYPE *errorsData = errors->data.TYPE; \
  • trunk/psLib/src/math/psClip.h

    r14452 r21183  
    44 * @author Paul Price, IfA.
    55 *
    6  * $Revision: 1.5 $ $Name: not supported by cvs2svn $
    7  * $Date: 2007-08-09 01:40:07 $
     6 * $Revision: 1.6 $ $Name: not supported by cvs2svn $
     7 * $Date: 2009-01-27 06:39:38 $
    88 * Copyright 2007 Institute for Astronomy, University of Hawaii
    99 */
     
    2525    int iter;                           ///< Number of rejection iterations; unused by psClip functions
    2626    float rej;                          ///< Rejection limit (standard deviations)
    27     psMaskType masked;                  ///< Mask value for entries already masked
    28     psMaskType clipped;                 ///< Mask value to give to clipped entries
     27    psVectorMaskType masked;                  ///< Mask value for entries already masked
     28    psVectorMaskType clipped;                 ///< Mask value to give to clipped entries
    2929    double mean;                        ///< Resultant mean
    3030    double stdev;                       ///< Resultant stdev
     
    3535psClipParams *psClipParamsAlloc(psStatsOptions meanStat, ///< Stats option to use for mean
    3636                                psStatsOptions stdevStat, ///< Stats option to use for standard deviation
    37                                 psMaskType masked, ///< Mask value for entries already masked
    38                                 psMaskType clipped ///< Mask value to give to clipped entries
     37                                psVectorMaskType masked, ///< Mask value for entries already masked
     38                                psVectorMaskType clipped ///< Mask value to give to clipped entries
    3939    ) PS_ATTR_MALLOC;
    4040
  • trunk/psLib/src/math/psConstants.h

    r17035 r21183  
    55 * @author GLG, MHPCC
    66 *
    7  * @version $Revision: 1.96 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2008-03-18 18:25:00 $
     7 * @version $Revision: 1.97 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2009-01-27 06:39:38 $
    99 *
    1010 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    6767
    6868// These defines for bitwise opertaions are necessary to yield results of the proper size (use instead of ~)
    69 #define PS_NOT_U8(A)(UCHAR_MAX-(A)) // Perform bitwise NOT on A which is of type U8
    70 #define PS_NOT_U16(A)(USHORT_MAX-(A)) // Perform bitwaise NOT on A which is of type U16
     69#define PS_NOT_U8(A)(UINT8_MAX-(A)) // Perform bitwise NOT on A which is of type U8
     70#define PS_NOT_U16(A)(UINT16_MAX-(A)) // Perform bitwaise NOT on A which is of type U16
     71#define PS_NOT_U32(A)(UINT32_MAX-(A)) // Perform bitwise NOT on A which is of type U8
     72#define PS_NOT_U64(A)(UINT64_MAX-(A)) // Perform bitwaise NOT on A which is of type U16
    7173
    7274/// @}
  • trunk/psLib/src/math/psHistogram.c

    r17565 r21183  
    55 *  @author GLG (MHPCC), EAM (IfA)
    66 *
    7  *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2008-05-07 23:11:30 $
     7 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2009-01-27 06:39:38 $
    99 *
    1010 *  Copyright 2006 IfA, University of Hawaii
     
    231231                               const psVector* errors,
    232232                               const psVector* mask,
    233                                psMaskType maskVal)
     233                               psVectorMaskType maskVal)
    234234{
    235235    psTrace("psLib.math", 3, "---- %s() begin  ----\n", __func__);
     
    244244    if (mask) {
    245245        PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, false);
    246         PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
     246        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
    247247    }
    248248    if (errors) {
     
    274274    for (long i = 0; i < inF32->n; i++) {
    275275        // Check if this pixel is masked, and if so, skip it.
    276         if (!mask || (mask && (!(mask->data.U8[i] & maskVal)))) {
     276        if (!mask || (mask && (!(mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal)))) {
    277277            if (inF32->data.F32[i] < out->bounds->data.F32[0]) {
    278278                // If this pixel is below minimum value, count it, then skip.
  • trunk/psLib/src/math/psHistogram.h

    r14452 r21183  
    77 * @author GLG, MHPCC
    88 *
    9  * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    10  * @date $Date: 2007-08-09 01:40:07 $
     9 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     10 * @date $Date: 2009-01-27 06:39:38 $
    1111 *
    1212 * Copyright 2004-2005 IfA, University of Hawaii
     
    8888    const psVector* errors,            ///< Errors
    8989    const psVector* mask,              ///< Mask dat for input vector
    90     psMaskType maskVal                 ///< Mask value
    91 );
     90    psVectorMaskType maskVal            ///< Mask value
     91    );
    9292
    9393/// @}
  • trunk/psLib/src/math/psMinimizeLMM.c

    r19845 r21183  
    1010 *  @author EAM, IfA
    1111 *
    12  *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2008-10-02 20:49:22 $
     12 *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2009-01-27 06:39:38 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    7474    PS_ASSERT_VECTOR_TYPE(params,    PS_TYPE_F32,  false);
    7575    if (paramMask) {
    76         PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_MASK, false);
     76        PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false);
    7777    }
    7878
     
    113113    // set tmpBeta values which are not masked
    114114    for (int j = 0, n = 0; j < params->n; j++) {
    115         if (paramMask && (paramMask->data.U8[j])) continue;
     115        if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue;
    116116        tmpBeta->data.F32[j] = Beta->data.F32[n];
    117117        n++;
     
    120120    // apply Beta to get new Params values
    121121    for (int j = 0; j < params->n; j++) {
    122         if (paramMask && (paramMask->data.U8[j])) {
     122        if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) {
    123123            Params->data.F32[j] = params->data.F32[j];
    124124            continue;
     
    140140    // apply tmpBeta after limits have been checked
    141141    for (int j = 0, n = 0; j < params->n; j++) {
    142         if (paramMask && (paramMask->data.U8[j])) continue;
     142        if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue;
    143143        Beta->data.F32[n] = tmpBeta->data.F32[j];
    144144        n++;
     
    269269    PS_ASSERT_VECTOR_TYPE(params, PS_TYPE_F32, false);
    270270    if (paramMask) {
    271         PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_MASK, false);
     271        PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false);
    272272    }
    273273
     
    297297        // we track alpha,beta and params,deriv separately
    298298        for (int j = 0, J = 0; j < params->n; j++) {
    299             if (paramMask && (paramMask->data.U8[j])) continue;
     299            if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue;
    300300
    301301            weight = deriv->data.F32[j] * dy->data.F32[i];
    302302
    303303            for (int k = 0, K = 0; k <= j; k++) {
    304                 if (paramMask && (paramMask->data.U8[k])) continue;
     304                if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue;
    305305                alpha->data.F32[J][K] += weight * deriv->data.F32[k];
    306306                K++;
     
    351351        paramMask = constraint->paramMask;
    352352        if (paramMask != NULL) {
    353             PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_U8, false);
     353            PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false);
    354354            PS_ASSERT_VECTORS_SIZE_EQUAL(params, paramMask, false);
    355355        }
     
    493493        psImageInit (covar, 0.0);
    494494        for (int j = 0, J = 0; j < params->n; j++) {
    495             if (paramMask && (paramMask->data.U8[j])) {
     495            if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) {
    496496                covar->data.F32[j][j] = 1.0;
    497497                continue;
    498498            }
    499499            for (int k = 0, K = 0; k < params->n; k++) {
    500                 if (paramMask && (paramMask->data.U8[k])) continue;
     500                if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue;
    501501                covar->data.F32[j][k] = Alpha->data.F32[J][K];
    502502                K++;
     
    535535        nParams = 0;
    536536        for (int i = 0; i < paramMask->n; i++) {
    537             if (paramMask->data.U8[i]) continue;
     537            if (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue;
    538538            nParams ++;
    539539        }
  • trunk/psLib/src/math/psMinimizeLMM_ND.c

    r17442 r21183  
    88 *  @author EAM, IfA
    99 *
    10  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2008-04-11 08:01:29 $
     10 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2009-01-27 06:39:38 $
    1212 *
    1313 *  Copyright 2007 Institute for Astronomy, University of Hawaii
     
    5555        paramMask = constraint->paramMask;
    5656        if (paramMask != NULL) {
    57             PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_U8, false);
     57            PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false);
    5858            PS_ASSERT_VECTORS_SIZE_EQUAL(params, paramMask, false);
    5959        }
     
    201201        psImageInit (covar, 0.0);
    202202        for (int j = 0, J = 0; j < params->n; j++) {
    203             if (paramMask && (paramMask->data.U8[j])) {
     203            if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) {
    204204                covar->data.F32[j][j] = 1.0;
    205205                continue;
    206206            }
    207207            for (int k = 0, K = 0; k < params->n; k++) {
    208                 if (paramMask && (paramMask->data.U8[k])) continue;
     208                if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue;
    209209                covar->data.F32[j][k] = Alpha->data.F32[J][K];
    210210                K++;
     
    251251    PS_ASSERT_VECTOR_TYPE(params,    PS_TYPE_F32,  false);
    252252    if (paramMask) {
    253         PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_MASK, false);
     253        PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false);
    254254    }
    255255
     
    282282    // set tmpBeta values which are not masked
    283283    for (int j = 0, n = 0; j < params->n; j++) {
    284         if (paramMask && (paramMask->data.U8[j])) continue;
     284        if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue;
    285285        tmpBeta->data.F32[j] = Beta->data.F32[n];
    286286        n++;
     
    289289    // apply Beta to get new Params values
    290290    for (int j = 0; j < params->n; j++) {
    291         if (paramMask && (paramMask->data.U8[j])) {
     291        if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) {
    292292            Params->data.F32[j] = params->data.F32[j];
    293293            continue;
     
    309309    // apply tmpBeta after limits have been checked
    310310    for (int j = 0, n = 0; j < params->n; j++) {
    311         if (paramMask && (paramMask->data.U8[j])) continue;
     311        if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue;
    312312        Beta->data.F32[n] = tmpBeta->data.F32[j];
    313313        n++;
     
    438438    PS_ASSERT_VECTOR_TYPE(params, PS_TYPE_F32, false);
    439439    if (paramMask) {
    440         PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_MASK, false);
     440        PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false);
    441441    }
    442442
     
    474474        // we track alpha,beta and params,deriv separately
    475475        for (int j = 0, J = 0; j < params->n; j++) {
    476             if (paramMask && (paramMask->data.U8[j])) continue;
     476            if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) continue;
    477477
    478478            weight = deriv->data.F32[j] * dy->data.F32[i];
    479479
    480480            for (int k = 0, K = 0; k <= j; k++) {
    481                 if (paramMask && (paramMask->data.U8[k])) continue;
     481                if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue;
    482482                alpha->data.F32[J][K] += weight * deriv->data.F32[k];
    483483                K++;
     
    512512        nParams = 0;
    513513        for (int i = 0; i < paramMask->n; i++) {
    514             if (paramMask->data.U8[i]) continue;
     514            if (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue;
    515515            nParams ++;
    516516        }
  • trunk/psLib/src/math/psMinimizePolyFit.c

    r19304 r21183  
    1010 *  @author EAM, IfA
    1111 *
    12  *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2008-09-02 19:03:38 $
     12 *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2009-01-27 06:39:38 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    307307    psPolynomial1D* myPoly,
    308308    const psVector *mask,
    309     psMaskType maskValue,
     309    psVectorMaskType maskValue,
    310310    const psVector* y,
    311311    const psVector* yErr,
     
    326326    if (mask != NULL) {
    327327        PS_ASSERT_VECTORS_SIZE_EQUAL(y, mask, NULL);
    328         PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, NULL);
     328        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, NULL);
    329329    }
    330330
     
    354354    psF64 **matrix = A->data.F64;       // Least-squares matrix
    355355    psF64 *vector = B->data.F64;        // Least-squares vector
    356     psU8 *dataMask = NULL;              // Mask for data
     356    psVectorMaskType *dataMask = NULL;              // Mask for data
    357357    if (mask) {
    358         dataMask = mask->data.U8;
    359     }
    360     psU8 *coeffMask = myPoly->coeffMask;      // Mask for polynomial terms
     358        dataMask = mask->data.PS_TYPE_VECTOR_MASK_DATA;
     359    }
     360    psMaskType *coeffMask = myPoly->coeffMask;      // Mask for polynomial terms
    361361    psF64 *yData = y->data.F64;         // Coordinate data
    362362    psF64 *yErrData = NULL;             // Errors in the coordinate
     
    473473    psPolynomial1D* myPoly,
    474474    const psVector *mask,
    475     psMaskType maskValue,
     475    psVectorMaskType maskValue,
    476476    const psVector *f,
    477477    const psVector *fErr,
     
    484484    if (mask) {
    485485        PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false);
    486         PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
     486        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
    487487    }
    488488    if (x) {
     
    529529
    530530    // Dereference some pointers for speed in the loop
    531     psU8 *dataMask = NULL;              // Dereferenced version of mask for data points
     531    psVectorMaskType *dataMask = NULL;              // Dereferenced version of mask for data points
    532532    if (mask) {
    533         dataMask = mask->data.U8;
    534     }
    535     psU8 *coeffMask = myPoly->coeffMask;      // Dereferenced version of mask for polynomial terms
     533        dataMask = mask->data.PS_TYPE_VECTOR_MASK_DATA;
     534    }
     535    psMaskType *coeffMask = myPoly->coeffMask;      // Dereferenced version of mask for polynomial terms
    536536    psF64 *ordinates = NULL;            // Dereferenced version of ordinate data
    537537    if (x) {
     
    698698    psPolynomial1D *poly,
    699699    const psVector *mask,
    700     psMaskType maskValue,
     700    psVectorMaskType maskValue,
    701701    const psVector *f,
    702702    const psVector *fErr,
     
    711711    if (mask != NULL) {
    712712        PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false);
    713         PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
     713        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
    714714    }
    715715    if (fErr != NULL) {
     
    782782    psStats *stats,
    783783    const psVector *mask,
    784     psMaskType maskValue,
     784    psVectorMaskType maskValue,
    785785    const psVector *f,
    786786    const psVector *fErr,
     
    794794    PS_ASSERT_VECTOR_NON_NULL(mask, false);
    795795    PS_ASSERT_VECTORS_SIZE_EQUAL(mask, f, false);
    796     PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
     796    PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
    797797
    798798    if (fErr != NULL) {
     
    862862            if (mask != NULL) {
    863863                for (psS32 i = 0 ; i < mask->n ; i++) {
    864                     psTrace("psLib.math", 6,  "mask[%d] is %d\n", i, mask->data.U8[i]);
     864                    psTrace("psLib.math", 6,  "mask[%d] is %d\n", i, mask->data.PS_TYPE_VECTOR_MASK_DATA[i]);
    865865                }
    866866            }
     
    895895            if (mask != NULL) {
    896896                for (psS32 i = 0 ; i < mask->n ; i++) {
    897                     if (!((mask != NULL) && (mask->data.U8[i] & maskValue))) {
     897                    if (!((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue))) {
    898898                        psTrace("psLib.math", 6,  "(f, fit)[%d] is (%f, %f).  resid is (%f)\n",
    899899                                i, f->data.F32[i], fit->data.F32[i], resid->data.F64[i]);
     
    922922        // recovery is not allowed with this scheme
    923923        for (psS32 i = 0; i < resid->n; i++) {
    924             if ((mask != NULL) && (mask->data.U8[i] & maskValue)) {
     924            if ((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) {
    925925                continue;
    926926            }
     
    936936
    937937                if (mask != NULL) {
    938                     mask->data.U8[i] |= 0x01;
     938                    mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01;
    939939                }
    940940                continue;
     
    979979    psPolynomial2D* myPoly,
    980980    const psVector* mask,
    981     psMaskType maskValue,
     981    psVectorMaskType maskValue,
    982982    const psVector *f,
    983983    const psVector *fErr,
     
    10031003    if (mask != NULL) {
    10041004        PS_ASSERT_VECTORS_SIZE_EQUAL(y, mask, false);
    1005         PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
     1005        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
    10061006    }
    10071007
     
    10261026    psF64 **matrix = A->data.F64;       // Dereference the least-squares matrix
    10271027    psF64 *vector = B->data.F64;        // Dereference the least-squares vector
    1028     psU8 **coeffMask = myPoly->coeffMask;     // Dereference mask for polynomial terms
    1029     psU8 *dataMask = NULL;              // Dereference mask for data
     1028    psMaskType **coeffMask = myPoly->coeffMask;     // Dereference mask for polynomial terms
     1029    psVectorMaskType *dataMask = NULL;              // Dereference mask for data
    10301030    if (mask) {
    1031         dataMask = mask->data.U8;
     1031        dataMask = mask->data.PS_TYPE_VECTOR_MASK_DATA;
    10321032    }
    10331033    psF64 *xData = x->data.F64;         // Dereference x
     
    11621162    psPolynomial2D *poly,
    11631163    const psVector *mask,
    1164     psMaskType maskValue,
     1164    psVectorMaskType maskValue,
    11651165    const psVector *f,
    11661166    const psVector *fErr,
     
    11791179    if (mask != NULL) {
    11801180        PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false);
    1181         PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
     1181        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
    11821182    }
    11831183    if (fErr != NULL) {
     
    12311231    psStats *stats,
    12321232    const psVector *mask,
    1233     psMaskType maskValue,
     1233    psVectorMaskType maskValue,
    12341234    const psVector *f,
    12351235    const psVector *fErr,
     
    12541254
    12551255    PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false);
    1256     PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
     1256    PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
    12571257
    12581258    if (fErr != NULL) {
     
    13001300            if (mask != NULL) {
    13011301                for (psS32 i = 0 ; i < mask->n ; i++) {
    1302                     psTrace("psLib.math", 7,  "mask[%d] is %d\n", i, mask->data.U8[i]);
     1302                    psTrace("psLib.math", 7,  "mask[%d] is %d\n", i, mask->data.PS_TYPE_VECTOR_MASK_DATA[i]);
    13031303                }
    13041304            }
     
    13291329            if (mask != NULL) {
    13301330                for (psS32 i = 0 ; i < mask->n ; i++) {
    1331                     if (!((mask != NULL) && (mask->data.U8[i] & maskValue))) {
     1331                    if (!((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue))) {
    13321332                        psTrace("psLib.math", 7,  "point %d at %f %f : value, fit : %f  %f resid: %f\n",
    13331333                                i, x->data.F32[i], y->data.F32[i], f->data.F32[i], fit->data.F32[i], resid->data.F64[i]);
     
    13561356        // recovery is not allowed with this scheme
    13571357        for (psS32 i = 0; i < resid->n; i++) {
    1358             if ((mask != NULL) && (mask->data.U8[i] & maskValue)) {
     1358            if ((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) {
    13591359                continue;
    13601360            }
     
    13701370
    13711371                if (mask != NULL) {
    1372                     mask->data.U8[i] |= 0x01;
     1372                    mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01;
    13731373                }
    13741374                continue;
     
    14031403    psPolynomial3D* myPoly,
    14041404    const psVector* mask,
    1405     psMaskType maskValue,
     1405    psVectorMaskType maskValue,
    14061406    const psVector *f,
    14071407    const psVector *fErr,
     
    14331433    if (mask != NULL) {
    14341434        PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false);
    1435         PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
     1435        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
    14361436    }
    14371437
     
    14641464        fErrData = fErr->data.F64;
    14651465    }
    1466     psU8 *dataMask = NULL;              // Mask for data
     1466    psVectorMaskType *dataMask = NULL;              // Mask for data
    14671467    if (mask) {
    1468         dataMask = mask->data.U8;
    1469     }
    1470     psU8 ***coeffMask = myPoly->coeffMask;    // Mask for polynomial terms
     1468        dataMask = mask->data.PS_TYPE_VECTOR_MASK_DATA;
     1469    }
     1470    psMaskType ***coeffMask = myPoly->coeffMask;    // Mask for polynomial terms
    14711471    int nYZterm = nYterm * nZterm;      // Multiplication of the numbers, to calculate the index
    14721472
     
    16031603    psPolynomial3D *poly,
    16041604    const psVector *mask,
    1605     psMaskType maskValue,
     1605    psVectorMaskType maskValue,
    16061606    const psVector *f,
    16071607    const psVector *fErr,
     
    16231623    if (mask != NULL) {
    16241624        PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false);
    1625         PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
     1625        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
    16261626    }
    16271627    if (fErr != NULL) {
     
    16771677    psStats *stats,
    16781678    const psVector *mask,
    1679     psMaskType maskValue,
     1679    psVectorMaskType maskValue,
    16801680    const psVector *f,
    16811681    const psVector *fErr,
     
    17051705
    17061706    PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false);
    1707     PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
     1707    PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
    17081708
    17091709    if (fErr != NULL) {
     
    17511751            if (mask != NULL) {
    17521752                for (psS32 i = 0 ; i < mask->n ; i++) {
    1753                     psTrace("psLib.math", 6,  "mask[%d] is %d\n", i, mask->data.U8[i]);
     1753                    psTrace("psLib.math", 6,  "mask[%d] is %d\n", i, mask->data.PS_TYPE_VECTOR_MASK_DATA[i]);
    17541754                }
    17551755            }
     
    17781778            if (mask != NULL) {
    17791779                for (psS32 i = 0 ; i < mask->n ; i++) {
    1780                     if (!((mask != NULL) && (mask->data.U8[i] & maskValue))) {
     1780                    if (!((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue))) {
    17811781                        psTrace("psLib.math", 6,  "(f, fit)[%d] is (%f, %f).  resid is (%f)\n",
    17821782                                i, f->data.F32[i], fit->data.F32[i], resid->data.F64[i]);
     
    18051805        // recovery is not allowed with this scheme
    18061806        for (psS32 i = 0; i < resid->n; i++) {
    1807             if ((mask != NULL) && (mask->data.U8[i] & maskValue)) {
     1807            if ((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) {
    18081808                continue;
    18091809            }
     
    18191819
    18201820                if (mask != NULL) {
    1821                     mask->data.U8[i] |= 0x01;
     1821                    mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01;
    18221822                }
    18231823                continue;
     
    18501850    psPolynomial4D* myPoly,
    18511851    const psVector* mask,
    1852     psMaskType maskValue,
     1852    psVectorMaskType maskValue,
    18531853    const psVector *f,
    18541854    const psVector *fErr,
     
    18841884    if (mask) {
    18851885        PS_ASSERT_VECTORS_SIZE_EQUAL(y, mask, false);
    1886         PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
     1886        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
    18871887    }
    18881888
     
    19181918        fErrData = fErr->data.F64;
    19191919    }
    1920     psU8 *dataMask = NULL;              // Mask for data
     1920    psVectorMaskType *dataMask = NULL;              // Mask for data
    19211921    if (mask) {
    1922         dataMask = mask->data.U8;
    1923     }
    1924     psU8 ****coeffMask = myPoly->coeffMask;    // Mask for polynomial terms
     1922        dataMask = mask->data.PS_TYPE_VECTOR_MASK_DATA;
     1923    }
     1924    psMaskType ****coeffMask = myPoly->coeffMask;    // Mask for polynomial terms
    19251925    int nYZTterm = nYterm * nZterm * nTterm; // Multiplication of the numbers, for calculating the index
    19261926    int nZTterm = nZterm * nTterm;      // Multiplication of the numbers, for calculating the index
     
    20682068    psPolynomial4D *poly,
    20692069    const psVector *mask,
    2070     psMaskType maskValue,
     2070    psVectorMaskType maskValue,
    20712071    const psVector *f,
    20722072    const psVector *fErr,
     
    20912091    if (mask) {
    20922092        PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false);
    2093         PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
     2093        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
    20942094    }
    20952095    if (fErr != NULL) {
     
    21482148    psStats *stats,
    21492149    const psVector *mask,
    2150     psMaskType maskValue,
     2150    psVectorMaskType maskValue,
    21512151    const psVector *f,
    21522152    const psVector *fErr,
     
    21812181
    21822182    PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, false);
    2183     PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
     2183    PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
    21842184
    21852185    if (fErr != NULL) {
     
    22272227            if (mask != NULL) {
    22282228                for (psS32 i = 0 ; i < mask->n ; i++) {
    2229                     psTrace("psLib.math", 6,  "mask[%d] is %d\n", i, mask->data.U8[i]);
     2229                    psTrace("psLib.math", 6,  "mask[%d] is %d\n", i, mask->data.PS_TYPE_VECTOR_MASK_DATA[i]);
    22302230                }
    22312231            }
     
    22552255            if (mask != NULL) {
    22562256                for (psS32 i = 0 ; i < mask->n ; i++) {
    2257                     if (!((mask != NULL) && (mask->data.U8[i] & maskValue))) {
     2257                    if (!((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue))) {
    22582258                        psTrace("psLib.math", 6,  "(f, fit)[%d] is (%f, %f).  resid is (%f)\n",
    22592259                                i, f->data.F32[i], fit->data.F32[i], resid->data.F64[i]);
     
    22822282        // recovery is not allowed with this scheme
    22832283        for (psS32 i = 0; i < resid->n; i++) {
    2284             if ((mask != NULL) && (mask->data.U8[i] & maskValue)) {
     2284            if ((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) {
    22852285                continue;
    22862286            }
     
    22962296
    22972297                if (mask != NULL) {
    2298                     mask->data.U8[i] |= 0x01;
     2298                    mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01;
    22992299                }
    23002300                continue;
  • trunk/psLib/src/math/psMinimizePolyFit.h

    r11248 r21183  
    77 * @author GLG, MHPCC
    88 *
    9  * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    10  * @date $Date: 2007-01-23 22:47:23 $
     9 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     10 * @date $Date: 2009-01-27 06:39:38 $
    1111 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1212 *
     
    4848    psPolynomial1D *poly,
    4949    const psVector *mask,
    50     psMaskType maskValue,
     50    psVectorMaskType maskValue,
    5151    const psVector *f,
    5252    const psVector *fErr,
     
    5757    psPolynomial2D *poly,
    5858    const psVector *mask,
    59     psMaskType maskValue,
     59    psVectorMaskType maskValue,
    6060    const psVector *f,
    6161    const psVector *fErr,
     
    6767    psPolynomial3D *poly,
    6868    const psVector *mask,
    69     psMaskType maskValue,
     69    psVectorMaskType maskValue,
    7070    const psVector *f,
    7171    const psVector *fErr,
     
    7878    psPolynomial4D *poly,
    7979    const psVector *mask,
    80     psMaskType maskValue,
     80    psVectorMaskType maskValue,
    8181    const psVector *f,
    8282    const psVector *fErr,
     
    9292    psStats *stats,
    9393    const psVector *mask,
    94     psMaskType maskValue,
     94    psVectorMaskType maskValue,
    9595    const psVector *f,
    9696    const psVector *fErr,
     
    102102    psStats *stats,
    103103    const psVector *mask,
    104     psMaskType maskValue,
     104    psVectorMaskType maskValue,
    105105    const psVector *f,
    106106    const psVector *fErr,
     
    113113    psStats *stats,
    114114    const psVector *mask,
    115     psMaskType maskValue,
     115    psVectorMaskType maskValue,
    116116    const psVector *f,
    117117    const psVector *fErr,
     
    125125    psStats *stats,
    126126    const psVector *mask,
    127     psMaskType maskValue,
     127    psVectorMaskType maskValue,
    128128    const psVector *f,
    129129    const psVector *fErr,
  • trunk/psLib/src/math/psMinimizePowell.c

    r11668 r21183  
    1111 *  NOTE: XXX: The SDR is silent about data types.  F32 is implemented here.
    1212 *
    13  *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2007-02-06 21:36:09 $
     13 *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2009-01-27 06:39:38 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4343#define PS_VECTOR_ADD_MULTIPLE(BASE, BASEMASK, LINE, OUT, MUL) \
    4444for (psS32 i=0;i<BASE->n;i++) { \
    45     if (BASEMASK->data.U8[i] == 0) { \
     45    if (BASEMASK->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) { \
    4646        OUT->data.F32[i] = BASE->data.F32[i] + (MUL * LINE->data.F32[i]); \
    4747    } else { \
     
    6262BOOL_VAR = true; \
    6363for (psS32 i=0;i<IN->n;i++) { \
    64     if ((INMASK->data.U8[i] == 0) && (fabs(IN->data.F32[i]) >= FLT_EPSILON)) { \
     64    if ((INMASK->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) && (fabs(IN->data.F32[i]) >= FLT_EPSILON)) { \
    6565        BOOL_VAR = false; \
    6666        break; \
     
    359359    PS_ASSERT_VECTOR_NON_NULL(paramMask, NAN);
    360360    PS_ASSERT_VECTOR_NON_EMPTY(paramMask, NAN);
    361     PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_U8, NAN);
     361    PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, NAN);
    362362    PS_ASSERT_PTR_NON_NULL(coords, NAN);
    363363    PS_ASSERT_PTR_NON_NULL(func, NAN);
     
    388388        for (i=0;i<params->n;i++) {
    389389            psTrace("psLib.math", 6, "(params, paramMask, line)[%d] is (%f %d %f)\n", i,
    390                     params->data.F32[i], paramMask->data.U8[i], line->data.F32[i]);
     390                    params->data.F32[i], paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i], line->data.F32[i]);
    391391        }
    392392    }
     
    527527
    528528    if (paramMask == NULL) {
    529         myParamMask = psVectorAlloc(params->n, PS_TYPE_U8);
     529        myParamMask = psVectorAlloc(params->n, PS_TYPE_VECTOR_MASK);
    530530        psVectorInit(myParamMask, 0);
    531531    } else {
     
    572572        biggestIter = 0;
    573573        for (i=0;i<numDims;i++) {
    574             if (myParamMask->data.U8[i] == 0) {
     574            if (myParamMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) {
    575575                P_PSMINIMIZATION_SET_MAXITER((&dummyMin),PS_MINIMIZE_POWELL_LINEMIN_MAX_ITERATIONS);
    576576                *(float*)&dummyMin.tol = PS_MINIMIZE_POWELL_LINEMIN_ERROR_TOLERANCE;
     
    603603        // 4: Set the vector u = Q - P
    604604        for (i=0;i<numDims;i++) {
    605             if (myParamMask->data.U8[i] == 0) {
     605            if (myParamMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) {
    606606                u->data.F32[i] = Q->data.F32[i] - params->data.F32[i];
    607607                u->n++;
     
    649649
    650650        for (i=0;i<numDims;i++) {
    651             if (myParamMask->data.U8[i] == 0) {
     651            if (myParamMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) {
    652652                pQP->data.F32[i] = (2 * Q->data.F32[i]) - params->data.F32[i];
    653653            } else {
     
    663663        if (term1 < term2) {
    664664            for (i=0;i<numDims;i++) {
    665                 if (myParamMask->data.U8[i] == 0) {
     665                if (myParamMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) {
    666666                    ((psVector *) v->data[biggestIter])->data.F32[i] = u->data.F32[i];
    667667                }
     
    671671        // 7: Set P to Q
    672672        for (i=0;i<numDims;i++) {
    673             if (myParamMask->data.U8[i] == 0) {
     673            if (myParamMask->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) {
    674674                params->data.F32[i] = Q->data.F32[i];
    675675            }
  • trunk/psLib/src/math/psPolynomialMD.c

    r19085 r21183  
    132132                              const psVector *values, // Measured values
    133133                              const psVector *mask, // Mask for values
    134                               psMaskType maskVal
     134                              psVectorMaskType maskVal
    135135                              )
    136136{
     
    143143    int numGood = numValues;            // Number of good values
    144144    for (int i = 0; i < numValues; i++) {
    145         if (mask && (mask->data.U8[i] & maskVal)) {
     145        if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal)) {
    146146            numGood--;
    147147            continue;
     
    253253
    254254bool psPolynomialMDFit(psPolynomialMD *poly, const psVector *values, const psVector *errors,
    255                        const psVector *mask, psMaskType maskVal, const psArray *coordsArray)
     255                       const psVector *mask, psVectorMaskType maskVal, const psArray *coordsArray)
    256256{
    257257    PS_ASSERT_POLYNOMIALMD_NON_NULL(poly, false);
     
    268268    if (mask) {
    269269        PS_ASSERT_VECTOR_NON_NULL(mask, false);
    270         PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_MASK, false);
     270        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
    271271        PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, false);
    272272    }
     
    294294        PS_ASSERT_VECTOR_TYPE(coords, PS_TYPE_F32, false);
    295295
    296         if (mask && (mask->data.PS_TYPE_MASK_DATA[i] & maskVal)) {
     296        if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal)) {
    297297            continue;
    298298        }
     
    321321}
    322322
    323 // XXX this function should take a (psMaskType markVal) argument
     323// XXX this function should take a (psVectorMaskType markVal) argument
    324324bool psPolynomialMDClipFit(psPolynomialMD *poly, const psVector *values, const psVector *errors,
    325                            const psVector *mask, psMaskType maskVal, const psArray *coordsArray,
     325                           const psVector *mask, psVectorMaskType maskVal, const psArray *coordsArray,
    326326                           int numIter, float rej)
    327327{
     
    340340    if (mask) {
    341341        PS_ASSERT_VECTOR_NON_NULL(mask, false);
    342         PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_MASK, false);
     342        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
    343343        PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, false);
    344344    }
     
    355355
    356356    // copy the input mask to a local temporary mask
    357     poly->ownMask = psVectorRecycle(poly->ownMask, numValues, PS_TYPE_U8); // Our own mask for input values
     357    poly->ownMask = psVectorRecycle(poly->ownMask, numValues, PS_TYPE_VECTOR_MASK); // Our own mask for input values
    358358    psVectorInit(poly->ownMask, 0);
    359359    for (int i = 0; mask && (i < numValues); i++) {
    360         if (mask->data.PS_TYPE_MASK_DATA[i] & maskVal) {
    361             poly->ownMask->data.U8[i] = 0xff;
     360        if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal) {
     361            poly->ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff;
    362362            numGood--;
    363363        }
     
    392392                    i, values->data.F32[i], values->data.F32[i] - poly->deviations->data.F32[i], poly->deviations->data.F32[i], limit);
    393393
    394             if (poly->ownMask->data.U8[i]) continue;
     394            if (poly->ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue;
    395395
    396396            if (fabs(poly->deviations->data.F32[i]) > limit) {
     
    398398                        i, values->data.F32[i], values->data.F32[i] + poly->deviations->data.F32[i],
    399399                        poly->deviations->data.F32[i], limit);
    400                 poly->ownMask->data.U8[i] = 0xff;
     400                poly->ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff;
    401401                numClipped++;
    402402                numGood--;
     
    435435    psVectorInit(vector, 0.0);
    436436    for (int i = 0; i < numValues; i++) {
    437         if (mask->data.U8[i]) {
     437        if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    438438            continue;
    439439        }
     
    462462
    463463bool psPolynomialMDClipFit(psPolynomialMD *poly, const psVector *values, const psVector *errors,
    464                            const psVector *mask, psMaskType maskVal, const psArray *coordsArray,
     464                           const psVector *mask, psVectorMaskType maskVal, const psArray *coordsArray,
    465465                           int numIter, float rej)
    466466{
     
    478478    if (mask) {
    479479        PS_ASSERT_VECTOR_NON_NULL(mask, false);
    480         PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_MASK, false);
     480        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
    481481        PS_ASSERT_VECTORS_SIZE_EQUAL(values, mask, false);
    482482    }
     
    500500        PS_ASSERT_VECTOR_TYPE(coords, PS_TYPE_F32, false);
    501501
    502         if (mask && (mask->data.PS_TYPE_MASK_DATA[i] & maskVal)) {
     502        if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal)) {
    503503            continue;
    504504        }
     
    516516    psImage *matrix = psImageAlloc(numTerms, numTerms, PS_TYPE_F64); // Least-squares matrix
    517517    psVector *vector = psVectorAlloc(numTerms, PS_TYPE_F64); // Least-squares vector
    518     psVector *ownMask = psVectorAlloc(numValues, PS_TYPE_U8); // Our own mask for input values
     518    psVector *ownMask = psVectorAlloc(numValues, PS_TYPE_VECTOR_MASK); // Our own mask for input values
    519519    psVectorInit(ownMask, 0);
    520520    if (mask) {
    521521        for (int i = 0; i < numValues; i++) {
    522             if (mask->data.PS_TYPE_MASK_DATA[i] & maskVal) {
    523                 ownMask->data.U8[i] = 0xff;
     522            if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskVal) {
     523                ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff;
    524524                numGood--;
    525525            }
     
    551551        float limit = rej * poly->stdevFit; // Rejection limit
    552552        for (int i = 0; i < numValues; i++) {
    553             if (ownMask->data.U8[i]) {
     553            if (ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    554554                continue;
    555555            }
     
    558558                        i, values->data.F32[i], psPolynomialMDEval(poly, coordsArray->data[i]),
    559559                        deviations->data.F32[i], limit);
    560                 ownMask->data.U8[i] = 0xff;
     560                ownMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff;
    561561                numClipped++;
    562562                numGood--;
  • trunk/psLib/src/math/psPolynomialMD.h

    r19085 r21183  
    5252                       const psVector *errors, ///< Errors
    5353                       const psVector *mask, ///< Mask
    54                        psMaskType maskVal, ///< Value to mask
     54                       psVectorMaskType maskVal, ///< Value to mask
    5555                       const psArray *coordsArray ///< Array of coordinates
    5656    );
     
    6161                           const psVector *errors, ///< Errors
    6262                           const psVector *mask, ///< Mask
    63                            psMaskType maskVal, ///< Value to mask
     63                           psVectorMaskType maskVal, ///< Value to mask
    6464                           const psArray *coordsArray, ///< Array of coordinates
    6565                           int numIter,    ///< Number of rejection iterations
  • trunk/psLib/src/math/psPolynomialUtils.c

    r19844 r21183  
    2121    psStats *stats,
    2222    const psVector *mask,
    23     psMaskType maskValue,
     23    psVectorMaskType maskValue,
    2424    const psVector *f,
    2525    const psVector *fErr,
     
    3636    if (mask != NULL) {
    3737        PS_ASSERT_VECTORS_SIZE_EQUAL(f, mask, NULL);
    38         PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, NULL);
     38        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, NULL);
    3939    }
    4040    PS_ASSERT_VECTOR_NON_NULL(x, NULL);
     
    106106        // recovery is not allowed with this scheme
    107107        for (int i = 0; i < resid->n; i++) {
    108             if ((mask != NULL) && (mask->data.U8[i] & maskValue)) {
     108            if ((mask != NULL) && (mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValue)) {
    109109                continue;
    110110            }
     
    112112            if (resid->data.F64[i] - stats->sampleMedian > sigma*maxClipSigma) {
    113113                if (mask != NULL) {
    114                     mask->data.U8[i] |= 0x01;
     114                    mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01;
    115115                }
    116116                continue;
     
    118118            if (resid->data.F64[i] - stats->sampleMedian < sigma*minClipSigma) {
    119119                if (mask != NULL) {
    120                     mask->data.U8[i] |= 0x01;
     120                    mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= 0x01;
    121121                }
    122122                continue;
  • trunk/psLib/src/math/psPolynomialUtils.h

    r11248 r21183  
    22 * @brief extra psPolynomial-related functions
    33 *
    4  * $Revision: 1.5 $ $Name: not supported by cvs2svn $
    5  * $Date: 2007-01-23 22:47:23 $
     4 * $Revision: 1.6 $ $Name: not supported by cvs2svn $
     5 * $Date: 2009-01-27 06:39:38 $
    66 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    77 */
     
    2424    psStats *stats,                     // Statistics to use in clipping
    2525    const psVector *mask,               // Mask for input values
    26     psMaskType maskValue,               // Mask value
     26    psVectorMaskType maskValue,         // Mask value
    2727    const psVector *f,                  // Value of the function, f(x,y,z,t)
    2828    const psVector *fErr,               // Error in the value
  • trunk/psLib/src/math/psStats.c

    r20515 r21183  
    1313 * use ->min and ->max (PS_STAT_USE_RANGE)
    1414 *
    15  *  @version $Revision: 1.230 $ $Name: not supported by cvs2svn $
    16  *  @date $Date: 2008-11-04 00:55:14 $
     15 *  @version $Revision: 1.231 $ $Name: not supported by cvs2svn $
     16 *  @date $Date: 2009-01-27 06:39:38 $
    1717 *
    1818 *  Copyright 2006 IfA, University of Hawaii
     
    6868#define PS_CLIPPED_SIGMA_UB 10.0
    6969#define PS_POLY_MEDIAN_MAX_ITERATIONS 30
    70 #define MASK_MARK 0x80   // bit to use internally to mark data as bad
     70
     71#define MASK_MARK 0x80   // XXX : can we change this? bit to use internally to mark data as bad
    7172#define PS_ROBUST_MAX_ITERATIONS 20     // Maximum number of iterations for robust statistics
    7273
     
    178179                                 const psVector* errors,
    179180                                 const psVector* maskVector,
    180                                  psMaskType maskVal,
     181                                 psVectorMaskType maskVal,
    181182                                 psStats* stats)
    182183{
     
    190191    int numData = myVector->n;          // Number of data points
    191192
    192     psU8 *maskData = (maskVector == NULL) ? NULL : maskVector->data.U8;
     193    psVectorMaskType *maskData = (maskVector == NULL) ? NULL : maskVector->data.PS_TYPE_VECTOR_MASK_DATA;
    193194    bool useRange = stats->options & PS_STAT_USE_RANGE;
    194195
     
    245246    static long vectorMinMax(const psVector* myVector,
    246247                             const psVector* maskVector,
    247                              psMaskType maskVal,
     248                             psVectorMaskType maskVal,
    248249                             psStats* stats
    249250        )
     
    257258    int numValid = 0;                   // Number of valid values
    258259
    259     psU8 *maskData = (maskVector == NULL) ? NULL : maskVector->data.U8;
     260    psVectorMaskType *maskData = (maskVector == NULL) ? NULL : maskVector->data.PS_TYPE_VECTOR_MASK_DATA;
    260261    bool useRange = stats->options & PS_STAT_USE_RANGE;
    261262
     
    302303static bool vectorSampleMedian(const psVector* inVector,
    303304                               const psVector* maskVector,
    304                                psMaskType maskVal,
     305                               psVectorMaskType maskVal,
    305306                               psStats* stats)
    306307{
     
    308309
    309310    bool useRange = stats->options & PS_STAT_USE_RANGE;
    310     psU8 *maskData = (maskVector == NULL) ? NULL : maskVector->data.U8; // Dereference the vector
     311    psVectorMaskType *maskData = (maskVector == NULL) ? NULL : maskVector->data.PS_TYPE_VECTOR_MASK_DATA; // Dereference the vector
    311312    psF32 *input = inVector->data.F32; // Dereference the vector
    312313
     
    387388                              const psVector* errors,
    388389                              const psVector* maskVector,
    389                               psMaskType maskVal,
     390                              psVectorMaskType maskVal,
    390391                              psStats* stats)
    391392{
     
    407408
    408409    psF32 *data = myVector->data.F32;   // Dereference
    409     psU8 *maskData = (maskVector == NULL) ? NULL : maskVector->data.U8;
     410    psVectorMaskType *maskData = (maskVector == NULL) ? NULL : maskVector->data.PS_TYPE_VECTOR_MASK_DATA;
    410411    bool useRange = stats->options & PS_STAT_USE_RANGE;
    411412    psF32 *errorsData = (errors == NULL) ? NULL : errors->data.F32;
     
    468469static bool vectorSampleMoments(const psVector* myVector,
    469470                                const psVector* maskVector,
    470                                 psMaskType maskVal,
     471                                psVectorMaskType maskVal,
    471472                                psStats* stats)
    472473{
     
    490491
    491492    psF32 *data = myVector->data.F32;   // Dereference
    492     psU8 *maskData = (maskVector == NULL) ? NULL : maskVector->data.U8;
     493    psVectorMaskType *maskData = (maskVector == NULL) ? NULL : maskVector->data.PS_TYPE_VECTOR_MASK_DATA;
    493494    bool useRange = stats->options & PS_STAT_USE_RANGE;
    494495
     
    557558                               const psVector* errors,
    558559                               psVector* maskInput,
    559                                psMaskType maskValInput,
     560                               psVectorMaskType maskValInput,
    560561                               psStats* stats
    561562    )
     
    580581
    581582    // We copy the mask vector, to preserve the original
    582     psMaskType maskVal = MASK_MARK | maskValInput;
     583    psVectorMaskType maskVal = MASK_MARK | maskValInput;
    583584
    584585    // use the temporary vector for local temporary mask
    585     stats->tmpMask = psVectorRecycle (stats->tmpMask, myVector->n, PS_TYPE_U8);
     586    stats->tmpMask = psVectorRecycle (stats->tmpMask, myVector->n, PS_TYPE_VECTOR_MASK);
    586587    psVector *tmpMask = stats->tmpMask;
    587588    psVectorInit(tmpMask, 0);
    588589    if (maskInput) {
    589590        for (long i = 0; i < myVector->n; i++) {
    590             if (maskInput->data.U8[i] & maskValInput) {
    591                 tmpMask->data.U8[i] = maskVal;
     591            if (maskInput->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValInput) {
     592                tmpMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = maskVal;
    592593            }
    593594        }
     
    629630            // sqrt(A))
    630631            for (long j = 0; j < myVector->n; j++) {
    631                 if (!tmpMask->data.U8[j] &&
     632                if (!tmpMask->data.PS_TYPE_VECTOR_MASK_DATA[j] &&
    632633                    fabsf(myVector->data.F32[j] - clippedMean) > stats->clipSigma * errors->data.F32[j]) {
    633                     tmpMask->data.U8[j] = 0xff;
     634                    tmpMask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xff;
    634635                    psTrace(TRACE, 10, "Clipped %ld: %f +/- %f\n", j,
    635636                            myVector->data.F32[j], errors->data.F32[j]);
     
    640641        } else {
    641642            for (long j = 0; j < myVector->n; j++) {
    642                 if (!tmpMask->data.U8[j] &&
     643                if (!tmpMask->data.PS_TYPE_VECTOR_MASK_DATA[j] &&
    643644                    fabsf(myVector->data.F32[j] - clippedMean) > (stats->clipSigma * clippedStdev)) {
    644                     tmpMask->data.U8[j] = 0xff;
     645                    tmpMask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xff;
    645646                    psTrace(TRACE, 10, "Clipped %ld: %f\n", j, myVector->data.F32[j]);
    646647                    numClipped++;
     
    715716                              const psVector* errors,
    716717                              psVector* maskInput,
    717                               psMaskType maskValInput,
     718                              psVectorMaskType maskValInput,
    718719                              psStats* stats)
    719720{
     
    726727    // and tested even if there is no supplied mask (and/or the maskVal is 0)
    727728    // XXX this would be better if we had globally defined mask values
    728     psMaskType maskVal = MASK_MARK | maskValInput;
    729     psVector *mask = psVectorAlloc(myVector->n, PS_TYPE_MASK); // The actual mask we will use
     729    psVectorMaskType maskVal = MASK_MARK | maskValInput;
     730    psVector *mask = psVectorAlloc(myVector->n, PS_TYPE_VECTOR_MASK); // The actual mask we will use
    730731    psVectorInit(mask, 0);
    731732    if (maskInput) {
    732733        for (long i = 0; i < myVector->n; i++) {
    733             if (maskInput->data.U8[i] & maskValInput) {
    734                 mask->data.U8[i] = maskVal;
     734            if (maskInput->data.PS_TYPE_VECTOR_MASK_DATA[i] & maskValInput) {
     735                mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = maskVal;
    735736            }
    736737        }
     
    934935                if ((myVector->data.F32[i] < medianLo) || (myVector->data.F32[i] > medianHi)) {
    935936                    // XXXX is this correct?  is MASK_MARK safe?
    936                     mask->data.U8[i] |= MASK_MARK;
     937                    mask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= MASK_MARK;
    937938                    psTrace(TRACE, 6, "Masking element %ld is %f\n", i, myVector->data.F32[i]);
    938939                }
     
    998999    long N50 = 0;
    9991000    for (long i = 0 ; i < myVector->n ; i++) {
    1000         if (!mask->data.U8[i] &&
     1001        if (!mask->data.PS_TYPE_VECTOR_MASK_DATA[i] &&
    10011002            (binLo25F32 <= myVector->data.F32[i]) && (binHi25F32 >= myVector->data.F32[i])) {
    10021003            N50++;
     
    10461047                               const psVector* errors,
    10471048                               psVector* mask,
    1048                                psMaskType maskVal,
     1049                               psVectorMaskType maskVal,
    10491050                               psStats* stats)
    10501051{
     
    12241225                                  const psVector* errors,
    12251226                                  psVector* mask,
    1226                                   psMaskType maskVal,
     1227                                  psVectorMaskType maskVal,
    12271228                                  psStats* stats)
    12281229{
     
    13471348        // fitStats->clipIter = 3.0;
    13481349        // fitStats->clipSigma = 3.0;
    1349         // psVector *fitMask = psVectorAlloc(y->n, PS_TYPE_U8);
     1350        // psVector *fitMask = psVectorAlloc(y->n, PS_TYPE_VECTOR_MASK);
    13501351        // psVectorInit (fitMask, 0);
    13511352
     
    14181419                                  const psVector* errors,
    14191420                                  psVector* mask,
    1420                                   psMaskType maskVal,
     1421                                  psVectorMaskType maskVal,
    14211422                                  psStats* stats)
    14221423{
     
    17131714                                  const psVector* errors,
    17141715                                  psVector* mask,
    1715                                   psMaskType maskVal,
     1716                                  psVectorMaskType maskVal,
    17161717                                  psStats* stats)
    17171718{
     
    22252226                   const psVector* errors,
    22262227                   const psVector* mask,
    2227                    psMaskType maskVal)
     2228                   psVectorMaskType maskVal)
    22282229{
    22292230    psTrace(TRACE, 3,"---- %s() begin  ----\n", __func__);
     
    22332234    if (mask) {
    22342235        PS_ASSERT_VECTORS_SIZE_EQUAL(mask, in, false);
    2235         PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
     2236        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
    22362237    }
    22372238    if (errors) {
     
    22552256        }
    22562257    }
    2257     psVector *maskU8 = NULL;            // Input mask vector, U8 version
     2258    psVector *maskVector = NULL;            // Input mask vector, U8 version
    22582259    if (mask) {
    2259         if (mask->type.type == PS_TYPE_MASK) {
    2260             maskU8 = psMemIncrRefCounter((psPtr)mask);
     2260        if (mask->type.type == PS_TYPE_VECTOR_MASK) {
     2261            maskVector = psMemIncrRefCounter((psPtr)mask);
    22612262        } else {
    2262             maskU8 = psVectorCopy(NULL, mask, PS_TYPE_MASK);
     2263            maskVector = psVectorCopy(NULL, mask, PS_TYPE_VECTOR_MASK);
    22632264        }
    22642265    }
     
    22792280    // ************************************************************************
    22802281    if (stats->options & PS_STAT_SAMPLE_MEAN) {
    2281         if (!vectorSampleMean(inF32, errorsF32, maskU8, maskVal, stats)) {
     2282        if (!vectorSampleMean(inF32, errorsF32, maskVector, maskVal, stats)) {
    22822283            psError(PS_ERR_UNKNOWN, false, "Failed to calculate vector sample mean");
    22832284            status &= false;
     
    22872288    // ************************************************************************
    22882289    if (stats->options & (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_QUARTILE)) {
    2289         if (!vectorSampleMedian(inF32, maskU8, maskVal, stats)) {
     2290        if (!vectorSampleMedian(inF32, maskVector, maskVal, stats)) {
    22902291            psError(PS_ERR_UNKNOWN, false, "Failed to calculate sample median");
    22912292            status &= false;
     
    22952296    // ************************************************************************
    22962297    if (stats->options & PS_STAT_SAMPLE_STDEV) {
    2297         if (!vectorSampleStdev(inF32, errorsF32, maskU8, maskVal, stats)) {
     2298        if (!vectorSampleStdev(inF32, errorsF32, maskVector, maskVal, stats)) {
    22982299            psError(PS_ERR_UNKNOWN, false, "Failed to calculate sample stdev");
    22992300            status &= false;
     
    23022303
    23032304    if (stats->options & (PS_STAT_SAMPLE_SKEWNESS | PS_STAT_SAMPLE_KURTOSIS)) {
    2304         if (!vectorSampleMoments(inF32, maskU8, maskVal, stats)) {
     2305        if (!vectorSampleMoments(inF32, maskVector, maskVal, stats)) {
    23052306            psError(PS_ERR_UNKNOWN, false, "Failed to calculate sample moments");
    23062307            status &= false;
     
    23102311    // ************************************************************************
    23112312    if (stats->options & (PS_STAT_MAX | PS_STAT_MIN)) {
    2312         if (vectorMinMax(inF32, maskU8, maskVal, stats) == 0) {
     2313        if (vectorMinMax(inF32, maskVector, maskVal, stats) == 0) {
    23132314            psError(PS_ERR_UNKNOWN, false, "Failed to calculate vector minimum and maximum");
    23142315            status &= false;
     
    23182319    // ************************************************************************
    23192320    if (stats->options & (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV | PS_STAT_ROBUST_QUARTILE)) {
    2320         if (!vectorRobustStats(inF32, errorsF32, maskU8, maskVal, stats)) {
     2321        if (!vectorRobustStats(inF32, errorsF32, maskVector, maskVal, stats)) {
    23212322            psError(PS_ERR_UNKNOWN, false, _("Failed to calculate robust statistics"));
    23222323            status &= false;
     
    23262327    // ************************************************************************
    23272328    if (stats->options & (PS_STAT_FITTED_MEAN | PS_STAT_FITTED_STDEV)) {
    2328         if (!vectorFittedStats(inF32, errorsF32, maskU8, maskVal, stats)) {
     2329        if (!vectorFittedStats(inF32, errorsF32, maskVector, maskVal, stats)) {
    23292330            psError(PS_ERR_UNKNOWN, false, _("Failed to calculate fitted statistics"));
    23302331            status &= false;
     
    23372338            psAbort("you may not specify both FITTED_MEAN and FITTED_MEAN_V2");
    23382339        }
    2339         if (!vectorFittedStats_v2(inF32, errorsF32, maskU8, maskVal, stats)) {
     2340        if (!vectorFittedStats_v2(inF32, errorsF32, maskVector, maskVal, stats)) {
    23402341            psError(PS_ERR_UNKNOWN, false, _("Failed to calculate fitted statistics"));
    23412342            status &= false;
     
    23482349            psAbort("you may not specify both FITTED_MEAN and FITTED_MEAN_V3");
    23492350        }
    2350         if (!vectorFittedStats_v3(inF32, errorsF32, maskU8, maskVal, stats)) {
     2351        if (!vectorFittedStats_v3(inF32, errorsF32, maskVector, maskVal, stats)) {
    23512352            psError(PS_ERR_UNKNOWN, false, _("Failed to calculate fitted statistics"));
    23522353            status &= false;
     
    23592360            psAbort("you may not specify both FITTED_MEAN and FITTED_MEAN_V4");
    23602361        }
    2361         if (!vectorFittedStats_v4(inF32, errorsF32, maskU8, maskVal, stats)) {
     2362        if (!vectorFittedStats_v4(inF32, errorsF32, maskVector, maskVal, stats)) {
    23622363            psError(PS_ERR_UNKNOWN, false, _("Failed to calculate fitted statistics"));
    23632364            status &= false;
     
    23672368    // ************************************************************************
    23682369    if ((stats->options & PS_STAT_CLIPPED_MEAN) || (stats->options & PS_STAT_CLIPPED_STDEV)) {
    2369         if (!vectorClippedStats(inF32, errorsF32, maskU8, maskVal, stats)) {
     2370        if (!vectorClippedStats(inF32, errorsF32, maskVector, maskVal, stats)) {
    23702371            psError(PS_ERR_UNKNOWN, false, "Failed to calculate clipped statistics\n");
    23712372            status &= false;
     
    23752376    psFree(inF32);
    23762377    psFree(errorsF32);
    2377     psFree(maskU8);
     2378    psFree(maskVector);
    23782379    psTrace(TRACE, 3,"---- %s() end  ----\n", __func__);
    23792380    return status;
  • trunk/psLib/src/math/psStats.h

    r18876 r21183  
    88 * @author GLG, MHPCC
    99 *
    10  * @version $Revision: 1.65 $ $Name: not supported by cvs2svn $
    11  * @date $Date: 2008-08-03 20:55:09 $
     10 * @version $Revision: 1.66 $ $Name: not supported by cvs2svn $
     11 * @date $Date: 2009-01-27 06:39:38 $
    1212 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1313 */
     
    9696 */
    9797bool psVectorStats(
    98     psStats* stats,                    ///< stats structure defines stats to be calculated and how
    99     const psVector* in,                ///< Vector to be analysed.
    100     const psVector* errors,            ///< Errors.
    101     const psVector* mask,              ///< Ignore elements where (maskVector & maskVal) != 0: must be INT or NULL
    102     psMaskType maskVal                ///< Only mask elements with one of these bits set in maskVector
     98    psStats* stats,            ///< stats structure defines stats to be calculated and how
     99    const psVector* in,                 ///< Vector to be analysed.
     100    const psVector* errors,             ///< Errors.
     101    const psVector* mask, ///< Ignore elements where (maskVector & maskVal) != 0: must be INT or NULL
     102    psVectorMaskType maskVal ///< Only mask elements with one of these bits set in maskVector
    103103);
    104104
  • trunk/psLib/src/mathtypes/psVector.c

    r20547 r21183  
    1010*  @author Joshua Hoblitt, University of Hawaii
    1111*
    12 *  @version $Revision: 1.104 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2008-11-05 11:12:40 $
     12*  @version $Revision: 1.105 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2009-01-27 06:39:38 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    987987}
    988988
    989 // count number of pixels with given mask value
     989// count number of pixels with given mask value.  the comparison is against a U64 type to
     990// allow any int-type of vector.  all signed and unsigned int types are allowed
    990991long psVectorCountPixelMask (psVector *mask,
    991                              psMaskType value)
     992                             psU64 value)
    992993{
    993994    long Npixels = 0;
     
    998999    }
    9991000
    1000     psElemType type;
    1001     type = mask->type.type;
    1002 
    1003     if (type != PS_TYPE_MASK) {
    1004         psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    1005                 "psVector type does not match the specified psMaskType!\n");
    1006         return -1;
    1007     }
    1008 
     1001# define PS_VECTOR_COUNT_PIXEL_MASK(NAME,TYPE) \
     1002    case PS_TYPE_##NAME: \
     1003        for (long i = 0; i < mask->n; i++) { \
     1004            if (mask->data.TYPE[i] & value) { \
     1005                Npixels ++; \
     1006            } \
     1007        } \
     1008        break;
     1009
     1010    psElemType type = mask->type.type;
    10091011    switch (type) {
    1010     case PS_TYPE_U8:
    1011     case PS_TYPE_U16:
    1012         for (long i = 0; i < mask->n; i++) {
    1013             if (mask->data.PS_TYPE_MASK_DATA[i] & value) {
    1014                 Npixels ++;
    1015             }
    1016         }
    1017         break;
    1018     case PS_TYPE_S8:
    1019     case PS_TYPE_S16:
    1020     case PS_TYPE_S32:
    1021     case PS_TYPE_S64:
    1022     case PS_TYPE_U32:
    1023     case PS_TYPE_U64:
    1024     case PS_TYPE_F32:
    1025     case PS_TYPE_F64:
     1012        PS_VECTOR_COUNT_PIXEL_MASK(U8, U8);
     1013        PS_VECTOR_COUNT_PIXEL_MASK(U16,U16);
     1014        PS_VECTOR_COUNT_PIXEL_MASK(U32,U32);
     1015        PS_VECTOR_COUNT_PIXEL_MASK(U64,U64);
     1016        PS_VECTOR_COUNT_PIXEL_MASK(S8, S8);
     1017        PS_VECTOR_COUNT_PIXEL_MASK(S16,S16);
     1018        PS_VECTOR_COUNT_PIXEL_MASK(S32,S32);
     1019        PS_VECTOR_COUNT_PIXEL_MASK(S64,S64);
    10261020    default:
    10271021        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
  • trunk/psLib/src/mathtypes/psVector.h

    r19502 r21183  
    1010 * @author Joshua Hoblitt, University of Hawaii
    1111 *
    12  * @version $Revision: 1.73 $ $Name: not supported by cvs2svn $
    13  * @date $Date: 2008-09-12 00:22:48 $
     12 * @version $Revision: 1.74 $ $Name: not supported by cvs2svn $
     13 * @date $Date: 2009-01-27 06:39:38 $
    1414 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1515 */
     
    379379 */
    380380long psVectorCountPixelMask(
    381     psVector *mask,                    ///< input vector to count
    382     psMaskType value                   ///< the mask value to satisfy
     381    psVector *mask,                     ///< input vector to count
     382    psU64 value                         ///< the mask value to satisfy
    383383);
    384384
  • trunk/psLib/src/sys/psType.h

    r14454 r21183  
    1010*  @author Ross Harman, MHPCC
    1111*
    12 *  @version $Revision: 1.62 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2007-08-09 03:30:47 $
     12*  @version $Revision: 1.63 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2009-01-27 06:39:38 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    141141} psDataType;
    142142
     143// macros to abstract the generic mask type : these values must be consistent
    143144#define PS_TYPE_MASK PS_TYPE_U8        /**< the psElemType to use for mask image */
    144145#define PS_TYPE_MASK_DATA U8           /**< the data member to use for mask image */
    145146#define PS_TYPE_MASK_NAME "psU8"       /**< the data type for mask as a string */
    146 
     147#define PS_MIN_MASK_TYPE 0             /**< minimum valid Mask value */
     148#define PS_MAX_MASK_TYPE UINT8_MAX     /**< maximum valid Mask value */
    147149typedef psU8 psMaskType;               ///< the C datatype for a mask image
     150#define PS_NOT_MASK(A)(UINT8_MAX-(A))
     151
     152// alternate versions if needed
     153// #define PS_NOT_MASK(A)(UINT16_MAX-(A))
     154// #define PS_NOT_MASK(A)(UINT32_MAX-(A))
     155// #define PS_NOT_MASK(A)(UINT64_MAX-(A))
     156
     157// macros to abstract the vector mask type : these values must be consistent
     158#define PS_TYPE_VECTOR_MASK PS_TYPE_U8        /**< the psElemType to use for mask image */
     159#define PS_TYPE_VECTOR_MASK_DATA U8           /**< the data member to use for mask image */
     160#define PS_TYPE_VECTOR_MASK_NAME "psU8"       /**< the data type for mask as a string */
     161#define PS_MIN_VECTOR_MASK_TYPE 0             /**< minimum valid Vector Mask value */
     162#define PS_MAX_VECTOR_MASK_TYPE UINT8_MAX     /**< maximum valid Vector Mask value */
     163typedef psU8 psVectorMaskType;                    ///< the C datatype for a mask image
     164#define PS_NOT_VECTOR_MASK(A)(UINT8_MAX-(A))
     165
     166// macros to abstract the image mask type : these values must be consistent
     167#define PS_TYPE_IMAGE_MASK PS_TYPE_U16       /**< the psElemType to use for mask image */
     168#define PS_TYPE_IMAGE_MASK_DATA U16          /**< the data member to use for mask image */
     169#define PS_TYPE_IMAGE_MASK_NAME "psU16"      /**< the data type for mask as a string */
     170#define PS_MIN_IMAGE_MASK_TYPE 0             /**< minimum valid Image Mask value */
     171#define PS_MAX_IMAGE_MASK_TYPE UINT16_MAX    /**< maximum valid Image Mask value */
     172typedef psU16 psImageMaskType;               ///< the C datatype for a mask image
     173#define PS_NOT_IMAGE_MASK(A)(UINT16_MAX-(A))
    148174
    149175#define PS_MIN_S8        INT8_MIN      /**< minimum valid psS8 value */
  • trunk/psLib/src/types/psMetadata.c

    r20417 r21183  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.174 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2008-10-28 00:13:19 $
     14 *  @version $Revision: 1.175 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2009-01-27 06:39:38 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    866866METADATA_ADD_TYPE(F32,psF32,PS_DATA_F32)
    867867METADATA_ADD_TYPE(F64,psF64,PS_DATA_F64)
     868
     869METADATA_ADD_TYPE(Mask,psMaskType,PS_TYPE_MASK)
     870METADATA_ADD_TYPE(VectorMask,psVectorMaskType,PS_TYPE_VECTOR_MASK)
     871METADATA_ADD_TYPE(ImageMask,psImageMaskType,PS_TYPE_IMAGE_MASK)
     872
    868873METADATA_ADD_TYPE(List,psList*,PS_DATA_LIST)
    869874METADATA_ADD_TYPE(Str,const char*,PS_DATA_STRING)
     
    10111016}
    10121017
    1013 #define psMetadataLookupNumTYPE(TYPE) \
    1014 ps##TYPE psMetadataLookup##TYPE(bool *status, const psMetadata *md, const char *key) \
     1018#define psMetadataLookupNumTYPE(TYPE,NAME) \
     1019ps##TYPE psMetadataLookup##NAME(bool *status, const psMetadata *md, const char *key) \
    10151020{ \
    10161021    psMetadataItem *metadataItem = NULL; \
     
    10811086}
    10821087
    1083 psMetadataLookupNumTYPE(F32)
    1084 psMetadataLookupNumTYPE(F64)
    1085 psMetadataLookupNumTYPE(S8)
    1086 psMetadataLookupNumTYPE(S16)
    1087 psMetadataLookupNumTYPE(S32)
    1088 psMetadataLookupNumTYPE(S64)
    1089 psMetadataLookupNumTYPE(U8)
    1090 psMetadataLookupNumTYPE(U16)
    1091 psMetadataLookupNumTYPE(U32)
    1092 psMetadataLookupNumTYPE(U64)
    1093 psMetadataLookupNumTYPE(Bool)
     1088psMetadataLookupNumTYPE(F32,F32)
     1089psMetadataLookupNumTYPE(F64,F64)
     1090psMetadataLookupNumTYPE(S8,S8)
     1091psMetadataLookupNumTYPE(S16,S16)
     1092psMetadataLookupNumTYPE(S32,S32)
     1093psMetadataLookupNumTYPE(S64,S64)
     1094psMetadataLookupNumTYPE(U8,U8)
     1095psMetadataLookupNumTYPE(U16,U16)
     1096psMetadataLookupNumTYPE(U32,U32)
     1097psMetadataLookupNumTYPE(U64,U64)
     1098psMetadataLookupNumTYPE(Bool,Bool)
     1099
     1100psMetadataLookupNumTYPE(MaskType,Mask)
     1101psMetadataLookupNumTYPE(VectorMaskType,VectorMask)
     1102psMetadataLookupNumTYPE(ImageMaskType,ImageMask)
    10941103
    10951104psMetadataItem* psMetadataGet(const psMetadata *md,
  • trunk/psLib/src/types/psMetadata.h

    r19056 r21183  
    99*  @author Ross Harman, MHPCC
    1010*
    11 *  @version $Revision: 1.105 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2008-08-14 03:18:41 $
     11*  @version $Revision: 1.106 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2009-01-27 06:39:38 $
    1313*
    1414*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    763763
    764764
     765/** Add a psMaskType value to metadata collection.
     766 *
     767 *  @return bool:  True for success, False for failure.
     768 */
     769bool psMetadataAddMask(
     770    psMetadata* md,                    ///< Metadata collection to insert metadata item
     771    long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
     772    const char* name,                  ///< Name of metadata item
     773    int format,                        ///< psMetadataFlag options/flags
     774    const char* comment,               ///< Comment for metadata item
     775    psMaskType value                    ///< Value for metadata item data
     776);
     777
     778
     779/** Add a psVectorMaskType value to metadata collection.
     780 *
     781 *  @return bool:  True for success, False for failure.
     782 */
     783bool psMetadataAddVectorMask(
     784    psMetadata* md,                    ///< Metadata collection to insert metadata item
     785    long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
     786    const char* name,                  ///< Name of metadata item
     787    int format,                        ///< psMetadataFlag options/flags
     788    const char* comment,               ///< Comment for metadata item
     789    psVectorMaskType value                      ///< Value for metadata item data
     790);
     791
     792
     793/** Add a psImageMaskType value to metadata collection.
     794 *
     795 *  @return bool:  True for success, False for failure.
     796 */
     797bool psMetadataAddImageMask(
     798    psMetadata* md,                    ///< Metadata collection to insert metadata item
     799    long location,                     ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL
     800    const char* name,                  ///< Name of metadata item
     801    int format,                        ///< psMetadataFlag options/flags
     802    const char* comment,               ///< Comment for metadata item
     803    psImageMaskType value                       ///< Value for metadata item data
     804);
     805
     806
     807
    765808/** Add a psList to metadata collection.
    766809 *
     
    10951138 */
    10961139psU64 psMetadataLookupU64(
     1140    bool *status,                      ///< Status of lookup.
     1141    const psMetadata *md,              ///< Metadata collection to lookup metadata item.
     1142    const char *key                    ///< Name of metadata key.
     1143);
     1144
     1145
     1146/** Find an item in the metadata collection based on key name and return its integer value.
     1147 *
     1148 *  Items may be found in the metadata by providing a key. If the key is
     1149 *  non-unique, the value of the first item is returned. If the item is not
     1150 *  found, zero is returned.
     1151 *
     1152 * @return psMaskType : Value of metadata item.
     1153 */
     1154psMaskType psMetadataLookupMask(
     1155    bool *status,                      ///< Status of lookup.
     1156    const psMetadata *md,              ///< Metadata collection to lookup metadata item.
     1157    const char *key                    ///< Name of metadata key.
     1158);
     1159
     1160
     1161/** Find an item in the metadata collection based on key name and return its integer value.
     1162 *
     1163 *  Items may be found in the metadata by providing a key. If the key is
     1164 *  non-unique, the value of the first item is returned. If the item is not
     1165 *  found, zero is returned.
     1166 *
     1167 * @return psVectorMaskType : Value of metadata item.
     1168 */
     1169psVectorMaskType psMetadataLookupVectorMask(
     1170    bool *status,                      ///< Status of lookup.
     1171    const psMetadata *md,              ///< Metadata collection to lookup metadata item.
     1172    const char *key                    ///< Name of metadata key.
     1173);
     1174
     1175
     1176/** Find an item in the metadata collection based on key name and return its integer value.
     1177 *
     1178 *  Items may be found in the metadata by providing a key. If the key is
     1179 *  non-unique, the value of the first item is returned. If the item is not
     1180 *  found, zero is returned.
     1181 *
     1182 * @return psImageMaskType : Value of metadata item.
     1183 */
     1184psImageMaskType psMetadataLookupImageMask(
    10971185    bool *status,                      ///< Status of lookup.
    10981186    const psMetadata *md,              ///< Metadata collection to lookup metadata item.
  • trunk/psLib/src/types/psPixels.c

    r19539 r21183  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2008-09-12 22:36:29 $
     9 *  @version $Revision: 1.44 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2009-01-27 06:39:38 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    150150                        const psPixels *pixels,
    151151                        psRegion region,
    152                         psMaskType maskVal)
     152                        psImageMaskType maskVal)
    153153{
    154154    PS_ASSERT_PIXELS_NON_NULL(pixels, NULL);
     
    169169    int numRows = y1 - y0 + 1, numCols = x1 - x0 + 1; // Size of image
    170170
    171     out = psImageRecycle(out, numCols, numRows, PS_TYPE_MASK);
     171    out = psImageRecycle(out, numCols, numRows, PS_TYPE_IMAGE_MASK);
    172172    if (!out) {
    173173        psError(PS_ERR_UNKNOWN, false, _("Failed to create image of size %dx%d."), numCols, numRows);
     
    181181    // cycle through the vector of pixels and insert pixels into image
    182182    long length = pixels->n;            // Length of pixel array
    183     psMaskType** outData = out->data.PS_TYPE_MASK_DATA;
     183    psImageMaskType** outData = out->data.PS_TYPE_IMAGE_MASK_DATA;
    184184    for (int p = 0; p < length; p++) {
    185185        float x = pixels->data[p].x;
     
    196196psPixels* psPixelsFromMask(psPixels* out,
    197197                           const psImage* mask,
    198                            psMaskType maskVal)
     198                           psImageMaskType maskVal)
    199199{
    200200    PS_ASSERT_IMAGE_NON_NULL(mask, NULL);
    201     PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
     201    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
    202202
    203203    int numRows = mask->numRows, numCols = mask->numCols; // Size of image
     
    214214    for (int y = 0; y < numRows; y++) {
    215215        for (int x = 0; x < numCols; x++) {
    216             if (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
     216            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) {
    217217                psPixelsAdd(out, out->nalloc, x, y);
    218218            }
  • trunk/psLib/src/types/psPixels.h

    r19539 r21183  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2008-09-12 22:36:29 $
     8 *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-01-27 06:39:38 $
    1010 *
    1111 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    189189    const psPixels* pixels,            ///< list of pixels to use
    190190    psRegion region,                   ///< region to define the output mask image
    191     psMaskType maskVal                 ///< the mask bit-values to act upon
     191    psImageMaskType maskVal             ///< the mask bit-values to act upon
    192192);
    193193
     
    205205    psPixels *out,                     ///< psPixels to recycle, or NULL
    206206    const psImage *mask,               ///< the input mask psImage
    207     psMaskType maskVal                 ///< the mask bit-values to act upon
     207    psImageMaskType maskVal             ///< the mask bit-values to act upon
    208208);
    209209
  • trunk/psModules/src/astrom/pmAstrometryDistortion.c

    r19305 r21183  
    77*  @author EAM, IfA
    88*
    9 *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2008-09-02 19:05:09 $
     9*  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2009-01-27 06:39:38 $
    1111*
    1212*  Copyright 2006 Institute for Astronomy, University of Hawaii
     
    121121            // this analysis has too few data points to use the robust median method
    122122            stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV);
    123             mask = psVectorAlloc (Npts, PS_TYPE_MASK);
     123            mask = psVectorAlloc (Npts, PS_TYPE_VECTOR_MASK);
    124124            psVectorInit (mask, 0);
    125125
     
    206206    // this analysis has too few data points to use the robust median method
    207207    psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV);
    208     psVector *mask = psVectorAlloc (gradients->n, PS_TYPE_MASK);
     208    psVector *mask = psVectorAlloc (gradients->n, PS_TYPE_VECTOR_MASK);
    209209    psVectorInit (mask, 0);
    210210
  • trunk/psModules/src/astrom/pmAstrometryObjects.c

    r20801 r21183  
    88*  @author EAM, IfA
    99*
    10 *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2008-11-20 01:26:07 $
     10*  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2009-01-27 06:39:38 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    227227
    228228    // constant errors
    229     psVector *mask = psVectorAlloc (match->n, PS_TYPE_U8);
     229    psVector *mask = psVectorAlloc (match->n, PS_TYPE_VECTOR_MASK);
    230230    psVectorInit (mask, 0);
    231231
  • trunk/psModules/src/camera/pmCellSquish.c

    r12696 r21183  
    1212
    1313
    14 bool pmCellSquish(pmCell *cell, psMaskType maskVal, bool useShifts)
     14bool pmCellSquish(pmCell *cell, psImageMaskType maskVal, bool useShifts)
    1515{
    1616    PS_ASSERT_PTR_NON_NULL(cell, false);
     
    116116    psImage *squishImage = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Squished image
    117117    psImageInit(squishImage, 0.0);
    118     psImage *squishMask = psImageAlloc(numCols, numRows, PS_TYPE_MASK); // Squished mask
     118    psImage *squishMask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); // Squished mask
    119119    psImageInit(squishMask, 0);
    120120
     
    159159                squishImage->data.F32[ySquish][xSquish] += image->data.F32[y][x];
    160160                if (mask) {
    161                     squishMask->data.PS_TYPE_MASK_DATA[ySquish][xSquish] |= mask->data.U8[y][x] & maskVal;
     161                    squishMask->data.PS_TYPE_IMAGE_MASK_DATA[ySquish][xSquish] |= mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal;
    162162                }
    163163            }
  • trunk/psModules/src/camera/pmCellSquish.h

    r12696 r21183  
    77/// already have been read) and masks.
    88bool pmCellSquish(pmCell *cell,         ///< Cell to have readouts combined
    9                   psMaskType maskVal,   ///< Value to be masked
     9                  psImageMaskType maskVal,   ///< Value to be masked
    1010                  bool useShifts        ///< Use the shifts when squishing?
    1111    );
  • trunk/psModules/src/camera/pmFPABin.c

    r20442 r21183  
    99#include "pmFPABin.h"
    1010
    11 bool pmReadoutRebin(pmReadout *out, const pmReadout *in, psMaskType maskVal, int xBin, int yBin)
     11bool pmReadoutRebin(pmReadout *out, const pmReadout *in, psImageMaskType maskVal, int xBin, int yBin)
    1212{
    1313    PM_ASSERT_READOUT_NON_NULL(out, false);
     
    5050            for (int y = yStart; y < yStop; y++) {
    5151                for (int x = xStart; x < xStop; x++) {
    52                     if (inMask && (inMask->data.PS_TYPE_MASK_DATA[y][x] & maskVal)) {
     52                    if (inMask && (inMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal)) {
    5353                        continue;
    5454                    }
  • trunk/psModules/src/camera/pmFPABin.h

    r19695 r21183  
    99bool pmReadoutRebin(pmReadout *out,     ///< Output readout
    1010                    const pmReadout *in,///< Input readout
    11                     psMaskType maskVal, ///< Value to mask
     11                    psImageMaskType maskVal, ///< Value to mask
    1212                    int xBin, int yBin  ///< Binning factors in x and y
    1313    );
  • trunk/psModules/src/camera/pmFPAMaskWeight.c

    r20749 r21183  
    4242            continue;
    4343        }
    44         masks->data[i] = psImageAlloc(image->numCols, image->numRows, PS_TYPE_U8);
     44        masks->data[i] = psImageAlloc(image->numCols, image->numRows, PS_TYPE_IMAGE_MASK);
    4545        psImageInit(masks->data[i], 0);
    4646    }
     
    9898//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    9999
    100 bool pmReadoutSetMask(pmReadout *readout, psMaskType satMask, psMaskType badMask)
     100bool pmReadoutSetMask(pmReadout *readout, psImageMaskType satMask, psImageMaskType badMask)
    101101{
    102102    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    124124    if (!readout->mask) {
    125125        // Generate a (throwaway) mask image, if required
    126         readout->mask = psImageAlloc(image->numCols, image->numRows, PS_TYPE_U8);
     126        readout->mask = psImageAlloc(image->numCols, image->numRows, PS_TYPE_IMAGE_MASK);
    127127    }
    128128    psImage *mask = readout->mask;      // The mask pixels
     
    131131    // Dereference pointers for speed
    132132    psF32 **imageData = image->data.F32;// The image
    133     psU8  **maskData  = mask->data.U8;  // The mask
     133    psImageMaskType **maskData = mask->data.PS_TYPE_IMAGE_MASK_DATA;  // The mask
    134134
    135135    for (int i = 0; i < image->numRows; i++) {
     
    153153// pixels.  currently, it will set mask bits if (value <= BAD) or (value >= SATURATION)
    154154// should we optionally ignore these tests?
    155 bool pmReadoutGenerateMask(pmReadout *readout, psMaskType satMask, psMaskType badMask)
     155bool pmReadoutGenerateMask(pmReadout *readout, psImageMaskType satMask, psImageMaskType badMask)
    156156{
    157157    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    294294}
    295295
    296 bool pmReadoutGenerateMaskWeight(pmReadout *readout, psMaskType satMask, psMaskType badMask, bool poisson)
     296bool pmReadoutGenerateMaskWeight(pmReadout *readout, psImageMaskType satMask, psImageMaskType badMask, bool poisson)
    297297{
    298298    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    306306}
    307307
    308 bool pmCellGenerateMaskWeight(pmCell *cell, psMaskType satMask, psMaskType badMask, bool poisson)
     308bool pmCellGenerateMaskWeight(pmCell *cell, psImageMaskType satMask, psImageMaskType badMask, bool poisson)
    309309{
    310310    PS_ASSERT_PTR_NON_NULL(cell, false);
     
    321321
    322322
    323 bool pmReadoutWeightRenormPixels(const pmReadout *readout, psMaskType maskVal,
     323bool pmReadoutWeightRenormPixels(const pmReadout *readout, psImageMaskType maskVal,
    324324                                 psStatsOptions meanStat, psStatsOptions stdevStat, psRandom *rng)
    325325{
     
    363363
    364364
    365 bool pmReadoutWeightRenormPhot(const pmReadout *readout, psMaskType maskVal, int num, float width,
     365bool pmReadoutWeightRenormPhot(const pmReadout *readout, psImageMaskType maskVal, int num, float width,
    366366                               psStatsOptions meanStat, psStatsOptions stdevStat, psRandom *rng)
    367367{
     
    411411    psVector *source = psVectorAlloc(num, PS_TYPE_F32); // Measurements of fake sources
    412412    psVector *guess = psVectorAlloc(num, PS_TYPE_F32); // Guess at significance
    413     psVector *photMask = psVectorAlloc(num, PS_TYPE_MASK); // Mask for fluxes
     413    psVector *photMask = psVectorAlloc(num, PS_TYPE_VECTOR_MASK); // Mask for fluxes
    414414    for (int i = 0; i < num; i++) {
    415415        // Coordinates of interest
     
    433433            float yGauss = gauss->data.F32[v]; // Value of Gaussian in y
    434434            for (int u = 0, x = xPix - size; u < fullSize; u++, x++) {
    435                 if (mask && mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
     435                if (mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) {
    436436                    continue;
    437437                }
     
    453453        }
    454454
    455         photMask->data.PS_TYPE_MASK_DATA[i] = ((isfinite(sumNoise) && isfinite(sumSource) &&
     455        photMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = ((isfinite(sumNoise) && isfinite(sumSource) &&
    456456                                                isfinite(sumWeight) && sumGauss > 0 && sumGauss2 > 0) ?
    457457                                               0 : 0xFF);
     
    493493        ratio->data.F32[i] = measuredSig / guess->data.F32[i];
    494494        if (guess->data.F32[i] <= 0.0 || source->data.F32[i] <= 0.0 || !isfinite(ratio->data.F32[i])) {
    495             photMask->data.PS_TYPE_MASK_DATA[i] = 0xFF;
     495            photMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xFF;
    496496        }
    497497        psTrace("psModules.camera", 9, "Ratio %d: %f, %f, %f\n",
     
    523523
    524524
    525 bool pmReadoutWeightRenorm(const pmReadout *readout, psMaskType maskVal, psStatsOptions meanStat,
     525bool pmReadoutWeightRenorm(const pmReadout *readout, psImageMaskType maskVal, psStatsOptions meanStat,
    526526                           psStatsOptions stdevStat, int width, psRandom *rng)
    527527{
     
    591591
    592592
    593 bool pmReadoutMaskNonfinite(pmReadout *readout, psMaskType maskVal)
     593bool pmReadoutMaskNonfinite(pmReadout *readout, psImageMaskType maskVal)
    594594{
    595595    PM_ASSERT_READOUT_NON_NULL(readout, false);
     
    601601
    602602    if (!readout->mask) {
    603         readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
     603        readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
    604604    }
    605605    psImage *mask = readout->mask;      // Readout's mask
     
    608608        for (int x = 0; x < numCols; x++) {
    609609            if (!isfinite(image->data.F32[y][x]) || (weight && !isfinite(weight->data.F32[y][x]))) {
    610                 mask->data.PS_TYPE_MASK_DATA[y][x] |= maskVal;
     610                mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= maskVal;
    611611            }
    612612        }
     
    618618
    619619
    620 bool pmReadoutMaskApply(pmReadout *readout, psMaskType maskVal)
     620bool pmReadoutMaskApply(pmReadout *readout, psImageMaskType maskVal)
    621621{
    622622    PM_ASSERT_READOUT_NON_NULL(readout, false);
     
    625625
    626626    int numCols = readout->image->numCols, numRows = readout->image->numRows; // Size of image
    627     psMaskType **maskData = readout->mask->data.PS_TYPE_MASK_DATA; // Dereference mask
     627    psImageMaskType **maskData = readout->mask->data.PS_TYPE_IMAGE_MASK_DATA; // Dereference mask
    628628    psF32 **imageData = readout->image->data.F32;// Dereference image
    629629    psF32 **weightData = readout->weight ? readout->weight->data.F32 : NULL; // Dereference weight map
     
    644644
    645645
    646 bool pmReadoutInterpolateBadPixels(pmReadout *readout, psMaskType maskVal, psImageInterpolateMode mode,
    647                                    float poorFrac, psMaskType maskPoor, psMaskType maskBad)
     646bool pmReadoutInterpolateBadPixels(pmReadout *readout, psImageMaskType maskVal, psImageInterpolateMode mode,
     647                                   float poorFrac, psImageMaskType maskPoor, psImageMaskType maskBad)
    648648{
    649649    PM_ASSERT_READOUT_NON_NULL(readout, false);
     
    667667    psVector *imagePix = psVectorAllocEmpty(PIXELS_BUFFER, PS_TYPE_F32); // Corresponding values for image
    668668    psVector *weightPix = psVectorAllocEmpty(PIXELS_BUFFER, PS_TYPE_F32); // Corresponding values for weight
    669     psVector *maskPix = psVectorAllocEmpty(PIXELS_BUFFER, PS_TYPE_MASK); // Corresponding values for mask
     669    psVector *maskPix = psVectorAllocEmpty(PIXELS_BUFFER, PS_TYPE_IMAGE_MASK); // Corresponding values for mask
     670    // NOTE: maskPix carries the actual image mask values -- do NOT use
     671    // PS_TYPE_VECTOR_MASK here; it is storage, and is not treated as a vector mask
    670672
    671673    long numBad = 0;                    // Number of bad pixels interpolated
    672674    for (int y = 0; y < numRows; y++) {
    673675        for (int x = 0; x < numCols; x++) {
    674             if (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
     676            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) {
    675677                double imageValue, weightValue; // Image and weight value from interpolation
    676                 psMaskType maskValue = 0; // Mask value from interpolation
    677                 psImageInterpolateStatus status = psImageInterpolate(&imageValue, &weightValue, &maskValue,
    678                                                                      x, y, interp);
     678                psImageMaskType maskValue = 0; // Mask value from interpolation
     679                psImageInterpolateStatus status = psImageInterpolate(&imageValue, &weightValue, &maskValue, x, y, interp);
    679680                if (status == PS_INTERPOLATE_STATUS_ERROR || status == PS_INTERPOLATE_STATUS_OFF) {
    680681                    psError(PS_ERR_UNKNOWN, false, "Unable to interpolate readout at %d,%d", x, y);
     
    697698                imagePix->data.F32[numBad] = imageValue;
    698699                weightPix->data.F32[numBad] = weightValue;
    699                 maskPix->data.PS_TYPE_MASK_DATA[numBad] = maskValue;
     700                maskPix->data.PS_TYPE_IMAGE_MASK_DATA[numBad] = maskValue;
    700701                numBad++;
    701702            }
     
    709710        image->data.F32[y][x] = imagePix->data.F32[i];
    710711        weight->data.F32[y][x] = weightPix->data.F32[i];
    711         mask->data.PS_TYPE_MASK_DATA[y][x] = maskPix->data.PS_TYPE_MASK_DATA[i];
     712        mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = maskPix->data.PS_TYPE_IMAGE_MASK_DATA[i];
    712713    }
    713714
  • trunk/psModules/src/camera/pmFPAMaskWeight.h

    r20486 r21183  
    55 * @author Eugene Magnier, IfA
    66 *
    7  * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2008-10-31 21:50:16 $
     7 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2009-01-27 06:39:38 $
    99 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    1010 */
     
    4242/// iterating using pmReadoutReadNext, in which case the HDU can't be generated.
    4343bool pmReadoutSetMask(pmReadout *readout, ///< Readout for which to set mask
    44                       psMaskType satMask, ///< Mask value to give saturated pixels
    45                       psMaskType badMask  ///< Mask value to give bad (low) pixels
     44                      psImageMaskType satMask, ///< Mask value to give saturated pixels
     45                      psImageMaskType badMask  ///< Mask value to give bad (low) pixels
    4646    );
    4747
     
    6262/// is suitable for output (complete with HDU entry).  This is intended for most operations.
    6363bool pmReadoutGenerateMask(pmReadout *readout, ///< Readout for which to generate mask
    64                            psMaskType sat, ///< Mask value to give saturated pixels
    65                            psMaskType bad ///< Mask value to give bad (low) pixels
     64                           psImageMaskType sat, ///< Mask value to give saturated pixels
     65                           psImageMaskType bad ///< Mask value to give bad (low) pixels
    6666    );
    6767
     
    7979/// Calls pmReadoutGenerateMask and pmReadoutGenerateWeight for the readout
    8080bool pmReadoutGenerateMaskWeight(pmReadout *readout, ///< Readout for which to generate mask and weights
    81                                  psMaskType sat, ///< Mask value to give saturated pixels
    82                                  psMaskType bad, ///< Mask value to give bad (low) pixels
     81                                 psImageMaskType sat, ///< Mask value to give saturated pixels
     82                                 psImageMaskType bad, ///< Mask value to give bad (low) pixels
    8383                                 bool poisson ///< Use poisson weights (in addition to read noise)?
    8484                                );
     
    8888/// Calls pmReadoutGenerateMaskWeight for each readout within the cell.
    8989bool pmCellGenerateMaskWeight(pmCell *cell, ///< Cell for which to generate mask and weights
    90                               psMaskType sat, ///< Mask value to give saturated pixels
    91                               psMaskType bad, ///< Mask value to give bad (low) pixels
     90                              psImageMaskType sat, ///< Mask value to give saturated pixels
     91                              psImageMaskType bad, ///< Mask value to give bad (low) pixels
    9292                              bool poisson ///< Use poisson weights (in addition to read noise)?
    9393                             );
     
    9898bool pmReadoutWeightRenormPixels(
    9999    const pmReadout *readout,           ///< Readout to normalise
    100     psMaskType maskVal,                 ///< Value to mask
     100    psImageMaskType maskVal,                 ///< Value to mask
    101101    psStatsOptions meanStat,            ///< Statistic to measure the mean (of the variance map)
    102102    psStatsOptions stdevStat,           ///< Statistic to measure the stdev (of the image)
     
    110110bool pmReadoutWeightRenormPhot(
    111111    const pmReadout *readout,           ///< Readout to normalise
    112     psMaskType maskVal,                 ///< Value to mask
     112    psImageMaskType maskVal,                 ///< Value to mask
    113113    int num,                            ///< Number of instances to measure over the image
    114114    float width,                        ///< Photometry width
     
    123123/// that patch corresponds.
    124124bool pmReadoutWeightRenorm(const pmReadout *readout, // Readout to normalise
    125                            psMaskType maskVal, // Value to mask
     125                           psImageMaskType maskVal, // Value to mask
    126126                           psStatsOptions meanStat, // Statistic to measure the mean (of the variance map)
    127127                           psStatsOptions stdevStat, // Statistic to measure the stdev (of the image)
     
    136136/// the provided value.
    137137bool pmReadoutMaskNonfinite(pmReadout *readout, ///< Readout to mask
    138                             psMaskType maskVal ///< Mask value to give non-finite pixels
     138                            psImageMaskType maskVal ///< Mask value to give non-finite pixels
    139139    );
    140140
     
    145145/// sets masked areas to NAN in the image and weight.
    146146bool pmReadoutMaskApply(pmReadout *readout, ///< Readout to mask
    147                         psMaskType maskVal ///< Mask value for which to apply mask
     147                        psImageMaskType maskVal ///< Mask value for which to apply mask
    148148    );
    149149
     
    152152/// Scan the mask image for bad pixels, and interpolate over them using the nominated options
    153153bool pmReadoutInterpolateBadPixels(pmReadout *readout, ///< Readout to work on
    154                                    psMaskType maskVal, ///< Value to mask
     154                                   psImageMaskType maskVal, ///< Value to mask
    155155                                   psImageInterpolateMode mode, ///< Interpolation mode
    156156                                   float poorFrac, ///< Maximum bad fraction of kernel for "poor" status
    157                                    psMaskType maskPoor, ///< Mask value to give poor pixels
    158                                    psMaskType maskBad ///< Mask value to give bad pixels
     157                                   psImageMaskType maskPoor, ///< Mask value to give poor pixels
     158                                   psImageMaskType maskBad ///< Mask value to give bad pixels
    159159    );
    160160
  • trunk/psModules/src/camera/pmFPAMosaic.c

    r19073 r21183  
    471471        numImages++;
    472472
    473         // Only implemented for F32 and U8 images so far.
    474         assert(image->type.type == PS_TYPE_F32 || image->type.type == PS_TYPE_U8);
    475473        // All input types must be the same
    476474        if (type == 0) {
     
    537535        if (xBinSource->data.S32[i] == xBinTarget && yBinSource->data.S32[i] == yBinTarget) {
    538536            switch (type) {
     537                COPY_WITH_PARITY_DIFFERENCE(U8);
     538                COPY_WITH_PARITY_DIFFERENCE(U16);
     539                COPY_WITH_PARITY_DIFFERENCE(U32);
     540                COPY_WITH_PARITY_DIFFERENCE(U64);
     541                COPY_WITH_PARITY_DIFFERENCE(S8);
     542                COPY_WITH_PARITY_DIFFERENCE(S16);
     543                COPY_WITH_PARITY_DIFFERENCE(S32);
     544                COPY_WITH_PARITY_DIFFERENCE(S64);
    539545                COPY_WITH_PARITY_DIFFERENCE(F32);
    540                 COPY_WITH_PARITY_DIFFERENCE(U8);
     546                COPY_WITH_PARITY_DIFFERENCE(F64);
    541547              default:
    542548                psAbort("Should never get here.\n");
     
    548554        // We have to do all of the hard work ourselves
    549555        switch (type) {
    550             FILL_IN(F32);
    551             FILL_IN(U8);
     556            FILL_IN(U8);
     557            FILL_IN(U16);
     558            FILL_IN(U32);
     559            FILL_IN(U64);
     560            FILL_IN(S8);
     561            FILL_IN(S16);
     562            FILL_IN(S32);
     563            FILL_IN(S64);
     564            FILL_IN(F32);
     565            FILL_IN(F64);
    552566          default:
    553567            psAbort("Should never get here.\n");
     
    730744                       const pmChip *chip, // Chip to mosaic
    731745                       const pmCell *targetCell, // Cell to which to mosaic
    732                        psMaskType blank // Mask value to give blank pixels
     746                       psImageMaskType blank // Mask value to give blank pixels
    733747                      )
    734748{
     
    838852                      const pmChip *targetChip, // Chip to which to mosaic
    839853                      const pmCell *targetCell, // Cell to which to mosaic
    840                       psMaskType blank  // Mask value to give blank pixels
     854                      psImageMaskType blank  // Mask value to give blank pixels
    841855                     )
    842856{
     
    9941008// the mosaic image.
    9951009
    996 bool pmChipMosaic(pmChip *target, const pmChip *source, bool deepCopy, psMaskType blank)
     1010bool pmChipMosaic(pmChip *target, const pmChip *source, bool deepCopy, psImageMaskType blank)
    9971011{
    9981012    // Target exists, and has only a single cell
     
    12251239
    12261240
    1227 bool pmFPAMosaic(pmFPA *target, const pmFPA *source, bool deepCopy, psMaskType blank)
     1241bool pmFPAMosaic(pmFPA *target, const pmFPA *source, bool deepCopy, psImageMaskType blank)
    12281242{
    12291243    // Target exists, and has only a single chip with single cell
  • trunk/psModules/src/camera/pmFPAMosaic.h

    r13898 r21183  
    44 * @author Paul Price, IfA
    55 *
    6  * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-06-20 02:22:26 $
     6 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2009-01-27 06:39:38 $
    88 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    99 */
     
    2424                  const pmChip *source, ///< Source chip whose cells will be mosaicked
    2525                  bool deepCopy,        ///< Require a deep copy (disregard 'nice' chip)
    26                   psMaskType blank      ///< Mask value to give blank pixels
     26                  psImageMaskType blank      ///< Mask value to give blank pixels
    2727    );
    2828
     
    3636                 const pmFPA *source,   ///< FPA whose chips and cells will be mosaicked
    3737                 bool deepCopy,         ///< Require a deep copy (disregard 'nice' chip)
    38                  psMaskType blank       ///< Mask value to give blank pixels
     38                 psImageMaskType blank       ///< Mask value to give blank pixels
    3939                );
    4040/// @}
  • trunk/psModules/src/camera/pmFPARead.c

    r19246 r21183  
    3535static psElemType pixelTypes[] = {
    3636    PS_TYPE_F32,
    37     PS_TYPE_MASK,
     37    PS_TYPE_IMAGE_MASK,
    3838    PS_TYPE_F32,
    3939    0
  • trunk/psModules/src/camera/pmFPA_JPEG.c

    r19653 r21183  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2008-09-23 02:00:36 $
     7 *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2009-01-27 06:39:38 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    157157    psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN);
    158158    stats->nSubsample = 10000;
    159     psMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask
     159    psImageMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask
    160160    float mean = 0, delta = 0;          //
    161161    if (!psImageBackground(stats, NULL, readout->image, readout->mask, maskVal, rng)) {
  • trunk/psModules/src/camera/pmHDU.c

    r19385 r21183  
    167167                     const psArray *images, // Images to write
    168168                     const psArray *masks, // Masks to use when writing
    169                      psMaskType maskVal,// Value to mask
     169                     psImageMaskType maskVal,// Value to mask
    170170                     psFits *fits       // FITS file to which to write
    171171                    )
     
    222222    PS_ASSERT_PTR_NON_NULL(fits, false);
    223223
    224     psMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask
     224    psImageMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask
    225225    return hduWrite(hdu, hdu->images, hdu->masks, maskVal, fits);
    226226}
     
    240240    PS_ASSERT_PTR_NON_NULL(fits, false);
    241241
    242     psMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask
     242    psImageMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask
    243243    return hduWrite(hdu, hdu->weights, hdu->masks, maskVal, fits);
    244244}
  • trunk/psModules/src/camera/pmReadoutStack.c

    r18830 r21183  
    7878
    7979// XXX for the moment, use col0, row0, numCols, numRows supplied from the outside
    80 bool pmReadoutStackDefineOutput(pmReadout *readout, int col0, int row0, int numCols, int numRows, bool mask, bool weight, psMaskType blank)
     80bool pmReadoutStackDefineOutput(pmReadout *readout, int col0, int row0, int numCols, int numRows, bool mask, bool weight, psImageMaskType blank)
    8181{
    8282    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    9494        // XXX is this an error?
    9595        if (readout->mask) return false;
    96         readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
     96        readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
    9797        psImageInit(readout->mask, blank);
    9898    }
     
    163163bool pmReadoutUpdateSize(pmReadout *readout, int minCols, int minRows,
    164164                         int numCols, int numRows, bool mask, bool weight,
    165                          psMaskType blank)
     165                         psImageMaskType blank)
    166166{
    167167    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    191191    if (mask) {
    192192        if (!readout->mask) {
    193             readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
     193            readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
    194194            psImageInit(readout->mask, blank);
    195195        }
    196196        if (readout->mask->numCols < numCols || readout->mask->numRows < numRows) {
    197             psImage *newMask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
     197            psImage *newMask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
    198198            psImageInit(newMask, blank);
    199199            psImageOverlaySection(newMask, readout->mask, readout->col0, readout->row0, "=");
  • trunk/psModules/src/camera/pmReadoutStack.h

    r18830 r21183  
    1414                         bool mask,     ///< Worry about the mask?
    1515                         bool weight,   ///< Worry about the weight?
    16                          psMaskType blank ///< Mask value to give to blank pixels
     16                         psImageMaskType blank ///< Mask value to give to blank pixels
    1717    );
    1818
     
    4747
    4848// XXX for the moment, use col0, row0, numCols, numRows supplied from the outside
    49 bool pmReadoutStackDefineOutput(pmReadout *readout, int col0, int row0, int numCols, int numRows, bool mask, bool weight, psMaskType blank);
     49bool pmReadoutStackDefineOutput(pmReadout *readout, int col0, int row0, int numCols, int numRows, bool mask, bool weight, psImageMaskType blank);
    5050
    5151bool pmReadoutStackSetOutputSize(int *col0, int *row0, int *numCols, int *numRows, const psArray *inputs);
  • trunk/psModules/src/concepts/pmConceptsStandard.c

    r20598 r21183  
    1616#include "pmConceptsWrite.h"
    1717#include "pmConceptsStandard.h"
     18
     19// XXX why are these functions not supporting all types (S64, U64 often missing)?
    1820
    1921// The functions in this file are intended to be called solely within the psModules concepts code.  For this
     
    591593        TYPE_CASE(binning, concept, U16);
    592594        TYPE_CASE(binning, concept, U32);
     595        // TYPE_CASE(binning, concept, U64);
    593596        TYPE_CASE(binning, concept, S8);
    594597        TYPE_CASE(binning, concept, S16);
    595598        TYPE_CASE(binning, concept, S32);
     599        // TYPE_CASE(binning, concept, S64);
    596600      default:
    597601        psError(PS_ERR_UNKNOWN, true, "Note sure how to parse %s of type %x --- assuming 1.\n", pattern->name,
  • trunk/psModules/src/config/pmConfigMask.c

    r19870 r21183  
    99#include "pmConfigMask.h"
    1010
    11 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
    12 // Private functions
    13 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
    14 
    15 // maskSetValues examine named mask values and set the bits for maskValue and markValue.
    16 // Ensures that the below-named bad mask values are set, and calculates the mask value to catch them all
    17 // Ensure that the below-named other mask values are set (to 0x00 if necessary)
    18 
    19 // List of mask names for "bad" (i.e., mask me please) pixels
    20 static const char *badMaskNames[] = { "DETECTOR", // Something is wrong with the detector
    21                                       "DARK", // Pixel doesn't dark-subtract properly
    22                                       "FLAT", // Pixel doesn't flat-field properly
    23                                       "BLANK", // Pixel doesn't contain valid data
    24                                       "RANGE",// Pixel is out-of-range of linearity
    25                                       "SAT",  // Pixel is saturated
    26                                       // "LOW",  // Pixel is low
    27                                       // "CONV", // Pixel is bad after convolution with a bad pixel
    28                                       "BAD", // Pixel is low
    29                                       "BAD.WARP", // Pixel is bad after convolution with a bad pixel
    30                                       "CR",   // Pixel contains a cosmic ray
    31                                       "GHOST",// Pixel contains an optical ghost
    32                                       NULL // End marker
     11static pmConfigMaskInfo masks[] = {
     12    { "DETECTOR",  NULL,       0x00, true  },   // Something is wrong with the detector
     13    { "DARK",      "DETECTOR", 0x00, true  },   // Pixel doesn't dark-subtract properly
     14    { "FLAT",      "DETECTOR", 0x01, true  },   // Pixel doesn't flat-field properly
     15    { "BLANK",     "DETECTOR", 0x01, true  },   // Pixel doesn't contain valid data
     16    { "RANGE",     NULL,       0x00, true  },   // Pixel is out-of-range of linearity
     17    { "SAT",       "RANGE",    0x01, true  },   // Pixel is saturated
     18    { "BAD",       "RANGE",    0x01, true  },   // Pixel is low
     19    { "BAD.WARP",  NULL,       0x01, true  },   // Pixel is bad after convolution with a bad pixel
     20    { "CR",        NULL,       0x00, true  },   // Pixel contains a cosmic ray
     21    { "GHOST",     NULL,       0x00, true  },   // Pixel contains an optical ghost
     22    { "POOR.WARP", NULL,       0x00, false },   // Pixel is poor after convolution with a bad pixel
     23    // "LOW"  Pixel is low
     24    // "CONV" Pixel is bad after convolution with a bad pixel
    3325};
    34 // Fallback names in case a bad mask name is not defined
    35 static const char *fallbackMaskNames[] = { NULL, // DETECTOR
    36                                            "DETECTOR", // DARK
    37                                            "DETECTOR", // FLAT
    38                                            "DETECTOR", // BLANK
    39                                            NULL, // RANGE
    40                                            "RANGE", // SAT
    41                                            "RANGE", // LOW
    42                                            NULL, // CONV
    43                                            NULL, // CR
    44                                            NULL, // GHOST
    45 };
    46 // Default values in case a bad mask name and its fallback is not defined
    47 static const psMaskType defaultMask[] = { 0x00, // DETECTOR
    48                                           0x00, // DARK
    49                                           0x01, // FLAT
    50                                           0x01, // BLANK
    51                                           0x00, // RANGE
    52                                           0x01, // SAT
    53                                           0x01, // LOW
    54                                           0x01, // CONV
    55                                           0x00, // CR
    56                                           0x00  // GHOST
    57 };
    58 // Other mask names to ensure exist; these shouldn't be combined in the MASK.VALUE
    59 static const char *otherMaskNames[] = { // "POOR", // Pixel is poor after convolution with a bad pixel
    60                                         "POOR.WARP", // Pixel is poor after convolution with a bad pixel
    61                                         NULL // End marker
    62 };
    63 
    64 static bool maskSetValues(psMaskType *outMaskValue, // Value of MASK.VALUE, returned
    65                           psMaskType *outMarkValue, // Value of MARK.VALUE, returned
    66                           psMetadata *source  // Source of mask bits
    67                           )
     26
     27// The functions in this file do not force the recipe or header values to be stored as the same
     28// type as psImageMaskType : they only check that the given values will fit in the space
     29// provided by psImageMaskType.  This should allow some backwards compatibility (old 8-bit
     30// masks will work with a 16-bit system), but will catch unhandled conflicts (trying to fit 16
     31// bits in 8-bits of space).
     32
     33// XXX this file does not have psError vs psWarning worked out correctly.  some of the
     34// failure modes should result in errors, not just warnings.
     35
     36// pmConfigMaskSetInMetadata examines named mask values and set the bits for maskValue and
     37// markValue.  Ensures that the below-named mask values are set, and calculates the mask value
     38// to catch all of the mask values marked as 'bad'.  Supplies the fallback name if the primary
     39// name is not found, or the default values if the fallback name is not found.
     40
     41bool pmConfigMaskSetInMetadata(psImageMaskType *outMaskValue, // Value of MASK.VALUE, returned
     42                               psImageMaskType *outMarkValue, // Value of MARK.VALUE, returned
     43                               psMetadata *source  // Source of mask bits
     44    )
    6845{
    6946    PS_ASSERT_METADATA_NON_NULL(source, false);
    70 
     47   
    7148    // Ensure all the bad mask names exist, and set the value to catch all bad pixels
    72     psMaskType maskValue = 0;           // Value to mask to catch all the bad pixels
    73     for (int i = 0; badMaskNames[i]; i++) {
    74         const char *name = badMaskNames[i]; // Name for mask
    75         const char *fallback = fallbackMaskNames[i]; // Fallback for mask
    76 
     49    psImageMaskType maskValue = 0;           // Value to mask to catch all the bad pixels
     50    psImageMaskType allMasks = 0;            // Value to mask to catch all masked bits (to set MARK)
     51
     52    int nMasks = sizeof (masks) / sizeof (pmConfigMaskInfo);
     53
     54    for (int i = 0; i < nMasks; i++) {
    7755        bool mdok;                      // Status of MD lookup
    78         psMaskType value = psMetadataLookupU8(&mdok, source, name); // Value of mask
     56        psImageMaskType value = psMetadataLookupImageMaskFromGeneric(&mdok, source, masks[i].badMaskName); // Value of mask
     57        if (!mdok) {
     58            psWarning ("problem with mask value %s\n", masks[i].badMaskName);
     59        }
     60
    7961        if (!value) {
    80             if (fallback) {
    81                 value = psMetadataLookupU8(&mdok, source, fallback);
    82             }
    83             if (!value) {
    84                 value = defaultMask[i];
    85             }
    86             psMetadataAddU8(source, PS_LIST_TAIL, name, PS_META_REPLACE, NULL, value);
    87         }
    88         maskValue |= value;
    89     }
    90 
    91     // Ensure all the other mask names exist
    92     for (int i = 0; otherMaskNames[i]; i++) {
    93         const char *name = otherMaskNames[i]; // Name for mask
    94         bool mdok;                      // Status of MD lookup
    95         psMaskType value = psMetadataLookupU8(&mdok, source, name); // Value of mask
    96         if (!value) {
    97             psMetadataAddU8(source, PS_LIST_TAIL, name, PS_META_REPLACE, NULL, 0x00);
    98         }
     62            if (masks[i].fallbackName) {
     63                value = psMetadataLookupImageMaskFromGeneric(&mdok, source, masks[i].fallbackName);
     64            }
     65            if (!value) {
     66                value = masks[i].defaultMaskValue;
     67            }
     68            psMetadataAddImageMask(source, PS_LIST_TAIL, masks[i].badMaskName, PS_META_REPLACE, NULL, value);
     69        }
     70        if (masks[i].isBad) {
     71            maskValue |= value;
     72        }
     73        allMasks |= value;
    9974    }
    10075
    10176    // search for an unset bit to use for MARK:
    102     psMaskType markValue = 0x80;
    103 
    104     int nBits = sizeof(psMaskType) * 8;
     77    psImageMaskType markValue = 0x00;
     78    psImageMaskType markTrial = 0x01;
     79
     80    int nBits = sizeof(psImageMaskType) * 8;
    10581    for (int i = 0; !markValue && (i < nBits); i++) {
    106         if (maskValue & markValue) {
    107             markValue >>= 1;
     82        if (allMasks & markTrial) {
     83            markTrial <<= 1;
    10884        } else {
    109             markValue = markValue;
     85            markValue = markTrial;
    11086        }
    11187    }
     
    11692
    11793    // update the list with the results
    118     psMetadataAddU8(source, PS_LIST_TAIL, "MASK.VALUE", PS_META_REPLACE, NULL, maskValue);
    119     psMetadataAddU8(source, PS_LIST_TAIL, "MARK.VALUE", PS_META_REPLACE, NULL, markValue);
     94    psMetadataAddImageMask(source, PS_LIST_TAIL, "MASK.VALUE", PS_META_REPLACE, NULL, maskValue);
     95    psMetadataAddImageMask(source, PS_LIST_TAIL, "MARK.VALUE", PS_META_REPLACE, NULL, markValue);
    12096
    12197    if (outMaskValue) {
     
    130106
    131107// Get a mask value by name(s)
    132 static psMaskType maskGet(psMetadata *source, // Source of masks
    133                           const char *masks // Mask values to get
    134                           )
    135 {
    136     psMaskType mask = 0;                // Mask value, to return
     108psImageMaskType pmConfigMaskGetFromMetadata(psMetadata *source, // Source of masks
     109                                            const char *masks // Mask values to get
     110    )
     111{
     112    psImageMaskType mask = 0;                // Mask value, to return
    137113
    138114    psArray *names = psStringSplitArray(masks, " ,;", false); // Array of symbolic names
     
    140116        const char *name = names->data[i]; // Symbolic name of interest
    141117        bool mdok;                      // Status of MD lookup
    142         psMaskType value = psMetadataLookupU8(&mdok, source, name);
     118        psImageMaskType value = psMetadataLookupImageMaskFromGeneric(&mdok, source, name);
    143119        if (!mdok) {
    144120            // Try and generate the value if we can
    145121            if (strcmp(name, "MASK.VALUE") == 0 || strcmp(name, "MARK.VALUE") == 0) {
    146                 if (!maskSetValues(NULL, NULL, source)) {
     122                if (!pmConfigMaskSetInMetadata(NULL, NULL, source)) {
    147123                    psError(PS_ERR_UNKNOWN, false, "Unable to set mask bits.");
    148124                    return 0;
    149125                }
    150                 value = psMetadataLookupU8(&mdok, source, name);
     126                value = psMetadataLookupImageMaskFromGeneric(&mdok, source, name);
    151127                psAssert(mdok, "Should have generated mask value");
    152128            } else {
     
    163139}
    164140
     141// lookup an image mask value by name from a psMetadata, without requiring the entry to
     142// be of type psImageMaskType, but verifying that it will fit in psImageMaskType
     143psImageMaskType psMetadataLookupImageMaskFromGeneric (bool *status, const psMetadata *md, const char *name) {
     144
     145    *status = true;
     146
     147        // select the mask bit name from the header
     148        psMetadataItem *item = psMetadataLookup (md, name);
     149        if (!item) {
     150            psWarning("Unable to find header keyword %s when parsing mask", name);
     151            *status = false;
     152            return 0;
     153        }
     154
     155        // the value may be any of the U8, U16, U32, U64 types : accept the value regardless of type size
     156        psU64 fullValue = 0;
     157        switch (item->type) {
     158          case PS_DATA_U8:
     159            fullValue = item->data.U8;
     160            break;
     161          case PS_DATA_U16:
     162            fullValue = item->data.U16;
     163            break;
     164          case PS_DATA_U32:
     165            fullValue = item->data.U32;
     166            break;
     167          case PS_DATA_U64:
     168            fullValue = item->data.U64;
     169            break;
     170          case PS_DATA_S8:
     171            fullValue = item->data.S8;
     172            break;
     173          case PS_DATA_S16:
     174            fullValue = item->data.S16;
     175            break;
     176          case PS_DATA_S32:
     177            fullValue = item->data.S32;
     178            break;
     179          case PS_DATA_S64:
     180            fullValue = item->data.S64;
     181            break;
     182          default:
     183            psWarning("Mask entry %s in metadata is not of a mask type", name);
     184            *status = false;
     185            return 0;
     186        }
     187
     188        // will the incoming value fit within the current image mask type?
     189        if (fullValue > PS_MAX_IMAGE_MASK_TYPE) {
     190            psWarning("Mask entry %s in metadata is larger than allowed by the psImageMaskType", name);
     191            *status = false;
     192            return 0;
     193        }
     194        psImageMaskType value = fullValue;
     195        // XXX validate that value is a 2^n value?
     196
     197        return value;
     198}
     199
    165200// Remove from the header keywords starting with the provided string
    166 static int maskRemoveHeader(psMetadata *header, // Header from which to remove keywords
    167                             const char *start // Remove keywords that start with this string
    168                             )
     201int pmConfigMaskRemoveHeaderKeywords(psMetadata *header, // Header from which to remove keywords
     202                                     const char *start // Remove keywords that start with this string
     203    )
    169204{
    170205    psString regex = NULL;              // Regular expression for keywords
     
    182217}
    183218
     219// look up the named mask value(s) from the MASKS recipe in the config system
     220psImageMaskType pmConfigMaskGet(const char *masks, const pmConfig *config)
     221{
     222    psAssert(config, "Require configuration");
     223    PS_ASSERT_STRING_NON_EMPTY(masks, 0);
     224
     225    bool mdok;                          // Status of MD lookup
     226    psMetadata *recipe = psMetadataLookupMetadata(&mdok, config->recipes, "MASKS"); // The recipe
     227    if (!recipe) {
     228        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe.");
     229        return 0;
     230    }
     231   
     232    psImageMaskType mask = pmConfigMaskGetFromMetadata (recipe, masks);
     233    return mask;
     234}
     235
     236bool pmConfigMaskSet(const pmConfig *config, const char *maskName, psImageMaskType maskValue)
     237{
     238    psAssert(config, "Require configuration");
     239    PS_ASSERT_STRING_NON_EMPTY(maskName, false);
     240
     241    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe
     242    if (!recipe) {
     243        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe.");
     244        return false;
     245    }
     246
     247    bool status = psMetadataAddImageMask(recipe, PS_LIST_TAIL, maskName, PS_META_REPLACE, NULL, maskValue);
     248    return status;
     249}
     250
     251
     252// replace the named masks in the recipe with values in the header:
     253// replace only the names in the header in the recipe
     254bool pmConfigMaskReadHeader(pmConfig *config, const psMetadata *header)
     255{
     256    PS_ASSERT_PTR_NON_NULL(config, false);
     257    PS_ASSERT_METADATA_NON_NULL(header, false);
     258
     259    bool status = false;
     260
     261    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe
     262    if (!recipe) {
     263        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe.");
     264        return false;
     265    }
     266
     267    // MASK.VALUE and MARK.VALUE aren't usually set in the recipe, but may be set in the header: create fake
     268    // versions so that it won't complain later
     269    if (!psMetadataLookup(recipe, "MASK.VALUE")) {
     270        psMetadataAddImageMask(recipe, PS_LIST_TAIL, "MASK.VALUE", 0, "Bits to mask", 0);
     271    }
     272    if (!psMetadataLookup(recipe, "MARK.VALUE")) {
     273        psMetadataAddImageMask(recipe, PS_LIST_TAIL, "MARK.VALUE", 0, "Bits for marking", 0);
     274    }
     275
     276    // How many mask values do we need to read?  We raise an error if this is not found,
     277    // unless the MASK.FORCE is set to true in the camera config
     278    int nMask = psMetadataLookupS32(&status, header, "MSKNUM");
     279    if (!status) {
     280        if (psMetadataLookupBool(&status, config->camera, "MASK.FORCE")) {
     281            psWarning("No mask values in header.  Assuming MASKS recipe is accurate because of MASK.FORCE");
     282            return true;
     283        }
     284        psError(PS_ERR_UNKNOWN, true, "Unable to find MSKNUM in header.");
     285        return false;
     286    }
     287
     288    // Loop over the expected number of header mask names.  For each named mask value, there
     289    // should be a pair of header keywords, one for the name and one for the value
     290    char namekey[80];                   // Keyword name for symbolic name of mask entry
     291    char valuekey[80];                  // Keyword name for value of mask entry
     292    for (int i = 0; i < nMask; i++) {
     293        snprintf(namekey,  64, "MSKNAM%02d", i);
     294        snprintf(valuekey, 64, "MSKVAL%02d", i);
     295
     296        char *name = psMetadataLookupStr(&status, header, namekey);
     297        if (!status || !name) {
     298            psWarning("Unable to find header keyword %s when parsing mask", namekey);
     299            continue;
     300        }
     301
     302        psImageMaskType headerValue = psMetadataLookupImageMaskFromGeneric (&status, header, valuekey);
     303        if (!status) {
     304            psWarning("Failed to get mask value %s from header, skipping", valuekey);
     305            continue;
     306        }           
     307
     308        // since we may read multiple mask files, we need to warn (or error?) if any of the
     309        // header mask values conflict with other header mask values; However, the original
     310        // mask values from the recipe do not need to match the header values.
     311
     312        // when we add a header mask value, we will also add the NAME.ALREADY entry; check for
     313        // the NAME.ALREADY entry to see if we have previously added this mask value from a
     314        // header.
     315
     316        psString nameAlready = NULL;    // Name of key with ".ALREADY" added
     317        psStringAppend(&nameAlready, "%s.ALREADY", name);
     318        bool already = psMetadataLookupBool(&status, recipe, nameAlready); // Already read this one?
     319
     320        bool inRecipe = false;
     321        psImageMaskType recipeValue = psMetadataLookupImageMaskFromGeneric (&inRecipe, recipe, name);
     322        if (!inRecipe) {
     323            psWarning("Mask value %s is not defined in the recipe", name);
     324        }           
     325
     326        if (already) {
     327            assert (inRecipe); // XXX makes no sense for NAME.ALREADY to be in without NAME
     328            if (recipeValue != headerValue) {
     329                psWarning("New mask header value does not match previously loaded entry: %x vs %x", headerValue, recipeValue);
     330                psMetadataAddImageMask(recipe, PS_LIST_TAIL, name, PS_META_REPLACE, "Bitmask bit value", headerValue);
     331                // XXX alternatively, error here
     332            }
     333        } else {
     334            psMetadataAddBool(recipe, PS_LIST_TAIL, nameAlready, 0, "Already read this mask value", true);
     335            psMetadataAddImageMask(recipe, PS_LIST_TAIL, name, PS_META_REPLACE, "Bitmask bit value", headerValue);
     336        }
     337
     338        psFree(nameAlready);
     339    }
     340
     341    return true;
     342}
     343
     344// write the named mask bits to the header
     345bool pmConfigMaskWriteHeader(const pmConfig *config, psMetadata *header)
     346{
     347    PS_ASSERT_PTR_NON_NULL(config, false);
     348    PS_ASSERT_METADATA_NON_NULL(header, false);
     349
     350    pmConfigMaskRemoveHeaderKeywords(header, "MSKNAM");
     351    pmConfigMaskRemoveHeaderKeywords(header, "MSKVAL");
     352    if (psMetadataLookup(header, "MSKNUM")) {
     353        psMetadataRemoveKey(header, "MSKNUM");
     354    }
     355
     356    char namekey[80];
     357    char valuekey[80];
     358
     359    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe
     360    if (!recipe) {
     361        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe.");
     362        return false;
     363    }
     364
     365    int nMask = 0;
     366
     367    psMetadataIterator *iter = psMetadataIteratorAlloc(recipe, PS_LIST_HEAD, NULL); // Iterator
     368    psMetadataItem *item;               // Item from iteration
     369    while ((item = psMetadataGetAndIncrement(iter))) {
     370
     371        // XXX this would give a false positive for mask which include '.ALREADY' in their names
     372        char *ptr = strstr (item->name, ".ALREADY");
     373        if (ptr) continue;
     374
     375        psU64 fullValue = 0;
     376        switch (item->type) {
     377          case PS_DATA_U8:
     378            fullValue = item->data.U8;
     379            break;
     380          case PS_DATA_U16:
     381            fullValue = item->data.U16;
     382            break;
     383          case PS_DATA_U32:
     384            fullValue = item->data.U32;
     385            break;
     386          case PS_DATA_U64:
     387            fullValue = item->data.U64;
     388            break;
     389          default:
     390            psWarning("mask recipe entry %s is not a bit value\n", item->name);
     391            continue;
     392        }
     393        assert (fullValue <= PS_MAX_IMAGE_MASK_TYPE); // this should have been asserted on read...
     394
     395        snprintf(namekey,  64, "MSKNAM%02d", nMask);
     396        snprintf(valuekey, 64, "MSKVAL%02d", nMask);
     397
     398        psMetadataAddStr(header, PS_LIST_TAIL, namekey, 0, "Bitmask bit name", item->name);
     399        psMetadataAddImageMask(header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", fullValue);
     400        nMask++;
     401    }
     402    psFree(iter);
     403
     404    psMetadataAddS32(header, PS_LIST_TAIL, "MSKNUM", 0, "Bitmask bit count", nMask);
     405    return true;
     406}
     407
     408
     409bool pmConfigMaskSetBits(psImageMaskType *outMaskValue, psImageMaskType *outMarkValue, const pmConfig *config)
     410{
     411    PS_ASSERT_PTR_NON_NULL(config, false);
     412
     413    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe
     414    if (!recipe) {
     415        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe.");
     416        return false;
     417    }
     418
     419    bool status = pmConfigMaskSetInMetadata(outMaskValue, outMarkValue, recipe);
     420    return status;
     421}
     422
    184423//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    185424// FPA version of mask functions.  These are not ready to go yet.
     
    187426
    188427#if 0
    189 bool pmFPAMaskSetValues(psMaskType *outMaskValue, psMaskType *outMarkValue, pmFPA *fpa)
    190 {
     428
     429bool pmFPAMaskWriteHeader(psMetadata *header, const pmFPA *fpa)
     430{
     431    PS_ASSERT_METADATA_NON_NULL(header, false);
    191432    PS_ASSERT_PTR_NON_NULL(fpa, false);
    192433
     434    // clear out the header of the associated keywords:
     435    pmConfigMaskRemoveHeaderKeywords(header, "MSKNAM");
     436    pmConfigMaskRemoveHeaderKeywords(header, "MSKVAL");
     437    if (psMetadataLookup(header, "MSKNUM")) {
     438        psMetadataRemoveKey(header, "MSKNUM");
     439    }
     440
     441    char namekey[80], valuekey[80];     // Mask name and mask value header keywords
     442    int numMask = 0;                    // Number of mask entries
     443
     444    psMetadataIterator *iter = psMetadataIteratorAlloc(fpa->masks, PS_LIST_HEAD, NULL); // Iterator
     445    psMetadataItem *item;               // Item from iteration
     446    while ((item = psMetadataGetAndIncrement(iter))) {
     447        if (item->type != PS_TYPE_IMAGE_MASK) {
     448            psWarning("mask recipe entry %s is not of a mask type (%x)", item->name, item->type);
     449            continue;
     450        }
     451
     452        snprintf(namekey,  64, "MSKNAM%02d", numMask);
     453        snprintf(valuekey, 64, "MSKVAL%02d", numMask);
     454
     455        psMetadataAddStr(header, PS_LIST_TAIL, namekey, 0, "Bitmask bit name", item->name);
     456        psMetadataAddImageMask(header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.PS_TYPE_IMAGE_MASK_DATA);
     457        numMask++;
     458    }
     459    psFree(iter);
     460
     461    return psMetadataAddS32(header, PS_LIST_TAIL, "MSKNUM", 0, "Number of named mask entries", numMask);
     462}
     463
     464bool pmFPAMaskSetValues(psImageMaskType *outMaskValue, psImageMaskType *outMarkValue, pmFPA *fpa)
     465{
     466    PS_ASSERT_PTR_NON_NULL(fpa, false);
     467
    193468    return maskSetValues(outMaskValue, outMarkValue, fpa->masks);
    194469}
    195470
    196 psMaskType pmFPAMaskGet(const pmFPA *fpa, const char *masks, const pmConfig *config)
     471psImageMaskType pmFPAMaskGet(const pmFPA *fpa, const char *masks, const pmConfig *config)
    197472{
    198473    PS_ASSERT_PTR_NON_NULL(fpa, 0);
     
    201476
    202477    if (fpa->masks) {
    203         return maskGet(fpa->masks, masks);
     478        return pmConfigMaskGetFromMetadata(fpa->masks, masks);
    204479    }
    205480    return pmConfigMaskGet(masks, config);
    206481}
    207482
    208 bool pmFPAMaskSet(pmFPA *fpa, const char *maskName, psMaskType maskValue)
     483bool pmFPAMaskSet(pmFPA *fpa, const char *maskName, psImageMaskType maskValue)
    209484{
    210485    PS_ASSERT_PTR_NON_NULL(fpa, 0);
     
    214489        fpa->masks = psMetadataAlloc();
    215490    }
    216     return psMetadataAddU8(fpa->masks, PS_LIST_TAIL, maskName, PS_META_REPLACE, NULL, maskValue);
     491    return psMetadataAddImageMask(fpa->masks, PS_LIST_TAIL, maskName, PS_META_REPLACE, NULL, maskValue);
    217492}
    218493
     
    250525            continue;
    251526        }
    252         psU8 bit = psMetadataLookupU8(&mdok, header, valuekey);
     527        psImageMaskType bit = psMetadataLookupImageMask(&mdok, header, valuekey);
    253528        if (!mdok) {
    254529            psWarning("Unable to find header keyword %s when parsing mask", namekey);
     
    260535        psMetadataItem *item = psMetadataLookup(fpa->masks, name); // Item in recipe with current value
    261536        if (item) {
    262             psAssert(item->type == PS_TYPE_MASK, "Mask entry %s is not of a mask type (%x)",
     537            psAssert(item->type == PS_TYPE_IMAGE_MASK, "Mask entry %s is not of a mask type (%x)",
    263538                     name, item->type);
    264             if (item->data.PS_TYPE_MASK_DATA != bit) {
     539            if (item->data.PS_TYPE_IMAGE_MASK_DATA != bit) {
    265540                psWarning("New mask entry %s doesn't match previously loaded entry: %x vs %x",
    266                           name, bit, item->data.PS_TYPE_MASK_DATA);
     541                          name, bit, item->data.PS_TYPE_IMAGE_MASK_DATA);
    267542            }
    268543        } else {
    269             psMetadataAddU8(fpa->masks, PS_LIST_TAIL, name, 0, NULL, bit);
     544            psMetadataAddImageMask(fpa->masks, PS_LIST_TAIL, name, 0, NULL, bit);
    270545        }
    271546    }
     
    281556    psMetadataItem *item;               // Item from iteration
    282557    while ((item = psMetadataGetAndIncrement(iter))) {
    283         if (item->type != PS_TYPE_MASK) {
     558        if (item->type != PS_TYPE_IMAGE_MASK) {
    284559            psWarning("Recipe mask entry %s is not of a mask type (%x)", item->name, item->type);
    285560            continue;
    286561        }
    287562        if (!psMetadataLookup(fpa->masks, item->name)) {
    288             psMetadataAddU8(fpa->masks, PS_LIST_TAIL, item->name, 0, item->comment,
    289                             item->data.PS_TYPE_MASK_DATA);
     563            psMetadataAddImageMask(fpa->masks, PS_LIST_TAIL, item->name, 0, item->comment,
     564                            item->data.PS_TYPE_IMAGE_MASK_DATA);
    290565        }
    291566    }
     
    294569    return true;
    295570}
    296 
    297 
    298 bool pmFPAMaskWriteHeader(psMetadata *header, const pmFPA *fpa)
    299 {
    300     PS_ASSERT_METADATA_NON_NULL(header, false);
    301     PS_ASSERT_PTR_NON_NULL(fpa, false);
    302 
    303     maskRemoveHeader(header, "MSKNAM");
    304     maskRemoveHeader(header, "MSKVAL");
    305     if (psMetadataLookup(header, "MSKNUM")) {
    306         psMetadataRemoveKey(header, "MSKNUM");
    307     }
    308 
    309     char namekey[80], valuekey[80];     // Mask name and mask value header keywords
    310     int numMask = 0;                    // Number of mask entries
    311 
    312     psMetadataIterator *iter = psMetadataIteratorAlloc(fpa->masks, PS_LIST_HEAD, NULL); // Iterator
    313     psMetadataItem *item;               // Item from iteration
    314     while ((item = psMetadataGetAndIncrement(iter))) {
    315         if (item->type != PS_TYPE_MASK) {
    316             psWarning("mask recipe entry %s is not of a mask type (%x)", item->name, item->type);
    317             continue;
    318         }
    319 
    320         snprintf(namekey,  64, "MSKNAM%02d", numMask);
    321         snprintf(valuekey, 64, "MSKVAL%02d", numMask);
    322 
    323         psMetadataAddStr(header, PS_LIST_TAIL, namekey, 0, "Bitmask bit name", item->name);
    324         psMetadataAddU8(header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.PS_TYPE_MASK_DATA);
    325         numMask++;
    326     }
    327     psFree(iter);
    328 
    329     return psMetadataAddS32(header, PS_LIST_TAIL, "MSKNUM", 0, "Number of named mask entries", numMask);
    330 }
    331 
    332571#endif
    333 
    334 
    335 psMaskType pmConfigMaskGet(const char *masks, const pmConfig *config)
    336 {
    337     psAssert(config, "Require configuration");
    338     PS_ASSERT_STRING_NON_EMPTY(masks, 0);
    339 
    340     bool mdok;                          // Status of MD lookup
    341     psMetadata *recipe = psMetadataLookupMetadata(&mdok, config->recipes, "MASKS"); // The recipe
    342     if (!recipe) {
    343         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe.");
    344         return 0;
    345     }
    346     return maskGet(recipe, masks);
    347 }
    348 
    349 
    350 bool pmConfigMaskSet(const pmConfig *config, const char *maskName, psMaskType maskValue)
    351 {
    352     psAssert(config, "Require configuration");
    353     PS_ASSERT_STRING_NON_EMPTY(maskName, false);
    354 
    355     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe
    356     if (!recipe) {
    357         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe.");
    358         return false;
    359     }
    360 
    361     return psMetadataAddU8(recipe, PS_LIST_TAIL, maskName, PS_META_REPLACE, NULL, maskValue);
    362 }
    363 
    364 
    365 // replace the named masks in the recipe with values in the header:
    366 // replace only the names in the header in the recipe
    367 bool pmConfigMaskReadHeader(pmConfig *config, const psMetadata *header)
    368 {
    369     PS_ASSERT_PTR_NON_NULL(config, false);
    370     PS_ASSERT_METADATA_NON_NULL(header, false);
    371 
    372     bool status = false;
    373 
    374     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe
    375     if (!recipe) {
    376         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe.");
    377         return false;
    378     }
    379 
    380     // MASK.VALUE and MARK.VALUE aren't usually set in the recipe, but may be set in the header: create fake
    381     // versions so that it won't complain later
    382     if (!psMetadataLookup(recipe, "MASK.VALUE")) {
    383         psMetadataAddU8(recipe, PS_LIST_TAIL, "MASK.VALUE", 0, "Bits to mask", 0);
    384     }
    385     if (!psMetadataLookup(recipe, "MARK.VALUE")) {
    386         psMetadataAddU8(recipe, PS_LIST_TAIL, "MARK.VALUE", 0, "Bits for marking", 0);
    387     }
    388 
    389     int nMask = psMetadataLookupS32(&status, header, "MSKNUM");
    390     if (!status) {
    391         if (psMetadataLookupBool(&status, config->camera, "MASK.FORCE")) {
    392             psWarning("No mask values in header.  Assuming MASKS recipe is accurate because of MASK.FORCE");
    393             return true;
    394         }
    395         psError(PS_ERR_UNKNOWN, true, "Unable to find MSKNUM in header.");
    396         return false;
    397     }
    398 
    399     char namekey[80];                   // Keyword name for symbolic name of mask entry
    400     char valuekey[80];                  // Keyword name for value of mask entry
    401     for (int i = 0; i < nMask; i++) {
    402         snprintf(namekey,  64, "MSKNAM%02d", i);
    403         snprintf(valuekey, 64, "MSKVAL%02d", i);
    404 
    405         char *name = psMetadataLookupStr(&status, header, namekey);
    406         if (!status || !name) {
    407             psWarning("Unable to find header keyword %s when parsing mask", namekey);
    408             continue;
    409         }
    410         psU8 bit = psMetadataLookupU8(&status, header, valuekey);
    411         if (!status) {
    412             psWarning("Unable to find header keyword %s when parsing mask", namekey);
    413             continue;
    414         }
    415 
    416         // XXX validate that bit is a 2^n value?
    417 
    418         psString nameAlready = NULL;    // Name of key with ".ALREADY" added
    419         psStringAppend(&nameAlready, "%s.ALREADY", name);
    420         bool already = psMetadataLookupBool(&status, recipe, nameAlready); // Already read this one?
    421 
    422         psMetadataItem *item = psMetadataLookup(recipe, name); // Item in recipe with current value
    423         if (item && item->type != PS_TYPE_MASK) {
    424             psWarning("Mask recipe entry is not of a mask type (%x)", item->type);
    425             item->type = PS_TYPE_MASK;
    426         }
    427 
    428         if (already) {
    429             if (item && item->data.U8 != bit) {
    430                 psWarning("New mask recipe entry doesn't match previously loaded entry: %x vs %x",
    431                           bit, item->data.U8);
    432             }
    433         } else {
    434             psMetadataAddBool(recipe, PS_LIST_TAIL, nameAlready, 0, "Already read this mask value", true);
    435         }
    436 
    437         if (!item) {
    438             psWarning("Mask recipe entry %s not in recipe\n", name);
    439             psMetadataAddU8(recipe, PS_LIST_TAIL, name, 0, "Bitmask bit value", bit);
    440         } else {
    441             item->data.U8 = bit;
    442         }
    443 
    444         psFree(nameAlready);
    445     }
    446 
    447 
    448     return true;
    449 }
    450 
    451 
    452 
    453 // write the named mask bits to the header
    454 bool pmConfigMaskWriteHeader(const pmConfig *config, psMetadata *header)
    455 {
    456     PS_ASSERT_PTR_NON_NULL(config, false);
    457     PS_ASSERT_METADATA_NON_NULL(header, false);
    458 
    459     maskRemoveHeader(header, "MSKNAM");
    460     maskRemoveHeader(header, "MSKVAL");
    461     if (psMetadataLookup(header, "MSKNUM")) {
    462         psMetadataRemoveKey(header, "MSKNUM");
    463     }
    464 
    465     char namekey[80];
    466     char valuekey[80];
    467 
    468     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe
    469     if (!recipe) {
    470         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe.");
    471         return false;
    472     }
    473 
    474     int nMask = 0;
    475 
    476     psMetadataIterator *iter = psMetadataIteratorAlloc(recipe, PS_LIST_HEAD, NULL); // Iterator
    477     psMetadataItem *item;               // Item from iteration
    478     while ((item = psMetadataGetAndIncrement(iter))) {
    479         if (strcmp(item->name + strlen(item->name) - strlen(".ALREADY"), ".ALREADY") == 0) {
    480             continue;
    481         }
    482 
    483         if (item->type != PS_DATA_U8) {
    484             psWarning("mask recipe entry %s is not a bit value\n", item->name);
    485             continue;
    486         }
    487 
    488         snprintf(namekey,  64, "MSKNAM%02d", nMask);
    489         snprintf(valuekey, 64, "MSKVAL%02d", nMask);
    490 
    491         psMetadataAddStr(header, PS_LIST_TAIL, namekey, 0, "Bitmask bit name", item->name);
    492         psMetadataAddU8(header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.U8);
    493         nMask++;
    494     }
    495     psFree(iter);
    496 
    497     psMetadataAddS32(header, PS_LIST_TAIL, "MSKNUM", 0, "Bitmask bit count", nMask);
    498     return true;
    499 }
    500 
    501 
    502 bool pmConfigMaskSetBits(psMaskType *outMaskValue, psMaskType *outMarkValue, const pmConfig *config)
    503 {
    504     PS_ASSERT_PTR_NON_NULL(config, false);
    505 
    506     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe
    507     if (!recipe) {
    508         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe.");
    509         return false;
    510     }
    511 
    512     return maskSetValues(outMaskValue, outMarkValue, recipe);
    513 }
  • trunk/psModules/src/config/pmConfigMask.h

    r18598 r21183  
    44 *  @author Paul Price, IfA
    55 *
    6  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    7  *  @date $Date: 2008-07-17 20:37:20 $
     6 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2009-01-27 06:39:38 $
    88 *  Copyright 2007 Institute for Astronomy, University of Hawaii
    99 */
     
    2020/// @{
    2121
     22// structure to hold the properties of a mask value
     23typedef struct {
     24    char *badMaskName;                  // name for "bad" (i.e., mask me please) pixels
     25    char *fallbackName;                 // Fallback name in case a bad mask name is not defined
     26    psImageMaskType defaultMaskValue;   // Default value in case a bad mask name and its fallback are not defined
     27    bool isBad; // include this value as part of the MASK.VALUE entry (generically bad)
     28} pmConfigMaskInfo;
     29
     30// pmConfigMaskSetInMetadata examines named mask values and set the bits for maskValue and
     31// markValue.  Ensures that the below-named mask values are set, and calculates the mask value
     32// to catch all of the mask values marked as 'bad'.  Supplies the fallback name if the primary
     33// name is not found, or the default values if the fallback name is not found.
     34bool pmConfigMaskSetInMetadata(psImageMaskType *outMaskValue, // Value of MASK.VALUE, returned
     35                               psImageMaskType *outMarkValue, // Value of MARK.VALUE, returned
     36                               psMetadata *source  // Source of mask bits
     37  );
     38
     39
     40// Get a mask value by name(s)
     41psImageMaskType pmConfigMaskGetFromMetadata(psMetadata *source, // Source of masks
     42                                            const char *masks // Mask values to get
     43  );
     44
     45
     46// lookup an image mask value by name from a psMetadata, without requiring the entry to
     47// be of type psImageMaskType, but verifying that it will fit in psImageMaskType
     48psImageMaskType psMetadataLookupImageMaskFromGeneric (bool *status, const psMetadata *md, const char *name);
     49
     50// Remove from the header keywords starting with the provided string
     51int pmConfigMaskRemoveHeaderKeywords(psMetadata *header, // Header from which to remove keywords
     52                                     const char *start // Remove keywords that start with this string
     53  );
     54
    2255/// Return a mask value given a list of symbolic names
    2356///
    2457/// The mask values are derived from the MASKS recipe
    25 psMaskType pmConfigMaskGet(const char *masks, ///< List of symbolic names, space/comma delimited
     58psImageMaskType pmConfigMaskGet(const char *masks, ///< List of symbolic names, space/comma delimited
    2659                           const pmConfig *config ///< Configuration
    2760    );
    2861
    29 bool pmConfigMaskSet(const pmConfig *config, const char *maskName, psMaskType maskValue);
     62bool pmConfigMaskSet(const pmConfig *config, const char *maskName, psImageMaskType maskValue);
    3063
    3164// replace the named masks in the recipe with values in the header:
     
    3669bool pmConfigMaskWriteHeader(const pmConfig *config, psMetadata *header);
    3770
    38 bool pmConfigMaskSetBits(psMaskType *outMaskValue, psMaskType *outMarkValue, const pmConfig *config);
     71bool pmConfigMaskSetBits(psImageMaskType *outMaskValue, psImageMaskType *outMarkValue, const pmConfig *config);
    3972
    4073#endif
  • trunk/psModules/src/detrend/pmBias.c

    r19432 r21183  
    4545                inImage->data.F32[i][j] -= subImage->data.F32[i+yOffset][j+xOffset];
    4646                if (inMask && subMask) {
    47                     inMask->data.U8[i][j] |= subMask->data.U8[i+yOffset][j+xOffset];
     47                    inMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] |= subMask->data.PS_TYPE_IMAGE_MASK_DATA[i+yOffset][j+xOffset];
    4848                }
    4949            }
     
    5454                inImage->data.F32[i][j] -= subImage->data.F32[i+yOffset][j+xOffset] * scale;
    5555                if (inMask && subMask) {
    56                     inMask->data.U8[i][j] |= subMask->data.U8[i+yOffset][j+xOffset];
     56                    inMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j] |= subMask->data.PS_TYPE_IMAGE_MASK_DATA[i+yOffset][j+xOffset];
    5757                }
    5858            }
  • trunk/psModules/src/detrend/pmDark.c

    r19432 r21183  
    103103{
    104104    psArray *values = psArrayAlloc(inputs->n);
    105     psVector *roMask = psVectorAlloc(inputs->n, PS_TYPE_U8); // Mask for bad readouts
     105    psVector *roMask = psVectorAlloc(inputs->n, PS_TYPE_VECTOR_MASK); // Mask for bad readouts
    106106    psVector *norm = normConcept ? psVectorAlloc(inputs->n, PS_TYPE_F32) : NULL; // Normalizations for each
    107107    psVector *orders = psVectorAlloc(ordinates->n, PS_TYPE_U8); // Orders for each concept
     
    121121        if (!ordinateLookup(&normValue, &inRange, normConcept, false, NAN, NAN, readout)) {
    122122            psWarning("Unable to find value of %s for readout %d", normConcept, i);
    123             roMask->data.U8[i] = 0xff;
     123            roMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff;
    124124            norm->data.F32[i] = NAN;
    125125            numBadInputs++;
     
    128128        if (normValue == 0.0) {
    129129            psWarning("Normalisation value (%s) for readout %d is zero", normConcept, i);
    130             roMask->data.U8[i] = 0xff;
     130            roMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff;
    131131            norm->data.F32[i] = NAN;
    132132            numBadInputs++;
     
    151151        for (int j = 0; j < inputs->n; j++) {
    152152            psVector *val = values->data[j]; // Value vector for readout
    153             if (roMask->data.U8[j]) {
     153            if (roMask->data.PS_TYPE_VECTOR_MASK_DATA[j]) {
    154154                val->data.F32[i] = NAN;
    155155                continue;
     
    159159            float value = NAN;          // Value of ordinate
    160160            if (!ordinateLookup(&value, &inRange, ord->name, ord->scale, ord->min, ord->max, readout)) {
    161                 roMask->data.U8[j] = 0xff;
     161                roMask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xff;
    162162                val->data.F32[i] = NAN;
    163163                numBadInputs++;
     
    165165            }
    166166            if (!inRange) {
    167                 roMask->data.U8[j] = 0xff;
     167                roMask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xff;
    168168                val->data.F32[i] = NAN;
    169169                numBadInputs++;
     
    263263
    264264// do the combine work for this portion of the output (range is set by input data)
    265 bool pmDarkCombine(pmCell *output, const psArray *inputs, int iter, float rej, psMaskType maskVal)
     265bool pmDarkCombine(pmCell *output, const psArray *inputs, int iter, float rej, psImageMaskType maskVal)
    266266{
    267267    PS_ASSERT_PTR_NON_NULL(output, false);
     
    314314    // Iterate over pixels, fitting polynomial
    315315    psVector *pixels = psVectorAlloc(inputs->n, PS_TYPE_F32); // Stack of pixels
    316     psVector *mask   = psVectorAlloc(inputs->n, PS_TYPE_MASK); // Mask for stack
     316    psVector *mask   = psVectorAlloc(inputs->n, PS_TYPE_VECTOR_MASK); // Mask for stack
    317317    for (int i = minInputRows; i < maxInputRows; i++) {
    318318        int yOut = i - outReadout->row0; // y position on output readout
     
    330330            psVectorInit(mask, 0);
    331331            for (int r = 0; r < inputs->n; r++) {
    332                 if (roMask->data.U8[r]) {
    333                     mask->data.PS_TYPE_MASK_DATA[r] = 0xff;
     332                if (roMask->data.PS_TYPE_VECTOR_MASK_DATA[r]) {
     333                    mask->data.PS_TYPE_VECTOR_MASK_DATA[r] = 0xff;
    334334                    continue;
    335335                }
     
    343343                }
    344344                if (readout->mask) {
    345                     mask->data.PS_TYPE_MASK_DATA[r] = readout->mask->data.PS_TYPE_MASK_DATA[yIn][xIn];
     345                    mask->data.PS_TYPE_VECTOR_MASK_DATA[r] = (readout->mask->data.PS_TYPE_IMAGE_MASK_DATA[yIn][xIn] & maskVal);
    346346                }
    347347
    348348            }
    349349
    350             if (!psPolynomialMDClipFit(poly, pixels, NULL, mask, maskVal, values, iter, rej)) {
     350            if (!psPolynomialMDClipFit(poly, pixels, NULL, mask, 0xff, values, iter, rej)) {
    351351                psErrorClear();         // Nothing we can do about it
    352352                psVectorInit(poly->coeff, NAN);
     
    376376    const psVector *values = job->args->data[3]; // Values for each ordinate
    377377
    378     psMaskType bad = PS_SCALAR_VALUE(job->args->data[4], U8); // Mask value to give bad pixels
     378    psImageMaskType bad = PS_SCALAR_VALUE(job->args->data[4], PS_TYPE_IMAGE_MASK_DATA); // Mask value to give bad pixels
    379379    bool doNorm    = PS_SCALAR_VALUE(job->args->data[5], U8); // Normalise values?
    380380    float norm     = PS_SCALAR_VALUE(job->args->data[6], F32); // Value by which to normalise
     
    386386
    387387bool pmDarkApplyScan(pmReadout *readout, const pmCell *dark, const psVector *orders, const psVector *values,
    388                      psMaskType bad, bool doNorm, float norm, int rowStart, int rowStop)
     388                     psImageMaskType bad, bool doNorm, float norm, int rowStart, int rowStop)
    389389{
    390390    int numCols = readout->image->numCols;
     
    405405            readout->image->data.F32[y][x] -= value;
    406406            if (readout->mask && !isfinite(value)) {
    407                 readout->mask->data.PS_TYPE_MASK_DATA[y][x] = bad;
     407                readout->mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = bad;
    408408            }
    409409        }
     
    414414}
    415415
    416 bool pmDarkApply(pmReadout *readout, pmCell *dark, psMaskType bad)
     416bool pmDarkApply(pmReadout *readout, pmCell *dark, psImageMaskType bad)
    417417{
    418418    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    424424        PS_ASSERT_IMAGE_NON_NULL(readout->mask, false);
    425425        PS_ASSERT_IMAGES_SIZE_EQUAL(readout->mask, readout->image, false);
    426         PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_MASK, false);
     426        PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_IMAGE_MASK, false);
    427427    }
    428428    int numTerms = dark->readouts->n;   // Number of polynomial terms
     
    496496            psArrayAdd(job->args, 1, orders);
    497497            psArrayAdd(job->args, 1, values);
    498             PS_ARRAY_ADD_SCALAR(job->args, bad, PS_TYPE_MASK);
     498            PS_ARRAY_ADD_SCALAR(job->args, bad, PS_TYPE_IMAGE_MASK);
    499499            PS_ARRAY_ADD_SCALAR(job->args, doNorm, PS_TYPE_U8);
    500500            PS_ARRAY_ADD_SCALAR(job->args, norm, PS_TYPE_F32);
  • trunk/psModules/src/detrend/pmDark.h

    r19432 r21183  
    3737                   int iter,            // Number of rejection iterations
    3838                   float rej,           // Rejection threshold (standard deviations)
    39                    psMaskType maskVal   // Value to mask
     39                   psImageMaskType maskVal   // Value to mask
    4040    );
    4141
     
    4949                     const psVector *orders, // Polynomial orders for each ordinate
    5050                     const psVector *values, // Values for each ordinate
    51                      psMaskType bad,    // Value to give bad pixels
     51                     psImageMaskType bad,    // Value to give bad pixels
    5252                     bool doNorm,       // Normalise values?
    5353                     float norm,        // Value by which to normalise
     
    5858bool pmDarkApply(pmReadout *readout,    // Readout to which to apply dark
    5959                 pmCell *dark,    // Dark to apply
    60                  psMaskType bad         // Mask value to give bad pixels
     60                 psImageMaskType bad         // Mask value to give bad pixels
    6161    );
    6262
  • trunk/psModules/src/detrend/pmFlatField.c

    r19432 r21183  
    2222    const psImage *flatMask  = job->args->data[3]; // Flat-field mask
    2323
    24     psMaskType badFlat = PS_SCALAR_VALUE(job->args->data[4],U8);
     24    psImageMaskType badFlat = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA);
    2525    int xOffset        = PS_SCALAR_VALUE(job->args->data[5],S32);
    2626    int yOffset        = PS_SCALAR_VALUE(job->args->data[6],S32);
     
    3838            ps##TYPE flatValue = flatImage->data.TYPE[j + yOffset][i + xOffset]; \
    3939            if (!isfinite(flatValue) || flatValue <= 0.0 || \
    40                 (flatMask && flatMask->data.U8[j + yOffset][i + xOffset])) { \
     40                (flatMask && flatMask->data.PS_TYPE_IMAGE_MASK_DATA[j + yOffset][i + xOffset])) { \
    4141                if (inMask) { \
    42                     inMask->data.PS_TYPE_MASK_DATA[j][i] |= badFlat; \
     42                    inMask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= badFlat; \
    4343                } \
    4444                inImage->data.TYPE[j][i] = SPECIAL; \
     
    5151
    5252bool pmFlatFieldScan(psImage *inImage, psImage *inMask, const psImage *flatImage, const psImage *flatMask,
    53                      psMaskType badFlat, int xOffset, int yOffset, int rowStart, int rowStop)
     53                     psImageMaskType badFlat, int xOffset, int yOffset, int rowStart, int rowStop)
    5454{
    5555    switch (inImage->type.type) {
     
    7272}
    7373
    74 bool pmFlatField(pmReadout *in, const pmReadout *flat, psMaskType badFlat)
     74bool pmFlatField(pmReadout *in, const pmReadout *flat, psImageMaskType badFlat)
    7575{
    7676    PS_ASSERT_PTR_NON_NULL(in, false);
     
    8181    PS_ASSERT_IMAGE_NON_EMPTY(flat->image, false);
    8282    if (in->mask) {
    83         PS_ASSERT_IMAGE_TYPE(in->mask, PS_TYPE_MASK, false);
     83        PS_ASSERT_IMAGE_TYPE(in->mask, PS_TYPE_IMAGE_MASK, false);
    8484        PS_ASSERT_IMAGES_SIZE_EQUAL(in->mask, in->image, false);
    8585    }
    8686    PS_ASSERT_IMAGE_TYPE(flat->image, in->image->type.type, false);
    8787    if (flat->mask) {
    88         PS_ASSERT_IMAGE_TYPE(flat->mask, PS_TYPE_MASK, false);
     88        PS_ASSERT_IMAGE_TYPE(flat->mask, PS_TYPE_IMAGE_MASK, false);
    8989        PS_ASSERT_IMAGES_SIZE_EQUAL(flat->mask, flat->image, false);
    9090    }
     
    148148          psArrayAdd(job->args, 1, flatImage);
    149149          psArrayAdd(job->args, 1, flatMask);
    150           PS_ARRAY_ADD_SCALAR(job->args, badFlat, PS_TYPE_U8);
     150          PS_ARRAY_ADD_SCALAR(job->args, badFlat, PS_TYPE_IMAGE_MASK);
    151151          PS_ARRAY_ADD_SCALAR(job->args, xOffset, PS_TYPE_S32);
    152152          PS_ARRAY_ADD_SCALAR(job->args, yOffset, PS_TYPE_S32);
  • trunk/psModules/src/detrend/pmFlatField.h

    r19432 r21183  
    55 * @author Paul Price, IfA
    66 *
    7  * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2008-09-09 04:10:14 $
     7 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2009-01-27 06:39:38 $
    99 * Copyright 2004-2006 Institute for Astronomy, University of Hawaii
    1010 */
     
    2525bool pmFlatField(pmReadout *in,         ///< Readout with input image
    2626                 const pmReadout *flat,  ///< Readout with flat image
    27                  psMaskType badFlat     ///< Mask value to give bad flat pixels
     27                 psImageMaskType badFlat     ///< Mask value to give bad flat pixels
    2828                );
    2929
     
    3838    const psImage *flatImage,           ///< Flat-field image
    3939    const psImage *flatMask,            ///< Flat-field mask
    40     psMaskType badFlag,                 ///< Mask value to give bad pixels
     40    psImageMaskType badFlag,                 ///< Mask value to give bad pixels
    4141    int xOffset, int yOffset,           ///< Offset between input and flat-field
    4242    int rowStart, int rowStop           ///< Scan range
  • trunk/psModules/src/detrend/pmFlatNormalize.c

    r9730 r21183  
    99
    1010#include "pmFlatNormalize.h"
     11
     12// XXX this function should take the abstract mask names and set bad values in a more precise way
    1113
    1214// I'm not sure that many many iterations are required, but rather suspect that the system converges within a
     
    5557    // Take the logarithms
    5658    psImage *flux = psImageCopy(NULL, bgMatrix, PS_TYPE_F32); // Copy of the input flux levels matrix
    57     psImage *fluxMask = psImageAlloc(numChips, numExps, PS_TYPE_U8); // Mask for bad measurements
     59    psImage *fluxMask = psImageAlloc(numChips, numExps, PS_TYPE_IMAGE_MASK); // Mask for bad measurements
    5860    psImageInit(fluxMask, 0);
    59     psVector *gainMask = psVectorAlloc(numChips, PS_TYPE_U8); // Mask for bad gains
     61    psVector *gainMask = psVectorAlloc(numChips, PS_TYPE_VECTOR_MASK); // Mask for bad gains
    6062    psVectorInit(gainMask, 0);
    61     psVector *expMask = psVectorAlloc(numExps, PS_TYPE_U8); // Mask for bad exposures
     63    psVector *expMask = psVectorAlloc(numExps, PS_TYPE_VECTOR_MASK); // Mask for bad exposures
    6264    psVectorInit(expMask, 0);
    6365    for (int i = 0; i < numChips; i++) {
     
    7577            } else {
    7678                // Blank out this measurement
    77                 fluxMask->data.U8[j][i] = 1;
     79                fluxMask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] = 1;
    7880                flux->data.F32[j][i] = NAN;
    7981            }
     
    9092        int numFluxes = 0;              // Number of fluxes
    9193        for (int i = 0; i < numExps; i++) {
    92             if (expMask->data.U8[i]) {
     94            if (expMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    9395                psTrace("psModules.detrend", 7, "Flux for exposure %d is masked.\n", i);
    9496                continue;
     
    98100            int number = 0;             // Number of chips contributing
    99101            for (int j = 0; j < numChips; j++) {
    100                 if (!gainMask->data.U8[j] && !fluxMask->data.U8[i][j]) {
     102                if (!gainMask->data.PS_TYPE_VECTOR_MASK_DATA[j] && !fluxMask->data.PS_TYPE_IMAGE_MASK_DATA[i][j]) {
    101103                    sum += flux->data.F32[i][j] - chipGains->data.F32[j];
    102104                    number++;
     
    106108                expFluxes->data.F32[i] = sum / (float)number;
    107109            } else {
    108                 expMask->data.U8[i] = 1;
     110                expMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;
    109111                expFluxes->data.F32[i] = NAN;
    110112            }
     
    116118        int numGains = 0;               // Number of gains
    117119        for (int i = 0; i < numChips; i++) {
    118             if (gainMask->data.U8[i]) {
     120            if (gainMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    119121                continue;
    120122            }
     
    122124            int number = 0;             // Numer of sources contributing
    123125            for (int j = 0; j < numExps; j++) {
    124                 if (!fluxMask->data.U8[j][i]) {
     126                if (!fluxMask->data.PS_TYPE_IMAGE_MASK_DATA[j][i]) {
    125127                    sum += flux->data.F32[j][i] - expFluxes->data.F32[j];
    126128                    number++;
     
    130132                chipGains->data.F32[i] = sum / (float)number;
    131133            } else {
    132                 gainMask->data.U8[i] = 1;
     134                gainMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;
    133135                chipGains->data.F32[i] = NAN;
    134136            }
     
    144146            diff = 0.0;
    145147            for (int i = 0; i < numChips; i++) {
    146                 if (gainMask->data.U8[i]) {
     148                if (gainMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    147149                    continue;
    148150                }
     
    151153            }
    152154            for (int i = 0; i < numExps; i++) {
    153                 if (expMask->data.U8[i]) {
     155                if (expMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    154156                    continue;
    155157                }
     
    171173    // Un-log the vectors
    172174    for (int i = 0; i < numChips; i++) {
    173         if (!gainMask->data.U8[i]) {
     175        if (!gainMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    174176            chipGains->data.F32[i] = expf(chipGains->data.F32[i]);
    175177        }
    176178    }
    177179    for (int i = 0; i < numExps; i++) {
    178         if (!expMask->data.U8[i]) {
     180        if (!expMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    179181            expFluxes->data.F32[i] = expf(expFluxes->data.F32[i]);
    180182        }
  • trunk/psModules/src/detrend/pmFringeStats.c

    r13776 r21183  
    7070    fringe->x = psVectorRecycle(fringe->x, fringe->nRequested, PS_TYPE_F32);
    7171    fringe->y = psVectorRecycle(fringe->y, fringe->nRequested, PS_TYPE_F32);
    72     fringe->mask = psVectorRecycle(fringe->mask, fringe->nRequested, PS_TYPE_U8);
     72    fringe->mask = psVectorRecycle(fringe->mask, fringe->nRequested, PS_TYPE_VECTOR_MASK);
    7373    fringe->x->n = fringe->y->n = fringe->mask->n = fringe->nRequested;
    7474    psVectorInit(fringe->mask, 0);
     
    115115    if (mask) {
    116116        PS_ASSERT_VECTOR_NON_NULL(mask, false);
    117         PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
     117        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
    118118        PS_ASSERT_VECTOR_SIZE(mask, (long)numRows, false);
    119119    }
     
    142142        psMetadataAddF32(row, PS_LIST_TAIL, "x", PS_META_REPLACE, "Fringe position in x", x->data.F32[i]);
    143143        psMetadataAddF32(row, PS_LIST_TAIL, "y", PS_META_REPLACE, "Fringe position in y", y->data.F32[i]);
    144         psU8 maskValue = 0;
    145         if (mask && mask->data.U8[i]) {
     144        psVectorMaskType maskValue = 0;
     145        if (mask && mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    146146            maskValue = 0xff;
    147147        }
    148         psMetadataAddU8(row, PS_LIST_TAIL, "mask", PS_META_REPLACE, "Mask", maskValue);
     148        psMetadataAddVectorMask(row, PS_LIST_TAIL, "mask", PS_META_REPLACE, "Mask", maskValue);
    149149        table->data[i] = row;
    150150    }
     
    207207    psVector *x = psVectorAlloc(numRows, PS_TYPE_F32); // x position
    208208    psVector *y = psVectorAlloc(numRows, PS_TYPE_F32); // y position
    209     psVector *mask = psVectorAlloc(numRows, PS_TYPE_U8); // mask
     209    psVector *mask = psVectorAlloc(numRows, PS_TYPE_VECTOR_MASK); // mask
    210210    regions->x = x;
    211211    regions->y = y;
    212212    regions->mask = mask;
    213213
    214     #define READ_REGIONS_ROW(VECTOR, TYPE, NAME, DESCRIPTION) \
    215     VECTOR->data.TYPE[i] = psMetadataLookup##TYPE(&mdok, row, NAME); \
     214    #define READ_REGIONS_ROW(VECTOR, TYPE, DATATYPE, NAME, DESCRIPTION) \
     215    VECTOR->data.DATATYPE[i] = psMetadataLookup##TYPE(&mdok, row, NAME); \
    216216    if (!mdok) { \
    217217        psError(PS_ERR_IO, true, "Unable to find " #DESCRIPTION " .\n"); \
     
    224224    for (long i = 0; i < numRows; i++) {
    225225        psMetadata *row = table->data[i]; // Table row
    226         READ_REGIONS_ROW(x, F32, "x", "x position");
    227         READ_REGIONS_ROW(y, F32, "y", "y position");
    228         READ_REGIONS_ROW(mask, U8, "mask", "mask");
     226        READ_REGIONS_ROW(x, F32, F32, "x", "x position");
     227        READ_REGIONS_ROW(y, F32, F32, "y", "y position");
     228        READ_REGIONS_ROW(mask, VectorMask, PS_TYPE_VECTOR_MASK_DATA, "mask", "mask");
    229229    }
    230230    psFree(table);
     
    259259}
    260260
    261 pmFringeStats *pmFringeStatsMeasure(pmFringeRegions *fringe, const pmReadout *readout, psMaskType maskVal)
     261pmFringeStats *pmFringeStatsMeasure(pmFringeRegions *fringe, const pmReadout *readout, psImageMaskType maskVal)
    262262{
    263263    PS_ASSERT_PTR_NON_NULL(fringe, NULL);
     
    490490    newRegions->x = psVectorAlloc(numPoints, PS_TYPE_F32);
    491491    newRegions->y = psVectorAlloc(numPoints, PS_TYPE_F32);
    492     newRegions->mask = psVectorAlloc(numPoints, PS_TYPE_U8);
     492    newRegions->mask = psVectorAlloc(numPoints, PS_TYPE_VECTOR_MASK);
    493493    pmFringeStats *newStats = pmFringeStatsAlloc(newRegions); // The new list of statistics
    494494
     
    500500        memcpy(&newRegions->x->data.F32[offset], regions->x->data.F32, regions->x->n * sizeof(psF32));
    501501        memcpy(&newRegions->y->data.F32[offset], regions->y->data.F32, regions->y->n * sizeof(psF32));
    502         memcpy(&newRegions->mask->data.U8[offset], regions->mask->data.U8, regions->mask->n * sizeof(psU8));
     502        memcpy(&newRegions->mask->data.PS_TYPE_VECTOR_MASK_DATA[offset], regions->mask->data.PS_TYPE_VECTOR_MASK_DATA, regions->mask->n * sizeof(psVectorMaskType));
    503503        memcpy(&newStats->f->data.F32[offset], fringe->f->data.F32, fringe->f->n * sizeof(psF32));
    504504        memcpy(&newStats->df->data.F32[offset], fringe->df->data.F32, fringe->df->n * sizeof(psF32));
     
    549549    if (mask) {
    550550        PS_ASSERT_VECTOR_NON_NULL(mask, false);
    551         PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_U8, false);
     551        PS_ASSERT_VECTOR_TYPE(mask, PS_TYPE_VECTOR_MASK, false);
    552552        PS_ASSERT_VECTOR_SIZE(mask, (long)numRows, false);
    553553    }
     
    580580        psMetadataAddF32(row, PS_LIST_TAIL, "x", PS_META_REPLACE, "Fringe position in x", x->data.F32[i]);
    581581        psMetadataAddF32(row, PS_LIST_TAIL, "y", PS_META_REPLACE, "Fringe position in y", y->data.F32[i]);
    582         psU8 maskValue = 0;             // Mask value
    583         if (mask && mask->data.U8[i]) {
     582        psVectorMaskType maskValue = 0;             // Mask value
     583        if (mask && mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    584584            maskValue = 0xff;
    585585        }
     
    601601        psFree(df);
    602602
    603         psMetadataAddU8(row, PS_LIST_TAIL, "mask", PS_META_REPLACE, "Mask", maskValue);
     603        psMetadataAddVectorMask(row, PS_LIST_TAIL, "mask", PS_META_REPLACE, "Mask", maskValue);
    604604        table->data[i] = row;
    605605    }
     
    648648    psVector *x = psVectorAlloc(numRows, PS_TYPE_F32); // x position
    649649    psVector *y = psVectorAlloc(numRows, PS_TYPE_F32); // y position
    650     psVector *mask = psVectorAlloc(numRows, PS_TYPE_U8); // mask
     650    psVector *mask = psVectorAlloc(numRows, PS_TYPE_VECTOR_MASK); // mask
    651651    regions->x = x;
    652652    regions->y = y;
     
    656656    psArray *fringes = NULL; // Array of fringes, to return
    657657
    658     #define READ_FRINGES_VECTOR_ROW(VECTOR, TYPE, NAME, DESCRIPTION) \
     658    #define READ_FRINGES_VECTOR_ROW(VECTOR, TYPE, DATATYPE, NAME, DESCRIPTION) \
    659659    { \
    660         VECTOR->data.TYPE[i] = psMetadataLookup##TYPE(&mdok, row, NAME); \
     660        VECTOR->data.DATATYPE[i] = psMetadataLookup##TYPE(&mdok, row, NAME); \
    661661        if (!mdok) { \
    662662            psError(PS_ERR_IO, true, "Unable to find " #DESCRIPTION " for row %ld.\n", i); \
     
    686686    }
    687687
     688    // XXX : need to extend this to support arbitrary types for the vectors on disk
    688689    // Translate the table into vectors
    689690    for (long i = 0; i < numRows; i++) {
    690691        psMetadata *row = table->data[i]; // Table row
    691         READ_FRINGES_VECTOR_ROW(x, F32, "x", "x position");
    692         READ_FRINGES_VECTOR_ROW(y, F32, "y", "y position");
    693         READ_FRINGES_VECTOR_ROW(mask, U8, "mask", "mask");
     692        READ_FRINGES_VECTOR_ROW(x, F32, F32, "x", "x position");
     693        READ_FRINGES_VECTOR_ROW(y, F32, F32, "y", "y position");
     694        READ_FRINGES_VECTOR_ROW(mask, VectorMask, PS_TYPE_VECTOR_MASK_DATA, "mask", "mask");
    694695        READ_FRINGES_ARRAY_ROW(f, F32, "f", "fringe measurement");
    695696        READ_FRINGES_ARRAY_ROW(df, F32, "df", "fringe error");
     
    782783            double matrix = 0.0;        // The matrix sum
    783784            for (int k = 0; k < numPoints; k++) {
    784                 if (!mask->data.U8[k]) {
     785                if (!mask->data.PS_TYPE_VECTOR_MASK_DATA[k]) {
    785786                    psF32 f1 = (fringe1) ? fringe1->data.F32[k] : 1.0; // Contribution from i fringe
    786787                    psF32 f2 = (fringe2) ? fringe2->data.F32[k] : 1.0; // Contribution from j fringe
     
    799800        double vector = 0.0;            // The vector sum
    800801        for (int k = 0; k < numPoints; k++) {
    801             if (!mask->data.U8[k]) {
     802            if (!mask->data.PS_TYPE_VECTOR_MASK_DATA[k]) {
    802803                psF32 f1 = (fringe1) ? fringe1->data.F32[k] : 1.0; // Contribution from fringe 1
    803804                psF32 s = science->f->data.F32[k]; // Contribution from science measurement
     
    855856
    856857    for (int i = 0; i < diff->n; i++) {
    857         if (!mask->data.U8[i]) {
     858        if (!mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    858859            float difference = science->f->data.F32[i] - scale->coeff->data.F32[0];
    859860            for (int j = 0; j < fringes->n; j++) {
     
    877878    assert(diffs->type.type == PS_TYPE_F32);
    878879    assert(mask);
    879     assert(mask->type.type == PS_TYPE_U8);
     880    assert(mask->type.type == PS_TYPE_VECTOR_MASK);
    880881    assert(diffs->n == mask->n);
    881882
     
    888889    int numClipped = 0;                 // Number clipped
    889890    for (int i = 0; i < diffs->n; i++) {
    890         psTrace("psModules.detrend", 10, "Region %d (%d): %f\n", i, mask->data.U8[i], diffs->data.F32[i]);
    891         if (!mask->data.U8[i] && fabs(diffs->data.F32[i]) > middle + thresh) {
     891        psTrace("psModules.detrend", 10, "Region %d (%d): %f\n", i, mask->data.PS_TYPE_VECTOR_MASK_DATA[i], diffs->data.F32[i]);
     892        if (!mask->data.PS_TYPE_VECTOR_MASK_DATA[i] && fabs(diffs->data.F32[i]) > middle + thresh) {
    892893            psTrace("psModules.detrend", 5, "Masking %d: %f\n", i, diffs->data.F32[i]);
    893             mask->data.U8[i] = 1;
     894            mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;
    894895            numClipped++;
    895896        }
     
    931932    // Set up the mask
    932933    if (!regions->mask) {
    933         regions->mask = psVectorAlloc(numRegions, PS_TYPE_U8);
     934        regions->mask = psVectorAlloc(numRegions, PS_TYPE_VECTOR_MASK);
    934935        psVectorInit(regions->mask, 0);
    935936    }
     
    946947        for (int j = 0; j < numRegions; j++) {
    947948            if (!isfinite(fringe->f->data.F32[j])) {
    948                 mask->data.U8[j] = 1;
     949                mask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 1;
    949950                psTrace("psModules.detrend", 9, "Masking region %d because not finite in fringe %d.\n", j, i);
    950951            }
     
    956957    FILE *f = fopen ("fringe.dat", "w");
    957958    for (int j = 0; j < numRegions; j++) {
    958         if (mask->data.U8[j]) continue;
     959        if (mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) continue;
    959960        fprintf (f, "%d %f %f ", j, science->f->data.F32[j], science->df->data.F32[j]);
    960961        for (int i = 0; i < fringes->n; i++) {
     
    10141015// XXX note that this modifies the input fringe images
    10151016psImage *pmFringeCorrect(pmReadout *readout, pmFringeRegions *fringes, psArray *fringeImages,
    1016                          psArray *fringeStats, psMaskType maskVal, float rej,
     1017                         psArray *fringeStats, psImageMaskType maskVal, float rej,
    10171018                         unsigned int nIter, float keepFrac)
    10181019{
  • trunk/psModules/src/detrend/pmFringeStats.h

    r11253 r21183  
    55 * @author Paul Price, IfA
    66 *
    7  * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2007-01-24 02:54:15 $
     7 * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2009-01-27 06:39:38 $
    99 * Copyright 2004-2006 Institute for Astronomy, University of Hawaii
    1010 */
     
    102102pmFringeStats *pmFringeStatsMeasure(pmFringeRegions *fringe, ///< Fringe regions at which to measure
    103103                                    const pmReadout *readout, ///< Readout for which to measure
    104                                     psMaskType maskVal ///< Mask value for image
     104                                    psImageMaskType maskVal ///< Mask value for image
    105105                                   );
    106106
     
    206206                         psArray *fringeImages, ///< Fringe template images to use in correction
    207207                         psArray *fringeStats, ///< Fringe stats (for templates) to use in correction
    208                          psMaskType maskVal, ///< Value to mask for science image
     208                         psImageMaskType maskVal, ///< Value to mask for science image
    209209                         float rej,     ///< Rejection threshold, for pmFringeScaleMeasure
    210210                         unsigned int nIter, ///< Maximum number of iterations, for pmFringeScaleMeasure
  • trunk/psModules/src/detrend/pmMaskBadPixels.c

    r18554 r21183  
    1414#include "pmMaskBadPixels.h"
    1515
    16 bool pmMaskBadPixels(pmReadout *input, const pmReadout *mask, psMaskType maskVal)
     16bool pmMaskBadPixels(pmReadout *input, const pmReadout *mask, psImageMaskType maskVal)
    1717{
    1818    PS_ASSERT_PTR_NON_NULL(input, false);
    1919    PS_ASSERT_PTR_NON_NULL(input->mask, false);
    20     PS_ASSERT_IMAGE_TYPE(input->mask, PS_TYPE_MASK, false);
     20    PS_ASSERT_IMAGE_TYPE(input->mask, PS_TYPE_IMAGE_MASK, false);
    2121
    2222    PS_ASSERT_PTR_NON_NULL(mask, false);
    2323    PS_ASSERT_PTR_NON_NULL(mask->mask, false);
    24     PS_ASSERT_IMAGE_TYPE(mask->mask, PS_TYPE_MASK, false);
     24    PS_ASSERT_IMAGE_TYPE(mask->mask, PS_TYPE_IMAGE_MASK, false);
    2525
    2626    psImage *inMask = input->mask;
     
    5353    int offRow = input->row0 - mask->row0;
    5454
    55     // masks are both of type PS_TYPE_MASK
    56     psMaskType **exVal = exMask->data.U8;
    57     psMaskType **inVal = inMask->data.U8;
     55    // masks are both of type PS_TYPE_IMAGE_MASK
     56    psImageMaskType **exVal = exMask->data.PS_TYPE_IMAGE_MASK_DATA;
     57    psImageMaskType **inVal = inMask->data.PS_TYPE_IMAGE_MASK_DATA;
    5858
    5959    // apply exMask values
     
    8282
    8383bool pmMaskFlagSuspectPixels(pmReadout *output, const pmReadout *readout, float median, float stdev,
    84                              float rej, psMaskType maskVal)
     84                             float rej, psImageMaskType maskVal)
    8585{
    8686    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    9292        PS_ASSERT_IMAGE_NON_EMPTY(readout->mask, false);
    9393        PS_ASSERT_IMAGES_SIZE_EQUAL(readout->image, readout->mask, false);
    94         PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_MASK, false);
     94        PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_IMAGE_MASK, false);
    9595    }
    9696    PS_ASSERT_PTR_NON_NULL(output, false);
     
    128128        for (int x = 0; x < image->numCols; x++) {
    129129            if (fabs((image->data.F32[y][x] - median) / stdev) < rej) continue;
    130             if (mask && (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal)) continue;
     130            if (mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal)) continue;
    131131            suspect->data.F32[y][x] += 1.0;
    132132        }
     
    142142
    143143// the maskVal supplied here is the value SET for this mask (ie, it is not used to avoid pixels)
    144 bool pmMaskIdentifyBadPixels(pmReadout *output, psMaskType maskVal, float thresh, pmMaskIdentifyMode mode)
     144bool pmMaskIdentifyBadPixels(pmReadout *output, psImageMaskType maskVal, float thresh, pmMaskIdentifyMode mode)
    145145{
    146146    PS_ASSERT_PTR_NON_NULL(output, false);
     
    155155        PS_ASSERT_IMAGE_NON_EMPTY(output->mask, false);
    156156        PS_ASSERT_IMAGES_SIZE_EQUAL(output->mask, suspects, false);
    157         PS_ASSERT_IMAGE_TYPE(output->mask, PS_TYPE_MASK, false);
     157        PS_ASSERT_IMAGE_TYPE(output->mask, PS_TYPE_IMAGE_MASK, false);
    158158    } else {
    159         output->mask = psImageAlloc(suspects->numCols, suspects->numRows, PS_TYPE_MASK);
     159        output->mask = psImageAlloc(suspects->numCols, suspects->numRows, PS_TYPE_IMAGE_MASK);
    160160    }
    161161    int num = psMetadataLookupS32(NULL, output->analysis, PM_MASK_ANALYSIS_NUM); // Number of inputs
     
    246246        for (int x = 0; x < suspects->numCols; x++) {
    247247            if (suspects->data.F32[y][x] >= limit) {
    248                 badpix->data.PS_TYPE_MASK_DATA[y][x] = maskVal;
     248                badpix->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = maskVal;
    249249            }
    250250        }
  • trunk/psModules/src/detrend/pmMaskBadPixels.h

    r17228 r21183  
    55 * @author Eugene Magnier, IfA
    66 *
    7  * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2008-03-29 03:10:17 $
     7 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2009-01-27 06:39:38 $
    99 * Copyright 2004 Institute for Astronomy, University of Hawaii
    1010 */
     
    4040bool pmMaskBadPixels(pmReadout *input,  ///< Input science image
    4141                     const pmReadout *mask, ///< Mask image to apply
    42                      psMaskType maskVal ///< Mask value to apply
     42                     psImageMaskType maskVal ///< Mask value to apply
    4343                    );
    4444
     
    5656                             float stdev, ///< Image standard deviation
    5757                             float rej, ///< Rejection threshold (standard deviations)
    58                              psMaskType maskVal ///< Mask value for statistics
     58                             psImageMaskType maskVal ///< Mask value for statistics
    5959    );
    6060
     
    6464/// according to the chosen mode.
    6565bool pmMaskIdentifyBadPixels(pmReadout *output, ///< Output readout, with suspect pixels imageOut
    66                              psMaskType maskVal, ///< Value to set for bad pixels
     66                             psImageMaskType maskVal, ///< Value to set for bad pixels
    6767                             float thresh, ///< Threshold for bad pixel
    6868                             pmMaskIdentifyMode mode ///< Mode for identifying bad pixels
  • trunk/psModules/src/detrend/pmOverscan.c

    r19846 r21183  
    6767    psVector *reduced = psVectorAlloc(pixels->n, PS_TYPE_F32); // Overscan for each row
    6868    psVector *ordinate = psVectorAlloc(pixels->n, PS_TYPE_F32); // Ordinate
    69     psVector *mask = psVectorAlloc(pixels->n, PS_TYPE_U8); // Mask for fitting
     69    psVector *mask = psVectorAlloc(pixels->n, PS_TYPE_VECTOR_MASK); // Mask for fitting
    7070
    7171    for (int i = 0; i < pixels->n; i++) {
    7272        psVector *values = pixels->data[i]; // Vector with overscan values
    7373        if (values->n > 0) {
    74             mask->data.U8[i] = 0;
     74            mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0;
    7575            ordinate->data.F32[i] = 2.0*(float)i/(float)pixels->n - 1.0; // Scale to [-1,1]
    7676            psVectorStats(myStats, values, NULL, NULL, 0);
     
    8282        } else {
    8383            // We'll fit this one out
    84             mask->data.U8[i] = 1;
     84            mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;
    8585        }
    8686    }
  • trunk/psModules/src/detrend/pmRemnance.c

    r20669 r21183  
    1313
    1414bool pmRemnance(pmReadout *ro,           ///< Readout with input image
    15                 psMaskType maskVal,      ///< Value of mask
    16                 psMaskType maskRem,       ///< Value to give remance
     15                psImageMaskType maskVal,      ///< Value of mask
     16                psImageMaskType maskRem,       ///< Value to give remance
    1717                int size,               ///< Size of accumulation patches
    1818                float threshold         ///< Threshold for masking
     
    2323    PM_ASSERT_READOUT_MASK(ro, false);
    2424
    25     psImage *image = ro->image, *mask = ro->mask; // Mask and image from readout
     25    psImage *image = ro->image;
     26    psImage *mask = ro->mask; // Mask and image from readout
     27
    2628    int numCols = image->numCols, numRows = image->numRows; // Size of image
    2729
     
    3335        psErrorClear();
    3436        psWarning("Unable to calculate image statistics: masking entire readout.");
    35         psBinaryOp(mask, mask, "|", psScalarAlloc(maskRem, PS_TYPE_MASK));
     37        psBinaryOp(mask, mask, "|", psScalarAlloc(maskRem, PS_TYPE_IMAGE_MASK));
    3638        psFree(stats);
    3739        psFree(rng);
     
    5759            }
    5860            for (int y = min; y < max; y++) {
    59                 if (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
     61                if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) {
    6062                    continue;
    6163                }
     
    8486            }
    8587            for (int y = 0; y < maxMask; y++) {
    86                 mask->data.PS_TYPE_MASK_DATA[y][x] |= maskRem;
     88                mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= maskRem;
    8789            }
    8890            numMasked += maxMask;
  • trunk/psModules/src/detrend/pmRemnance.h

    r20622 r21183  
    1313// GPC1 leaves remnance that flows down from where the annoyed pixels are.
    1414bool pmRemnance(pmReadout *ro,           ///< Readout with input image
    15                 psMaskType maskVal,      ///< Value of mask
    16                 psMaskType maskRem,       ///< Value to give remance
     15                psImageMaskType maskVal,      ///< Value of mask
     16                psImageMaskType maskRem,       ///< Value to give remance
    1717                int size,               ///< Size of accumulation patches
    1818                float threshold         ///< Threshold for masking
  • trunk/psModules/src/detrend/pmShifts.c

    r15322 r21183  
    412412}
    413413
    414 bool pmShiftsConvolve(pmReadout *detrend, const pmCell *source, psMaskType maskVal)
     414bool pmShiftsConvolve(pmReadout *detrend, const pmCell *source, psImageMaskType maskVal)
    415415{
    416416    PS_ASSERT_PTR(detrend, false);
  • trunk/psModules/src/detrend/pmShifts.h

    r12696 r21183  
    4646bool pmShiftsConvolve(pmReadout *detrend, ///< Detrend readout to convolve
    4747                      const pmCell *source, ///< Science exposure, containing a shifts kernel
    48                       psMaskType maskVal ///< Mask value to smear
     48                      psImageMaskType maskVal ///< Mask value to smear
    4949                      );
    5050
  • trunk/psModules/src/detrend/pmShutterCorrection.c

    r19432 r21183  
    198198pmShutterCorrection *pmShutterCorrectionLinFit(const psVector *exptime, const psVector *counts,
    199199                                               const psVector *cntError, const psVector *mask, float offref,
    200                                                int nIter, float rej, psMaskType maskVal)
     200                                               int nIter, float rej)
    201201{
    202202    PS_ASSERT_VECTOR_NON_NULL(exptime, NULL);
     
    241241    stats->clipIter = nIter;
    242242
    243     if (!psVectorClipFitPolynomial2D(line, stats, mask, maskVal, counts, cntError, x, y)) {
     243    if (!psVectorClipFitPolynomial2D(line, stats, mask, 0xff, counts, cntError, x, y)) {
    244244        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to fit shutter correction.\n");
    245245        psFree(stats);
     
    371371
    372372bool pmShutterCorrectionMeasure(pmReadout *output, const psArray *readouts, int size, psStatsOptions meanStat,
    373                                 psStatsOptions stdevStat, int nIter, float rej, psMaskType maskVal)
     373                                psStatsOptions stdevStat, int nIter, float rej, psImageMaskType maskVal)
    374374{
    375375    PS_ASSERT_ARRAY_NON_NULL(readouts, NULL);
     
    457457            masks->data[i] = psMemIncrRefCounter(mask);
    458458
    459             if (mask->type.type != PS_TYPE_U8) {
     459            if (mask->type.type != PS_TYPE_IMAGE_MASK) {
    460460                psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Bad type for mask: %x\n", mask->type.type);
    461461                goto MEASURE_ERROR;
     
    582582    psImage *shutter = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Shutter correction image
    583583    psImage *pattern = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Illumination pattern
    584     psVector *mask = psVectorAlloc(num, PS_TYPE_U8); // Mask for each image
     584    psVector *mask = psVectorAlloc(num, PS_TYPE_VECTOR_MASK); // Mask for each image
    585585    psVectorInit(mask, 0);
    586586    psTrace("psModules.detrend", 2, "Performing linear fit on individual pixels...\n");
     
    592592                psImage *maskImage;     // Mask image
    593593                if (masks && (maskImage = masks->data[i])) {
    594                     mask->data.U8[i] = maskImage->data.U8[y][x];
     594                    mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = (maskImage->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal);
    595595                }
    596596                psImage *weight;        // Weight image
     
    602602            }
    603603
    604             pmShutterCorrection *corr = pmShutterCorrectionLinFit(exptimes, counts, errors, mask, meanRef,
    605                                         nIter, rej, maskVal);
     604            pmShutterCorrection *corr = pmShutterCorrectionLinFit(exptimes, counts, errors, mask, meanRef, nIter, rej);
    606605            shutter->data.F32[y][x] = corr->offset;
    607606            pattern->data.F32[y][x] = corr->scale;
     
    665664
    666665    float exptime    = PS_SCALAR_VALUE(job->args->data[3],F32);
    667     psMaskType blank = PS_SCALAR_VALUE(job->args->data[4],U8);
     666    psImageMaskType blank = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA);
    668667    int rowStart     = PS_SCALAR_VALUE(job->args->data[5],S32);
    669668    int rowStop      = PS_SCALAR_VALUE(job->args->data[6],S32);
     
    672671
    673672bool pmShutterCorrectionApplyScan(psImage *image, const psImage *shutterImage, psImage *mask, float exptime,
    674                                   psMaskType blank, int rowStart, int rowStop)
     673                                  psImageMaskType blank, int rowStart, int rowStop)
    675674{
    676675    for (int y = rowStart; y < rowStop; y++) {
    677676        for (int x = 0; x < image->numCols; x++) {
    678677            if (mask && !isfinite(shutterImage->data.F32[y][x])) {
    679                 mask->data.PS_TYPE_MASK_DATA[y][x] |= blank;
     678                mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= blank;
    680679                image->data.F32[y][x] = NAN;
    681680                continue;
     
    687686}
    688687
    689 bool pmShutterCorrectionApply(pmReadout *readout, const pmReadout *shutter, psMaskType blank)
     688bool pmShutterCorrectionApply(pmReadout *readout, const pmReadout *shutter, psImageMaskType blank)
    690689{
    691690    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    746745            for (int x = 0; x < image->numCols; x++) {
    747746                if (mask && !isfinite(shutterImage->data.F32[y][x])) {
    748                     mask->data.PS_TYPE_MASK_DATA[y][x] |= blank;
     747                    mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= blank;
    749748                    image->data.F32[y][x] = NAN;
    750749                    continue;
     
    770769                psArrayAdd(job->args, 1, mask);
    771770                PS_ARRAY_ADD_SCALAR(job->args, exptime, PS_TYPE_F32);
    772                 PS_ARRAY_ADD_SCALAR(job->args, blank, PS_TYPE_MASK);
     771                PS_ARRAY_ADD_SCALAR(job->args, blank, PS_TYPE_IMAGE_MASK);
    773772                PS_ARRAY_ADD_SCALAR(job->args, rowStart, PS_TYPE_S32);
    774773                PS_ARRAY_ADD_SCALAR(job->args, rowStop, PS_TYPE_S32);
     
    860859                                   psStatsOptions meanStat, ///< Statistic to use for mean
    861860                                   psStatsOptions stdevStat, ///< Statistic to use for stdev
    862                                    psMaskType maskVal, ///< Mask value
     861                                   psImageMaskType maskVal, ///< Mask value
    863862                                   psRandom *rng ///< Random number generator
    864863    )
     
    876875    if (readout->mask) {
    877876        PS_ASSERT_IMAGE_NON_NULL(readout->mask, NULL);
    878         PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_MASK, NULL);
     877        PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_IMAGE_MASK, NULL);
    879878        PS_ASSERT_IMAGE_SIZE(readout->mask, data->numCols, data->numRows, NULL);
    880879    }
     
    10221021
    10231022bool pmShutterCorrectionGeneratePrepare(pmReadout *shutter, pmReadout *pattern, const psArray *inputs,
    1024                                         psMaskType maskVal)
     1023                                        psImageMaskType maskVal)
    10251024{
    10261025    PS_ASSERT_PTR_NON_NULL(shutter, false);
     
    10841083bool pmShutterCorrectionGenerate(pmReadout *shutter, pmReadout *pattern, const psArray *inputs,
    10851084                                 float reference, const pmShutterCorrectionData *data,
    1086                                  int nIter, float rej, psMaskType maskVal)
     1085                                 int nIter, float rej, psImageMaskType maskVal)
    10871086{
    10881087    PS_ASSERT_PTR_NON_NULL(shutter, false);
     
    11161115    psVector *counts = psVectorAlloc(num, PS_TYPE_F32); // Counts in each image
    11171116    psVector *errors = psVectorAlloc(num, PS_TYPE_F32); // Counts in each image
    1118     psVector *mask = psVectorAlloc(num, PS_TYPE_MASK); // Mask for each image
     1117    psVector *mask = psVectorAlloc(num, PS_TYPE_VECTOR_MASK); // Mask for each image
    11191118    psTrace("psModules.detrend", 2, "Performing linear fit on individual pixels...\n");
    11201119    for (int i = minInputRows; i < maxInputRows; i++) {
     
    11321131                counts->data.F32[r] = image->data.F32[yIn][xIn] * ref;
    11331132                if (readout->mask) {
    1134                     mask->data.PS_TYPE_MASK_DATA[r] = readout->mask->data.PS_TYPE_MASK_DATA[yIn][xIn];
     1133                    mask->data.PS_TYPE_VECTOR_MASK_DATA[r] = (readout->mask->data.PS_TYPE_IMAGE_MASK_DATA[yIn][xIn] & maskVal);
    11351134                }
    11361135                if (readout->weight) {
     
    11421141            }
    11431142
    1144             pmShutterCorrection *corr = pmShutterCorrectionLinFit(data->exptimes, counts, errors, mask,
    1145                                                                   reference, nIter, rej, maskVal);
     1143            pmShutterCorrection *corr = pmShutterCorrectionLinFit(data->exptimes, counts, errors, mask, reference, nIter, rej);
    11461144            if (!corr) {
    11471145                // Nothing we can do about it
  • trunk/psModules/src/detrend/pmShutterCorrection.h

    r19432 r21183  
    55 * @author Paul Price, IfA
    66 *
    7  * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2008-09-09 04:10:14 $
     7 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2009-01-27 06:39:38 $
    99 * Copyright 2006 Institute for Astronomy, University of Hawaii
    1010 */
     
    9191    float offref,                       ///< Reference time offset
    9292    int nIter,                          ///< Number of iterations
    93     float rej,                          ///< Rejection threshold (sigma)
    94     psMaskType maskVal                  ///< Mask value
     93    float rej                           ///< Rejection threshold (sigma)
    9594    );
    9695
     
    121120    int nIter,                          ///< Number of iterations
    122121    float rej,                          ///< Rejection threshold (sigma)
    123     psMaskType maskVal                  ///< Mask value
     122    psImageMaskType maskVal                  ///< Mask value
    124123    );
    125124
     
    135134    psImage *mask,                      ///< Input mask image
    136135    float exptime,                      ///< Exposure time to which to correct
    137     psMaskType blank,                   ///< Mask value to give blank pixels
     136    psImageMaskType blank,                   ///< Mask value to give blank pixels
    138137    int rowStart, int rowStop           ///< Range of scan
    139138    );
     
    145144    pmReadout *readout,                 ///< Readout to which to apply shutter correction
    146145    const pmReadout *shutter,           ///< Shutter correction readout, with dT for each pixel
    147     psMaskType blank                    ///< Value to give blank pixels
     146    psImageMaskType blank                    ///< Value to give blank pixels
    148147    );
    149148
     
    181180    psStatsOptions meanStat,            ///< Statistic to use for mean
    182181    psStatsOptions stdevStat,           ///< Statistic to use for stdev
    183     psMaskType maskVal,                 ///< Mask value
     182    psImageMaskType maskVal,                 ///< Mask value
    184183    psRandom *rng                       ///< Random number generator
    185184    );
     
    201200    int nIter,                          ///< Number of iterations
    202201    float rej,                          ///< Rejection threshold (sigma)
    203     psMaskType maskVal                  ///< Mask value
     202    psImageMaskType maskVal                  ///< Mask value
    204203    );
    205204
    206205// prepare outputs for shutter correction
    207206bool pmShutterCorrectionGeneratePrepare(pmReadout *shutter, pmReadout *pattern, const psArray *inputs,
    208                                         psMaskType maskVal);
     207                                        psImageMaskType maskVal);
    209208
    210209/// @}
  • trunk/psModules/src/detrend/pmSkySubtract.c

    r12742 r21183  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-04-04 22:42:48 $
     8 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-01-27 06:39:38 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    114114
    115115    psVector *binVector = psVectorAlloc(binFactor * binFactor, PS_TYPE_F32);
    116     psVector *binMask = psVectorAlloc(binFactor * binFactor, PS_TYPE_U8);
     116    psVector *binMask = psVectorAlloc(binFactor * binFactor, PS_TYPE_VECTOR_MASK);
    117117    psStats *myStats = psStatsAlloc(statOptions);
    118118
     
    126126                        binVector->data.F32[count] =
    127127                            origImage->data.F32[row + binRow][col + binCol];
    128                         binMask->data.U8[count] = 0;
     128                        binMask->data.PS_TYPE_VECTOR_MASK_DATA[count] = 0;
    129129                    } else {
    130130                        binVector->data.F32[count] = 0.0;
    131                         binMask->data.U8[count] = 1;
     131                        binMask->data.PS_TYPE_VECTOR_MASK_DATA[count] = 1;
    132132                    }
    133133                    count++;
     
    313313    PS_ASSERT_IMAGE_NON_NULL(maskImage, NULL);
    314314    PS_ASSERT_IMAGE_NON_EMPTY(maskImage, NULL);
    315     PS_ASSERT_IMAGE_TYPE(maskImage, PS_TYPE_U8, NULL);
     315    PS_ASSERT_IMAGE_TYPE(maskImage, PS_TYPE_IMAGE_MASK, NULL);
    316316    PS_ASSERT_IMAGES_SIZE_EQUAL(dataImage, maskImage, NULL);
    317317    psS32 oldPolyX = -1;
     
    361361    for (x=0;x<dataImage->numRows;x++) {
    362362        for (y=0;y<dataImage->numCols;y++) {
    363             if (maskImage->data.U8[x][y] == 0) {
     363            if (maskImage->data.PS_TYPE_IMAGE_MASK_DATA[x][y] == 0) {
    364364                buildSums((psF64) x, (psF64) y, myPoly->nX, myPoly->nY);
    365365
     
    572572
    573573        if (in->mask != NULL) {
    574             binnedMaskImage = psImageCopy(binnedMaskImage, in->mask, PS_TYPE_U8);
     574            binnedMaskImage = psImageCopy(binnedMaskImage, in->mask, PS_TYPE_IMAGE_MASK);
    575575            if (binnedMaskImage == NULL) {
    576576                psError(PS_ERR_UNKNOWN, false, "psImageCopy() returned NULL.  Returning in image.\n");
     
    581581            binnedMaskImage = psImageAlloc(binnedImage->numCols,
    582582                                           binnedImage->numRows,
    583                                            PS_TYPE_U8);
     583                                           PS_TYPE_IMAGE_MASK);
    584584            psImageInit(binnedMaskImage, 0);
    585585        }
     
    592592        binnedMaskImage = psImageAlloc(binnedImage->numCols,
    593593                                       binnedImage->numRows,
    594                                        PS_TYPE_U8);
     594                                       PS_TYPE_IMAGE_MASK);
    595595        psImageInit(binnedMaskImage, 0);
    596596    }
     
    625625                if (fabs(binnedImage->data.F32[row][col] - binnedMean) >
    626626                        (clipSD * binnedStdev)) {
    627                     binnedMaskImage->data.U8[row][col] = 1;
     627                    binnedMaskImage->data.PS_TYPE_IMAGE_MASK_DATA[row][col] = 1;
    628628                }
    629629            }
  • trunk/psModules/src/imcombine/pmImageCombine.c

    r12742 r21183  
    88 *  @author GLG, MHPCC
    99 *
    10  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2007-04-04 22:42:48 $
     10 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2009-01-27 06:39:38 $
    1212 *
    1313 *  XXX: pmRejectPixels() has a known bug with the pmImageTransform() call.
     
    1717 */
    1818
     19// XXX this is somewhat messy and unclear on the masking.
     20
    1921#ifdef HAVE_CONFIG_H
    2022#include <config.h>
     
    5355
    5456    buffer->pixels = psVectorAlloc(numImages, PS_TYPE_F32);
    55     buffer->masks = psVectorAlloc(numImages, PS_TYPE_MASK);
     57    buffer->masks = psVectorAlloc(numImages, PS_TYPE_VECTOR_MASK);
    5658    buffer->errors = psVectorAlloc(numImages, PS_TYPE_F32);
    5759    buffer->stats = psStatsAlloc(PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV);
     
    6769                          const psArray *errors, // Array of input error images
    6870                          const psArray *masks, // Array of input masks
    69                           psU32 maskVal, // Mask value
     71                          psImageMaskType maskVal, // Mask value
    7072                          psS32 numIter, // Number of rejection iterations
    7173                          psF32 sigmaClip, // Number of standard deviations at which to reject
     
    115117        if (masks) {
    116118            psImage *mask = masks->data[i]; // Mask of interest
    117             pixelMasks->data.U8[i] = mask->data.U8[y][x];
    118         }        // Set the pixel error data, if necessary
     119            pixelMasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal);
     120        }       
     121        // Set the pixel error data, if necessary
    119122        if (errors) {
    120123            psImage *error = errors->data[i]; // Error image of interest
     
    128131    for (int iter = 0; iter < numIter; iter++) {
    129132        // Combine all the pixels, using the specified stat.
    130         if (!psVectorStats(stats, pixelData, pixelErrors, pixelMasks, maskVal)) {
     133        if (!psVectorStats(stats, pixelData, pixelErrors, pixelMasks, 0xff)) {
    131134            combine->data.F32[y][x] = NAN;
    132135            psFree(buffer);
     
    148151        float stdev = stats->sampleStdev;
    149152        for (int i = 0; i < numImages; i++) {
    150             if (!(pixelMasks->data.U8[i] & maskVal) &&
     153            if (!(pixelMasks->data.PS_TYPE_VECTOR_MASK_DATA[i] & 0xff) &&
    151154                    fabs(pixelData->data.F32[i] - combinedPixel) > sigmaClip * stdev) {
    152155                // Reject pixel as questionable
    153156                numRejects++;
    154                 pixelMasks->data.U8[i] = maskVal;
     157                pixelMasks->data.PS_TYPE_IMAGE_MASK_DATA[i] = 0xff;
    155158                if (questionablePixels) {
    156159                    // Mark the pixel as questionable
     
    191194    const psArray *errors,              ///< Array of input error images
    192195    const psArray *masks,               ///< Array of input masks
    193     psU32 maskVal,                      ///< Mask value
     196    psImageMaskType maskVal,                      ///< Mask value
    194197    const psPixels *pixels,             ///< Pixels to combine
    195198    psS32 numIter,                      ///< Number of rejection iterations
     
    231234            psImage *mask  = masks->data[i];
    232235            PS_ASSERT_IMAGE_SIZE(mask, numCols, numRows, NULL);
    233             PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, NULL);
     236            PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, NULL);
    234237        }
    235238    }
     
    319322    int num = 0;
    320323    psVector *pixels = psVectorAlloc(8, PS_TYPE_F32); // Array of pixels
    321     psVector *mask = psVectorAlloc(8, PS_TYPE_U8); // Corresponding mask
     324    psVector *mask = psVectorAlloc(8, PS_TYPE_VECTOR_MASK); // Corresponding mask
    322325
    323326    // Get limits
     
    329332        for (int j = yMin; j <= yMax; j++) {
    330333            for (int i = xMin; i <= xMax; i++) {
    331                 if ((i != x) && (j != y) && (0 == imageMask->data.U8[j][i])) {
     334                if ((i != x) && (j != y) && (0 == imageMask->data.PS_TYPE_IMAGE_MASK_DATA[j][i])) {
    332335                    pixels->data.F32[num] = image->data.F32[j][i];
    333                     mask->data.U8[num] = 0;
     336                    mask->data.PS_TYPE_VECTOR_MASK_DATA[num] = 0;
    334337                    num++;
    335338                } else {
    336                     mask->data.U8[num] = 1;
     339                    mask->data.PS_TYPE_VECTOR_MASK_DATA[num] = 1;
    337340                }
    338341            }
     
    347350                if ((i != x) && (j != y)) {
    348351                    pixels->data.F32[num] = image->data.F32[j][i];
    349                     mask->data.U8[num] = 0;
     352                    mask->data.PS_TYPE_VECTOR_MASK_DATA[num] = 0;
    350353                    num++;
    351354                } else {
    352                     mask->data.U8[num] = 1;
     355                    mask->data.PS_TYPE_VECTOR_MASK_DATA[num] = 1;
    353356                }
    354357            }
     
    473476    for (psS32 i = 0 ; i < image->numRows ; i++) {
    474477        for (psS32 j = 0 ; j < image->numCols ; j++) {
    475             imgF32->data.F32[i][j] = (psF32) image->data.U8[i][j];
     478            imgF32->data.F32[i][j] = (psF32) image->data.PS_TYPE_IMAGE_MASK_DATA[i][j];
    476479        }
    477480    }
     
    518521            PS_ASSERT_IMAGE_NON_NULL(tmpMask, NULL);
    519522            PS_ASSERT_IMAGE_NON_EMPTY(tmpMask, NULL);
    520             PS_ASSERT_IMAGE_TYPE(tmpMask, PS_TYPE_F32, NULL);
     523            PS_ASSERT_IMAGE_TYPE(tmpMask, PS_TYPE_F32, NULL); // XXX really F32??
    521524            PS_ASSERT_IMAGES_SIZE_EQUAL(tmpImage, tmpMask, NULL);
    522525        }
     
    571574
    572575        //
    573         // Create a psU8 mask image from the list of cosmic pixels.
     576        // Create a psImageMaskType mask image from the list of cosmic pixels.
    574577        //
    575578        psImage *maskImage = NULL;
  • trunk/psModules/src/imcombine/pmPSFEnvelope.c

    r20999 r21183  
    223223    // *** readout->weight = (psImage*)psBinaryOp(NULL, readout->image, "*", psScalarAlloc(WEIGHT_FACTOR, PS_TYPE_F32));
    224224    readout->weight = (psImage*)psBinaryOp(NULL, readout->image, "+", psScalarAlloc(WEIGHT_VAL, PS_TYPE_F32));
    225     readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
     225    readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
    226226    psImageInit(readout->mask, 0);
    227227
  • trunk/psModules/src/imcombine/pmReadoutCombine.c

    r19086 r21183  
    105105
    106106    // note the mask value actually used
    107     psMaskType maskVal = params->maskVal; // The mask value
     107    psImageMaskType maskVal = params->maskVal; // The mask value
    108108    if (maskVal) {
    109109        psString comment = NULL;        // Comment to add to header
     
    247247    psF32 *pixelsData = pixels->data.F32; // Dereference pixels
    248248
    249     psVector *mask   = psVectorAlloc(inputs->n, PS_TYPE_U8); // Mask for stack
    250     psU8 *maskData = mask->data.U8;     // Dereference mask
     249    psVector *mask   = psVectorAlloc(inputs->n, PS_TYPE_VECTOR_MASK); // Mask for stack
     250    psVectorMaskType *maskData = mask->data.PS_TYPE_VECTOR_MASK_DATA;     // Dereference mask
    251251
    252252    psVector *weights = NULL;           // Stack of weights
     
    260260
    261261    float keepFrac = 1.0 - params->fracLow - params->fracHigh; // Fraction of pixels to keep
    262     psMaskType maskVal = params->maskVal; // The mask value
     262    psImageMaskType maskVal = params->maskVal; // The mask value
    263263
    264264    #ifndef PS_NO_TRACE
     
    278278    // Dereference output products
    279279    psF32 **outputImage  = output->image->data.F32; // Output image
    280     psU8  **outputMask   = output->mask->data.U8; // Output mask
     280    psImageMaskType **outputMask   = output->mask->data.PS_TYPE_IMAGE_MASK_DATA; // Output mask
    281281    psF32 **outputWeight = NULL; // Output weight map
    282282    if (output->weight) {
     
    303303
    304304            int numValid = 0;           // Number of valid pixels in the stack
    305             memset(maskData, 0, mask->n * sizeof(psU8)); // Reset the mask
     305            memset(maskData, 0, mask->n * sizeof(psVectorMaskType)); // Reset the mask
    306306            for (int r = 0; r < inputs->n; r++) {
    307307                pmReadout *readout = inputs->data[r]; // Input readout
     
    318318                // Check mask
    319319                psImage *roMask = readout->mask; // The mask image
    320                 if (roMask && roMask->data.U8[yIn][xIn] & maskVal) {
     320                if (roMask && roMask->data.PS_TYPE_IMAGE_MASK_DATA[yIn][xIn] & maskVal) {
    321321                    maskData[r] = 1;
    322322                    continue;
  • trunk/psModules/src/imcombine/pmReadoutCombine.h

    r18830 r21183  
    55 * @author Paul Price, IfA
    66 *
    7  * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2008-08-01 00:01:26 $
     7 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2009-01-27 06:39:38 $
    99 * Copyright 2004-2006 Institute for Astronomy, University of Hawaii
    1010 */
     
    2222typedef struct {
    2323    psStatsOptions combine;             ///< Statistic to use when performing the combination
    24     psMaskType maskVal;                 ///< Mask value
    25     psMaskType blank;                   ///< Mask value to give blank (i.e., no data) pixels
     24    psImageMaskType maskVal;            ///< Mask value
     25    psImageMaskType blank;            ///< Mask value to give blank (i.e., no data) pixels
    2626    int nKeep;                          ///< Mimimum number of pixels to keep
    2727    float fracHigh;                     ///< Fraction of high pixels to immediately throw
  • trunk/psModules/src/imcombine/pmStack.c

    r20712 r21183  
    88 *  @author GLG, MHPCC
    99 *
    10  *  @version $Revision: 1.45 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2008-11-13 03:50:30 $
     10 *  @version $Revision: 1.46 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2009-01-27 06:39:38 $
    1212 *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
    1313 *
     
    6363
    6464    buffer->pixels = psVectorAlloc(numImages, PS_TYPE_F32);
    65     buffer->masks = psVectorAlloc(numImages, PS_TYPE_MASK);
     65    buffer->masks = psVectorAlloc(numImages, PS_TYPE_VECTOR_MASK);
    6666    buffer->variances = psVectorAlloc(numImages, PS_TYPE_F32);
    6767    buffer->weights = psVectorAlloc(numImages, PS_TYPE_F32);
     
    143143    assert(!masks || values->n == masks->n);
    144144    assert(values->type.type == PS_TYPE_F32);
    145     assert(!masks || masks->type.type == PS_TYPE_MASK);
     145    assert(!masks || masks->type.type == PS_TYPE_VECTOR_MASK);
    146146    assert(sortBuffer && sortBuffer->nalloc >= values->n && sortBuffer->type.type == PS_TYPE_F32);
    147147
     
    149149    int num = 0;            // Number of valid values
    150150    for (int i = 0; i < values->n; i++) {
    151         if (!masks || !masks->data.PS_TYPE_MASK_DATA[i]) {
     151        if (!masks || !masks->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    152152            sortBuffer->data.F32[num++] = values->data.F32[i];
    153153        }
     
    215215                          const psVector *reject, // Indices of pixels to reject, or NULL
    216216                          int x, int y, // Coordinates of interest; frame of output image
    217                           psMaskType maskVal, // Value to mask
    218                           psMaskType bad, // Value to give bad pixels
     217                          psImageMaskType maskVal, // Value to mask
     218                          psImageMaskType bad, // Value to give bad pixels
    219219                          int numIter, // Number of rejection iterations
    220220                          float rej, // Number of standard deviations at which to reject
     
    258258        int xIn = x - data->readout->col0, yIn = y - data->readout->row0; // Coordinates on input readout
    259259        psImage *mask = data->readout->mask; // Mask of interest
    260         if (mask->data.PS_TYPE_MASK_DATA[yIn][xIn] & maskVal) {
     260        if (mask->data.PS_TYPE_IMAGE_MASK_DATA[yIn][xIn] & maskVal) {
    261261            continue;
    262262        }
     
    283283    // Default option is that the pixel is bad
    284284    float imageValue = NAN, varianceValue = NAN; // Value for combined image and variance map
    285     psMaskType maskValue = bad;         // Value for combined mask
     285    psImageMaskType maskValue = bad;         // Value for combined mask
    286286    switch (num) {
    287287      case 0:
     
    382382// Mask a pixel for inspection
    383383#define MASK_PIXEL_FOR_INSPECTION() \
    384     pixelMasks->data.PS_TYPE_MASK_DATA[j] = 0xff; \
     384    pixelMasks->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xff; \
    385385    combineInspect(inputs, x, y, pixelSources->data.U16[j]); \
    386386    numClipped++; \
     
    388388
    389389              for (int j = 0; j < num; j++) {
    390                   if (pixelMasks->data.PS_TYPE_MASK_DATA[j]) {
     390                  if (pixelMasks->data.PS_TYPE_VECTOR_MASK_DATA[j]) {
    391391                      continue;
    392392                  }
     
    408408
    409409    image->data.F32[y][x] = imageValue;
    410     mask->data.PS_TYPE_MASK_DATA[y][x] = maskValue;
     410    mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = maskValue;
    411411    if (variance) {
    412412        variance->data.F32[y][x] = varianceValue;
     
    438438    PS_ASSERT_IMAGE_TYPE(data->readout->image, PS_TYPE_F32, false);
    439439    PS_ASSERT_IMAGE_NON_NULL(data->readout->mask, false);
    440     PS_ASSERT_IMAGE_TYPE(data->readout->mask, PS_TYPE_MASK, false);
     440    PS_ASSERT_IMAGE_TYPE(data->readout->mask, PS_TYPE_IMAGE_MASK, false);
    441441    PS_ASSERT_IMAGES_SIZE_EQUAL(data->readout->image, data->readout->mask, false);
    442442    *numCols = data->readout->image->numCols;
     
    469469        PS_ASSERT_IMAGE_NON_NULL(data->readout->mask, false);
    470470        PS_ASSERT_IMAGE_TYPE(data->readout->image, PS_TYPE_F32, false);
    471         PS_ASSERT_IMAGE_TYPE(data->readout->mask, PS_TYPE_MASK, false);
     471        PS_ASSERT_IMAGE_TYPE(data->readout->mask, PS_TYPE_IMAGE_MASK, false);
    472472        PS_ASSERT_IMAGE_SIZE(data->readout->image, *numCols, *numRows, false);
    473473        PS_ASSERT_IMAGES_SIZE_EQUAL(data->readout->image, data->readout->mask, false);
     
    562562
    563563/// Stack input images
    564 bool pmStackCombine(pmReadout *combined, psArray *input, psMaskType maskVal, psMaskType bad,
     564bool pmStackCombine(pmReadout *combined, psArray *input, psImageMaskType maskVal, psImageMaskType bad,
    565565                    int kernelSize, int numIter, float rej, float sys,
    566566                    bool entire, bool useVariance, bool safe)
     
    587587        PS_ASSERT_IMAGE_TYPE(combined->image, PS_TYPE_F32, false);
    588588        PS_ASSERT_IMAGE_NON_NULL(combined->mask, false);
    589         PS_ASSERT_IMAGE_TYPE(combined->mask, PS_TYPE_MASK, false);
     589        PS_ASSERT_IMAGE_TYPE(combined->mask, PS_TYPE_IMAGE_MASK, false);
    590590        PS_ASSERT_IMAGES_SIZE_EQUAL(combined->image, combined->mask, false);
    591591    }
     
    698698        psImage *combinedMask = combined->mask; // Combined mask
    699699        if (!combinedMask) {
    700             combined->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
     700            combined->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
    701701            combinedMask = combined->mask;
    702702        }
  • trunk/psModules/src/imcombine/pmStack.h

    r20497 r21183  
    88 * @author GLG, MHPCC
    99 *
    10  * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    11  * @date $Date: 2008-11-01 02:59:33 $
     10 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     11 * @date $Date: 2009-01-27 06:39:38 $
    1212 *
    1313 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii
     
    4343bool pmStackCombine(pmReadout *combined,///< Combined readout (output)
    4444                    psArray *input,     ///< Input array of pmStackData
    45                     psMaskType maskVal, ///< Mask value of bad pixels
    46                     psMaskType bad,     ///< Mask value to give rejected pixels
     45                    psImageMaskType maskVal, ///< Mask value of bad pixels
     46                    psImageMaskType bad,     ///< Mask value to give rejected pixels
    4747                    int kernelSize,     ///< Half-size of the convolution kernel
    4848                    int numIter,        ///< Number of iterations
  • trunk/psModules/src/imcombine/pmStackReject.c

    r20838 r21183  
    6161        }
    6262
    63         int numBytes = (xMax - xMin) * PSELEMTYPE_SIZEOF(PS_TYPE_MASK); // Number of bytes to copy
     63        int numBytes = (xMax - xMin) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK); // Number of bytes to copy
    6464        psAssert(convolved->numCols - 2 * box == xMax - xMin, "Bad number of columns");
    6565        psAssert(convolved->numRows - 2 * box == yMax - yMin, "Bad number of rows");
    6666
    6767        for (int yTarget = yMin, ySource = box; yTarget < yMax; yTarget++, ySource++) {
    68             memcpy(&target->data.PS_TYPE_MASK_DATA[yTarget][xMin],
    69                    &convolved->data.PS_TYPE_MASK_DATA[ySource][box], numBytes);
     68            memcpy(&target->data.PS_TYPE_IMAGE_MASK_DATA[yTarget][xMin],
     69                   &convolved->data.PS_TYPE_IMAGE_MASK_DATA[ySource][box], numBytes);
    7070        }
    7171        psFree(convolved);
    7272    } else {
    7373        // Just copy over
    74         int numBytes = (xMax - xMin) * PSELEMTYPE_SIZEOF(PS_TYPE_MASK); // Number of bytes to copy
     74        int numBytes = (xMax - xMin) * PSELEMTYPE_SIZEOF(PS_TYPE_IMAGE_MASK); // Number of bytes to copy
    7575        for (int yTarget = yMin; yTarget < yMax; yTarget++) {
    76             memcpy(&target->data.PS_TYPE_MASK_DATA[yTarget][xMin],
    77                    &source->data.PS_TYPE_MASK_DATA[yTarget][xMin], numBytes);
     76            memcpy(&target->data.PS_TYPE_IMAGE_MASK_DATA[yTarget][xMin],
     77                   &source->data.PS_TYPE_IMAGE_MASK_DATA[yTarget][xMin], numBytes);
    7878        }
    7979    }
     
    262262    bool oldThreads = psImageConvolveSetThreads(false); // Old value of threading for psImageColvolve
    263263
    264     psImage *target = psImageRecycle(convolved, numCols, numRows, PS_TYPE_MASK); // Grown image
     264    psImage *target = psImageRecycle(convolved, numCols, numRows, PS_TYPE_IMAGE_MASK); // Grown image
    265265    psImageInit(target, 0);
    266266    if (threaded) {
  • trunk/psModules/src/imcombine/pmSubtraction.c

    r20838 r21183  
    246246                        psImage *image, // Image to convolve
    247247                        psImage *mask, // Mask image
    248                         psMaskType maskVal, // Value to mask
     248                        psImageMaskType maskVal, // Value to mask
    249249                        const psKernel *kernel, // Kernel by which to convolve
    250250                        psRegion region,// Region of interest
     
    291291                              psImage *sys, // Systematic error image
    292292                              psImage *mask, // Mask image
    293                               psMaskType maskVal, // Value to mask
     293                              psImageMaskType maskVal, // Value to mask
    294294                              const psKernel *kernel, // Kernel by which to convolve
    295295                              psRegion region,// Region of interest
     
    373373                                  float background, // Background value to apply
    374374                                  psRegion region, // Region to convolve
    375                                   psMaskType maskBad, // Value to give bad pixels
    376                                   psMaskType maskPoor, // Value to give poor pixels
     375                                  psImageMaskType maskBad, // Value to give bad pixels
     376                                  psImageMaskType maskPoor, // Value to give poor pixels
    377377                                  float poorFrac, // Fraction for "poor"
    378378                                  bool useFFT,  // Use FFT to convolve?
     
    385385    }
    386386
    387     psMaskType subBad;                  // Bad pixels in subtraction mask
    388     psMaskType subConvBad;              // Bad pixels in subtraction mask when convolving
    389     psMaskType subConvPoor;             // Poor pixels in subtraction mask when convolving
     387    psImageMaskType subBad;                  // Bad pixels in subtraction mask
     388    psImageMaskType subConvBad;              // Bad pixels in subtraction mask when convolving
     389    psImageMaskType subConvPoor;             // Poor pixels in subtraction mask when convolving
    390390    if (kernels->mode == PM_SUBTRACTION_MODE_1 || (kernels->mode == PM_SUBTRACTION_MODE_DUAL && !wantDual)) {
    391391        subBad = PM_SUBTRACTION_MASK_BAD_1;
     
    437437            for (int yTarget = rowMin, ySource = box; yTarget < rowMax; yTarget++, ySource++) {
    438438                // Dereference images
    439                 psMaskType *target = &convMask->data.PS_TYPE_MASK_DATA[yTarget][colMin]; // Target values
    440                 psMaskType *source = &convolved->data.PS_TYPE_MASK_DATA[ySource][box]; // Source values
     439                psImageMaskType *target = &convMask->data.PS_TYPE_IMAGE_MASK_DATA[yTarget][colMin]; // Target values
     440                psImageMaskType *source = &convolved->data.PS_TYPE_IMAGE_MASK_DATA[ySource][box]; // Source values
    441441                for (int xTarget = colMin; xTarget < colMax; xTarget++, target++, source++) {
    442442                    if (*source & subConvBad) {
     
    783783    PS_ASSERT_VECTOR_TYPE(deviations, PS_TYPE_F32, -1);
    784784    PS_ASSERT_IMAGE_NON_EMPTY(subMask, -1);
    785     PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_MASK, -1);
     785    PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_IMAGE_MASK, -1);
    786786
    787787    // I used to measure the rms deviation about zero, and use that as the sigma against which to clip, but
     
    794794
    795795    int numStamps = 0;                  // Number of used stamps
    796     psVector *mask = psVectorAlloc(stamps->num, PS_TYPE_MASK); // Mask, for statistics
     796    psVector *mask = psVectorAlloc(stamps->num, PS_TYPE_VECTOR_MASK); // Mask, for statistics
    797797    psVectorInit(mask, 0);
    798798    for (int i = 0; i < stamps->num; i++) {
    799799        pmSubtractionStamp *stamp = stamps->stamps->data[i]; // Stamp of interest
    800800        if (stamp->status != PM_SUBTRACTION_STAMP_USED) {
    801             mask->data.PS_TYPE_MASK_DATA[i] = 0xff;
     801            mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff;
    802802            continue;
    803803        }
     
    869869                for (int y = stamp->y - footprint; y <= stamp->y + footprint; y++) {
    870870                    for (int x = stamp->x - footprint; x <= stamp->x + footprint; x++) {
    871                         subMask->data.PS_TYPE_MASK_DATA[y][x] |= PM_SUBTRACTION_MASK_REJ;
     871                        subMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= PM_SUBTRACTION_MASK_REJ;
    872872                    }
    873873                }
     
    997997                                     psImage *sys1, psImage *sys2, // Systematic error images
    998998                                     psImage *subMask, // Input subtraction mask
    999                                      psMaskType maskBad, // Mask value to give bad pixels
    1000                                      psMaskType maskPoor, // Mask value to give poor pixels
     999                                     psImageMaskType maskBad, // Mask value to give bad pixels
     1000                                     psImageMaskType maskPoor, // Mask value to give poor pixels
    10011001                                     float poorFrac, // Fraction for "poor"
    10021002                                     const psRegion *region, // Patch to convolve
     
    10351035
    10361036    if ((kernels->mode == PM_SUBTRACTION_MODE_1 || kernels->mode == PM_SUBTRACTION_MODE_DUAL) && ro1->mask) {
    1037         psMaskType **target = convMask->data.PS_TYPE_MASK_DATA; // Target mask
    1038         psMaskType **source = ro1->mask->data.PS_TYPE_MASK_DATA; // Source mask
     1037        psImageMaskType **target = convMask->data.PS_TYPE_IMAGE_MASK_DATA; // Target mask
     1038        psImageMaskType **source = ro1->mask->data.PS_TYPE_IMAGE_MASK_DATA; // Source mask
    10391039
    10401040        for (int y = yMin; y < yMax; y++) {
     
    10451045    }
    10461046    if ((kernels->mode == PM_SUBTRACTION_MODE_2 || kernels->mode == PM_SUBTRACTION_MODE_DUAL) && ro2->mask) {
    1047         psMaskType **target = convMask->data.PS_TYPE_MASK_DATA; // Target mask
    1048         psMaskType **source = ro2->mask->data.PS_TYPE_MASK_DATA; // Source mask
     1047        psImageMaskType **target = convMask->data.PS_TYPE_IMAGE_MASK_DATA; // Target mask
     1048        psImageMaskType **source = ro2->mask->data.PS_TYPE_IMAGE_MASK_DATA; // Source mask
    10491049
    10501050        for (int y = yMin; y < yMax; y++) {
     
    10751075    psImage *sys2 = args->data[10]; // Systematic error image 2
    10761076    psImage *subMask = args->data[11]; // Subtraction mask
    1077     psMaskType maskBad = PS_SCALAR_VALUE(args->data[12], U8); // Output mask value for bad pixels
    1078     psMaskType maskPoor = PS_SCALAR_VALUE(args->data[13], U8); // Output mask value for poor pixels
     1077    psImageMaskType maskBad = PS_SCALAR_VALUE(args->data[12], PS_TYPE_IMAGE_MASK_DATA); // Output mask value for bad pixels
     1078    psImageMaskType maskPoor = PS_SCALAR_VALUE(args->data[13], PS_TYPE_IMAGE_MASK_DATA); // Output mask value for poor pixels
    10791079    float poorFrac = PS_SCALAR_VALUE(args->data[14], F32); // Fraction for "poor"
    10801080    const psRegion *region = args->data[15]; // Region to convolve
    10811081    const pmSubtractionKernels *kernels = args->data[16]; // Kernels
    1082     bool doBG = PS_SCALAR_VALUE(args->data[17], U8); // Do background subtraction?
    1083     bool useFFT = PS_SCALAR_VALUE(args->data[18], U8); // Use FFT for convolution?
     1082    bool doBG = PS_SCALAR_VALUE(args->data[17], PS_TYPE_IMAGE_MASK_DATA); // Do background subtraction?
     1083    bool useFFT = PS_SCALAR_VALUE(args->data[18], PS_TYPE_IMAGE_MASK_DATA); // Use FFT for convolution?
    10841084
    10851085    return subtractionConvolvePatch(numCols, numRows, x0, y0, out1, out2, convMask, ro1, ro2, sys1, sys2,
     
    10881088
    10891089bool pmSubtractionConvolve(pmReadout *out1, pmReadout *out2, const pmReadout *ro1, const pmReadout *ro2,
    1090                            psImage *subMask, int stride, psMaskType maskBad, psMaskType maskPoor,
     1090                           psImage *subMask, int stride, psImageMaskType maskBad, psImageMaskType maskPoor,
    10911091                           float poorFrac, float sysError, const psRegion *region,
    10921092                           const pmSubtractionKernels *kernels, bool doBG, bool useFFT)
     
    11211121    if (subMask) {
    11221122        PS_ASSERT_IMAGE_NON_NULL(subMask, false);
    1123         PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_MASK, false);
     1123        PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_IMAGE_MASK, false);
    11241124        PS_ASSERT_IMAGE_SIZE(subMask, numCols, numRows, false);
    11251125    }
     
    11821182        if (kernels->mode == PM_SUBTRACTION_MODE_1 || kernels->mode == PM_SUBTRACTION_MODE_DUAL) {
    11831183            if (!out1->mask) {
    1184                 out1->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
     1184                out1->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
    11851185            }
    11861186            convMask = out1->mask;
     
    11941194            } else {
    11951195                if (!out2->mask) {
    1196                     out2->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
     1196                    out2->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
    11971197                }
    11981198                convMask = out2->mask;
     
    12851285                    psMutexUnlock(subMask);
    12861286                }
    1287                 PS_ARRAY_ADD_SCALAR(args, maskBad, PS_TYPE_U8);
    1288                 PS_ARRAY_ADD_SCALAR(args, maskPoor, PS_TYPE_U8);
     1287                PS_ARRAY_ADD_SCALAR(args, maskBad, PS_TYPE_IMAGE_MASK);
     1288                PS_ARRAY_ADD_SCALAR(args, maskPoor, PS_TYPE_IMAGE_MASK);
    12891289                PS_ARRAY_ADD_SCALAR(args, poorFrac, PS_TYPE_F32);
    12901290                psArrayAdd(args, 1, subRegion);
  • trunk/psModules/src/imcombine/pmSubtraction.h

    r20568 r21183  
    66 * @author GLG, MHPCC
    77 *
    8  * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
    9  * @date $Date: 2008-11-07 00:03:18 $
     8 * @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
     9 * @date $Date: 2009-01-27 06:39:38 $
    1010 * Copyright 2004-207 Institute for Astronomy, University of Hawaii
    1111 */
     
    104104                           psImage *subMask, ///< Subtraction mask (or NULL)
    105105                           int stride,  ///< Size of convolution patches
    106                            psMaskType maskBad, ///< Mask value to give bad pixels
    107                            psMaskType maskPoor, ///< Mask value to give poor pixels
     106                           psImageMaskType maskBad, ///< Mask value to give bad pixels
     107                           psImageMaskType maskPoor, ///< Mask value to give poor pixels
    108108                           float poorFrac, ///< Fraction for "poor"
    109109                           float sysError, ///< Relative systematic error
  • trunk/psModules/src/imcombine/pmSubtractionMask.c

    r20832 r21183  
    2020                             psImage *weight, // Weight map to mark as blank (or NULL)
    2121                             int x, int y, // Coordinates to mark blank
    22                              psMaskType blank // Blank mask value
     22                             psImageMaskType blank // Blank mask value
    2323    )
    2424{
    2525    image->data.F32[y][x] = NAN;
    2626    if (mask) {
    27         mask->data.PS_TYPE_MASK_DATA[y][x] |= blank;
     27        mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= blank;
    2828    }
    2929    if (weight) {
     
    3737//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    3838
    39 psImage *pmSubtractionMask(const psImage *mask1, const psImage *mask2, psMaskType maskVal,
     39psImage *pmSubtractionMask(const psImage *mask1, const psImage *mask2, psImageMaskType maskVal,
    4040                           int size, int footprint, float badFrac, bool useFFT)
    4141{
    4242    PS_ASSERT_IMAGE_NON_NULL(mask1, NULL);
    43     PS_ASSERT_IMAGE_TYPE(mask1, PS_TYPE_MASK, NULL);
     43    PS_ASSERT_IMAGE_TYPE(mask1, PS_TYPE_IMAGE_MASK, NULL);
    4444    if (mask2) {
    4545        PS_ASSERT_IMAGE_NON_NULL(mask2, NULL);
    46         PS_ASSERT_IMAGE_TYPE(mask2, PS_TYPE_MASK, NULL);
     46        PS_ASSERT_IMAGE_TYPE(mask2, PS_TYPE_IMAGE_MASK, NULL);
    4747        PS_ASSERT_IMAGES_SIZE_EQUAL(mask2, mask1, NULL);
    4848    }
     
    5757
    5858    // Dereference inputs for convenience
    59     psMaskType **data1 = mask1->data.PS_TYPE_MASK_DATA;
    60     psMaskType **data2 = NULL;
     59    psImageMaskType **data1 = mask1->data.PS_TYPE_IMAGE_MASK_DATA;
     60    psImageMaskType **data2 = NULL;
    6161    if (mask2) {
    62         data2 = mask2->data.PS_TYPE_MASK_DATA;
     62        data2 = mask2->data.PS_TYPE_IMAGE_MASK_DATA;
    6363    }
    6464
     
    8686
    8787    // Worried about the masks for bad pixels and bad stamps colliding, so make our own mask
    88     psImage *mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK); // The global mask
     88    psImage *mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); // The global mask
    8989    psImageInit(mask, 0);
    90     psMaskType **maskData = mask->data.PS_TYPE_MASK_DATA; // Dereference for convenience
     90    psImageMaskType **maskData = mask->data.PS_TYPE_IMAGE_MASK_DATA; // Dereference for convenience
    9191
    9292    // Block out a border around the edge of the image
     
    161161
    162162bool pmSubtractionBorder(psImage *image, psImage *weight, psImage *mask,
    163                          int size, psMaskType blank)
     163                         int size, psImageMaskType blank)
    164164{
    165165    PS_ASSERT_IMAGE_NON_NULL(image, false);
     
    168168        PS_ASSERT_IMAGE_NON_NULL(mask, false);
    169169        PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, false);
    170         PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, false);
     170        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false);
    171171    }
    172172    if (weight) {
     
    211211    }
    212212    PS_ASSERT_IMAGE_NON_NULL(mask, false);
    213     PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, false);
     213    PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_IMAGE_MASK, false);
    214214    PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, false);
    215215
     
    233233
    234234    int numCols = image->numCols, numRows = image->numRows; // Size of image
    235     psMaskType **maskData = mask->data.PS_TYPE_MASK_DATA; // Dereference mask
     235    psImageMaskType **maskData = mask->data.PS_TYPE_IMAGE_MASK_DATA; // Dereference mask
    236236
    237237    for (int y = 0; y < numRows; y++) {
  • trunk/psModules/src/imcombine/pmSubtractionMask.h

    r17729 r21183  
    77psImage *pmSubtractionMask(const psImage *refMask, ///< Mask for the reference image (will be convolved)
    88                           const psImage *inMask, ///< Mask for the input image, or NULL
    9                            psMaskType maskVal, ///< Value to mask out
     9                           psImageMaskType maskVal, ///< Value to mask out
    1010                           int size, ///< Half-size of the kernel (pmSubtractionKernels.size)
    1111                           int footprint, ///< Half-size of the kernel footprint
     
    1919                         psImage *mask, ///< Mask (or NULL)
    2020                         int size,      ///< Kernel half-size
    21                          psMaskType blank ///< Mask value for blank regions
     21                         psImageMaskType blank ///< Mask value for blank regions
    2222    );
    2323
  • trunk/psModules/src/imcombine/pmSubtractionMatch.c

    r21149 r21183  
    9898                        int inner, int ringsOrder, int binning, float penalty,
    9999                        bool optimum, const psVector *optFWHMs, int optOrder, float optThreshold,
    100                         int iter, float rej, float sysError, psMaskType maskVal, psMaskType maskBad,
    101                         psMaskType maskPoor, float poorFrac, float badFrac, pmSubtractionMode subMode)
     100                        int iter, float rej, float sysError, psImageMaskType maskVal, psImageMaskType maskBad,
     101                        psImageMaskType maskPoor, float poorFrac, float badFrac, pmSubtractionMode subMode)
    102102{
    103103    if (subMode != PM_SUBTRACTION_MODE_2) {
     
    565565    if (width1 == 0 || width2 == 0) {
    566566        ratios->data.F32[index] = NAN;
    567         mask->data.PS_TYPE_MASK_DATA[index] = 0xff;
     567        mask->data.PS_TYPE_IMAGE_MASK_DATA[index] = 0xff;
    568568    } else {
    569569        ratios->data.F32[index] = (float)width1 / (float)width2;
    570         mask->data.PS_TYPE_MASK_DATA[index] = 0;
     570        mask->data.PS_TYPE_IMAGE_MASK_DATA[index] = 0;
    571571        psTrace("psModules.imcombine", 3, "Stamp %d (%.1f,%.1f) widths: %d, %d --> %f\n",
    572572                index, stamp->x, stamp->y, width1, width2, ratios->data.F32[index]);
     
    596596    PM_ASSERT_SUBTRACTION_STAMP_LIST_NON_NULL(stamps, PM_SUBTRACTION_MODE_ERR);
    597597
    598     psVector *mask = psVectorAlloc(stamps->num, PS_TYPE_MASK); // Mask for stamps
     598    psVector *mask = psVectorAlloc(stamps->num, PS_TYPE_VECTOR_MASK); // Mask for stamps
    599599    psVector *ratios = psVectorAlloc(stamps->num, PS_TYPE_F32); // Ratios of widths
    600600
     
    624624        pmSubtractionStamp *stamp = stamps->stamps->data[i]; // Stamp of interest
    625625        if (stamp->status != PM_SUBTRACTION_STAMP_CALCULATE && stamp->status != PM_SUBTRACTION_STAMP_USED) {
    626             mask->data.PS_TYPE_MASK_DATA[i] = 0xff;
     626            mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff;
    627627            continue;
    628628        }
  • trunk/psModules/src/imcombine/pmSubtractionMatch.h

    r20568 r21183  
    4040                        float rej,      ///< Rejection threshold
    4141                        float sysError, ///< Relative systematic error
    42                         psMaskType maskVal, ///< Value to mask for input
    43                         psMaskType maskBad, ///< Mask for output bad pixels
    44                         psMaskType maskPoor, ///< Mask for output poor pixels
     42                        psImageMaskType maskVal, ///< Value to mask for input
     43                        psImageMaskType maskBad, ///< Mask for output bad pixels
     44                        psImageMaskType maskPoor, ///< Mask for output poor pixels
    4545                        float poorFrac, ///< Fraction for "poor"
    4646                        float badFrac,   ///< Maximum fraction of bad input pixels to accept
  • trunk/psModules/src/imcombine/pmSubtractionStamps.c

    r20937 r21183  
    9898
    9999    // Determine mask value
    100     psMaskType maskVal = PM_SUBTRACTION_MASK_BORDER | PM_SUBTRACTION_MASK_BAD_1 | PM_SUBTRACTION_MASK_BAD_2;
     100    psImageMaskType maskVal = PM_SUBTRACTION_MASK_BORDER | PM_SUBTRACTION_MASK_BAD_1 | PM_SUBTRACTION_MASK_BAD_2;
    101101    switch (mode) {
    102102      case PM_SUBTRACTION_MODE_1:
     
    115115
    116116    // Check the immediate pixel
    117     if (clean && (mask->data.PS_TYPE_MASK_DATA[y][x] & (maskVal | PM_SUBTRACTION_MASK_REJ))) {
     117    if (clean && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & (maskVal | PM_SUBTRACTION_MASK_REJ))) {
    118118        clean = false;
    119119    }
     
    126126        for (int j = yMin; j <= yMax; j++) {
    127127            for (int i = xMin; i <= xMax; i++) {
    128                 if (mask->data.PS_TYPE_MASK_DATA[j][i] & maskVal) {
     128                if (mask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] & maskVal) {
    129129                    clean = false;
    130130                    goto CHECK_STAMP_MASK_DONE;
     
    139139        for (int j = yMin; j <= yMax; j++) {
    140140            for (int i = xMin; i <= xMax; i++) {
    141                 mask->data.PS_TYPE_MASK_DATA[j][i] |= PM_SUBTRACTION_MASK_REJ;
     141                mask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= PM_SUBTRACTION_MASK_REJ;
    142142            }
    143143        }
     
    235235        PS_ASSERT_IMAGE_NON_NULL(subMask, NULL);
    236236        PS_ASSERT_IMAGES_SIZE_EQUAL(image, subMask, NULL);
    237         PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_MASK, NULL);
     237        PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_IMAGE_MASK, NULL);
    238238    }
    239239    PS_ASSERT_INT_NONNEGATIVE(footprint, NULL);
     
    377377    if (subMask) {
    378378        PS_ASSERT_IMAGE_NON_NULL(subMask, NULL);
    379         PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_MASK, NULL);
     379        PS_ASSERT_IMAGE_TYPE(subMask, PS_TYPE_IMAGE_MASK, NULL);
    380380        if (image) {
    381381            PS_ASSERT_IMAGE_NON_NULL(image, NULL);
  • trunk/psModules/src/objects/pmFootprintArrayGrow.c

    r20937 r21183  
    33 * @author RHL, Princeton & IfA; EAM, IfA
    44 *
    5  * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    6  * @date $Date: 2008-12-08 02:51:14 $
     5 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     6 * @date $Date: 2009-01-27 06:39:38 $
    77 * Copyright 2006 Institute for Astronomy, University of Hawaii
    88 */
     
    4545    // Use a separable convolution: should be faster
    4646    idImage = (psImage*)psBinaryOp(idImage, idImage, "MIN", psScalarAlloc(1, PS_TYPE_S32));
    47     psImage *idImageMask = psImageCopy(NULL, idImage, PS_TYPE_MASK); // Image with 1 = object
     47    psImage *idImageMask = psImageCopy(NULL, idImage, PS_TYPE_IMAGE_MASK); // Image with 1 = object
    4848    psImage *grownIdImage = psImageConvolveMask(NULL, idImageMask, 0x01, 0x01, -r, r, -r, r); // Grown mask
    4949    if (!grownIdImage) {
  • trunk/psModules/src/objects/pmFootprintFindAtPoint.c

    r20937 r21183  
    44 * @author RHL, Princeton & IfA; EAM, IfA
    55 *
    6  * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2008-12-08 02:51:14 $
     6 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2009-01-27 06:39:38 $
    88 * Copyright 2006 Institute for Astronomy, University of Hawaii
    99 */
     
    7777   
    7878    if (mask != NULL) {                 // remember that we've detected these pixels
    79         psMaskType *mpix = &mask->data.PS_TYPE_MASK_DATA[span->y - mask->row0][span->x0 - mask->col0];
     79        psImageMaskType *mpix = &mask->data.PS_TYPE_IMAGE_MASK_DATA[span->y - mask->row0][span->x0 - mask->col0];
    8080
    8181        for (int i = 0; i <= span->x1 - span->x0; i++) {
     
    143143    psF32 *imgRowF32 = NULL;            // row pointer if F32
    144144    psS32 *imgRowS32 = NULL;            //  "   "   "  "  !F32
    145     psMaskType *maskRow = NULL;         //  masks's row pointer
     145    psImageMaskType *maskRow = NULL;            //  masks's row pointer
    146146   
    147147    const int row0 = img->row0;
     
    186186        imgRowF32 = img->data.F32[i];   // only one of
    187187        imgRowS32 = img->data.S32[i];   //      these is valid!
    188         maskRow = mask->data.PS_TYPE_MASK_DATA[i];
     188        maskRow = mask->data.PS_TYPE_IMAGE_MASK_DATA[i];
    189189        //
    190190        // Search left from the pixel diagonally to the left of (i - di, x0). If there's
     
    354354 * looking for the rest of the pmFootprint.  These are generally set from peaks.
    355355 */
    356    psImage *mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
     356   psImage *mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
    357357   P_PSIMAGE_SET_ROW0(mask, row0);
    358358   P_PSIMAGE_SET_COL0(mask, col0);
     
    365365       for (int i = 0; i < peaks->n; i++) {
    366366           pmPeak *peak = peaks->data[i];
    367            mask->data.PS_TYPE_MASK_DATA[peak->y - mask->row0][peak->x - mask->col0] |= PM_SSPAN_STOP;
     367           mask->data.PS_TYPE_IMAGE_MASK_DATA[peak->y - mask->row0][peak->x - mask->col0] |= PM_SSPAN_STOP;
    368368       }
    369369   }
     
    375375   imgRowF32 = img->data.F32[row];      // only one of
    376376   imgRowS32 = img->data.S32[row];      //      these is valid!
    377    psMaskType *maskRow = mask->data.PS_TYPE_MASK_DATA[row];
     377   psImageMaskType *maskRow = mask->data.PS_TYPE_IMAGE_MASK_DATA[row];
    378378   {
    379379       int i;
  • trunk/psModules/src/objects/pmGrowthCurveGenerate.c

    r20937 r21183  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2008-12-08 02:51:14 $
     7 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2009-01-27 06:39:38 $
    99 *
    1010 *  Copyright 2004 Institute for Astronomy, University of Hawaii
     
    4141#include "pmErrorCodes.h"
    4242
    43 pmGrowthCurve *pmGrowthCurveForPosition (psImage *image, pmPSF *psf, bool ignore, psMaskType maskVal, psMaskType markVal, float xc, float yc);
     43pmGrowthCurve *pmGrowthCurveForPosition (psImage *image, pmPSF *psf, bool ignore, psImageMaskType maskVal, psImageMaskType markVal, float xc, float yc);
    4444
    4545/*****************************************************************************/
     
    4848
    4949// we generate the growth curve for the center of the image with the specified psf model
    50 bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, psMaskType maskVal, psMaskType markVal)
     50bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, psImageMaskType maskVal, psImageMaskType markVal)
    5151{
    5252    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    119119}
    120120
    121 pmGrowthCurve *pmGrowthCurveForPosition (psImage *image, pmPSF *psf, bool ignore, psMaskType maskVal, psMaskType markVal, float xc, float yc) {
     121pmGrowthCurve *pmGrowthCurveForPosition (psImage *image, pmPSF *psf, bool ignore, psImageMaskType maskVal, psImageMaskType markVal, float xc, float yc) {
    122122
    123123    float fitMag, apMag;
     
    162162    psImage *view = psImageSubset (image, region);
    163163    psImage *pixels = psImageCopy (NULL, view, PS_TYPE_F32);
    164     psImage *mask = psImageCopy (NULL, view, PS_TYPE_U8);
     164    psImage *mask = psImageCopy (NULL, view, PS_TYPE_IMAGE_MASK);
    165165
    166166    psImageInit (pixels, 0.0);
     
    189189            return NULL;
    190190        }
    191         psImageKeepCircle (mask, xc, yc, radius, "AND", PS_NOT_U8(markVal));
     191        psImageKeepCircle (mask, xc, yc, radius, "AND", PS_NOT_IMAGE_MASK(markVal));
    192192
    193193        // the 'ignore' mode is for testing
  • trunk/psModules/src/objects/pmModel.c

    r20592 r21183  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2008-11-09 00:28:18 $
     8 *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-01-27 06:39:38 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    172172                          pmModelOpMode mode,
    173173                          bool add,
    174                           psMaskType maskVal,
     174                          psImageMaskType maskVal,
    175175                          int dx,
    176176                          int dy
     
    229229    psF32 **Rx = NULL;
    230230    psF32 **Ry = NULL;
    231     psU8 **Rm = NULL;
     231    psImageMaskType **Rm = NULL;
    232232
    233233    if (model->residuals) {
     
    237237        Rx = (model->residuals->Rx)   ? model->residuals->Rx->data.F32 : NULL;
    238238        Ry = (model->residuals->Ry)   ? model->residuals->Ry->data.F32 : NULL;
    239         Rm = (model->residuals->mask) ? model->residuals->mask->data.U8 : NULL;
     239        Rm = (model->residuals->mask) ? model->residuals->mask->data.PS_TYPE_IMAGE_MASK_DATA : NULL;
    240240        if (Ro) {
    241241            NX = model->residuals->Ro->numCols;
     
    249249    for (psS32 iy = 0; iy < image->numRows; iy++) {
    250250        for (psS32 ix = 0; ix < image->numCols; ix++) {
    251             if ((mask != NULL) && (mask->data.U8[iy][ix] & maskVal))
     251            if ((mask != NULL) && (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] & maskVal))
    252252                continue;
    253253
     
    351351                pmModel *model,
    352352                pmModelOpMode mode,
    353                 psMaskType maskVal)
     353                psImageMaskType maskVal)
    354354{
    355355    psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     
    365365                pmModel *model,
    366366                pmModelOpMode mode,
    367                 psMaskType maskVal)
     367                psImageMaskType maskVal)
    368368{
    369369    psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     
    379379                          pmModel *model,
    380380                          pmModelOpMode mode,
    381                           psMaskType maskVal,
     381                          psImageMaskType maskVal,
    382382                          int dx,
    383383                          int dy)
     
    395395                          pmModel *model,
    396396                          pmModelOpMode mode,
    397                           psMaskType maskVal,
     397                          psImageMaskType maskVal,
    398398                          int dx,
    399399                          int dy)
  • trunk/psModules/src/objects/pmModel.h

    r20945 r21183  
    55 * @author EAM, IfA
    66 *
    7  * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2008-12-09 21:16:09 $
     7 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2009-01-27 06:39:38 $
    99 *
    1010 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    150150    pmModel *model,                     ///< The input pmModel
    151151    pmModelOpMode mode,                 ///< mode to control how the model is added into the image
    152     psMaskType maskVal                  ///< Value to mask
     152    psImageMaskType maskVal             ///< Value to mask
    153153);
    154154
     
    168168    pmModel *model,                     ///< The input pmModel
    169169    pmModelOpMode mode,                 ///< mode to control how the model is added into the image
    170     psMaskType maskVal                  ///< Value to mask
     170    psImageMaskType maskVal             ///< Value to mask
    171171);
    172172
     
    175175                          pmModel *model,
    176176                          pmModelOpMode mode,
    177                           psMaskType maskVal,
     177                          psImageMaskType maskVal,
    178178                          int dx,
    179179                          int dy);
     
    183183                          pmModel *model,
    184184                          pmModelOpMode mode,
    185                           psMaskType maskVal,
     185                          psImageMaskType maskVal,
    186186                          int dx,
    187187                          int dy);
  • trunk/psModules/src/objects/pmPSF.h

    r20945 r21183  
    66 * @author EAM, IfA
    77 *
    8  * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    9  * @date $Date: 2008-12-09 21:16:09 $
     8 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     9 * @date $Date: 2009-01-27 06:39:38 $
    1010 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1111 */
     
    102102double pmPSF_SXYtoModel (psF32 *fittedPar);
    103103
    104 bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, psMaskType maskVal, psMaskType mark);
     104bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, psImageMaskType maskVal, psImageMaskType mark);
    105105pmPSF *pmPSFBuildSimple (char *typeName, float sxx, float syy, float sxy, ...);
    106106
  • trunk/psModules/src/objects/pmPSF_IO.c

    r20937 r21183  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2008-12-08 02:51:14 $
     8 *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-01-27 06:39:38 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    871871            psFitsReadImageBuffer(psf->residuals->Ry, file->fits, fullImage, 2); // Desired pixels
    872872        }
     873        // XXX notice that we are not saving the resid->mask
    873874    }
    874875
  • trunk/psModules/src/objects/pmPSFtry.c

    r21173 r21183  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.68 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2009-01-27 00:01:33 $
    9  *
     7 *  @version $Revision: 1.69 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2009-01-27 06:39:38 $
    109 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1110 *
     
    115114    test->metricErr = psVectorAlloc (sources->n, PS_TYPE_F32);
    116115    test->fitMag    = psVectorAlloc (sources->n, PS_TYPE_F32);
    117     test->mask      = psVectorAlloc (sources->n, PS_TYPE_U8);
     116    test->mask      = psVectorAlloc (sources->n, PS_TYPE_VECTOR_MASK);
    118117
    119118    psVectorInit (test->mask,        0);
     
    148147
    149148// generate a pmPSFtry with a copy of the test PSF sources
    150 pmPSFtry *pmPSFtryModel (const psArray *sources, const char *modelName, pmPSFOptions *options, psMaskType maskVal, psMaskType markVal)
     149pmPSFtry *pmPSFtryModel (const psArray *sources, const char *modelName, pmPSFOptions *options, psImageMaskType maskVal, psImageMaskType markVal)
    151150{
    152151    bool status;
     
    176175        pmSource *source = psfTry->sources->data[i];
    177176        if (!source->moments) {
    178             psfTry->mask->data.U8[i] = PSFTRY_MASK_EXT_FAIL;
     177            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL;
    179178            continue;
    180179        }
    181180        if (!source->moments->nPixels) {
    182             psfTry->mask->data.U8[i] = PSFTRY_MASK_EXT_FAIL;
     181            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL;
    183182            continue;
    184183        }
     
    186185        source->modelEXT = pmSourceModelGuess (source, psfTry->psf->type);
    187186        if (source->modelEXT == NULL) {
    188             psfTry->mask->data.U8[i] = PSFTRY_MASK_EXT_FAIL;
     187            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL;
    189188            psTrace ("psModules.objects", 4, "masking %d (%d,%d) : failed to generate model guess\n", i, source->peak->x, source->peak->y);
    190189            continue;
     
    198197
    199198        // clear object mask to define valid pixels
    200         psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_U8(markVal));
     199        psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_IMAGE_MASK(markVal));
    201200
    202201        // exclude the poor fits
    203202        if (!status) {
    204             psfTry->mask->data.U8[i] = PSFTRY_MASK_EXT_FAIL;
     203            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_EXT_FAIL;
    205204            psTrace ("psModules.objects", 4, "masking %d (%d,%d) : status is poor\n", i, source->peak->x, source->peak->y);
    206205            continue;
     
    231230
    232231        // masked for: bad model fit, outlier in parameters
    233         if (psfTry->mask->data.U8[i] & PSFTRY_MASK_ALL) {
     232        if (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL) {
    234233            psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : source is masked\n", i, source->peak->x, source->peak->y);
    235234            continue;
     
    239238        source->modelPSF = pmModelFromPSF (source->modelEXT, psfTry->psf);
    240239        if (source->modelPSF == NULL) {
    241             psfTry->mask->data.U8[i] = PSFTRY_MASK_BAD_MODEL;
     240            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_BAD_MODEL;
    242241            abort();
    243242            continue;
     
    253252        // skip poor fits
    254253        if (!status) {
    255             psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_U8(markVal));
    256             psfTry->mask->data.U8[i] = PSFTRY_MASK_PSF_FAIL;
     254            psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_IMAGE_MASK(markVal));
     255            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_PSF_FAIL;
    257256            psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : failed PSF fit\n", i, source->peak->x, source->peak->y);
    258257            continue;
     
    261260        status = pmSourceMagnitudes (source, psfTry->psf, PM_SOURCE_PHOT_INTERP, maskVal);
    262261        if (!status || isnan(source->apMag)) {
    263             psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_U8(markVal));
    264             psfTry->mask->data.U8[i] = PSFTRY_MASK_BAD_PHOT;
     262            psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_IMAGE_MASK(markVal));
     263            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_BAD_PHOT;
    265264            psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : poor photometry\n", i, source->peak->x, source->peak->y);
    266265            continue;
     
    268267
    269268        // clear object mask to define valid pixels
    270         psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_U8(markVal));
     269        psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_IMAGE_MASK(markVal));
    271270
    272271        psfTry->fitMag->data.F32[i] = source->psfMag;
     
    292291    psVector *flux  = psVectorAlloc (psfTry->sources->n, PS_TYPE_F32);
    293292    psVector *chisq = psVectorAlloc (psfTry->sources->n, PS_TYPE_F32);
    294     psVector *mask  = psVectorAlloc (psfTry->sources->n, PS_TYPE_MASK);
     293    psVector *mask  = psVectorAlloc (psfTry->sources->n, PS_TYPE_VECTOR_MASK);
    295294
    296295    // generate the x and y vectors, and mask missing models
     
    300299            flux->data.F32[i] = 0.0;
    301300            chisq->data.F32[i] = 0.0;
    302             mask->data.U8[i] = 0xff;
     301            mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xff;
    303302        } else {
    304303            flux->data.F32[i] = source->modelPSF->params->data.F32[PM_PAR_I0];
    305304            chisq->data.F32[i] = source->modelPSF->chisq / source->modelPSF->nDOF;
    306             mask->data.U8[i] = 0;
     305            mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0;
    307306        }
    308307    }
     
    312311
    313312    // linear clipped fit of chisq trend vs flux
    314     bool result = psVectorClipFitPolynomial1D(psfTry->psf->ChiTrend, options->stats, mask,
    315                                               0xff, chisq, NULL, flux);
     313    bool result = psVectorClipFitPolynomial1D(psfTry->psf->ChiTrend, options->stats, mask, 0xff, chisq, NULL, flux);
    316314    psStatsOptions meanStat = psStatsMeanOption(options->stats->options); // Statistic for mean
    317315    psStatsOptions stdevStat = psStatsStdevOption(options->stats->options); // Statistic for stdev
     
    370368
    371369    for (int i = 0; i < psfTry->sources->n; i++) {
    372         if (psfTry->mask->data.U8[i] & PSFTRY_MASK_ALL)
     370        if (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL)
    373371            continue;
    374372        r2rflux->data.F32[i] = PS_SQR(RADIUS) * pow(10.0, 0.4*psfTry->fitMag->data.F32[i]);
     
    379377        FILE *f = fopen ("apresid.dat", "w");
    380378        for (int i = 0; i < psfTry->sources->n; i++) {
    381             int keep = (psfTry->mask->data.U8[i] & PSFTRY_MASK_ALL);
     379            int keep = (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL);
    382380
    383381            pmSource *source = psfTry->sources->data[i];
     
    427425        psVector *apfit = psPolynomial1DEvalVector (poly, r2rflux);
    428426        for (int i = 0; i < psfTry->sources->n; i++) {
    429             int keep = (psfTry->mask->data.U8[i] & PSFTRY_MASK_ALL);
     427            int keep = (psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL);
    430428
    431429            pmSource *source = psfTry->sources->data[i];
     
    603601    for (int i = 0; i < sources->n; i++) {
    604602        // skip any masked sources (failed to fit one of the model steps or get a magnitude)
    605         if (srcMask->data.U8[i]) continue;
     603        if (srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue;
    606604       
    607605        pmSource *source = sources->data[i];
     
    624622
    625623        psVector *dz = NULL;
    626         psVector *mask = psVectorAlloc (sources->n, PS_TYPE_U8);
     624        psVector *mask = psVectorAlloc (sources->n, PS_TYPE_VECTOR_MASK);
    627625
    628626        // check the fit residuals and increase Nx,Ny until the error is minimized
     
    632630            // copy srcMask to mask (we do not want the mask values set in pmPSFFitShapeParamsMap to be sticky)
    633631            for (int i = 0; i < mask->n; i++) {
    634                 mask->data.U8[i] = srcMask->data.U8[i];
     632                mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i];
    635633            }
    636634            if (!pmPSFFitShapeParamsMap (psf, i, &scatterTotal, mask, x, y, mag, e0, e1, e2, dz)) {
     
    651649        // copy srcMask to mask (we do not want the mask values set in pmPSFFitShapeParamsMap to be sticky)
    652650        for (int i = 0; i < mask->n; i++) {
    653             mask->data.U8[i] = srcMask->data.U8[i];
     651            mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i];
    654652        }
    655653        if (!pmPSFFitShapeParamsMap (psf, entryMin, &scatterTotal, mask, x, y, mag, e0, e1, e2, dz)) {
     
    663661        // copy mask back to srcMask
    664662        for (int i = 0; i < mask->n; i++) {
    665             srcMask->data.U8[i] = mask->data.U8[i];
     663            srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = mask->data.PS_TYPE_VECTOR_MASK_DATA[i];
    666664        }
    667665
     
    736734                     pmTrend2DEval (psf->params->data[PM_PAR_E1], x->data.F32[i], y->data.F32[i]),
    737735                     pmTrend2DEval (psf->params->data[PM_PAR_E2], x->data.F32[i], y->data.F32[i]),
    738                      srcMask->data.U8[i]);
     736                     srcMask->data.PS_TYPE_VECTOR_MASK_DATA[i]);
    739737        }
    740738        fclose (f);
     
    851849
    852850    // the mask marks the values not used to calculate the ApTrend
    853     psVector *fitMask = psVectorAlloc (x_fit->n, PS_TYPE_U8);
     851    psVector *fitMask = psVectorAlloc (x_fit->n, PS_TYPE_VECTOR_MASK);
    854852    // copy mask values to fitMask as a starting point
    855853    for (int i = 0; i < fitMask->n; i++) {
    856         fitMask->data.U8[i] = mask->data.U8[i];
     854        fitMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = mask->data.PS_TYPE_VECTOR_MASK_DATA[i];
    857855    }
    858856
     
    943941    // XXX copy fitMask values back to mask
    944942    for (int i = 0; i < fitMask->n; i++) {
    945         mask->data.U8[i] = fitMask->data.U8[i];
     943        mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = fitMask->data.PS_TYPE_VECTOR_MASK_DATA[i];
    946944    }
    947945    psFree (fitMask);
     
    951949
    952950// calculate the scatter of the parameters
    953 bool pmPSFShapeParamsScatter(float *scatterTotal, psVector *e0res, psVector *e1res, psVector *e2res, psVector *mask, psMaskType maskValue, psStatsOptions stdevOpt)
     951bool pmPSFShapeParamsScatter(float *scatterTotal, psVector *e0res, psVector *e1res, psVector *e2res, psVector *mask, psVectorMaskType maskValue, psStatsOptions stdevOpt)
    954952{
    955953
     
    994992    psVector *dE1subset = psVectorAllocEmpty (nGroup, PS_TYPE_F32);
    995993    psVector *dE2subset = psVectorAllocEmpty (nGroup, PS_TYPE_F32);
    996     psVector *mkSubset  = psVectorAllocEmpty (nGroup, PS_TYPE_U8);
     994    psVector *mkSubset  = psVectorAllocEmpty (nGroup, PS_TYPE_VECTOR_MASK);
    997995
    998996    int n = 0;
     
    10071005            dE2subset->data.F32[j] = e2res->data.F32[N];
    10081006
    1009             mkSubset->data.U8[j]   = mask->data.U8[N];
    1010             if (!mask->data.U8[N]) nValid ++;
     1007            mkSubset->data.PS_TYPE_VECTOR_MASK_DATA[j]   = mask->data.PS_TYPE_VECTOR_MASK_DATA[N];
     1008            if (!mask->data.PS_TYPE_VECTOR_MASK_DATA[N]) nValid ++;
    10111009        }
    10121010        if (nValid < 3) continue;
  • trunk/psModules/src/objects/pmPSFtry.h

    r21174 r21183  
    66 * @author EAM, IfA
    77 *
    8  * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    9  * @date $Date: 2009-01-27 00:02:16 $
     8 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     9 * @date $Date: 2009-01-27 06:39:38 $
    1010 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1111 */
     
    4848    pmPSF      *psf;                    ///< Add comment.
    4949    psArray    *sources;                ///< pointers to the original sources
    50     psVector   *mask;                   ///< Add comment.
     50    psVector   *mask;                   ///< PS_TYPE_VECTOR_MASK to flag good and bad sources
    5151    psVector   *metric;                 ///< Add comment.
    5252    psVector   *metricErr;              ///< Add comment.
     
    8989 *
    9090 */
    91 pmPSFtry *pmPSFtryModel (const psArray *sources, const char *modelName, pmPSFOptions *options, psMaskType maskVal, psMaskType mark);
     91pmPSFtry *pmPSFtryModel (const psArray *sources, const char *modelName, pmPSFOptions *options, psImageMaskType maskVal, psImageMaskType mark);
    9292
    9393/** pmPSFtryMetric()
     
    129129bool pmPSFFitShapeParams (pmPSF *psf, psArray *sources, psVector *x, psVector *y, psVector *srcMask);
    130130bool pmPSFFitShapeParamsMap (pmPSF *psf, int scale, float *scatterTotal, psVector *mask, psVector *x, psVector *y, psVector *mag, psVector *e0obs, psVector *e1obs, psVector *e2obs, psVector *dz);
    131 bool pmPSFShapeParamsScatter(float *scatterTotal, psVector *e0res, psVector *e1res, psVector *e2res, psVector *mask, psMaskType maskValue, psStatsOptions stdevOpt);
     131bool pmPSFShapeParamsScatter(float *scatterTotal, psVector *e0res, psVector *e1res, psVector *e2res, psVector *mask, psVectorMaskType maskValue, psStatsOptions stdevOpt);
    132132bool pmPSFShapeParamsErrors (float *errorFloor, psVector *mag, psVector *e0res, psVector *e1res, psVector *e2res, psVector *mask, int nGroup, psStatsOptions stdevOpt);
    133133
  • trunk/psModules/src/objects/pmResiduals.c

    r15562 r21183  
    44 *
    55 * @author EAM, IfA
    6  * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-11-10 01:09:20 $
     6 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2009-01-27 06:39:38 $
    88 * Copyright 2004 IfA, University of Hawaii
    99 */
     
    4343    resid->Ry  = psImageAlloc (nX, nY, PS_TYPE_F32);
    4444    resid->weight = psImageAlloc (nX, nY, PS_TYPE_F32);
    45     resid->mask   = psImageAlloc (nX, nY, PS_TYPE_U8);
     45    resid->mask   = psImageAlloc (nX, nY, PM_TYPE_RESID_MASK);
     46
     47    // NOTE : the residual mask is internal only : 1 byte is sufficient
    4648
    4749    resid->xBin = xBin;
  • trunk/psModules/src/objects/pmResiduals.h

    r15562 r21183  
    44 *
    55 * @author EAM, IfA
    6  * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-11-10 01:09:20 $
     6 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2009-01-27 06:39:38 $
    88 * Copyright 2004 IfA, University of Hawaii
    99 */
     
    3131bool psMemCheckResiduals(psPtr ptr);
    3232
     33// macros to abstract the resid mask type : these values must be consistent
     34#define PM_TYPE_RESID_MASK PS_TYPE_U8        /**< the psElemType to use for mask image */
     35#define PM_TYPE_RESID_MASK_DATA U8           /**< the data member to use for mask image */
     36#define PM_TYPE_RESID_MASK_NAME "psU8"       /**< the data type for mask as a string */
     37typedef psU8 pmResidMaskType;               ///< the C datatype for a mask image
     38#define PM_NOT_RESID_MASK(A)(UINT8_MAX-(A))
     39
    3340/// @}
    3441# endif
  • trunk/psModules/src/objects/pmSource.c

    r20937 r21183  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.66 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2008-12-08 02:51:14 $
     8 *  @version $Revision: 1.67 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-01-27 06:39:38 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    171171
    172172    // the maskObj is a unique mask array; create a new mask image
    173     source->maskObj = in->maskObj ? psImageCopy (NULL, in->maskObj, PS_TYPE_MASK) : NULL;
     173    source->maskObj = in->maskObj ? psImageCopy (NULL, in->maskObj, PS_TYPE_IMAGE_MASK) : NULL;
    174174
    175175    source->type = in->type;
     
    205205        mySource->maskView = psImageSubset(readout->mask,  srcRegion);
    206206        // the object mask is a copy, and used to define the source pixels
    207         mySource->maskObj = psImageCopy(NULL, mySource->maskView, PS_TYPE_MASK);
     207        mySource->maskObj = psImageCopy(NULL, mySource->maskView, PS_TYPE_IMAGE_MASK);
    208208    }
    209209    mySource->region   = srcRegion;
     
    255255        // re-copy the main mask pixels.  NOTE: the user will need to reset the object mask
    256256        // pixels (eg, with psImageKeepCircle)
    257         mySource->maskObj = psImageCopy (mySource->maskObj, mySource->maskView, PS_TYPE_MASK);
     257        mySource->maskObj = psImageCopy (mySource->maskObj, mySource->maskView, PS_TYPE_IMAGE_MASK);
    258258
    259259        // drop the old modelFlux pixels and force the user to re-create
     
    505505*****************************************************************************/
    506506
    507 bool pmSourceRoughClass(psRegion *region, psArray *sources, psMetadata *recipe, pmPSFClump clump, psMaskType maskSat)
     507bool pmSourceRoughClass(psRegion *region, psArray *sources, psMetadata *recipe, pmPSFClump clump, psImageMaskType maskSat)
    508508{
    509509    psTrace("psModules.objects", 5, "---- begin ----");
     
    738738        psF32 *vPix = source->pixels->data.F32[row];
    739739        psF32 *vWgt = source->weight->data.F32[row];
    740         psU8  *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.U8[row];
     740        psImageMaskType *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row];
    741741
    742742        for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) {
     
    848848# endif
    849849// construct a realization of the source model
    850 bool pmSourceCacheModel (pmSource *source, psMaskType maskVal) {
     850bool pmSourceCacheModel (pmSource *source, psImageMaskType maskVal) {
    851851    PS_ASSERT_PTR_NON_NULL(source, false);
    852852    // select appropriate model
     
    867867// construct a realization of the source model
    868868// XXX this function should optionally save an existing psf image from modelFlux
    869 bool pmSourceCachePSF (pmSource *source, psMaskType maskVal) {
     869bool pmSourceCachePSF (pmSource *source, psImageMaskType maskVal) {
    870870    PS_ASSERT_PTR_NON_NULL(source, false);
    871871
     
    885885
    886886// should we call pmSourceCacheModel if it does not exist?
    887 bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add, psMaskType maskVal, int dx, int dy)
     887bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add, psImageMaskType maskVal, int dx, int dy)
    888888{
    889889    PS_ASSERT_PTR_NON_NULL(source, false);
     
    915915        }
    916916
    917         psU8 **mask = NULL;
     917        psImageMaskType **mask = NULL;
    918918        if (source->maskObj) {
    919             mask = source->maskObj->data.U8;
     919            mask = source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA;
    920920        }
    921921
     
    957957}
    958958
    959 bool pmSourceAdd (pmSource *source, pmModelOpMode mode, psMaskType maskVal) {
     959bool pmSourceAdd (pmSource *source, pmModelOpMode mode, psImageMaskType maskVal) {
    960960    return pmSourceOp (source, mode, true, maskVal, 0, 0);
    961961}
    962962
    963 bool pmSourceSub (pmSource *source, pmModelOpMode mode, psMaskType maskVal) {
     963bool pmSourceSub (pmSource *source, pmModelOpMode mode, psImageMaskType maskVal) {
    964964    return pmSourceOp (source, mode, false, maskVal, 0, 0);
    965965}
    966966
    967 bool pmSourceAddWithOffset (pmSource *source, pmModelOpMode mode, psMaskType maskVal, int dx, int dy) {
     967bool pmSourceAddWithOffset (pmSource *source, pmModelOpMode mode, psImageMaskType maskVal, int dx, int dy) {
    968968    return pmSourceOp (source, mode, true, maskVal, dx, dy);
    969969}
    970970
    971 bool pmSourceSubWithOffset (pmSource *source, pmModelOpMode mode, psMaskType maskVal, int dx, int dy) {
     971bool pmSourceSubWithOffset (pmSource *source, pmModelOpMode mode, psImageMaskType maskVal, int dx, int dy) {
    972972    return pmSourceOp (source, mode, false, maskVal, dx, dy);
    973973}
  • trunk/psModules/src/objects/pmSource.h

    r20945 r21183  
    33 * @author EAM, IfA; GLG, MHPCC
    44 *
    5  * @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
    6  * @date $Date: 2008-12-09 21:16:09 $
     5 * @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
     6 * @date $Date: 2009-01-27 06:39:38 $
    77 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    88 */
     
    210210    psMetadata *metadata,               ///< Contains classification parameters
    211211    pmPSFClump clump,                   ///< Statistics about the PSF clump
    212     psMaskType maskSat                  ///< Mask value for saturated pixels
     212    psImageMaskType maskSat             ///< Mask value for saturated pixels
    213213);
    214214
     
    231231pmModel *pmSourceGetModel (bool *isPSF, const pmSource *source);
    232232
    233 bool pmSourceAdd (pmSource *source, pmModelOpMode mode, psMaskType maskVal);
    234 bool pmSourceSub (pmSource *source, pmModelOpMode mode, psMaskType maskVal);
    235 bool pmSourceAddWithOffset (pmSource *source, pmModelOpMode mode, psMaskType maskVal, int dx, int dy);
    236 bool pmSourceSubWithOffset (pmSource *source, pmModelOpMode mode, psMaskType maskVal, int dx, int dy);
    237 
    238 bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add, psMaskType maskVal, int dx, int dy);
    239 bool pmSourceCacheModel (pmSource *source, psMaskType maskVal);
    240 bool pmSourceCachePSF (pmSource *source, psMaskType maskVal);
     233bool pmSourceAdd (pmSource *source, pmModelOpMode mode, psImageMaskType maskVal);
     234bool pmSourceSub (pmSource *source, pmModelOpMode mode, psImageMaskType maskVal);
     235bool pmSourceAddWithOffset (pmSource *source, pmModelOpMode mode, psImageMaskType maskVal, int dx, int dy);
     236bool pmSourceSubWithOffset (pmSource *source, pmModelOpMode mode, psImageMaskType maskVal, int dx, int dy);
     237
     238bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add, psImageMaskType maskVal, int dx, int dy);
     239bool pmSourceCacheModel (pmSource *source, psImageMaskType maskVal);
     240bool pmSourceCachePSF (pmSource *source, psImageMaskType maskVal);
    241241
    242242int             pmSourceSortBySN (const void **a, const void **b);
  • trunk/psModules/src/objects/pmSourceFitModel.c

    r20937 r21183  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2008-12-08 02:51:14 $
     8 *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-01-27 06:39:38 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5656                       pmModel *model,
    5757                       pmSourceFitMode mode,
    58                        psMaskType maskVal)
     58                       psImageMaskType maskVal)
    5959{
    6060    psTrace("psModules.objects", 5, "---- %s begin ----\n", __func__);
     
    8181        for (psS32 j = 0; j < source->pixels->numCols; j++) {
    8282            // skip masked points
    83             if (source->maskObj->data.U8[i][j] & maskVal) {
     83            if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j] & maskVal) {
    8484                continue;
    8585            }
     
    121121    // create the minimization constraints
    122122    psMinConstraint *constraint = psMinConstraintAlloc();
    123     constraint->paramMask = psVectorAlloc (params->n, PS_TYPE_U8);
     123    constraint->paramMask = psVectorAlloc (params->n, PS_TYPE_VECTOR_MASK);
    124124    constraint->checkLimits = model->modelLimits;
    125125
     
    131131        nParams = 1;
    132132        psVectorInit (constraint->paramMask, 1);
    133         constraint->paramMask->data.U8[PM_PAR_I0] = 0;
     133        constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_I0] = 0;
    134134        break;
    135135    case PM_SOURCE_FIT_PSF:
     
    137137        nParams = 3;
    138138        psVectorInit (constraint->paramMask, 1);
    139         constraint->paramMask->data.U8[PM_PAR_I0] = 0;
    140         constraint->paramMask->data.U8[PM_PAR_XPOS] = 0;
    141         constraint->paramMask->data.U8[PM_PAR_YPOS] = 0;
     139        constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_I0] = 0;
     140        constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_XPOS] = 0;
     141        constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_YPOS] = 0;
    142142        break;
    143143    case PM_SOURCE_FIT_EXT:
     
    145145        nParams = params->n - 1;
    146146        psVectorInit (constraint->paramMask, 0);
    147         constraint->paramMask->data.U8[PM_PAR_SKY] = 1;
     147        constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_SKY] = 1;
    148148        break;
    149149    default:
     
    175175            fprintf (stderr, "%f ", params->data.F32[i]);
    176176        }
    177         if ((constraint->paramMask != NULL) && constraint->paramMask->data.U8[i])
     177        if ((constraint->paramMask != NULL) && constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i])
    178178            continue;
    179179        dparams->data.F32[i] = sqrt(covar->data.F32[i][i]);
     
    192192    if (constraint->paramMask != NULL) {
    193193        psVector *delta = psVectorAlloc (params->n, PS_TYPE_F32);
    194         psVector *altmask = psVectorAlloc (params->n, PS_TYPE_U8);
    195         altmask->data.U8[0] = 1;
     194        psVector *altmask = psVectorAlloc (params->n, PS_TYPE_VECTOR_MASK);
     195        altmask->data.PS_TYPE_VECTOR_MASK_DATA[0] = 1;
    196196        for (int i = 1; i < dparams->n; i++) {
    197             altmask->data.U8[i] = (constraint->paramMask->data.U8[i]) ? 0 : 1;
     197            altmask->data.PS_TYPE_VECTOR_MASK_DATA[i] = (constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) ? 0 : 1;
    198198        }
    199199        psMinimizeGaussNewtonDelta(delta, params, altmask, x, y, yErr, model->modelFunc);
    200200
    201201        for (int i = 0; i < dparams->n; i++) {
    202             if (!constraint->paramMask->data.U8[i])
     202            if (!constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i])
    203203                continue;
    204204            // note that delta is the value *subtracted* from the parameter
  • trunk/psModules/src/objects/pmSourceFitModel.h

    r13898 r21183  
    33 * @author EAM, IfA; GLG, MHPCC
    44 *
    5  * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    6  * @date $Date: 2007-06-20 02:22:26 $
     5 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     6 * @date $Date: 2009-01-27 06:39:38 $
    77 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    88 */
     
    4141    pmModel *model,   ///< model to be fitted
    4242    pmSourceFitMode mode,  ///< define parameters to be fitted
    43     psMaskType maskVal                  ///< Value to mask
     43    psImageMaskType maskVal             ///< Value to mask
    4444);
    4545
     
    7171    psArray *modelSet,   ///< model to be fitted
    7272    pmSourceFitMode mode,  ///< define parameters to be fitted
    73     psMaskType maskVal                  ///< Vale to mask
     73    psImageMaskType maskVal             ///< Vale to mask
    7474
    7575);
  • trunk/psModules/src/objects/pmSourceFitSet.c

    r21163 r21183  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2009-01-24 20:52:26 $
    10  *
     8 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-01-27 06:39:38 $
    1110 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1211 *
     
    394393            for (int j = 0; j < paramOne->n; j++) {
    395394                if (j == PM_PAR_I0) continue;
    396                 constraint->paramMask->data.U8[n + j] = 1;
     395                constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n + j] = 1;
    397396            }
    398397            break;
     
    403402                if (j == PM_PAR_YPOS) continue;
    404403                if (j == PM_PAR_I0) continue;
    405                 constraint->paramMask->data.U8[n + j] = 1;
     404                constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n + j] = 1;
    406405            }
    407406            break;
    408407          case PM_SOURCE_FIT_EXT:
    409408            // EXT model fits all params (except sky)
    410             constraint->paramMask->data.U8[n + PM_PAR_SKY] = 1;
     409            constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n + PM_PAR_SKY] = 1;
    411410            break;
    412411          default:
     
    445444                     psArray *modelSet,
    446445                     pmSourceFitMode mode,
    447                      psMaskType maskVal)
     446                     psImageMaskType maskVal)
    448447{
    449448    psTrace("psModules.objects", 3, "---- %s begin ----\n", __func__);
     
    469468        for (psS32 j = 0; j < source->pixels->numCols; j++) {
    470469            // skip masked points
    471             if (source->maskObj->data.U8[i][j] & maskVal) {
     470            if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j] & maskVal) {
    472471                continue;
    473472            }
     
    515514    // create the minimization constraints
    516515    psMinConstraint *constraint = psMinConstraintAlloc();
    517     constraint->paramMask = psVectorAlloc (thisSet->nParamSet, PS_TYPE_U8);
     516    constraint->paramMask = psVectorAlloc (thisSet->nParamSet, PS_TYPE_VECTOR_MASK);
    518517    constraint->checkLimits = pmSourceFitSetCheckLimits;
    519518
     
    528527    if (psTraceGetLevel("psModules.objects") >= 5) {
    529528        for (int i = 0; i < params->n; i++) {
    530             fprintf (stderr, "%d %f %d\n", i, params->data.F32[i], constraint->paramMask->data.U8[i]);
     529            fprintf (stderr, "%d %f %d\n", i, params->data.F32[i], constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]);
    531530        }
    532531    }
     
    560559    psVector *dparams = psVectorAlloc (thisSet->nParamSet, PS_TYPE_F32);
    561560    for (int i = 0; i < dparams->n; i++) {
    562         if ((constraint->paramMask != NULL) && constraint->paramMask->data.U8[i])
     561        if ((constraint->paramMask != NULL) && constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i])
    563562            continue;
    564563        dparams->data.F32[i] = sqrt(covar->data.F32[i][i]);
     
    568567    if (constraint->paramMask != NULL) {
    569568        psVector *delta = psVectorAlloc (params->n, PS_TYPE_F32);
    570         psVector *altmask = psVectorAlloc (params->n, PS_TYPE_U8);
    571         altmask->data.U8[0] = 1;
     569        psVector *altmask = psVectorAlloc (params->n, PS_TYPE_VECTOR_MASK);
     570        altmask->data.PS_TYPE_VECTOR_MASK_DATA[0] = 1;
    572571        for (int i = 1; i < dparams->n; i++) {
    573             altmask->data.U8[i] = (constraint->paramMask->data.U8[i]) ? 0 : 1;
     572            altmask->data.PS_TYPE_VECTOR_MASK_DATA[i] = (constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) ? 0 : 1;
    574573        }
    575574        psMinimizeGaussNewtonDelta(delta, params, altmask, x, y, yErr, pmSourceFitSetFunction);
    576575
    577576        for (int i = 0; i < dparams->n; i++) {
    578             if (!constraint->paramMask->data.U8[i])
     577            if (!constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i])
    579578                continue;
    580579            // note that delta is the value *subtracted* from the parameter
  • trunk/psModules/src/objects/pmSourceFitSet.h

    r21163 r21183  
    33 * @author EAM, IfA; GLG, MHPCC
    44 *
    5  * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    6  * @date $Date: 2009-01-24 20:52:26 $
     5 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     6 * @date $Date: 2009-01-27 06:39:38 $
    77 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    88 */
     
    5454 */
    5555bool pmSourceFitSet(
    56     pmSource *source,   ///< The input pmSource
    57     psArray *modelSet,   ///< model to be fitted
    58     pmSourceFitMode mode,  ///< define parameters to be fitted
    59     psMaskType maskVal                  ///< Vale to mask
     56    pmSource *source,                   ///< The input pmSource
     57    psArray *modelSet,                  ///< model to be fitted
     58    pmSourceFitMode mode,               ///< define parameters to be fitted
     59    psImageMaskType maskVal             ///< Vale to mask
    6060
    6161);
  • trunk/psModules/src/objects/pmSourceMatch.c

    r21105 r21183  
    122122    match->image = psVectorAllocEmpty(num, PS_TYPE_U32);
    123123    match->index = psVectorAllocEmpty(num, PS_TYPE_U32);
    124     match->mask = psVectorAllocEmpty(num, PS_TYPE_MASK);
     124    match->mask = psVectorAllocEmpty(num, PS_TYPE_VECTOR_MASK);
    125125
    126126    return match;
     
    143143    match->image->data.S32[num] = image;
    144144    match->index->data.S32[num] = index;
    145     match->mask->data.PS_TYPE_MASK_DATA[num] = 0;
     145    match->mask->data.PS_TYPE_VECTOR_MASK_DATA[num] = 0;
    146146    match->num++;
    147147
     
    316316        double star = 0.0, starErr = 0.0; // Accumulators for star
    317317        for (int j = 0; j < match->num; j++) {
    318             if (match->mask->data.PS_TYPE_MASK_DATA[j]) {
     318            if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) {
    319319                continue;
    320320            }
     
    347347        pmSourceMatch *match = matches->data[i]; // Matched stars
    348348        for (int j = 0; j < match->num; j++) {
    349             if (match->mask->data.PS_TYPE_MASK_DATA[j]) {
     349            if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) {
    350350                continue;
    351351            }
     
    373373        pmSourceMatch *match = matches->data[i]; // Matched stars
    374374        for (int j = 0; j < match->num; j++) {
    375             if (match->mask->data.PS_TYPE_MASK_DATA[j]) {
     375            if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) {
    376376                continue;
    377377            }
     
    474474        pmSourceMatch *match = matches->data[i]; // Matched stars
    475475        for (int j = 0; j < match->num; j++) {
    476             if (match->mask->data.PS_TYPE_MASK_DATA[j]) {
     476            if (match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j]) {
    477477                continue;
    478478            }
     
    488488            if (PS_SQR(dev) > starClip * (PS_SQR(magErr) + sysErr2)) {
    489489                numRejected++;
    490                 match->mask->data.PS_TYPE_MASK_DATA[j] = 0xFF;
     490                match->mask->data.PS_TYPE_VECTOR_MASK_DATA[j] = 0xFF;
    491491            }
    492492        }
  • trunk/psModules/src/objects/pmSourceMoments.c

    r20937 r21183  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2008-12-08 02:51:14 $
     8 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-01-27 06:39:38 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    100100        psF32 *vPix = source->pixels->data.F32[row];
    101101        psF32 *vWgt = source->weight->data.F32[row];
    102         psU8  *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.U8[row];
     102        psImageMaskType *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row];
    103103
    104104        for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) {
     
    190190        psF32 *vPix = source->pixels->data.F32[row];
    191191        psF32 *vWgt = source->weight->data.F32[row];
    192         psU8  *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.U8[row];
     192        psImageMaskType  *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row];
    193193
    194194        for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) {
     
    342342        psF32 *vPix = source->pixels->data.F32[row];
    343343        psF32 *vWgt = source->weight->data.F32[row];
    344         psU8  *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.U8[row];
     344        psImageMaskType  *vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[row];
    345345
    346346        for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) {
  • trunk/psModules/src/objects/pmSourcePhotometry.c

    r20937 r21183  
    33 *  @author EAM, IfA; GLG, MHPCC
    44 *
    5  *  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2008-12-08 02:51:14 $
     5 *  @version $Revision: 1.48 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2009-01-27 06:39:38 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6666
    6767// XXX masked region should be (optionally) elliptical
    68 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psMaskType maskVal)
     68bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psImageMaskType maskVal)
    6969{
    7070    PS_ASSERT_PTR_NON_NULL(source, false);
     
    306306
    307307// return source aperture magnitude
    308 bool pmSourcePhotometryAper (float *apMag, pmModel *model, psImage *image, psImage *mask, psMaskType maskVal)
     308bool pmSourcePhotometryAper (float *apMag, pmModel *model, psImage *image, psImage *mask, psImageMaskType maskVal)
    309309{
    310310    PS_ASSERT_PTR_NON_NULL(apMag, false);
     
    324324
    325325    psF32 **imData = image->data.F32;
    326     psU8 **mkData = mask->data.U8;
     326    psImageMaskType **mkData = mask->data.PS_TYPE_IMAGE_MASK_DATA;
    327327
    328328    // measure apMag
     
    344344
    345345// return source aperture magnitude
    346 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask, psMaskType maskVal)
     346bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask, psImageMaskType maskVal)
    347347{
    348348    PS_ASSERT_PTR_NON_NULL(pixWeight, false);
     
    412412            if (my >= NY)
    413413                continue;
    414             if (mask->data.U8[my][mx] & maskVal)
     414            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskVal)
    415415                continue;
    416416
     
    475475    for (yi = yIs, yj = yJs; yi < yIe; yi++, yj++) {
    476476        for (xi = xIs, xj = xJs; xi < xIe; xi++, xj++) {
    477             if (Ti->data.U8[yi][xi])
    478                 continue;
    479             if (Tj->data.U8[yj][xj])
     477            if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi])
     478                continue;
     479            if (Tj->data.PS_TYPE_IMAGE_MASK_DATA[yj][xj])
    480480                continue;
    481481
     
    540540    for (yi = yIs, yj = yJs; yi < yIe; yi++, yj++) {
    541541        for (xi = xIs, xj = xJs; xi < xIe; xi++, xj++) {
    542             if (Ti->data.U8[yi][xi])
    543                 continue;
    544             if (Tj->data.U8[yj][xj])
     542            if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi])
     543                continue;
     544            if (Tj->data.PS_TYPE_IMAGE_MASK_DATA[yj][xj])
    545545                continue;
    546546
     
    578578    for (int yi = 0; yi < Pi->numRows; yi++) {
    579579        for (int xi = 0; xi < Pi->numCols; xi++) {
    580             if (Ti->data.U8[yi][xi])
     580            if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi])
    581581                continue;
    582582            if (!unweighted_sum) {
     
    613613
    614614bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight,
    615                     psMaskType maskVal)
     615                    psImageMaskType maskVal)
    616616{
    617617    PS_ASSERT_PTR_NON_NULL(model, false);
     
    624624    for (int j = 0; j < image->numRows; j++) {
    625625        for (int i = 0; i < image->numCols; i++) {
    626             if (mask->data.U8[j][i] & maskVal)
     626            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] & maskVal)
    627627                continue;
    628628            if (weight->data.F32[j][i] <= 0)
     
    657657    for (int yi = 0; yi < Pi->numRows; yi++) {
    658658        for (int xi = 0; xi < Pi->numCols; xi++) {
    659             if (Ti->data.U8[yi][xi])
     659            if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi])
    660660                continue;
    661661            if (!unweighted_sum) {
     
    734734    for (yi = yIs, yj = yJs; yi < yIe; yi++, yj++) {
    735735        for (xi = xIs, xj = xJs; xi < xIe; xi++, xj++) {
    736             if (Ti->data.U8[yi][xi])
    737                 continue;
    738             if (Tj->data.U8[yj][xj])
     736            if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi])
     737                continue;
     738            if (Tj->data.PS_TYPE_IMAGE_MASK_DATA[yj][xj])
    739739                continue;
    740740
     
    798798    for (yi = yIs, yj = yJs; yi < yIe; yi++, yj++) {
    799799        for (xi = xIs, xj = xJs; xi < xIe; xi++, xj++) {
    800             if (Ti->data.U8[yi][xi])
    801                 continue;
    802             if (Tj->data.U8[yj][xj])
     800            if (Ti->data.PS_TYPE_IMAGE_MASK_DATA[yi][xi])
     801                continue;
     802            if (Tj->data.PS_TYPE_IMAGE_MASK_DATA[yj][xj])
    803803                continue;
    804804
  • trunk/psModules/src/objects/pmSourcePhotometry.h

    r18554 r21183  
    44 * @author EAM, IfA; GLG, MHPCC
    55 *
    6  * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2008-07-15 20:25:00 $
     6 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2009-01-27 06:39:38 $
    88 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    99 */
     
    4646    psImage *image,                     ///< image pixels to be used
    4747    psImage *mask,                      ///< mask of pixels to ignore
    48     psMaskType maskVal                  ///< Value to mask
     48    psImageMaskType maskVal             ///< Value to mask
    4949);
    5050
    5151bool pmSourceMagnitudesInit (psMetadata *config);
    52 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psMaskType maskVal);
    53 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask, psMaskType maskVal);
    54 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight, psMaskType maskVal);
     52bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psImageMaskType maskVal);
     53bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask, psImageMaskType maskVal);
     54bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight, psImageMaskType maskVal);
    5555
    5656
  • trunk/psModules/src/objects/pmSourceSky.c

    r20937 r21183  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2008-12-08 02:51:14 $
     8 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-01-27 06:39:38 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5252    psStatsOptions statsOptions,
    5353    psF32 Radius,
    54     psMaskType maskVal,
    55     psMaskType markVal)
     54    psImageMaskType maskVal,
     55    psImageMaskType markVal)
    5656{
    5757    psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     
    8686        return false;
    8787    }
    88     psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_U8(markVal));
     88    psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_IMAGE_MASK(markVal));
    8989    double value = psStatsGetValue(myStats, statistic);
    9090    psFree(myStats);
     
    107107    psStatsOptions statsOptions,
    108108    psF32 Radius,
    109     psMaskType maskVal,
    110     psMaskType markVal
     109    psImageMaskType maskVal,
     110    psImageMaskType markVal
    111111)
    112112{
     
    142142        return false;
    143143    }
    144     psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_U8(markVal));
     144    psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_IMAGE_MASK(markVal));
    145145    double value = psStatsGetValue(myStats, statistic);
    146146    psFree(myStats);
  • trunk/psModules/src/objects/pmSourceSky.h

    r13898 r21183  
    22 * @author EAM, IfA; GLG, MHPCC
    33 *
    4  * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    5  * @date $Date: 2007-06-20 02:22:26 $
     4 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     5 * @date $Date: 2009-01-27 06:39:38 $
    66 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    77 */
     
    3030    psStatsOptions statsOptions, ///< The statistic used in calculating the background sky
    3131    float Radius,   ///< The inner radius of the square annulus to exclude
    32     psMaskType maskVal,                 ///< Value to mask
    33     psMaskType mark                     ///< Mask value for marking
     32    psImageMaskType maskVal,                 ///< Value to mask
     33    psImageMaskType mark                     ///< Mask value for marking
    3434);
    3535
     
    4040    psStatsOptions statsOptions, ///< The statistic used in calculating the background sky
    4141    float Radius,   ///< The inner radius of the square annulus to exclude
    42     psMaskType maskVal,                 ///< Value to mask
    43     psMaskType mark                     ///< Mask value for marking
     42    psImageMaskType maskVal,                 ///< Value to mask
     43    psImageMaskType mark                     ///< Mask value for marking
    4444);
    4545
  • trunk/psModules/src/objects/pmSourceVisual.c

    r20582 r21183  
    5757        model->data.F32[i] = pmTrend2DEval (trend, x->data.F32[i], y->data.F32[i]);
    5858        resid->data.F32[i] = param->data.F32[i] - model->data.F32[i];
    59         if (mask->data.U8[i]) continue;
     59        if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue;
    6060        min = PS_MIN (min, resid->data.F32[i]);
    6161        max = PS_MAX (max, resid->data.F32[i]);
  • trunk/psModules/src/objects/pmTrend2D.c

    r21172 r21183  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2009-01-27 00:00:44 $
     5 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2009-01-27 06:39:38 $
    77 *  Copyright 2004 Institute for Astronomy, University of Hawaii
    88 *
     
    179179}
    180180
    181 bool pmTrend2DFit(pmTrend2D *trend, psVector *mask, psMaskType maskVal, const psVector *x,
     181bool pmTrend2DFit(pmTrend2D *trend, psVector *mask, psVectorMaskType maskVal, const psVector *x,
    182182                  const psVector *y, const psVector *f, const psVector *df)
    183183{
     
    234234}
    235235
    236 psVector *pmTrend2DEvalVector(const pmTrend2D *trend, psVector *mask, psMaskType maskValue, const psVector *x, const psVector *y)
     236psVector *pmTrend2DEvalVector(const pmTrend2D *trend, psVector *mask, psVectorMaskType maskValue, const psVector *x, const psVector *y)
    237237{
    238238    PM_ASSERT_TREND2D_NON_NULL(trend, NULL);
  • trunk/psModules/src/objects/pmTrend2D.h

    r21172 r21183  
    55 * @author EAM, IfA
    66 *
    7  * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2009-01-27 00:00:45 $
     7 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2009-01-27 06:39:38 $
    99 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    1010 */
     
    8080bool pmTrend2DFit(pmTrend2D *trend,
    8181                  psVector *mask,       // Warning: mask is modified!
    82                   psMaskType maskVal,
     82                  psVectorMaskType maskVal,
    8383                  const psVector *x,
    8484                  const psVector *y,
     
    9090                     float x, float y
    9191    );
    92 psVector *pmTrend2DEvalVector(const pmTrend2D *trend, psVector *mask, psMaskType maskValue,
     92psVector *pmTrend2DEvalVector(const pmTrend2D *trend, psVector *mask, psVectorMaskType maskValue,
    9393                              const psVector *x, const psVector *y
    9494    );
  • trunk/psastro/src/psastroAstromGuess.c

    r20805 r21183  
    267267    psVector *cornerDn = psVectorAllocEmpty (100, PS_TYPE_F32);
    268268
    269     psVector *cornerMK = psVectorAllocEmpty (100, PS_TYPE_U8);
     269    psVector *cornerMK = psVectorAllocEmpty (100, PS_TYPE_VECTOR_MASK);
    270270
    271271    if (DEBUG) psastroDumpCorners ("corners.up.guess3.dat", "corners.dn.guess3.dat", fpa);
  • trunk/psastro/src/psastroFixChips.c

    r20805 r21183  
    160160    psPlaneTransform *map = psPlaneTransformAlloc (1, 1);
    161161 
    162     psVector *mask = psVectorAlloc (nPts, PS_TYPE_U8);
     162    psVector *mask = psVectorAlloc (nPts, PS_TYPE_VECTOR_MASK);
    163163    psVectorInit (mask, 0);
    164164
  • trunk/psastro/src/psastroLuminosityFunction.c

    r20805 r21183  
    9191    psLogMsg ("psastro", 4, "fitting %d points to luminosity function\n", n);
    9292
    93     psVector *mask = psVectorAlloc (Mag->n, PS_TYPE_MASK);
     93    psVector *mask = psVectorAlloc (Mag->n, PS_TYPE_VECTOR_MASK);
    9494    psVectorInit (mask, 0);
    9595
     
    108108    double mMaxValid = NAN;
    109109    for (int i = 0; i < Mag->n; i++) {
    110         if (mask->data.U8[i]) continue;
     110        if (mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue;
    111111        if (isnan(mMinValid) || (Mag->data.F32[i] < mMinValid)) {
    112112            mMinValid = Mag->data.F32[i];
  • trunk/psastro/src/psastroMaskUpdates.Mosaic.c

    r20650 r21183  
    99pmCell *pmCellInChip (pmChip *chip, float x, float y);
    1010bool pmCellCoordsForChip (float *xCell, float *yCell, pmCell *cell, float xChip, float yChip);
    11 bool psastroMaskCircle (psImage *mask, char value, float x0, float y0, float dX, float dY);
    12 bool psastroMaskBox (psImage *mask, char value, float x0, float y0, float dL, float dW, float theta);
    13 void psastroMaskLine (psImage *mask, char value, double x1, double y1, double x2, double y2, int dW);
    14 void psastroMaskLineBresen (psImage *mask, char value, int X1, int Y1, int X2, int Y2, int dW, int swapcoords);
    15 void psastroMaskRectangle (psImage *mask, char value, int x0, int y0, int x1, int y1);
     11bool psastroMaskCircle (psImage *mask, psImageMaskType value, float x0, float y0, float dX, float dY);
     12bool psastroMaskBox (psImage *mask, psImageMaskType value, float x0, float y0, float dL, float dW, float theta);
     13void psastroMaskLine (psImage *mask, psImageMaskType value, double x1, double y1, double x2, double y2, int dW);
     14void psastroMaskLineBresen (psImage *mask, psImageMaskType value, int X1, int Y1, int X2, int Y2, int dW, int swapcoords);
     15void psastroMaskRectangle (psImage *mask, psImageMaskType value, int x0, int y0, int x1, int y1);
    1616
    1717// create a mask or mask regions based on the collection of reference stars that are
     
    2525    float zeropt, exptime;
    2626
    27     psMaskType maskValue  = pmConfigMaskGet("GHOST", config); // Mask value for ghost pixels
    28     psMaskType maskBlank  = pmConfigMaskGet("BLANK", config); // Mask value for blank pixels
     27    psImageMaskType maskValue  = pmConfigMaskGet("GHOST", config); // Mask value for ghost pixels
     28    psImageMaskType maskBlank  = pmConfigMaskGet("BLANK", config); // Mask value for blank pixels
    2929
    3030    // select the current recipe
     
    342342
    343343// XXX should be doing an OR
    344 bool psastroMaskCircle (psImage *mask, char value, float x0, float y0, float dX, float dY) {
     344bool psastroMaskCircle (psImage *mask, psImageMaskType value, float x0, float y0, float dX, float dY) {
    345345
    346346    // XXX need to worry about row0, col0
     
    357357            if (r2 > 1.0) continue;
    358358           
    359             mask->data.U8[jy][jx] |= value;
     359            mask->data.PS_TYPE_IMAGE_MASK_DATA[jy][jx] |= value;
    360360        }
    361361    }
     
    364364
    365365// XXX should be doing an OR
    366 bool psastroMaskBox (psImage *mask, char value, float x0, float y0, float dL, float dW, float theta) {
     366bool psastroMaskBox (psImage *mask, psImageMaskType value, float x0, float y0, float dL, float dW, float theta) {
    367367
    368368    // draw a series of lines (from -0.5*dW to +0.5*dW) of length dL, starting at x0, y0, angle theta
     
    379379
    380380// identify the quadrant and draw the correct line
    381 void psastroMaskLine (psImage *mask, char value, double x1, double y1, double x2, double y2, int dW) {
     381void psastroMaskLine (psImage *mask, psImageMaskType value, double x1, double y1, double x2, double y2, int dW) {
    382382
    383383  int FlipDirect, FlipCoords;
     
    408408// use the Bresenham line drawing technique
    409409// integer-only Bresenham line-draw version which is fast
    410 void psastroMaskLineBresen (psImage *mask, char value, int X1, int Y1, int X2, int Y2, int dW, int swapcoords) {
     410void psastroMaskLineBresen (psImage *mask, psImageMaskType value, int X1, int Y1, int X2, int Y2, int dW, int swapcoords) {
    411411
    412412    int X, Y, dX, dY;
     
    425425                    if (y < 0) continue;
    426426                    if (y >= mask->numCols) continue;
    427                     mask->data.U8[X][y] |= value;
     427                    mask->data.PS_TYPE_IMAGE_MASK_DATA[X][y] |= value;
    428428                }
    429429            } else {
     
    432432                    if (y < 0) continue;
    433433                    if (y >= mask->numRows) continue;
    434                     mask->data.U8[y][X] |= value;
     434                    mask->data.PS_TYPE_IMAGE_MASK_DATA[y][X] |= value;
    435435                }
    436436            }
     
    450450}
    451451
    452 void psastroMaskRectangle (psImage *mask, char value, int x0, int y0, int x1, int y1) {
     452void psastroMaskRectangle (psImage *mask, psImageMaskType value, int x0, int y0, int x1, int y1) {
    453453    for (int iy = PS_MAX(0,y0); iy < PS_MIN(y1,mask->numRows); iy++) {
    454454        for (int ix = PS_MAX(0,x0); ix < PS_MIN(x1,mask->numCols); ix++) {
    455             mask->data.U8[iy][ix] |= value;
    456         }
    457     }
    458 }
    459 
     455            mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= value;
     456        }
     457    }
     458}
     459
  • trunk/psastro/src/psastroMaskUpdates.c

    r21018 r21183  
    1111bool pmChipCoordsForCell (float *xChip, float *yChip, pmCell *cell, float xCell, float yCell);
    1212
    13 bool psastroMaskCircle (psImage *mask, char value, float x0, float y0, float dX, float dY);
    14 bool psastroMaskBox (psImage *mask, char value, float x0, float y0, float dL, float dW, float theta);
    15 void psastroMaskLine (psImage *mask, char value, double x1, double y1, double x2, double y2, int dW);
    16 void psastroMaskLineBresen (psImage *mask, char value, int X1, int Y1, int X2, int Y2, int dW, int swapcoords);
    17 void psastroMaskRectangle (psImage *mask, char value, int x0, int y0, int x1, int y1);
     13bool psastroMaskCircle (psImage *mask, psImageMaskType value, float x0, float y0, float dX, float dY);
     14bool psastroMaskBox (psImage *mask, psImageMaskType value, float x0, float y0, float dL, float dW, float theta);
     15void psastroMaskLine (psImage *mask, psImageMaskType value, double x1, double y1, double x2, double y2, int dW);
     16void psastroMaskLineBresen (psImage *mask, psImageMaskType value, int X1, int Y1, int X2, int Y2, int dW, int swapcoords);
     17void psastroMaskRectangle (psImage *mask, psImageMaskType value, int x0, int y0, int x1, int y1);
    1818
    1919// create a mask or mask regions based on the collection of reference stars that are
     
    2727    float zeropt, exptime;
    2828
    29     psMaskType maskValue  = pmConfigMaskGet("GHOST", config); // Mask value for ghost pixels
    30 
    31     // psMaskType maskBlank  = pmConfigMaskGet("BLANK", config); // Mask value for blank pixels
     29    psImageMaskType maskValue  = pmConfigMaskGet("GHOST", config); // Mask value for ghost pixels
     30
     31    // psImageMaskType maskBlank  = pmConfigMaskGet("BLANK", config); // Mask value for blank pixels
    3232
    3333    // select the current recipe
     
    376376
    377377// XXX should be doing an OR
    378 bool psastroMaskCircle (psImage *mask, char value, float x0, float y0, float dX, float dY) {
     378bool psastroMaskCircle (psImage *mask, psImageMaskType value, float x0, float y0, float dX, float dY) {
    379379
    380380    // XXX need to worry about row0, col0
     
    391391            if (r2 > 1.0) continue;
    392392
    393             mask->data.U8[jy][jx] |= value;
     393            mask->data.PS_TYPE_IMAGE_MASK_DATA[jy][jx] |= value;
    394394        }
    395395    }
     
    398398
    399399// XXX should be doing an OR
    400 bool psastroMaskBox (psImage *mask, char value, float x0, float y0, float dL, float dW, float theta) {
     400bool psastroMaskBox (psImage *mask, psImageMaskType value, float x0, float y0, float dL, float dW, float theta) {
    401401
    402402    // draw a series of lines (from -0.5*dW to +0.5*dW) of length dL, starting at x0, y0, angle theta
     
    413413
    414414// identify the quadrant and draw the correct line
    415 void psastroMaskLine (psImage *mask, char value, double x1, double y1, double x2, double y2, int dW) {
     415void psastroMaskLine (psImage *mask, psImageMaskType value, double x1, double y1, double x2, double y2, int dW) {
    416416
    417417  int FlipDirect, FlipCoords;
     
    442442// use the Bresenham line drawing technique
    443443// integer-only Bresenham line-draw version which is fast
    444 void psastroMaskLineBresen (psImage *mask, char value, int X1, int Y1, int X2, int Y2, int dW, int swapcoords) {
     444void psastroMaskLineBresen (psImage *mask, psImageMaskType value, int X1, int Y1, int X2, int Y2, int dW, int swapcoords) {
    445445
    446446    int X, Y, dX, dY;
     
    459459                    if (y < 0) continue;
    460460                    if (y >= mask->numCols) continue;
    461                     mask->data.U8[X][y] |= value;
     461                    mask->data.PS_TYPE_IMAGE_MASK_DATA[X][y] |= value;
    462462                }
    463463            } else {
     
    466466                    if (y < 0) continue;
    467467                    if (y >= mask->numRows) continue;
    468                     mask->data.U8[y][X] |= value;
     468                    mask->data.PS_TYPE_IMAGE_MASK_DATA[y][X] |= value;
    469469                }
    470470            }
     
    484484}
    485485
    486 void psastroMaskRectangle (psImage *mask, char value, int x0, int y0, int x1, int y1) {
     486void psastroMaskRectangle (psImage *mask, psImageMaskType value, int x0, int y0, int x1, int y1) {
    487487
    488488    int xs = PS_MAX (0, PS_MIN (mask->numCols, PS_MIN (x0, x1)));
     
    493493    for (int iy = ys; iy < ye; iy++) {
    494494        for (int ix = xs; ix < xe; ix++) {
    495             mask->data.U8[iy][ix] |= value;
    496         }
    497     }
    498 }
    499 
     495            mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= value;
     496        }
     497    }
     498}
     499
  • trunk/psastro/src/psastroMosaicFPtoTP.c

    r19314 r21183  
    7474
    7575    // constant errors
    76     psVector *mask = psVectorAlloc (X->n, PS_TYPE_U8);
     76    psVector *mask = psVectorAlloc (X->n, PS_TYPE_VECTOR_MASK);
    7777    psVectorInit (mask, 0);
    7878
  • trunk/psphot/src/psphot.h

    r21166 r21183  
    4040bool            psphotMomentsStats (pmReadout *readout, psMetadata *recipe, psArray *sources);
    4141bool            psphotFitSourcesLinear (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final);
    42 bool            psphotReplaceUnfitSources (psArray *sources, psMaskType maskVal);
     42bool            psphotReplaceUnfitSources (psArray *sources, psImageMaskType maskVal);
     43
    4344bool            psphotReplaceAllSources (psArray *sources, psMetadata *recipe);
    4445bool            psphotRemoveAllSources (psArray *sources, psMetadata *recipe);
     
    7071
    7172// used by psphotFindDetections
    72 psImage        *psphotSignificanceImage (pmReadout *readout, psMetadata *recipe, const int pass, psMaskType maskVal);
     73psImage        *psphotSignificanceImage (pmReadout *readout, psMetadata *recipe, const int pass, psImageMaskType maskVal);
    7374psArray        *psphotFindPeaks (psImage *significance, pmReadout *readout, psMetadata *recipe, const float threshold, const int nMax);
    74 bool            psphotFindFootprints (pmDetections *detections, psImage *significance, pmReadout *readout, psMetadata *recipe, const int pass, psMaskType maskVal);
     75bool            psphotFindFootprints (pmDetections *detections, psImage *significance, pmReadout *readout, psMetadata *recipe, const int pass, psImageMaskType maskVal);
    7576psErrorCode     psphotCullPeaks(const psImage *img, const psImage *weight, const psMetadata *recipe, psArray *footprints);
    7677
     
    8182// basic support functions
    8283void            psphotModelClassInit (void);
    83 bool            psphotGrowthCurve (pmReadout *readout, pmPSF *psf, bool ignore, psMaskType maskVal);
     84bool            psphotGrowthCurve (pmReadout *readout, pmPSF *psf, bool ignore, psImageMaskType maskVal);
    8485bool            psphotSetMaskAndWeight (pmConfig *config, pmReadout *readout, psMetadata *recipe);
    8586void            psphotSourceFreePixels (psArray *sources);
     
    8788// functions to set the correct source pixels
    8889bool            psphotInitRadiusPSF (const psMetadata *recipe, const pmModelType type);
    89 bool            psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal);
    90 bool            psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal, float dR);
     90bool            psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal);
     91bool            psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal, float dR);
    9192bool            psphotInitRadiusEXT (psMetadata *recipe, pmModelType type);
    92 bool            psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal);
     93bool            psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal);
    9394
    9495// output functions
     
    109110bool            psphotInitLimitsPSF (psMetadata *recipe, pmReadout *readout);
    110111bool            psphotInitLimitsEXT (psMetadata *recipe);
    111 bool            psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal);
    112 bool            psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf, psMaskType maskVal, psMaskType markVal);
    113 bool            psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal);
    114 pmModel        *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, psMaskType markVal);
    115 psArray        *psphotFitDBL (pmReadout *readout, pmSource *source, psMaskType maskVal, psMaskType markVal);
     112bool            psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal);
     113bool            psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal);
     114bool            psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal);
     115pmModel        *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal);
     116psArray        *psphotFitDBL (pmReadout *readout, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal);
    116117
    117118// functions to support simultaneous multi-source fitting
    118 bool            psphotFitSet (pmSource *oneSrc, pmModel *oneModel, char *fitset, pmSourceFitMode mode, psMaskType maskVal);
     119bool            psphotFitSet (pmSource *oneSrc, pmModel *oneModel, char *fitset, pmSourceFitMode mode, psImageMaskType maskVal);
    119120
    120121// plotting functions (available if libkapa is installed)
     
    137138bool            psphotMosaicSubimage (psImage *outImage, pmSource *source, int Xo, int Yo, int DX, int DY, bool normalize);
    138139
    139 bool            psphotAddWithTest (pmSource *source, bool useState, psMaskType maskVal);
    140 bool            psphotSubWithTest (pmSource *source, bool useState, psMaskType maskVal);
    141 bool            psphotSetState (pmSource *source, bool curState, psMaskType maskVal);
     140bool            psphotAddWithTest (pmSource *source, bool useState, psImageMaskType maskVal);
     141bool            psphotSubWithTest (pmSource *source, bool useState, psImageMaskType maskVal);
     142bool            psphotSetState (pmSource *source, bool curState, psImageMaskType maskVal);
    142143bool            psphotDeblendSatstars (psArray *sources, psMetadata *recipe);
    143144bool            psphotSourceSize (pmConfig *config, pmReadout *readout, psArray *sources, psMetadata *recipe, long first);
    144145
    145 bool            psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf, psMaskType maskVal);
    146 
    147 pmModel        *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, psMaskType markVal, int psfSize);
     146bool            psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf, psImageMaskType maskVal);
     147
     148pmModel        *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal, int psfSize);
    148149
    149150psKernel       *psphotKernelFromPSF (pmSource *source, int nPix);
    150151
    151 bool            psphotRadialProfile (pmSource *source, psMetadata *recipe, psMaskType maskVal);
    152 bool            psphotPetrosian (pmSource *source, psMetadata *recipe, psMaskType maskVal);
    153 bool            psphotIsophotal (pmSource *source, psMetadata *recipe, psMaskType maskVal);
    154 bool            psphotAnnuli (pmSource *source, psMetadata *recipe, psMaskType maskVal);
    155 bool            psphotKron (pmSource *source, psMetadata *recipe, psMaskType maskVal);
     152bool            psphotRadialProfile (pmSource *source, psMetadata *recipe, psImageMaskType maskVal);
     153bool            psphotPetrosian (pmSource *source, psMetadata *recipe, psImageMaskType maskVal);
     154bool            psphotIsophotal (pmSource *source, psMetadata *recipe, psImageMaskType maskVal);
     155bool            psphotAnnuli (pmSource *source, psMetadata *recipe, psImageMaskType maskVal);
     156bool            psphotKron (pmSource *source, psMetadata *recipe, psImageMaskType maskVal);
    156157
    157158// psphotVisual functions
     
    168169bool psphotVisualShowSatStars (psMetadata *recipe, pmPSF *psf, psArray *sources);
    169170bool psphotVisualShowPSFModel (pmReadout *readout, pmPSF *psf);
    170 bool psphotVisualPlotRadialProfile (int myKapa, pmSource *source, psMaskType maskVal);
     171bool psphotVisualPlotRadialProfile (int myKapa, pmSource *source, psImageMaskType maskVal);
    171172bool psphotVisualPlotRadialProfiles (psMetadata *recipe, psArray *sources);
    172173bool psphotVisualShowFlags (psArray *sources);
     
    223224bool psphotMakeFluxScale (psImage *image, psMetadata *recipe, pmPSF *psf);
    224225bool psphotMakeGrowthCurve (pmReadout *readout, psMetadata *recipe, pmPSF *psf);
    225 bool psphotDumpPSFStars (pmReadout *readout, pmPSFtry *try, float radius, psMaskType maskVal, psMaskType markVal);
     226bool psphotDumpPSFStars (pmReadout *readout, pmPSFtry *try, float radius, psImageMaskType maskVal, psImageMaskType markVal);
    226227
    227228bool psphotCheckStarDistribution (psArray *sources, psArray *stars, pmPSFOptions *options);
  • trunk/psphot/src/psphotAddNoise.c

    r20593 r21183  
    2323
    2424    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    25     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     25    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    2626    assert (maskVal);
    2727
  • trunk/psphot/src/psphotAnnuli.c

    r17396 r21183  
    11# include "psphotInternal.h"
    22
    3 bool psphotAnnuli (pmSource *source, psMetadata *recipe, psMaskType maskVal) {
     3bool psphotAnnuli (pmSource *source, psMetadata *recipe, psImageMaskType maskVal) {
    44
    55  assert (source->extpars);
  • trunk/psphot/src/psphotApResid.c

    r21175 r21183  
    4444
    4545    // bit-masks to test for good/bad pixels
    46     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
     46    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
    4747    assert (maskVal);
    4848
    4949    // bit-mask to mark pixels not used in analysis
    50     psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     50    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
    5151    assert (markVal);
    5252
     
    100100            psArrayAdd(job->args, 1, psf);
    101101            PS_ARRAY_ADD_SCALAR(job->args, photMode, PS_TYPE_S32);
    102             PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_U8); // XXX change this to use abstract mask type info
     102            PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_IMAGE_MASK);
    103103
    104104            PS_ARRAY_ADD_SCALAR(job->args, 0,        PS_TYPE_S32); // this is used as a return value for Nskip
     
    139139
    140140    // gather the stats to assess the aperture residuals
    141     psVector *mask    = psVectorAllocEmpty (300, PS_TYPE_U8);
     141    psVector *mask    = psVectorAllocEmpty (300, PS_TYPE_VECTOR_MASK);
    142142    psVector *mag     = psVectorAllocEmpty (300, PS_TYPE_F32);
    143143    psVector *xPos    = psVectorAllocEmpty (300, PS_TYPE_F32);
     
    176176        yPos->data.F32[Npsf]    = model->params->data.F32[PM_PAR_YPOS];
    177177
    178         mask->data.U8[Npsf] = 0;
     178        mask->data.PS_TYPE_VECTOR_MASK_DATA[Npsf] = 0;
    179179
    180180        dMag->data.F32[Npsf] = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0];
     
    242242                     mag->data.F32[i], dMag->data.F32[i], dMagSys->data.F32[i],
    243243                     apResid->data.F32[i], apResidRes->data.F32[i],
    244                      mask->data.U8[i]);
     244                     mask->data.PS_TYPE_VECTOR_MASK_DATA[i]);
    245245        }
    246246        fclose (dumpFile);
     
    325325    psVector *dMSubset = psVectorAllocEmpty (nGroup, PS_TYPE_F32);
    326326    psVector *dASubset = psVectorAllocEmpty (nGroup, PS_TYPE_F32);
    327     psVector *mkSubset = psVectorAllocEmpty (nGroup, PS_TYPE_U8);
     327    psVector *mkSubset = psVectorAllocEmpty (nGroup, PS_TYPE_VECTOR_MASK);
    328328
    329329    int n = 0;
     
    334334            dMSubset->data.F32[j] = dMag->data.F32[N];
    335335            dASubset->data.F32[j] = dap->data.F32[N];
    336             mkSubset->data.U8[j]  = mask->data.U8[N];
     336            mkSubset->data.PS_TYPE_VECTOR_MASK_DATA[j] = mask->data.PS_TYPE_VECTOR_MASK_DATA[N];
    337337        }
    338338        dMSubset->n = j;
     
    460460    pmPSF *psf                      = job->args->data[1];
    461461    pmSourcePhotometryMode photMode = PS_SCALAR_VALUE(job->args->data[2],S32);
    462     psMaskType maskVal              = PS_SCALAR_VALUE(job->args->data[3],U8);
     462    psImageMaskType maskVal         = PS_SCALAR_VALUE(job->args->data[3],PS_TYPE_IMAGE_MASK_DATA);
    463463
    464464    for (int i = 0; i < sources->n; i++) {
  • trunk/psphot/src/psphotBlendFit.c

    r21166 r21183  
    133133
    134134    // bit-masks to test for good/bad pixels
    135     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
     135    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
    136136    assert (maskVal);
    137137
    138138    // bit-mask to mark pixels not used in analysis
    139     psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     139    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
    140140    assert (markVal);
    141141
  • trunk/psphot/src/psphotChoosePSF.c

    r21082 r21183  
    2424
    2525    // bit-masks to test for good/bad pixels
    26     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
     26    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
    2727    assert (maskVal);
    2828
    2929    // bit-mask to mark pixels not used in analysis
    30     psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     30    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
    3131    assert (markVal);
    3232
     
    258258    for (int i = 0; i < try->sources->n; i++) {
    259259        pmSource *source = try->sources->data[i];
    260         if (try->mask->data.U8[i]) {
     260        if (try->mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    261261            source->mode &= ~PM_SOURCE_MODE_PSFSTAR;
    262262        }
  • trunk/psphot/src/psphotExtendedSourceAnalysis.c

    r19881 r21183  
    1212
    1313    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    14     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     14    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    1515    assert (maskVal);
    1616
  • trunk/psphot/src/psphotExtendedSourceFits.c

    r19881 r21183  
    1313
    1414    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    15     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     15    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    1616    assert (maskVal);
    1717
    18     psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT"); // Mask value for bad pixels
     18    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT"); // Mask value for bad pixels
    1919    assert (markVal);
    2020
  • trunk/psphot/src/psphotExtendedSources.c

    r17111 r21183  
    1212
    1313    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    14     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     14    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    1515    assert (maskVal);
    1616
  • trunk/psphot/src/psphotFindDetections.c

    r20453 r21183  
    1010
    1111    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    12     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     12    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    1313    assert (maskVal);
    1414
  • trunk/psphot/src/psphotFindFootprints.c

    r20831 r21183  
    11# include "psphotInternal.h"
    22
    3 bool psphotFindFootprints (pmDetections *detections, psImage *significance, pmReadout *readout, psMetadata *recipe, const int pass, psMaskType maskVal) {
     3bool psphotFindFootprints (pmDetections *detections, psImage *significance, pmReadout *readout, psMetadata *recipe, const int pass, psImageMaskType maskVal) {
    44
    55    bool status;
  • trunk/psphot/src/psphotFitSet.c

    r14337 r21183  
    22
    33// This is only used by psphotModelTest.c
    4 bool psphotFitSet (pmSource *source, pmModel *oneModel, char *fitset, pmSourceFitMode mode, psMaskType maskVal) {
     4bool psphotFitSet (pmSource *source, pmModel *oneModel, char *fitset, pmSourceFitMode mode, psImageMaskType maskVal) {
    55
    66    double x, y, Io;
  • trunk/psphot/src/psphotFitSourcesLinear.c

    r20938 r21183  
    1010// the analysis is performed wrt the simulated pixel values
    1111
    12 static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, psMaskType markVal);
     12static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, psImageMaskType markVal);
    1313
    1414bool psphotFitSourcesLinear (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final) {
     
    2323
    2424    // bit-masks to test for good/bad pixels
    25     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
     25    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
    2626    assert (maskVal);
    2727
    2828    // bit-mask to mark pixels not used in analysis
    29     psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     29    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
    3030    assert (markVal);
    3131
     
    233233// on the pixels which correspond to all of the sources of interest.  These elements fill in
    234234// the border matrix components in the sparse matrix equation.
    235 static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, psMaskType markVal) {
     235static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, psImageMaskType markVal) {
    236236
    237237    // generate the image-wide weight terms
     
    248248        float x = model->params->data.F32[PM_PAR_XPOS];
    249249        float y = model->params->data.F32[PM_PAR_YPOS];
    250         psImageMaskCircle (source->maskView, x, y, model->radiusFit, "AND", PS_NOT_U8(markVal));
     250        psImageMaskCircle (source->maskView, x, y, model->radiusFit, "AND", PS_NOT_IMAGE_MASK(markVal));
    251251    }
    252252
     
    254254    psF32 **image  = readout->image->data.F32;
    255255    psF32 **weight = readout->weight->data.F32;
    256     psU8  **mask   = readout->mask->data.U8;
     256    psImageMaskType  **mask   = readout->mask->data.PS_TYPE_IMAGE_MASK_DATA;
    257257
    258258    double w, x, y, x2, xy, y2, xc, yc, wt, f, fo, fx, fy;
     
    288288
    289289    // turn off MARK for all image pixels
    290     psImageMaskRegion (readout->mask, fullArray, "AND", PS_NOT_U8(markVal));
     290    psImageMaskRegion (readout->mask, fullArray, "AND", PS_NOT_IMAGE_MASK(markVal));
    291291
    292292    // set the Border T elements
  • trunk/psphot/src/psphotGuessModels.c

    r21166 r21183  
    4141
    4242    // bit-masks to test for good/bad pixels
    43     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
     43    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
    4444    assert (maskVal);
    4545
    4646    // bit-mask to mark pixels not used in analysis
    47     psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     47    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
    4848    assert (markVal);
    4949
     
    7373
    7474            // XXX change these to use abstract mask type info
    75             PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_U8);
    76             PS_ARRAY_ADD_SCALAR(job->args, markVal,  PS_TYPE_U8);
     75            PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_IMAGE_MASK);
     76            PS_ARRAY_ADD_SCALAR(job->args, markVal,  PS_TYPE_IMAGE_MASK);
    7777
    7878            if (!psThreadJobAddPending(job)) {
     
    130130    pmPSF *psf         = job->args->data[2];
    131131   
    132     psMaskType maskVal = PS_SCALAR_VALUE(job->args->data[3],U8);
    133     psMaskType markVal = PS_SCALAR_VALUE(job->args->data[4],U8);
     132    psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[3],PS_TYPE_IMAGE_MASK_DATA);
     133    psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA);
    134134
    135135    int nSrc = 0;
  • trunk/psphot/src/psphotIsophotal.c

    r17561 r21183  
    11# include "psphotInternal.h"
    22
    3 bool psphotIsophotal (pmSource *source, psMetadata *recipe, psMaskType maskVal) {
     3bool psphotIsophotal (pmSource *source, psMetadata *recipe, psImageMaskType maskVal) {
    44
    55  assert (source->extpars);
  • trunk/psphot/src/psphotKron.c

    r17396 r21183  
    11# include "psphotInternal.h"
    22
    3 bool psphotKron (pmSource *source, psMetadata *recipe, psMaskType maskVal) {
     3bool psphotKron (pmSource *source, psMetadata *recipe, psImageMaskType maskVal) {
    44
    55  psLogMsg ("psphot", PS_LOG_INFO, "not implemented\n");
  • trunk/psphot/src/psphotMagnitudes.c

    r21166 r21183  
    2828
    2929    // bit-masks to test for good/bad pixels
    30     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
     30    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
    3131    assert (maskVal);
    3232
    3333    // bit-mask to mark pixels not used in analysis
    34     psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     34    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
    3535    assert (markVal);
    3636
  • trunk/psphot/src/psphotMakeGrowthCurve.c

    r20453 r21183  
    1111
    1212    // bit-masks to test for good/bad pixels
    13     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
     13    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
    1414    assert (maskVal);
    1515
    1616    // bit-mask to mark pixels not used in analysis
    17     psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     17    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
    1818    assert (markVal);
    1919
  • trunk/psphot/src/psphotMakeResiduals.c

    r20453 r21183  
    11# include "psphotInternal.h"
    22
    3 bool psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf, psMaskType maskVal) {
     3bool psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf, psImageMaskType maskVal) {
    44
    55    bool status, isPSF;
    66    double flux, dflux;
    7     psU8 mflux;
     7    psImageMaskType mflux;
    88
    99    psTimerStart ("psphot.residuals");
     
    6969    // - set output pixel, weight, and mask
    7070
    71     // XXX need to set these correctly!!
    72     const int badMask = 1;              // mask bits
    73     const int poorMask = 2;             //       from psImageInterpolate
    74     const int clippedMask = 4;          // mask bit set for clipped values
     71    // these mask values do not correspond to the recipe values: they
     72    // are not propagated to images: they just need to fit in an 8-bit
     73    // value.  they are supplied to psImageInterpolate, which takes a
     74    // psImageMaskType; the mask portion of the result from
     75    // psImageInterpolate is supplied to fmasks, which is then used by
     76    // psVectorStats
     77
     78    const psImageMaskType badMask     = 0x01;   // mask bits
     79    const psImageMaskType poorMask    = 0x02;   // from psImageInterpolate
     80    const psImageMaskType clippedMask = 0x04;   // mask bit set for clipped values
     81    const psVectorMaskType fmaskVal = badMask | poorMask | clippedMask;
    7582
    7683    // determine the maximum image size from the input sources
     
    95102        psImage *image  = psImageCopy (NULL, source->pixels,   PS_TYPE_F32);
    96103        psImage *weight = psImageCopy (NULL, source->weight,   PS_TYPE_F32);
    97         psImage *mask   = psImageCopy (NULL, source->maskView, PS_TYPE_U8);
     104        psImage *mask   = psImageCopy (NULL, source->maskView, PS_TYPE_IMAGE_MASK);
    98105        pmModelSub (image, mask, model, PM_MODEL_OP_FUNC, maskVal);
    99106
     
    103110        psBinaryOp (weight, weight, "/", psScalarAlloc(Io*Io, PS_TYPE_F32));
    104111
    105         // we will interpolate the image and weight - include the mask or not?
    106         // XXX consider better values for the mask bits
    107         psImageInterpolation *interp =
    108             psImageInterpolationAlloc(mode, image, weight, NULL, 0xff, 0.0, 0.0, badMask, poorMask, 0.0, 0);
    109         psArrayAdd (input,  100, interp);
     112        // we interpolate the image and weight - include the mask or not?
     113        // XXX why not the mask?
     114        // psImageInterpolation *interp = psImageInterpolationAlloc(mode, image, weight, mask, maskVal, 0.0, 0.0, badMask, poorMask, 0.0, 0);
     115        psImageInterpolation *interp = psImageInterpolationAlloc(mode, image, weight, NULL, 0xff, 0.0, 0.0, badMask, poorMask, 0.0, 0);
     116        psArrayAdd (input, 100, interp);
    110117
    111118        // save the X,Y position for future reference
     
    131138    psVector *fluxes  = psVectorAlloc (input->n, PS_TYPE_F32);
    132139    psVector *dfluxes = psVectorAlloc (input->n, PS_TYPE_F32);
    133     psVector *fmasks  = psVectorAlloc (input->n, PS_TYPE_U8);
     140    psVector *fmasks  = psVectorAlloc (input->n, PS_TYPE_VECTOR_MASK);
    134141
    135142    // statistic to use to determine baseline for clipping
     
    164171                bool offImage = false;
    165172                if (psImageInterpolate (&flux, &dflux, &mflux, ix, iy, interp) == PS_INTERPOLATE_STATUS_OFF) {
     173                    // fprintf (stderr, "off image: %f %f : %f %f\n", ix, iy, flux, dflux);
    166174                    // This pixel is off the image
    167175                    offImage = true;
    168                     fmasks->data.U8[i] = 1;
    169                     // fprintf (stderr, "off image: %f %f : %f %f\n", ix, iy, flux, dflux);
    170                 }
    171                 fluxes->data.F32[i] = flux;
    172                 dfluxes->data.F32[i] = dflux;
    173                 fmasks->data.U8[i] = mflux;
     176                    fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = badMask;
     177                } else {
     178                  fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = mflux; // XXX is mflux IMAGE or VECTOR type?
     179                }
     180                fluxes->data.F32[i] = flux;
     181                dfluxes->data.F32[i] = dflux;
    174182                if (isnan(flux)) {
    175                     fmasks->data.U8[i] = 1;
    176                 }
    177                 if (fmasks->data.U8[i] == 0) {
     183                    fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = badMask;
     184                }
     185                if (fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) {
    178186                    nGoodPixel ++;
    179187                }
    180188            }
    181189
    182             // skip pixels which are off the image...
     190            // skip pixels with insufficient data
    183191            bool validPixel = (SPATIAL_ORDER == 0) ? (nGoodPixel > 1) : (nGoodPixel > 3);
    184192            if (!validPixel) {
     
    186194                resid->Rx->data.F32[oy][ox] = 0.0;
    187195                resid->Ry->data.F32[oy][ox] = 0.0;
    188                 resid->mask->data.U8[oy][ox] = 1;
     196                resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox] = badMask;
    189197                continue;
    190198            }
     
    192200            // measure the robust median to determine a baseline reference value
    193201            *fluxClip = *fluxClipDef;
    194             psVectorStats (fluxClip, fluxes, NULL, fmasks, 0xff);
     202            psVectorStats (fluxClip, fluxes, NULL, fmasks, fmaskVal);
    195203            psErrorClear();             // clear (ignore) any outstanding errors
    196204
     
    202210                float swing = fabs(delta) / sigma;
    203211
    204                 // make this a user option
     212                // mask pixels which are out of range
    205213                if (swing > nSigma) {
    206                     fmasks->data.U8[i] = clippedMask;
    207                 }
    208                 if (!fmasks->data.U8[i]) nKeep++;
     214                    fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = clippedMask;
     215                }
     216                if (!fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i]) nKeep++;
    209217            }
    210218
     
    212220                // measure the desired statistic on the unclipped pixels
    213221                *fluxStats = *fluxStatsDef;
    214                 psVectorStats (fluxStats, fluxes, NULL, fmasks, 0xff);
     222                psVectorStats (fluxStats, fluxes, NULL, fmasks, fmaskVal);
    215223                psErrorClear();         // clear (ignore) any outstanding errors
    216224
     
    220228
    221229                if (fabs(resid->Ro->data.F32[oy][ox]) < pixelSN*fluxStats->sampleStdev/sqrt(nKeep)) {
    222                   resid->mask->data.U8[oy][ox] = 1;
    223                 }
    224 
    225                 // fprintf (stderr, "res: %2d %2d : %6.4f  %6.4f  %6.4f   %3d  %1d\n", ox, oy, resid->Ro->data.F32[oy][ox], fluxStats->sampleStdev, fluxStats->sampleStdev/sqrt(nKeep), nKeep, resid->mask->data.U8[oy][ox]);
     230                  resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox] = 1;
     231                }
     232
     233                // fprintf (stderr, "res: %2d %2d : %6.4f  %6.4f  %6.4f   %3d  %1d\n", ox, oy, resid->Ro->data.F32[oy][ox], fluxStats->sampleStdev, fluxStats->sampleStdev/sqrt(nKeep), nKeep, resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox]);
    226234
    227235            } else {
     
    230238                psVectorInit(B, 0.0);
    231239                for (int i = 0; i < fluxes->n; i++) {
    232                     if (fmasks->data.U8[i]) continue;
     240                    if (fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue;
    233241                    B->data.F64[0] += fluxes->data.F32[i]/dfluxes->data.F32[i];
    234242                    B->data.F64[1] += fluxes->data.F32[i]*xC->data.F32[i]/dfluxes->data.F32[i];
     
    260268
    261269                float dRo = sqrt(A->data.F32[0][0]);
    262                 // fprintf (stderr, "res: %2d %2d : %6.4f  %6.4f  %6.4f   %3d  %1d\n", ox, oy, resid->Ro->data.F32[oy][ox], dRo, dRo/sqrt(nKeep), nKeep, resid->mask->data.U8[oy][ox]);
     270                // fprintf (stderr, "res: %2d %2d : %6.4f  %6.4f  %6.4f   %3d  %1d\n",
     271                // ox, oy, resid->Ro->data.F32[oy][ox], dRo, dRo/sqrt(nKeep), nKeep, resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox]);
    263272
    264273                if (fabs(resid->Ro->data.F32[oy][ox]) < pixelSN*dRo/sqrt(nKeep)) {
    265                   resid->mask->data.U8[oy][ox] = 1;
     274                  resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox] = 1;
    266275                }
    267276                //resid->weight->data.F32[oy][ox] = XXX;
  • trunk/psphot/src/psphotMaskReadout.c

    r18832 r21183  
    99    // XXX drop the write to recipe and move config into psphotRoughClass?
    1010    // XXX alternatively, define a function to set the psphot recipe masks
    11     psMaskType maskSat  = pmConfigMaskGet("SAT", config); // Mask value for saturated pixels
    12     psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.SAT", PS_META_REPLACE, "user-defined mask", maskSat);
     11    psImageMaskType maskSat  = pmConfigMaskGet("SAT", config); // Mask value for saturated pixels
     12    psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MASK.SAT", PS_META_REPLACE, "user-defined mask", maskSat);
    1313
    14     psMaskType maskBad  = pmConfigMaskGet("BAD", config); // Mask value for bad pixels
    15     psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.BAD", PS_META_REPLACE, "user-defined mask", maskBad);
     14    psImageMaskType maskBad  = pmConfigMaskGet("BAD", config); // Mask value for bad pixels
     15    psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MASK.BAD", PS_META_REPLACE, "user-defined mask", maskBad);
    1616
    1717    // generate mask & weight images if they don't already exit
  • trunk/psphot/src/psphotModelBackground.c

    r21108 r21183  
    4646
    4747    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    48     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     48    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    4949    assert (maskVal);
    5050
  • trunk/psphot/src/psphotModelTest.c

    r19881 r21183  
    1313
    1414    // bit-masks to test for good/bad pixels
    15     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
     15    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
    1616    assert (maskVal);
    1717
    1818    // bit-mask to mark pixels not used in analysis
    19     psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     19    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
    2020    assert (markVal);
    2121
  • trunk/psphot/src/psphotModelWithPSF.c

    r17396 r21183  
    2020        paramMask = constraint->paramMask;
    2121        if (paramMask != NULL) {
    22             PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_U8, false);
     22          PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false);
    2323            PS_ASSERT_VECTORS_SIZE_EQUAL(params, paramMask, false);
    2424        }
     
    145145        psImageInit (covar, 0.0);
    146146        for (int j = 0, J = 0; j < params->n; j++) {
    147             if (paramMask && (paramMask->data.U8[j])) {
     147            if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[j])) {
    148148                covar->data.F32[j][j] = 1.0;
    149149                continue;
    150150            }
    151151            for (int k = 0, K = 0; k < params->n; k++) {
    152                 if (paramMask && (paramMask->data.U8[k])) continue;
     152                if (paramMask && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[k])) continue;
    153153                covar->data.F32[j][k] = Alpha->data.F32[J][K];
    154154                K++;
     
    197197    PS_ASSERT_VECTOR_TYPE(params, PS_TYPE_F32, false);
    198198    if (paramMask) {
    199         PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_MASK, false);
     199        PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false);
    200200    }
    201201
     
    224224            // XXX probably should not skipped masked points:
    225225            // XXX skip if convolution of unmasked pixels will not see this pixel
    226             // if (source->maskObj->data.U8[i][j]) {
     226            // if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j]) {
    227227            // continue;
    228228            // }
     
    246246
    247247            for (int n = 0; n < params->n; n++) {
    248                 if ((paramMask != NULL) && (paramMask->data.U8[n])) { continue; }
     248                if ((paramMask != NULL) && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n])) { continue; }
    249249                psImage *dmodel = pcm->dmodels->data[n];
    250250                dmodel->data.F32[i][j] = deriv->data.F32[n];
     
    285285            // XXX are we doing the right thing with the mask?
    286286            // skip masked points
    287             if (source->maskObj->data.U8[i][j]) {
     287            if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j]) {
    288288                continue;
    289289            }
     
    308308            // alpha & beta only contain unmasked elements
    309309            for (int n1 = 0, N1 = 0; n1 < params->n; n1++) {
    310                 if ((paramMask != NULL) && (paramMask->data.U8[n1])) continue;
     310                if ((paramMask != NULL) && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n1])) continue;
    311311                psImage *dmodel = pcm->dmodelsConv->data[n1];
    312312                float weight = dmodel->data.F32[i][j] * yweight;
    313313                for (int n2 = 0, N2 = 0; n2 <= n1; n2++) {
    314                     if ((paramMask != NULL) && (paramMask->data.U8[n2])) continue;
     314                    if ((paramMask != NULL) && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n2])) continue;
    315315                    dmodel = pcm->dmodelsConv->data[n2];
    316316                    alpha->data.F32[N1][N2] += weight * dmodel->data.F32[i][j];
     
    357357    for (psS32 n = 0; n < params->n; n++) {
    358358        pcm->dmodels->data[n] = NULL;
    359         if ((paramMask != NULL) && (paramMask->data.U8[n])) { continue; }
     359        if ((paramMask != NULL) && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n])) { continue; }
    360360        pcm->dmodels->data[n] = psImageCopy (NULL, source->pixels, PS_TYPE_F32);
    361361    }
     
    366366    for (psS32 n = 0; n < params->n; n++) {
    367367        pcm->dmodelsConv->data[n] = NULL;
    368         if ((paramMask != NULL) && (paramMask->data.U8[n])) { continue; }
     368        if ((paramMask != NULL) && (paramMask->data.PS_TYPE_VECTOR_MASK_DATA[n])) { continue; }
    369369        pcm->dmodelsConv->data[n] = psImageCopy (NULL, source->pixels, PS_TYPE_F32);
    370370    }
  • trunk/psphot/src/psphotMosaicChip.c

    r18712 r21183  
    2525    }
    2626
    27     psMaskType blankMask = pmConfigMaskGet("BLANK", config);
     27    psImageMaskType blankMask = pmConfigMaskGet("BLANK", config);
    2828
    2929    // mosaic the chip, forcing a deep copy (resulting images are not subimages)
  • trunk/psphot/src/psphotOutput.c

    r20237 r21183  
    7474        for (int j = 0; j < source->pixels->numCols; j++) {
    7575            // skip masked points
    76             if (source->maskObj->data.U8[i][j]) {
     76            if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j]) {
    7777                continue;
    7878            }
     
    8787                     source->pixels->data.F32[i][j],
    8888                     1.0 / source->weight->data.F32[i][j],
    89                      source->maskObj->data.U8[i][j]);
     89                     source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[i][j]);
    9090        }
    9191    }
     
    237237
    238238// XXX add args as needed
    239 bool psphotDumpPSFStars (pmReadout *readout, pmPSFtry *try, float radius, psMaskType maskVal, psMaskType markVal) {
     239bool psphotDumpPSFStars (pmReadout *readout, pmPSFtry *try, float radius, psImageMaskType maskVal, psImageMaskType markVal) {
    240240
    241241    psphotSaveImage (NULL, readout->image,  "rawstars.fits");
     
    243243    for (int i = 0; i < try->sources->n; i++) {
    244244        // masked for: bad model fit, outlier in parameters
    245         if (try->mask->data.U8[i] & PSFTRY_MASK_ALL)
     245        if (try->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL)
    246246            continue;
    247247
     
    256256        psImageKeepCircle (source->maskObj, x, y, radius, "OR", markVal);
    257257        pmModelSub (source->pixels, source->maskObj, source->modelPSF, PM_MODEL_OP_FULL, maskVal);
    258         psImageKeepCircle (source->maskObj, x, y, radius, "AND", PS_NOT_U8(markVal));
     258        psImageKeepCircle (source->maskObj, x, y, radius, "AND", PS_NOT_IMAGE_MASK(markVal));
    259259    }
    260260
     
    264264
    265265        // masked for: bad model fit, outlier in parameters
    266         if (try->mask->data.U8[i] & PSFTRY_MASK_ALL) continue;
     266        if (try->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PSFTRY_MASK_ALL) continue;
    267267
    268268        pmSource *source = try->sources->data[i];
  • trunk/psphot/src/psphotPSFConvModel.c

    r18555 r21183  
    99// modelConv to contain the fitted parameters, and the modelFlux to contain the
    1010// convolved model image.
    11 pmModel *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, psMaskType markVal, int psfSize) {
     11pmModel *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal, int psfSize) {
    1212   
    1313    // maskVal is used to test for rejected pixels, and must include markVal
     
    7272    // create the minimization constraints
    7373    psMinConstraint *constraint = psMinConstraintAlloc();
    74     constraint->paramMask = psVectorAlloc (params->n, PS_TYPE_U8);
     74    constraint->paramMask = psVectorAlloc (params->n, PS_TYPE_VECTOR_MASK);
    7575    constraint->checkLimits = modelConv->modelLimits;
    7676
     
    7979    int nParams = params->n - 1;
    8080    psVectorInit (constraint->paramMask, 0);
    81     constraint->paramMask->data.U8[PM_PAR_SKY] = 1;
     81    constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[PM_PAR_SKY] = 1;
    8282
    8383    // force the floating parameters to fall within the contraint ranges
     
    9797            fprintf (stderr, "%f ", params->data.F32[i]);
    9898        }
    99         if ((constraint->paramMask != NULL) && constraint->paramMask->data.U8[i])
     99        if ((constraint->paramMask != NULL) && constraint->paramMask->data.PS_TYPE_VECTOR_MASK_DATA[i])
    100100            continue;
    101101        dparams->data.F32[i] = sqrt(covar->data.F32[i][i]);
  • trunk/psphot/src/psphotPetrosian.c

    r17561 r21183  
    11# include "psphotInternal.h"
    22
    3 bool psphotPetrosian (pmSource *source, psMetadata *recipe, psMaskType maskVal) {
     3bool psphotPetrosian (pmSource *source, psMetadata *recipe, psImageMaskType maskVal) {
    44
    55  bool status;
  • trunk/psphot/src/psphotRadialPlot.c

    r15017 r21183  
    6060    for (int iy = 0; iy < source->pixels->numRows; iy++) {
    6161        for (int ix = 0; ix < source->pixels->numCols; ix++) {
    62             if (source->maskObj->data.U8[iy][ix]) {
     62            if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix]) {
    6363                rb->data.F32[nb] = hypot (ix - Xo, iy - Yo) ;
    6464                fb->data.F32[nb] = log10(source->pixels->data.F32[iy][ix]);
  • trunk/psphot/src/psphotRadialProfile.c

    r17396 r21183  
    1717}
    1818
    19 bool psphotRadialProfile (pmSource *source, psMetadata *recipe, psMaskType maskVal) {
     19bool psphotRadialProfile (pmSource *source, psMetadata *recipe, psImageMaskType maskVal) {
    2020
    2121    // allocate pmSourceExtendedParameters, if not already defined
     
    5454    for (int iy = 0; iy < source->pixels->numRows; iy++) {
    5555        for (int ix = 0; ix < source->pixels->numCols; ix++) {
    56             if (source->maskObj->data.U8[iy][ix]) continue;
     56            if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix]) continue;
    5757            radius->data.F32[n] = hypot (ix - Xo, iy - Yo) ;
    5858            flux->data.F32[n]   = source->pixels->data.F32[iy][ix];
  • trunk/psphot/src/psphotRadiusChecks.c

    r19308 r21183  
    1919
    2020// call this function whenever you (re)-define the PSF model
    21 bool psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal)
     21bool psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal)
    2222{
    2323    psF32 *PAR = model->params->data.F32;
     
    5050}
    5151
    52 bool psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal, float dR) {
     52bool psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal, float dR) {
    5353
    5454    psF32 *PAR = model->params->data.F32;
     
    8686
    8787// call this function whenever you (re)-define the EXT model
    88 bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal) {
     88bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psImageMaskType markVal) {
    8989
    9090    psF32 *PAR = model->params->data.F32;
  • trunk/psphot/src/psphotReplaceUnfit.c

    r20453 r21183  
    22
    33// replace the flux for sources which failed
    4 bool psphotReplaceUnfitSources (psArray *sources, psMaskType maskVal) {
     4bool psphotReplaceUnfitSources (psArray *sources, psImageMaskType maskVal) {
    55
    66    pmSource *source;
     
    3131
    3232    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    33     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     33    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    3434    assert (maskVal);
    3535
     
    5555
    5656    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    57     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     57    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    5858    assert (maskVal);
    5959
     
    7272
    7373// add source, if the source has been subtracted; do not modify state
    74 bool psphotAddWithTest (pmSource *source, bool useState, psMaskType maskVal) {
     74bool psphotAddWithTest (pmSource *source, bool useState, psImageMaskType maskVal) {
    7575
    7676    // what is current state? (true : add; false : sub)
     
    8383
    8484// sub source, if the source has been added; do not modify state
    85 bool psphotSubWithTest (pmSource *source, bool useState, psMaskType maskVal) {
     85bool psphotSubWithTest (pmSource *source, bool useState, psImageMaskType maskVal) {
    8686
    8787    // what is current state? (true : sub; false : add)
     
    9494
    9595// add or sub source to match recorded state: supply current state as true (add) or false (sub)
    96 bool psphotSetState (pmSource *source, bool curState, psMaskType maskVal) {
     96bool psphotSetState (pmSource *source, bool curState, psImageMaskType maskVal) {
    9797
    9898    // what is desired state? (true : add; false : sub)
  • trunk/psphot/src/psphotRoughClass.c

    r20453 r21183  
    5757
    5858    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    59     psMaskType maskSat = psMetadataLookupU8(&status, recipe, "MASK.SAT"); // Mask value for bad pixels
     59    psImageMaskType maskSat = psMetadataLookupImageMask(&status, recipe, "MASK.SAT"); // Mask value for bad pixels
    6060    assert (maskSat);
    6161
  • trunk/psphot/src/psphotSetMaskBits.c

    r18469 r21183  
    1010bool psphotSetMaskBits (pmConfig *config) {
    1111
    12     psMaskType maskValue;
    13     psMaskType markValue;
     12    psImageMaskType maskValue;
     13    psImageMaskType markValue;
    1414
    1515    if (!pmConfigMaskSetBits (&maskValue, &markValue, config)) {
     
    2626
    2727    // set maskValue and markValue in the psphot recipe
    28     psMetadataAddU8 (recipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "user-defined mask", markValue);
    29     psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskValue);
     28    psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "user-defined mask", markValue);
     29    psMetadataAddImageMask (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskValue);
    3030
    3131    return true;
  • trunk/psphot/src/psphotSignificanceImage.c

    r20829 r21183  
    44// (S/N)^2.  If FWMH_X,Y have been recorded, use them, otherwise use PEAKS_SMOOTH_SIGMA for the
    55// smoothing kernel.
    6 psImage *psphotSignificanceImage (pmReadout *readout, psMetadata *recipe, const int pass, psMaskType maskVal) {
     6psImage *psphotSignificanceImage (pmReadout *readout, psMetadata *recipe, const int pass, psImageMaskType maskVal) {
    77
    88    float SIGMA_SMTH, NSIGMA_SMTH;
     
    110110        for (int i = 0; i < smooth_im->numCols; i++) {
    111111            float value = smooth_im->data.F32[j][i];
    112             if (value < 0 || smooth_wt->data.F32[j][i] <= 0 || (mask->data.U8[j][i] & maskVal)) {
     112            if (value < 0 || smooth_wt->data.F32[j][i] <= 0 || (mask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] & maskVal)) {
    113113                smooth_im->data.F32[j][i] = 0.0;
    114114            } else {
  • trunk/psphot/src/psphotSkyReplace.c

    r20453 r21183  
    1717    // select the corresponding images
    1818    psF32 **image = readout->image->data.F32;
    19     psU8  **mask  = readout->mask->data.U8;
     19    psImageMaskType  **mask  = readout->mask->data.PS_TYPE_IMAGE_MASK_DATA;
    2020    psF32 **back  = background->image->data.F32;
    2121
  • trunk/psphot/src/psphotSourceFits.c

    r21166 r21183  
    2222}
    2323
    24 bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal) {
     24bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal) {
    2525
    2626    float x, y, dR;
     
    147147}
    148148
    149 bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal) {
     149bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal) {
    150150
    151151    double chiTrend;
     
    208208}
    209209
    210 bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *newSources, pmPSF *psf, psMaskType maskVal, psMaskType markVal) {
     210bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *newSources, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal) {
    211211
    212212    bool okEXT, okDBL;
     
    318318
    319319// fit a double PSF source to an extended blob
    320 psArray *psphotFitDBL (pmReadout *readout, pmSource *source, psMaskType maskVal, psMaskType markVal) {
     320psArray *psphotFitDBL (pmReadout *readout, pmSource *source, psImageMaskType maskVal, psImageMaskType markVal) {
    321321
    322322    float dx, dy;
     
    370370}
    371371
    372 pmModel *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, psMaskType markVal) {
     372pmModel *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psImageMaskType maskVal, psImageMaskType markVal) {
    373373
    374374    NfitEXT ++;
  • trunk/psphot/src/psphotSourcePlots.c

    r19869 r21183  
    77
    88    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    9     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     9    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    1010    assert (maskVal);
    1111
  • trunk/psphot/src/psphotSourceSize.c

    r20938 r21183  
    33
    44static float psphotModelContour(const psImage *image, const psImage *weight, const psImage *mask,
    5                                 psMaskType maskVal, const pmModel *model, float Ro);
    6 
    7 bool psphotMaskCosmicRay_Old (pmSource *source, psMaskType maskVal, psMaskType crMask);
    8 bool psphotMaskCosmicRay_New (psImage *mask, pmSource *source, psMaskType maskVal, psMaskType crMask);
     5                                psImageMaskType maskVal, const pmModel *model, float Ro);
     6
     7bool psphotMaskCosmicRay_Old (pmSource *source, psImageMaskType maskVal, psImageMaskType crMask);
     8bool psphotMaskCosmicRay_New (psImage *mask, pmSource *source, psImageMaskType maskVal, psImageMaskType crMask);
    99
    1010// we need to call this function after sources have been fitted to the PSF model and
     
    2121
    2222    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    23     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     23    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    2424    assert (maskVal);
    2525
    2626    // bit to mask the cosmic-ray pixels
    27     psMaskType crMask  = pmConfigMaskGet("CR", config); // Mask value for cosmic rays
     27    psImageMaskType crMask  = pmConfigMaskGet("CR", config); // Mask value for cosmic rays
    2828
    2929    float CR_NSIGMA_LIMIT = psMetadataLookupF32 (&status, recipe, "PSPHOT.CR.NSIGMA.LIMIT");
     
    6363        psF32 **resid  = source->pixels->data.F32;
    6464        psF32 **weight = source->weight->data.F32;
    65         psU8 **mask    = source->maskObj->data.U8;
     65        psImageMaskType **mask    = source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA;
    6666
    6767        // check for extendedness: measure the delta flux significance at the 1 sigma contour
     
    191191// deviations?
    192192static float psphotModelContour(const psImage *image, const psImage *weight, const psImage *mask,
    193                                 psMaskType maskVal, const pmModel *model, float Ro)
     193                                psImageMaskType maskVal, const pmModel *model, float Ro)
    194194{
    195195    psF32 *PAR = model->params->data.F32; // Model parameters
     
    239239
    240240        if (yPixM >= 0 && yPixM < image->numRows &&
    241             !(mask && (mask->data.PS_TYPE_MASK_DATA[yPixM][xPix] & maskVal))) {
     241            !(mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[yPixM][xPix] & maskVal))) {
    242242            float dSigma = image->data.F32[yPixM][xPix] / sqrtf(weight->data.F32[yPixM][xPix]);
    243243            nSigma += dSigma;
     
    250250
    251251        if (yPixP >= 0 && yPixP < image->numRows &&
    252             !(mask && (mask->data.PS_TYPE_MASK_DATA[yPixP][xPix] & maskVal))) {
     252            !(mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[yPixP][xPix] & maskVal))) {
    253253            float dSigma = image->data.F32[yPixP][xPix] / sqrtf(weight->data.F32[yPixP][xPix]);
    254254            nSigma += dSigma;
     
    260260}
    261261
    262 bool psphotMaskCosmicRay_New (psImage *mask, pmSource *source, psMaskType maskVal, psMaskType crMask) {
     262bool psphotMaskCosmicRay_New (psImage *mask, pmSource *source, psImageMaskType maskVal, psImageMaskType crMask) {
    263263
    264264    // replace the source flux
     
    294294       
    295295        for (int ix = xs; ix < xe; ix++) {
    296             mask->data.U8[iy][ix] |= crMask;
     296            mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= crMask;
    297297        }
    298298    }
     
    300300}
    301301
    302 bool psphotMaskCosmicRay_Old (pmSource *source, psMaskType maskVal, psMaskType crMask) {
     302bool psphotMaskCosmicRay_Old (pmSource *source, psImageMaskType maskVal, psImageMaskType crMask) {
    303303
    304304    source->mode |= PM_SOURCE_MODE_CR_LIMIT;
     
    320320        float SN = pixels->data.F32[yo][ix] / sqrt(weight->data.F32[yo][ix]);
    321321        if (SN > SN_LIMIT) {
    322             mask->data.U8[yo][ix] |= crMask;
     322            mask->data.PS_TYPE_IMAGE_MASK_DATA[yo][ix] |= crMask;
    323323        }
    324324    }
     
    326326        float SN = pixels->data.F32[yo][ix] / sqrt(weight->data.F32[yo][ix]);
    327327        if (SN > SN_LIMIT) {
    328             mask->data.U8[yo][ix] |= crMask;
     328            mask->data.PS_TYPE_IMAGE_MASK_DATA[yo][ix] |= crMask;
    329329        }
    330330    }
     
    339339
    340340            bool valid = false;
    341             valid |= (mask->data.U8[iy+1][ix] & crMask);
    342             valid |= (ix > 0) ? (mask->data.U8[iy+1][ix-1] & crMask) : 0;
    343             valid |= (ix <= mask->numCols) ? (mask->data.U8[iy+1][ix+1] & crMask) : 0;
     341            valid |= (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+1][ix] & crMask);
     342            valid |= (ix > 0) ? (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+1][ix-1] & crMask) : 0;
     343            valid |= (ix <= mask->numCols) ? (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy+1][ix+1] & crMask) : 0;
    344344
    345345            if (!valid) continue;
    346             mask->data.U8[iy][ix] |= crMask;
     346            mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= crMask;
    347347        }
    348348    }
     
    355355
    356356            bool valid = false;
    357             valid |= (mask->data.U8[iy-1][ix] & crMask);
    358             valid |= (ix > 0) ? (mask->data.U8[iy-1][ix-1] & crMask) : 0;
    359             valid |= (ix <= mask->numCols) ? (mask->data.U8[iy-1][ix+1] & crMask) : 0;
     357            valid |= (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy-1][ix] & crMask);
     358            valid |= (ix > 0) ? (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy-1][ix-1] & crMask) : 0;
     359            valid |= (ix <= mask->numCols) ? (mask->data.PS_TYPE_IMAGE_MASK_DATA[iy-1][ix+1] & crMask) : 0;
    360360
    361361            if (!valid) continue;
    362             mask->data.U8[iy][ix] |= crMask;
     362            mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] |= crMask;
    363363        }
    364364    }
  • trunk/psphot/src/psphotSourceStats.c

    r21166 r21183  
    1717        nThreads = 0;
    1818    }
    19     // nThreads = 0; // XXX until testing is complete, do not thread this function
    2019
    2120    // determine properties (sky, moments) of initial sources
     
    144143
    145144    // bit-masks to test for good/bad pixels
    146     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
     145    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT");
    147146    assert (maskVal);
    148147
    149148    // bit-mask to mark pixels not used in analysis
    150     psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     149    psImageMaskType markVal = psMetadataLookupImageMask(&status, recipe, "MARK.PSPHOT");
    151150    assert (markVal);
    152151
  • trunk/psphot/src/psphotSubtractBackground.c

    r20453 r21183  
    2828
    2929    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    30     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     30    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    3131    assert (maskVal);
    3232
  • trunk/psphot/src/psphotTestPSF.c

    r18555 r21183  
    111111        psImageKeepCircle (source->mask, x, y, RADIUS, "OR", markVal);
    112112        status = pmSourceFitModel (source, model, PM_SOURCE_FIT_EXT);
    113         psImageKeepCircle (source->mask, x, y, RADIUS, "AND", PS_NOT_U8(markVal));
     113        psImageKeepCircle (source->mask, x, y, RADIUS, "AND", PS_NOT_IMAGE_MASK(markVal));
    114114
    115115        // write fitted parameters to file
  • trunk/psphot/src/psphotTestSourceOutput.c

    r14655 r21183  
    8080                float oy = yBin*(iy + 0.5 + image->row0 - yCenter) + yResidCenter;
    8181
    82                 psU8 mflux = 0;
     82                psImageMaskType mflux = 0;
    8383                double Fo = 0.0;
    8484                double Fx = 0.0;
  • trunk/psphot/src/psphotVisual.c

    r20938 r21183  
    5151        ALLOCATE (image.data2d[iy], float, image.Nx);
    5252        for (int ix = 0; ix < image.Nx; ix++) {
    53             image.data2d[iy][ix] = inImage->data.U8[iy][ix];
     53            image.data2d[iy][ix] = inImage->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix];
    5454        }
    5555    }
     
    813813
    814814    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    815     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     815    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    816816    assert (maskVal);
    817817
     
    973973
    974974    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    975     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     975    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    976976    assert (maskVal);
    977977
     
    10971097}
    10981098
    1099 bool psphotVisualPlotRadialProfile (int myKapa, pmSource *source, psMaskType maskVal) {
     1099bool psphotVisualPlotRadialProfile (int myKapa, pmSource *source, psImageMaskType maskVal) {
    11001100
    11011101    Graphdata graphdata;
     
    11181118    for (int iy = 0; iy < source->pixels->numRows; iy++) {
    11191119        for (int ix = 0; ix < source->pixels->numCols; ix++) {
    1120             if (source->maskObj->data.U8[iy][ix]) {
     1120            if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix]) {
    11211121                // rb->data.F32[nb] = hypot (ix + 0.5 - Xo, iy + 0.5 - Yo) ;
    11221122                rb->data.F32[nb] = hypot (ix - Xo, iy - Yo) ;
     
    12271227    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    12281228    bool status;
    1229     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     1229    psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    12301230    assert (maskVal);
    12311231
  • trunk/pswarp/src/pswarpLoop.c

    r21178 r21183  
    6767
    6868    // output mask bits
    69     psMaskType maskValue = psMetadataLookupU8(&status, recipe, "MASK.OUTPUT");
     69    psImageMaskType maskValue = psMetadataLookupImageMask(&status, recipe, "MASK.OUTPUT");
    7070    psAssert (status, "MASK.OUTPUT was not defined");
    7171
  • trunk/pswarp/src/pswarpPixelFraction.c

    r18558 r21183  
    2020    PS_ASSERT_IMAGE_NON_NULL(readout->mask, false);
    2121    PS_ASSERT_IMAGES_SIZE_EQUAL(readout->mask, readout->image, false);
    22     PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_MASK, false);
     22    PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_IMAGE_MASK, false);
    2323
    2424    if (stats) {
     
    4040
    4141    // output mask bits
    42     psMaskType maskValue = psMetadataLookupU8(&status, recipe, "MASK.OUTPUT");
     42    psImageMaskType maskValue = psMetadataLookupImageMask(&status, recipe, "MASK.OUTPUT");
    4343    psAssert (status, "MASK.OUTPUT was not defined");
    4444
     
    5555    for (int y = 0; y < numRows; y++) {
    5656        for (int x = 0; x < numCols; x++) {
    57             if (mask->data.PS_TYPE_MASK_DATA[y][x] & maskValue) {
     57            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskValue) {
    5858                numBad++;
    5959            } else {
  • trunk/pswarp/src/pswarpSetMaskBits.c

    r18558 r21183  
    1010bool pswarpSetMaskBits (pmConfig *config) {
    1111
    12     psMaskType maskIn = 0x00;                   // mask for the input image
    13     psMaskType markIn = 0x00;                   // mark for the input image
    14     psMaskType maskOut = 0x00;                  // mask for the output image
    15     psMaskType markOut = 0x00;                  // mark for the output image
     12    psImageMaskType maskIn = 0x00;                      // mask for the input image
     13    psImageMaskType markIn = 0x00;                      // mark for the input image
     14    psImageMaskType maskOut = 0x00;                     // mask for the output image
    1615
    1716    // this function sets the required single-image mask bits
     
    2221
    2322    // mask for non-linear flat regions (default to DETECTOR if not defined)
    24     psMaskType badMask = pmConfigMaskGet("BAD.WARP", config);
     23    psImageMaskType badMask = pmConfigMaskGet("BAD.WARP", config);
    2524    if (!badMask) {
    2625        badMask = 0x01;
     
    3029
    3130    // mask for non-linear flat regions (default to DETECTOR if not defined)
    32     psMaskType poorMask = pmConfigMaskGet("POOR.WARP", config);
     31    psImageMaskType poorMask = pmConfigMaskGet("POOR.WARP", config);
    3332    if (!poorMask) {
    3433        poorMask = 0x02;
     
    3837
    3938    // search for an unset bit to use for MARK:
    40     markOut = 0x80;
     39    psImageMaskType markOut   = 0x00;
     40    psImageMaskType markTrial = 0x01;
    4141
    42     int nBits = sizeof(psMaskType) * 8;
     42    int nBits = sizeof(psImageMaskType) * 8;
    4343    for (int i = 0; !markOut && (i < nBits); i++) {
    44         if (maskOut & markOut) {
    45             markOut >>= 1;
    46         } else {
    47             markOut = markOut;
    48         }
     44        if (maskOut & markTrial) {
     45            markTrial <<= 1;
     46        } else {
     47            markOut = markTrial;
     48        }
    4949    }
    50 
    5150    if (!markOut) {
    52         psError (PS_ERR_UNKNOWN, true, "Unable to define the MARK bit mask: all bits taken!");
    53         return false;
     51        psError (PS_ERR_UNKNOWN, true, "Unable to define the MARK bit mask: all bits taken!");
     52        return false;
    5453    }
    5554
     
    6362    // set maskOut and markOut in the psphot recipe
    6463    // NOTE: psphot works on the output images, not input images, so set the MARK and MASK correctly here
    65     psMetadataAddU8 (warpRecipe, PS_LIST_TAIL, "MASK.INPUT",  PS_META_REPLACE, "user-defined mask", maskIn);
    66     psMetadataAddU8 (warpRecipe, PS_LIST_TAIL, "MARK.INPUT",  PS_META_REPLACE, "user-defined mask", markIn);
    67     psMetadataAddU8 (warpRecipe, PS_LIST_TAIL, "MASK.OUTPUT", PS_META_REPLACE, "user-defined mask", maskOut);
    68     psMetadataAddU8 (warpRecipe, PS_LIST_TAIL, "MARK.OUTPUT", PS_META_REPLACE, "user-defined mask", markOut);
     64    psMetadataAddImageMask (warpRecipe, PS_LIST_TAIL, "MASK.INPUT",  PS_META_REPLACE, "user-defined mask", maskIn);
     65    psMetadataAddImageMask (warpRecipe, PS_LIST_TAIL, "MARK.INPUT",  PS_META_REPLACE, "user-defined mask", markIn);
     66    psMetadataAddImageMask (warpRecipe, PS_LIST_TAIL, "MASK.OUTPUT", PS_META_REPLACE, "user-defined mask", maskOut);
     67    psMetadataAddImageMask (warpRecipe, PS_LIST_TAIL, "MARK.OUTPUT", PS_META_REPLACE, "user-defined mask", markOut);
    6968
    7069    // update the psphot recipe
     
    7776    // set maskOut and markOut in the psphot recipe
    7877    // NOTE: psphot works on the output images, not input images, so set the MARK and MASK correctly here
    79     psMetadataAddU8 (psphotRecipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "user-defined mask", markOut);
    80     psMetadataAddU8 (psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskOut);
     78    psMetadataAddImageMask (psphotRecipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "user-defined mask", markOut);
     79    psMetadataAddImageMask (psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskOut);
    8180
    8281    return true;
  • trunk/pswarp/src/pswarpTransformReadout.c

    r20334 r21183  
    2222
    2323    // output mask bits
    24     psMaskType maskIn   = psMetadataLookupU8(&mdok, recipe, "MASK.INPUT");
    25     psMaskType maskPoor = pmConfigMaskGet("POOR.WARP", config);
    26     psMaskType maskBad  = pmConfigMaskGet("BAD.WARP", config);
     24    psImageMaskType maskIn   = psMetadataLookupImageMask(&mdok, recipe, "MASK.INPUT");
     25    psImageMaskType maskPoor = pmConfigMaskGet("POOR.WARP", config);
     26    psImageMaskType maskBad  = pmConfigMaskGet("BAD.WARP", config);
    2727    psAssert(mdok, "MASK.INPUT was not defined");
    2828
     
    8080    }
    8181    if ((input->mask || maskPoor || maskBad) && !output->mask) {
    82         output->mask = psImageAlloc(output->image->numCols, output->image->numRows, PS_TYPE_MASK);
     82        output->mask = psImageAlloc(output->image->numCols, output->image->numRows, PS_TYPE_IMAGE_MASK);
    8383        psImageInit(output->mask, maskBad);
    8484    }
  • trunk/pswarp/src/pswarpTransformTile.c

    r19395 r21183  
    4949    psF32 **outImageData     = args->output->image->data.F32;
    5050    psF32 **outVarData       = (args->output->weight) ? args->output->weight->data.F32 : NULL;
    51     psMaskType **outMaskData = (args->output->mask)   ? args->output->mask->data.PS_TYPE_MASK_DATA : NULL;
    52     psMaskType **inMaskData  = (args->input->mask)    ? args->input->mask->data.PS_TYPE_MASK_DATA : NULL;
     51    psImageMaskType **outMaskData = (args->output->mask)   ? args->output->mask->data.PS_TYPE_IMAGE_MASK_DATA : NULL;
     52    psImageMaskType **inMaskData  = (args->input->mask)    ? args->input->mask->data.PS_TYPE_IMAGE_MASK_DATA : NULL;
    5353
    5454    pswarpMap *map = args->grid->maps[args->gridX][args->gridY]; // Map for this tile
     
    6767
    6868            // Only transform those pixels requested
    69             if (region && region->data.U8[y][x]) {
     69            if (region && region->data.PS_TYPE_IMAGE_MASK_DATA[y][x]) {
    7070                continue;
    7171            }
     
    8282            // psImagePixelInterpolate determines the value at pixel coordinate (x,y) in child coordinates
    8383            double imageValue, varValue; // Value of image and variance map
    84             psMaskType maskValue = inMaskData ? inMaskData[(int)yIn][(int)xIn] : 0; // Value of mask
     84            psImageMaskType maskValue = inMaskData ? inMaskData[(int)yIn][(int)xIn] : 0; // Value of mask
    8585            if (!psImageInterpolate(&imageValue, &varValue, &maskValue, xIn, yIn, args->interp)) {
    8686                psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");
Note: See TracChangeset for help on using the changeset viewer.