IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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/psModules/src/detrend
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • 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            }
Note: See TracChangeset for help on using the changeset viewer.