IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21090


Ignore:
Timestamp:
Jan 7, 2009, 6:43:53 PM (17 years ago)
Author:
eugene
Message:

mask modifications for Image and Vector mask types (ppSim, ppStack, ppSub, pswarp, psphot)

Location:
branches/eam_branch_20081230
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20081230/ppSim/src/ppSimPhotom.c

    r21087 r21090  
    1515    psphotInit ();
    1616
    17  XXX : should this be a psImageMaskType?
    18     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...
    1918    ppSimMosaicChip(config, blankMask, view, "PPSIM.FORCE.CHIP", "PPSIM.INPUT");
    2019    ppSimMosaicChip(config, blankMask, view, "PPSIM.FAKE.CHIP", "PPSIM.OUTPUT");
  • branches/eam_branch_20081230/ppStack/src/ppStackArguments.c

    r20995 r21090  
    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
  • branches/eam_branch_20081230/ppStack/src/ppStackLoop.c

    r20997 r21090  
    401401    int numGood = 0;                    // Number of good frames
    402402    int numCols = 0, numRows = 0;       // Size of image
    403     psVector *inputMask = psVectorAlloc(num, PS_TYPE_U8); // Mask for inputs
     403    psVector *inputMask = psVectorAlloc(num, PS_TYPE_VECTOR_MASK); // Mask for inputs
    404404    psVectorInit(inputMask, 0);
    405405    psVector *matchChi2 = psVectorAlloc(num, PS_TYPE_F32); // chi^2 for stamps when matching
     
    445445                          sourceLists->data[i], targetPSF, rng, config)) {
    446446            psErrorStackPrint(stderr, "Unable to match image %d --- ignoring.", i);
    447             inputMask->data.U8[i] = PPSTACK_MASK_MATCH;
     447            inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PPSTACK_MASK_MATCH;
    448448            psErrorClear();
    449449            continue;
     
    501501        psVector *values = psVectorAllocEmpty(num, PS_TYPE_F32); // Values to sort
    502502        for (int i = 0; i < num; i++) {
    503             if (inputMask->data.PS_TYPE_MASK_DATA[i] & PPSTACK_MASK_ALL) {
     503            if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PPSTACK_MASK_ALL) {
    504504                continue;
    505505            }
     
    534534            numGood = 0;                    // Number of good images
    535535            for (int i = 0; i < num; i++) {
    536                 if (inputMask->data.PS_TYPE_MASK_DATA[i] & PPSTACK_MASK_ALL) {
     536              if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] & PPSTACK_MASK_ALL) {
    537537                    continue;
    538538                }
    539539                if (matchChi2->data.F32[i] > thresh) {
    540540                    numRej++;
    541                     inputMask->data.PS_TYPE_MASK_DATA[i] |= PPSTACK_MASK_CHI2;
     541                    inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= PPSTACK_MASK_CHI2;
    542542                    psLogMsg("ppStack", PS_LOG_INFO, "Rejecting image %d because of large matching chi^2: %f",
    543543                             i, matchChi2->data.F32[i]);
     
    612612
    613613        psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits to mask for bad
    614         psMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
     614        psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
    615615        if (!pmReadoutStackDefineOutput(outRO, col0, row0, numCols, numRows, true, true, maskBad)) {
    616616            psError(PS_ERR_UNKNOWN, false, "Unable to prepare output.");
     
    714714        inspect = psArrayAlloc(num);
    715715        for (int i = 0; i < num; i++) {
    716             if (inputMask->data.U8[i]) {
     716            if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    717717                continue;
    718718            }
     
    725725            psArray *results = job->results; // Results of job
    726726            for (int i = 0; i < num; i++) {
    727                 if (inputMask->data.U8[i]) {
     727                if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    728728                    continue;
    729729                }
     
    751751        // Count images rejected out of hand
    752752        for (int i = 0; i < num; i++) {
    753             if (inputMask->data.U8[i]) {
     753            if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    754754                numRejected++;
    755755            }
     
    757757
    758758        for (int i = 0; i < num; i++) {
    759             if (inputMask->data.U8[i]) {
     759            if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    760760                continue;
    761761            }
     
    802802        // Reject bad pixels
    803803        for (int i = 0; i < num; i++) {
    804             if (inputMask->data.U8[i]) {
     804            if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    805805                continue;
    806806            }
     
    845845                psWarning("Rejection on image %d didn't work --- reject entire image.", i);
    846846                numRejected++;
    847                 inputMask->data.U8[i] = PPSTACK_MASK_REJECT;
     847                inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PPSTACK_MASK_REJECT;
    848848            } else {
    849849                float frac = reject->n / (float)(numCols * numRows); // Pixel fraction
     
    856856                    // reject == NULL means reject image completely
    857857                    reject = NULL;
    858                     inputMask->data.U8[i] = PPSTACK_MASK_BAD;
     858                    inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PPSTACK_MASK_BAD;
    859859                    numRejected++;
    860860                }
     
    968968    {
    969969        psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits for bad
    970         psMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
     970        psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
    971971        if (!pmReadoutMaskApply(outRO, maskBad)) {
    972972            psWarning("Unable to apply mask");
     
    979979    float totExposure = 0.0;            // Total exposure time
    980980    for (int i = 0; i < num; i++) {
    981         if (inputMask->data.U8[i]) {
     981        if (inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
    982982            continue;
    983983        }
     
    10441044        pmCell *cell1 = pmFPAfileThisCell(config->files, view, "PPSTACK.OUTPUT.JPEG1");
    10451045        pmCell *cell2 = pmFPAfileThisCell(config->files, view, "PPSTACK.OUTPUT.JPEG2");
    1046         psMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask
     1046        psImageMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask
    10471047
    10481048        pmReadout *ro1 = pmReadoutAlloc(cell1), *ro2 = pmReadoutAlloc(cell2); // Binned readouts
     
    10661066        int renormNum = psMetadataLookupS32(&mdok, recipe, "RENORM.NUM"); // Number of samples
    10671067        float renormWidth = psMetadataLookupS32(&mdok, recipe, "RENORM.WIDTH"); // Width of Gaussian phot
    1068         psMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask
     1068        psImageMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask
    10691069        if (!pmReadoutWeightRenormPhot(outRO, maskValue, renormNum, renormWidth,
    10701070                                       renormMean, renormStdev, NULL)) {
     
    11121112        psTrace("ppStack", 1, "Gathering statistics on stacked image....\n");
    11131113        psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits for bad
    1114         psMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
     1114        psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
    11151115
    11161116        ppStatsFPA(stats, outRO->parent->parent->parent, view, maskBad, config);
  • branches/eam_branch_20081230/ppStack/src/ppStackMatch.c

    r21021 r21090  
    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
  • branches/eam_branch_20081230/ppStack/src/ppStackPhotometry.c

    r20995 r21090  
    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)) {
  • branches/eam_branch_20081230/ppStack/src/ppStackReadout.c

    r21072 r21090  
    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
  • branches/eam_branch_20081230/ppStack/src/ppStackSources.c

    r21016 r21090  
    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                }
  • branches/eam_branch_20081230/ppSub/src/ppSubArguments.c

    r20568 r21090  
    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);
  • branches/eam_branch_20081230/ppSub/src/ppSubBackground.c

    r20775 r21090  
    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;
  • branches/eam_branch_20081230/ppSub/src/ppSubReadout.c

    r21072 r21090  
    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.");
  • branches/eam_branch_20081230/psphot/src/psphotMakeResiduals.c

    r21087 r21090  
    11# include "psphotInternal.h"
    22
    3 XXX this function is probably broken: fmasks is confused between Image and Vector.  it is used by psVectorStats, so it must be Vector, but
    4   is populated by mflux, which seems to be Image..
    53bool psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf, psImageMaskType maskVal) {
    64
     
    7169    // - set output pixel, weight, and mask
    7270
    73     XXX need to set these correctly based on the RECIPE values
    74     const int badMask = 1;              // mask bits
    75     const int poorMask = 2;             //       from psImageInterpolate
    76     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;
    7782
    7883    // determine the maximum image size from the input sources
     
    105110        psBinaryOp (weight, weight, "/", psScalarAlloc(Io*Io, PS_TYPE_F32));
    106111
    107         // we will interpolate the image and weight - include the mask or not?
    108         // XXX consider better values for the mask bits
    109         psImageInterpolation *interp =
    110             psImageInterpolationAlloc(mode, image, weight, NULL, 0xff, 0.0, 0.0, badMask, poorMask, 0.0, 0);
    111         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);
    112117
    113118        // save the X,Y position for future reference
     
    166171                bool offImage = false;
    167172                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);
    168174                    // This pixel is off the image
    169175                    offImage = true;
    170                     fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;
    171                     // fprintf (stderr, "off image: %f %f : %f %f\n", ix, iy, flux, dflux);
    172                 }
    173                 fluxes->data.F32[i] = flux;
    174                 dfluxes->data.F32[i] = dflux;
    175                 fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = mflux; // XXX is mflux IMAGE or VECTOR type?
     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;
    176182                if (isnan(flux)) {
    177                     fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = 1;
     183                    fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = badMask;
    178184                }
    179185                if (fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] == 0) {
     
    182188            }
    183189
    184             // skip pixels which are off the image...
     190            // skip pixels with insufficient data
    185191            bool validPixel = (SPATIAL_ORDER == 0) ? (nGoodPixel > 1) : (nGoodPixel > 3);
    186192            if (!validPixel) {
     
    188194                resid->Rx->data.F32[oy][ox] = 0.0;
    189195                resid->Ry->data.F32[oy][ox] = 0.0;
    190                 resid->mask->data.PS_TYPE_IMAGE_MASK_DATA[oy][ox] = 1;
     196                resid->mask->data.PS_TYPE_IMAGE_MASK_DATA[oy][ox] = badMask;
    191197                continue;
    192198            }
     
    194200            // measure the robust median to determine a baseline reference value
    195201            *fluxClip = *fluxClipDef;
    196             psVectorStats (fluxClip, fluxes, NULL, fmasks, 0xff);
     202            psVectorStats (fluxClip, fluxes, NULL, fmasks, fmaskVal);
    197203            psErrorClear();             // clear (ignore) any outstanding errors
    198204
     
    204210                float swing = fabs(delta) / sigma;
    205211
    206                 // make this a user option
     212                // mask pixels which are out of range
    207213                if (swing > nSigma) {
    208214                    fmasks->data.PS_TYPE_VECTOR_MASK_DATA[i] = clippedMask;
     
    214220                // measure the desired statistic on the unclipped pixels
    215221                *fluxStats = *fluxStatsDef;
    216                 psVectorStats (fluxStats, fluxes, NULL, fmasks, 0xff);
     222                psVectorStats (fluxStats, fluxes, NULL, fmasks, fmaskVal);
    217223                psErrorClear();         // clear (ignore) any outstanding errors
    218224
  • branches/eam_branch_20081230/psphot/src/psphotModelWithPSF.c

    r21087 r21090  
    2020        paramMask = constraint->paramMask;
    2121        if (paramMask != NULL) {
    22           PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_TYPE, false);
     22          PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_VECTOR_MASK, false);
    2323            PS_ASSERT_VECTORS_SIZE_EQUAL(params, paramMask, false);
    2424        }
  • branches/eam_branch_20081230/pswarp/src/pswarpLoop.c

    r20348 r21090  
    8080
    8181    // output mask bits
    82     psMaskType maskValue = psMetadataLookupU8(&status, recipe, "MASK.OUTPUT");
     82    psImageMaskType maskValue = psMetadataLookupImageMask(&status, recipe, "MASK.OUTPUT");
    8383    psAssert (status, "MASK.OUTPUT was not defined");
    8484
  • branches/eam_branch_20081230/pswarp/src/pswarpPixelFraction.c

    r21072 r21090  
    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 {
  • branches/eam_branch_20081230/pswarp/src/pswarpSetMaskBits.c

    r21072 r21090  
    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;
  • branches/eam_branch_20081230/pswarp/src/pswarpTransformReadout.c

    r20334 r21090  
    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    }
  • branches/eam_branch_20081230/pswarp/src/pswarpTransformTile.c

    r21072 r21090  
    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.