IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18472


Ignore:
Timestamp:
Jul 11, 2008, 8:35:04 AM (18 years ago)
Author:
eugene
Message:

total overhaul of mask handling

Location:
branches/eam_branch_20080706
Files:
44 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20080706/ppImage/src/Makefile.am

    r16084 r18472  
    2929        ppImageReplaceBackground.c \
    3030        ppImageDefineFile.c \
     31        ppImageSetMaskBits.c \
    3132        ppImageFileCheck.c \
    3233        ppImageVersion.c \
     
    5859        ppImageReplaceBackground.c \
    5960        ppImageDefineFile.c \
     61        ppImageSetMaskBits.c \
    6062        ppImageFileCheck.c \
    6163        ppImageVersion.c \
  • branches/eam_branch_20080706/ppImage/src/ppImage.h

    r16084 r18472  
    5656    // make values for abstract concepts of masking
    5757    psMaskType maskValue;               // apply this bit-mask to choose masked bits
     58    psMaskType markValue;               // apply this bit-mask to choose masked bits
    5859    psMaskType satMask;                 // Mask value to give saturated pixels
    5960    psMaskType badMask;                 // Mask value to give bad pixels
     
    101102// Determine what type of camera, and initialise
    102103ppImageOptions *ppImageParseCamera(pmConfig *config);
     104bool ppImageSetMaskBits (pmConfig *config, ppImageOptions *options);
    103105
    104106// Loop over the input
     
    134136bool ppImageMosaicFPA (pmConfig *config, const ppImageOptions *options,
    135137                       const char *outFile, const char *inFile);
     138
     139bool ppImageSetMaskBits (pmConfig *config, ppImageOptions *options);
    136140
    137141void ppImageFileCheck (pmConfig *config);
  • branches/eam_branch_20080706/ppImage/src/ppImageDetrendReadout.c

    r17218 r18472  
    7474    if (options->doShutter) {
    7575        pmReadout *shutter = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.SHUTTER");
    76         if (!pmShutterCorrectionApply(input, shutter, pmConfigMask("FLAT", config))) {
     76        if (!pmShutterCorrectionApply(input, shutter, pmConfigMaskGet("FLAT", config))) {
    7777            return false;
    7878        }
  • branches/eam_branch_20080706/ppImage/src/ppImageLoop.c

    r18430 r18472  
    6565                // XXX set the options->*Mask values here (after the mask images have been loaded
    6666                // and before any of the value are used)
    67                 ppImageSetMaskBits (config, options);
     67                if (!ppImageSetMaskBits (config, options))
     68                    ESCAPE ("Unable to set bit masks");
    6869
    6970                // perform the detrend analysis
  • branches/eam_branch_20080706/ppImage/src/ppImageMetadataStats.c

    r18430 r18472  
    1313        return true;
    1414    }
    15 
    16     // XXX should this be just options->maskValue?? I think so...
    17     psMaskType maskVal = options->satMask | options->badMask | options->maskValue;
    1815
    1916    // Extract statistics from the last output fpa
     
    5148    pmFPAview *view = pmFPAviewAlloc(0);
    5249
    53     if (!ppStatsMetadata(stats, output->fpa, view, maskVal, config)) {
     50    if (!ppStatsMetadata(stats, output->fpa, view, options->maskValue, config)) {
    5451        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to generate stats for image.");
    5552        psFree(view);
  • branches/eam_branch_20080706/ppImage/src/ppImageMosaic.c

    r18430 r18472  
    3232            in->name, out->name, in->xBin, in->yBin, out->xBin, out->yBin);
    3333
    34     // XXX mosaic the chip, making a deep copy.  this has the side effect of making the
    35     // output image products pure trimmed images, but also increases the memory footprint.
    36     // XXX I think we should be using options->maskValue
     34    // Mosaic the chip, making a deep copy.  This has the side effect of making the output
     35    // image products pure trimmed images, but also increases the memory footprint.
    3736    status = pmChipMosaic(outChip, inChip, true, options->blankMask);
    3837    return status;
  • branches/eam_branch_20080706/ppImage/src/ppImageOptions.c

    r18430 r18472  
    5050
    5151    // default flags for various activities
    52     options->maskValue       = 0x00;    // Default mask value
    53     options->satMask         = 0x00;    // Saturated pixels
    54     options->badMask         = 0x00;    // Bad pixels
    55     options->flatMask        = 0x00;    // Bad flat pixels
    56     options->blankMask       = 0x00;    // Blank (no data, cell gap) pixels
     52    options->maskValue       = 0x00;    // Default mask value (used to skip / ignore pixels)
     53    options->satMask         = 0x00;    // Saturated pixels (supplied to pmReadoutGenerateMask)
     54    options->badMask         = 0x00;    // Bad (low) pixels (supplied to pmReadoutGenerateMask)
     55    options->flatMask        = 0x00;    // Bad flat pixels (supplied to pmFlatField)
     56    options->blankMask       = 0x00;    // Blank (no data, cell gap) pixels (supplied to pmChipMosaic, pmFPAMosaic)
     57    options->markValue       = 0x00;    // A safe bit for internal marking
    5758
    5859    // Non-linearity default options
     
    190191    options->doWeightBuild = psMetadataLookupBool(NULL, recipe, "WEIGHT.BUILD");
    191192
    192     // Mask recipe options
    193     // XXX we cannot set these values here; wait until just before ppImageDetrend
     193    // Mask recipe options (note that mask bit values are set in ppImageSetMaskBits.c)
    194194    options->doMask = psMetadataLookupBool(NULL, recipe, "MASK");
    195 
    196 # if (0)   
    197     const char *masks = psMetadataLookupStr(&status, recipe, "MASK.VALUE");
    198     if (status) {
    199         options->maskValue = pmConfigMask(masks, config);
    200     }
    201     options->satMask = pmConfigMask("SAT", config);
    202     options->badMask = pmConfigMask("BAD", config);
    203     options->flatMask = pmConfigMask("FLAT", config);
    204     options->blankMask = pmConfigMask("BLANK", config);
    205     // XXX should it be an error for these to not exist?
    206 # endif
    207195
    208196    options->doBias = psMetadataLookupBool(NULL, recipe, "BIAS");
  • branches/eam_branch_20080706/ppImage/src/ppImagePixelStats.c

    r18430 r18472  
    99
    1010    bool mdok;              // Status of MD lookup
    11 
    12     // XXX should this be just options->maskValue?? I think so...
    13     psMaskType maskVal = options->satMask | options->badMask | options->maskValue;
    1411
    1512    // loop over the cells/readouts for this chip
     
    4946        }
    5047
    51         if (!ppStatsPixels(stats, output->fpa, view, maskVal, config)) {
     48        if (!ppStatsPixels(stats, output->fpa, view, options->maskValue, config)) {
    5249            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to generate stats for image.");
    5350            psFree (view);
  • branches/eam_branch_20080706/ppImage/src/ppImageReplaceBackground.c

    r18430 r18472  
    4040    psAssert (replaceSkyMode != MODE_NONE, "replace sky mode not defined");
    4141
    42     // define the mask value to be used in ppImage
    43     // XXX should this be just options->maskValue?? I think so...  (but it should certainly include flat!)
    44     psMaskType maskVal  = options->satMask | options->badMask | options->flatMask | options->blankMask;
     42    // XXX Should this be options->maskValue or & ~options->satMask? the latter will leave saturated pixels high
     43    // psMaskType maskVal  = options->maskValue & ~options->satMask;
     44    psMaskType maskVal  = options->maskValue;
    4545
    4646    pmFPAfile *modelFile = NULL;
  • branches/eam_branch_20080706/ppImage/src/ppImageSetMaskBits.c

    r18430 r18472  
    77bool ppImageSetMaskBits (pmConfig *config, ppImageOptions *options) {
    88
    9     // Mask recipe options
    10     const char *masks = psMetadataLookupStr(&status, recipe, "MASK.VALUE");
    11     if (status) {
    12         options->maskValue = pmConfigMask(masks, config);
     9    if (!pmConfigMaskSetBits (&options->maskValue, &options->markValue, config)) {
     10        psError (PS_ERR_UNKNOWN, true, "Unable to define the mask bit values");
     11        return false;
    1312    }
    1413
    15     darkMask           = pmConfigMask("DARK",     config);
    16     options->flatMask  = pmConfigMask("FLAT",     config);
    17     options->blankMask = pmConfigMask("BLANK",    config);
    18     detectorMask       = pmConfigMask("DETECTOR", config);
     14    // at this point we know we have valid values for required entries SAT, BAD, FLAT, BLANK:
    1915
    20     options->satMask   = pmConfigMask("SAT",      config);
    21     options->badMask   = pmConfigMask("BAD",      config);
     16    // mask for non-linear flat corrections
     17    options->flatMask = pmConfigMaskGet("FLAT", config);
     18    psAssert (options->flatMask, "flat mask not set");
    2219
    23     rangeMask          = pmConfigMask("RANGE",    config);
     20    // mask for non-existent data  (default to DETECTOR if not defined)
     21    options->blankMask = pmConfigMaskGet("BLANK", config);
     22    psAssert (options->blankMask, "blank mask not set");
    2423
    25     crMask             = pmConfigMask("CR",       config);
    26     ghostMask          = pmConfigMask("GHOST",    config);
     24    // mask for saturated data  (default to RANGE if not defined)
     25    options->satMask = pmConfigMaskGet("SAT", config);
     26    psAssert (options->satMask, "sat mask not set");
     27   
     28    // mask for below-range data  (default to RANGE if not defined)
     29    options->badMask = pmConfigMaskGet("BAD", config);
     30    psAssert (options->badMask, "bad mask not set");
    2731
    28     // XXX it should be an error for these to not exist
    29     if (!options->flatMask) {
    30       psWarning ("FLAT MASK is not set");
     32    // save MASK and MARK on the PSPHOT recipe
     33    psMetadata *recipe = psMetadataLookupPtr (NULL, config->recipes, PSPHOT_RECIPE);
     34    if (!recipe) {
     35        psError(PSPHOT_ERR_CONFIG, false, "missing recipe %s", PSPHOT_RECIPE);
     36        return false;
    3137    }
    32     if (!options->flatMask) {
    33       psWarning ("FLAT MASK is not set");
    34     }
     38
     39    // set maskValue and markValue in the psphot recipe
     40    psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", options->maskValue);
     41    psMetadataAddU8 (recipe, PS_LIST_TAIL, "MARK.PSPHOT", PS_META_REPLACE, "user-defined mask", options->markValue);
    3542
    3643    return true;
  • branches/eam_branch_20080706/ppImage/src/ppImageStats.c

    r14000 r18472  
    5757            }
    5858
    59             if (!ppStatsFPA(stats, output->fpa, view,
    60                          options->satMask | options->badMask | options->maskValue,
    61                          config)) {
     59            if (!ppStatsFPA(stats, output->fpa, view, options->maskValue, config)) {
    6260                psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to generate stats for image.");
    6361                psFree(view);
  • branches/eam_branch_20080706/psModules/src/camera/pmFPAMaskWeight.h

    r17732 r18472  
    55 * @author Eugene Magnier, IfA
    66 *
    7  * @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2008-05-17 02:42:01 $
     7 * @version $Revision: 1.13.8.1 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2008-07-11 18:35:04 $
    99 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    1010 */
     
    3232    PM_MASK_MARK     = 0x80,            ///< The pixel is marked as temporarily ignored
    3333} pmMaskValue;
    34 #else
    3534#define PM_MASK_MARK 0x80            ///< The pixel is marked as temporarily ignored
    3635#define PM_MASK_SAT  0x04            ///< The pixel is saturated in the image of interest
     
    4342/// iterating using pmReadoutReadNext, in which case the HDU can't be generated.
    4443bool pmReadoutSetMask(pmReadout *readout, ///< Readout for which to set mask
    45                       psMaskType sat ///< Mask value to give saturated pixels
    46                       psMaskType bad    ///< Mask value to give bad (low) pixels
     44                      psMaskType satMask, ///< Mask value to give saturated pixels
     45                      psMaskType badMask  ///< Mask value to give bad (low) pixels
    4746    );
    4847
  • branches/eam_branch_20080706/psModules/src/camera/pmFPAfileFitsIO.c

    r18330 r18472  
    77
    88#include "pmConfig.h"
     9#include "pmConfigMask.h"
    910#include "pmDetrendDB.h"
    1011
     
    496497    }
    497498
     499    // whenever we write out a mask image, we should define the bits which represent mask concepts
     500    if (file->type == PM_FPA_FILE_MASK) {
     501        assert (phu->header);
     502        if (!pmConfigMaskWriteHeader (config, phu->header)) {
     503            psError(PS_ERR_UNKNOWN, false, "failed to set the bitmask names in the PHU header for Image %s (%s)\n", file->filename, file->name);
     504            return false;
     505        }
     506    }
     507
    498508    switch (file->fileLevel) {
    499509      case PM_FPA_LEVEL_FPA:
  • branches/eam_branch_20080706/psModules/src/camera/pmFPAfileIO.c

    r18430 r18472  
    99
    1010#include "pmConfig.h"
     11#include "pmConfigMask.h"
    1112#include "pmDetrendDB.h"
    1213
     
    428429            }
    429430            pmConfigConformHeader(hdu->header, file->format);
     431
     432            // whenever we write out a mask image, we should define the bits which represent mask concepts
     433            if (file->type == PM_FPA_FILE_MASK) {
     434                assert (hdu->header);
     435                if (!pmConfigMaskWriteHeader (config, hdu->header)) {
     436                    psError(PS_ERR_UNKNOWN, false, "failed to set the bitmask names in the PHU header for Image %s (%s)\n", file->filename, file->name);
     437                    return false;
     438                }
     439            }
    430440        }
    431441
  • branches/eam_branch_20080706/psModules/src/camera/pmHDUUtils.c

    r18431 r18472  
    1212pmHDU *pmHDUGetFirst (const pmFPA *fpa) {
    1313
    14   // XXX we probably should have an indicator in pmFPA about the depths.
     14    // XXX we probably should have an indicator in pmFPA about the depths.
    1515
    16   if (!fpa) return NULL;
    17   if (fpa->hdu) return fpa->hdu;
     16    if (!fpa) return NULL;
     17    if (fpa->hdu) return fpa->hdu;
    1818
    19   for (int i = 0; i < fpa->chips->n; i++) {
    20     pmChip *chip = fpa->chips[i];
    21     if (!chip) continue;
    22     if (chip->hdu) return chip->hdu;
    23     if (!chip->cells) continue;
    24     for (int j = 0; j < chip->cells->n; j++) {
    25       pmCell *cell = chip->cells[j];
    26       if (!cell) continue;
    27       if (cell->hdu) return cell->hdu;
     19    for (int i = 0; i < fpa->chips->n; i++) {
     20        pmChip *chip = fpa->chips->data[i];
     21        if (!chip) continue;
     22        if (chip->hdu) return chip->hdu;
     23        if (!chip->cells) continue;
     24        for (int j = 0; j < chip->cells->n; j++) {
     25            pmCell *cell = chip->cells->data[j];
     26            if (!cell) continue;
     27            if (cell->hdu) return cell->hdu;
     28        }
    2829    }
    29   }
    30   return NULL;
     30    return NULL;
    3131}
    3232
  • branches/eam_branch_20080706/psModules/src/config/pmConfigMask.c

    r18430 r18472  
    99#include "pmConfigMask.h"
    1010
    11 psMaskType pmConfigMask(const char *masks, const pmConfig *config)
     11psMaskType pmConfigMaskGet(const char *masks, const pmConfig *config)
    1212{
    1313    assert (config);
     
    4040}
    4141
     42bool pmConfigMaskSet(const pmConfig *config, const char *maskName, psMaskType maskValue)
     43{
     44    assert (config);
     45    PS_ASSERT_STRING_NON_EMPTY(maskName, false);
     46
     47    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe
     48    if (!recipe) {
     49        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe.");
     50        return false;
     51    }
     52
     53    psMetadataAddU8 (recipe, PS_LIST_TAIL, maskName, PS_META_REPLACE, "user-defined mask", maskValue);
     54
     55    return true;
     56}
     57
    4258// replace the named masks in the recipe with values in the header:
    4359// replace only the names in the header in the recipe
    44 void pmConfigMasksReadHeader (pmConfig *config, psMetadata *header) {
     60bool pmConfigMaskReadHeader (pmConfig *config, psMetadata *header) {
     61
     62    bool status = false;
     63    char namekey[80];
     64    char valuekey[80];
    4565
    4666    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe
     
    6888        psMetadataItem *item = psMetadataLookup (header, name);
    6989        if (!item) {
    70           psWarning("mask recipe entry %s not in recipe\n", name);
    71           psMetadataAddU8 (recipe, PS_LIST_TAIL, name, 0, "Bitmask bit value", bit);
     90            psWarning("mask recipe entry %s not in recipe\n", name);
     91            psMetadataAddU8 (recipe, PS_LIST_TAIL, name, 0, "Bitmask bit value", bit);
    7292        } else {
    73           item->data.U8 = bit;
     93            item->data.U8 = bit;
    7494        }
    7595    }
     
    7999
    80100// write the named mask bits to the header
    81 bool pmConfigMasksWriteHeader (pmConfig *config, psMetadata *header) {
     101bool pmConfigMaskWriteHeader (pmConfig *config, psMetadata *header) {
     102
     103    char namekey[80];
     104    char valuekey[80];
    82105
    83106    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe
     
    110133    return true;
    111134}
     135
     136// examine named mask values in mask recipe and set the bits for maskValue and markValue
     137// this function sets an appropriate value for the following required named mask concepts:
     138// FLAT (used to mark out-of-range corrections in the flat-fielding)
     139// BLANK (used to mark non-existent pixels)
     140// SAT (used to mark pixels with values out-of-range on the high end)
     141// BAD (used to mark pixels with values out-of-range on the low end)
     142// If there is no explicit value for the above, the 'DETECTOR' and 'RANGE' bits are used
     143// If these latter do not exist, the value 0x01 is used.
     144// The values actually used for these names are written back to the config file
     145bool pmConfigMaskSetBits (psMaskType *outMaskValue, psMaskType *outMarkValue, pmConfig *config) {
     146
     147    psMaskType maskValue = 0;
     148
     149    // mask for generic detector defect
     150    psMaskType detectorMask = pmConfigMaskGet("DETECTOR", config);
     151    maskValue |= detectorMask;
     152
     153    // mask for dark structures
     154    psMaskType darkMask = pmConfigMaskGet("DARK", config);
     155    maskValue |= darkMask;
     156
     157    // mask for non-linear flat regions (default to DETECTOR if not defined)
     158    psMaskType flatMask = pmConfigMaskGet("FLAT", config);
     159    if (!flatMask) {
     160        flatMask = detectorMask;
     161        pmConfigMaskSet (config, "FLAT", flatMask);
     162    }
     163    if (!flatMask) {
     164        flatMask = 0x01;
     165        pmConfigMaskSet (config, "FLAT", flatMask);
     166    }
     167    maskValue |= flatMask;
     168
     169    // mask for non-existent data  (default to DETECTOR if not defined)
     170    psMaskType blankMask = pmConfigMaskGet("BLANK", config);
     171    if (!blankMask) {
     172        blankMask = detectorMask;
     173        pmConfigMaskSet (config, "BLANK", blankMask);
     174    }
     175    if (!blankMask) {
     176        blankMask = 0x01;
     177        pmConfigMaskSet (config, "BLANK", blankMask);
     178    }
     179    maskValue |= blankMask;
     180
     181    // mask for generic data range errors
     182    psMaskType rangeMask = pmConfigMaskGet("RANGE", config);
     183    maskValue |= rangeMask;
     184
     185    // mask for saturated data  (default to RANGE if not defined)
     186    psMaskType satMask = pmConfigMaskGet("SAT", config);
     187    if (!satMask) {
     188        satMask = rangeMask;
     189        pmConfigMaskSet (config, "SAT", satMask);
     190    }
     191    if (!satMask) {
     192        satMask = 0x01;
     193        pmConfigMaskSet (config, "SAT", satMask);
     194    }
     195    maskValue |= satMask;
     196   
     197    // mask for below-range data  (default to RANGE if not defined)
     198    psMaskType badMask = pmConfigMaskGet("BAD", config);
     199    if (!badMask) {
     200        badMask = rangeMask;
     201        pmConfigMaskSet (config, "BAD", badMask);
     202    }
     203    if (!badMask) {
     204        badMask = 0x01;
     205        pmConfigMaskSet (config, "BAD", badMask);
     206    }
     207    maskValue |= badMask;
     208
     209    // XXX not sure what to do with these
     210    psMaskType crMask = pmConfigMaskGet("CR", config);
     211    maskValue |= crMask;
     212
     213    psMaskType ghostMask = pmConfigMaskGet("GHOST", config);
     214    maskValue |= ghostMask;
     215
     216    // search for an unset bit to use for MARK:
     217    psMaskType markValue = 0x80;
     218
     219    int nBits = sizeof(psMaskType) * 8;
     220    for (int i = 0; !markValue && (i < nBits); i++) {
     221        if (maskValue & markValue) {
     222            markValue >>= 1;
     223        } else {
     224            markValue = markValue;
     225        }
     226    }
     227    if (!markValue) {
     228        psError (PS_ERR_UNKNOWN, true, "Unable to define the MARK bit mask: all bits taken!");
     229        return false;
     230    }
     231
     232    // update the config table
     233    pmConfigMaskSet (config, "MASK.VALUE", maskValue);
     234    pmConfigMaskSet (config, "MARK.VALUE", markValue);
     235
     236    *outMaskValue = maskValue;
     237    *outMarkValue = markValue;
     238
     239    return true;
     240}
  • branches/eam_branch_20080706/psModules/src/config/pmConfigMask.h

    r16816 r18472  
    44 *  @author Paul Price, IfA
    55 *
    6  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    7  *  @date $Date: 2008-03-05 01:06:37 $
     6 *  @version $Revision: 1.2.14.1 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2008-07-11 18:35:04 $
    88 *  Copyright 2007 Institute for Astronomy, University of Hawaii
    99 */
     
    2323///
    2424/// The mask values are derived from the MASKS recipe
    25 psMaskType pmConfigMask(const char *masks, ///< List of symbolic names, space/comma delimited
     25psMaskType pmConfigMaskGet(const char *masks, ///< List of symbolic names, space/comma delimited
    2626                        const pmConfig *config ///< Configuration
    2727                        );
    2828
     29bool pmConfigMaskSet(const pmConfig *config, const char *maskName, psMaskType maskValue);
     30
     31// replace the named masks in the recipe with values in the header:
     32// replace only the names in the header in the recipe
     33bool pmConfigMaskReadHeader (pmConfig *config, psMetadata *header);
     34
     35// write the named mask bits to the header
     36bool pmConfigMaskWriteHeader (pmConfig *config, psMetadata *header);
     37
     38bool pmConfigMaskSetBits (psMaskType *outMaskValue, psMaskType *outMarkValue, pmConfig *config);
     39
    2940#endif
  • branches/eam_branch_20080706/psModules/src/detrend/pmMaskBadPixels.c

    r18364 r18472  
    123123    psTrace ("psModules.detrend", 3, "suspect: %f +/- %f\n", median, stdev);
    124124
     125    // XXX this loop could result in pixels with suspect = 0.0 but no valid input pixels (all
     126    // masked).  need to track the number of good as well as suspect pixels?
    125127    for (int y = 0; y < image->numRows; y++) {
    126128        for (int x = 0; x < image->numCols; x++) {
    127             if (fabs((image->data.F32[y][x] - median) / stdev) >= rej &&
    128                 (!mask || !(mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal))) {
    129                 suspect->data.F32[y][x] += 1.0;
    130             }
     129            if (fabs((image->data.F32[y][x] - median) / stdev) < rej) continue;
     130            if (mask && (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal)) continue;
     131            suspect->data.F32[y][x] += 1.0;
    131132        }
    132133    }
     
    140141}
    141142
     143// the maskVal supplied here is the value SET for this mask (ie, it is not used to avoid pixels)
    142144bool pmMaskIdentifyBadPixels(pmReadout *output, psMaskType maskVal, float thresh, pmMaskIdentifyMode mode)
    143145{
  • branches/eam_branch_20080706/psModules/src/objects/pmPSF.c

    r15983 r18472  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2008-01-02 20:41:55 $
     8 *  @version $Revision: 1.35.18.1 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2008-07-11 18:35:04 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    404404
    405405// we generate the growth curve for the center of the image with the specified psf model
    406 bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, psMaskType maskVal, psMaskType mark)
     406bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, psMaskType maskVal, psMaskType markVal)
    407407{
    408408    PS_ASSERT_PTR_NON_NULL(readout, false);
     
    416416    // create template model
    417417    pmModel *modelRef = pmModelAlloc(psf->type);
     418
     419    // maskVal is used to test for rejected pixels, and must include markVal
     420    maskVal |= markVal;
    418421
    419422    // use the center of the center pixel of the image
     
    465468
    466469        // mask the given aperture and measure the apMag
    467         psImageKeepCircle (mask, xc, yc, radius, "OR", mark);
     470        psImageKeepCircle (mask, xc, yc, radius, "OR", markVal);
    468471        if (!pmSourcePhotometryAper (&apMag, model, image, mask, maskVal)) {
    469472            psError(PM_ERR_PHOTOM, false, "Measuring apMag for radius == %g", radius);
     
    473476            break;
    474477        }
    475 
    476         // XXX since we re-mask on each pass, this could be dropped.
    477         psImageKeepCircle (mask, xc, yc, radius, "AND", PS_NOT_U8(mark));
     478        psImageKeepCircle (mask, xc, yc, radius, "AND", PS_NOT_U8(markVal));
    478479
    479480        // the 'ignore' mode is for testing
  • branches/eam_branch_20080706/psModules/src/objects/pmPSFtry.c

    r18040 r18472  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2008-06-10 01:32:15 $
     7 *  @version $Revision: 1.56.8.1 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2008-07-11 18:35:04 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    9898
    9999// generate a pmPSFtry with a copy of the test PSF sources
    100 pmPSFtry *pmPSFtryModel (const psArray *sources, const char *modelName, pmPSFOptions *options, psMaskType maskVal, psMaskType mark)
     100pmPSFtry *pmPSFtryModel (const psArray *sources, const char *modelName, pmPSFOptions *options, psMaskType maskVal, psMaskType markVal)
    101101{
    102102    bool status;
     
    116116        return NULL;
    117117    }
     118
     119    // maskVal is used to test for rejected pixels, and must include markVal
     120    maskVal |= markVal;
    118121
    119122    // stage 1:  fit an EXT model to all candidates PSF sources
     
    129132        }
    130133
    131         // set object mask to define valid pixels -- XXX not unset?
    132         psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "OR", mark);
     134        // set object mask to define valid pixels
     135        psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "OR", markVal);
    133136
    134137        // fit model as EXT, not PSF
    135138        status = pmSourceFitModel (source, source->modelEXT, PM_SOURCE_FIT_EXT, maskVal);
     139
     140        // clear object mask to define valid pixels
     141        psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_U8(markVal));
    136142
    137143        // exclude the poor fits
     
    170176        source->modelPSF->radiusFit = options->radius;
    171177
    172         // set object mask to define valid pixels -- XXX not unset?
    173         psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "OR", mark);
     178        // set object mask to define valid pixels
     179        psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "OR", markVal);
    174180
    175181        // fit the PSF model to the source
     
    178184        // skip poor fits
    179185        if (!status) {
     186            psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_U8(markVal));
    180187            psfTry->mask->data.U8[i] = PSFTRY_MASK_PSF_FAIL;
    181188            psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : failed PSF fit\n", i, source->peak->x, source->peak->y);
     
    183190        }
    184191
    185         // XXX : use a different aperture radius from the fit radius?
    186         status = pmSourceMagnitudes (source, psfTry->psf, PM_SOURCE_PHOT_INTERP, maskVal, mark);
     192        status = pmSourceMagnitudes (source, psfTry->psf, PM_SOURCE_PHOT_INTERP, maskVal);
    187193        if (!status || isnan(source->apMag)) {
     194            psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_U8(markVal));
    188195            psfTry->mask->data.U8[i] = PSFTRY_MASK_BAD_PHOT;
    189196            psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : poor photometry\n", i, source->peak->x, source->peak->y);
    190197            continue;
    191198        }
     199
     200        // clear object mask to define valid pixels
     201        psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->radius, "AND", PS_NOT_U8(markVal));
    192202
    193203        psfTry->fitMag->data.F32[i] = source->psfMag;
  • branches/eam_branch_20080706/psModules/src/objects/pmSource.c

    r18042 r18472  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.54 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2008-06-10 02:26:17 $
     8 *  @version $Revision: 1.54.8.1 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2008-07-11 18:35:04 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    838838
    839839// should we call pmSourceCacheModel if it does not exist?
    840 bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add,
    841                  psMaskType maskVal, int dx, int dy)
     840bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add, psMaskType maskVal, int dx, int dy)
    842841{
    843842    PS_ASSERT_PTR_NON_NULL(source, false);
  • branches/eam_branch_20080706/psModules/src/objects/pmSourcePhotometry.c

    r17998 r18472  
    33 *  @author EAM, IfA; GLG, MHPCC
    44 *
    5  *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2008-06-09 00:43:46 $
     5 *  @version $Revision: 1.42.8.1 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2008-07-11 18:35:04 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6464
    6565// XXX masked region should be (optionally) elliptical
    66 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode,
    67                          psMaskType maskVal, psMaskType mark)
     66bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psMaskType maskVal)
    6867{
    6968    PS_ASSERT_PTR_NON_NULL(source, false);
     
    230229        mask = source->maskObj;
    231230    }
    232     // set aperture mask circle to model radius
    233     // XXX use a different radius for apertures and fits...
    234     // XXX can I remove this?  the source should have the mask defined when it is constructed or
    235     // when the fit / aperture radius is changed...
    236     psImageKeepCircle (source->maskObj, x, y, model->radiusFit, "OR", mark);
    237231
    238232    // measure the weight of included pixels
    239233    // XXX is this supposed to use the weight or the flux?
    240234    if (mode & PM_SOURCE_PHOT_WEIGHT) {
    241         pmSourcePixelWeight (&source->pixWeight, model, source->pixels, source->maskObj, maskVal | mark);
     235        pmSourcePixelWeight (&source->pixWeight, model, source->pixels, source->maskObj, maskVal);
    242236    }
    243237
    244238    // measure object aperture photometry
    245     status = pmSourcePhotometryAper  (&source->apMag, model, flux, mask, maskVal | mark);
     239    status = pmSourcePhotometryAper  (&source->apMag, model, flux, mask, maskVal);
    246240    if (!status) {
    247241        psTrace ("psModules.objects", 3, "fail mag : bad Ap Mag");
     
    264258        psFree(mask);
    265259    }
    266 
    267     // unmask aperture
    268     // XXX can I remove this?  this will probably break things downstream...
    269     psImageKeepCircle (source->maskObj, x, y, model->radiusFit, "AND", PS_NOT_U8(mark));
    270260
    271261    // if source was originally subtracted, re-subtract object, leave local sky
     
    308298
    309299// return source aperture magnitude
    310 bool pmSourcePhotometryAper (float *apMag, pmModel *model, psImage *image, psImage *mask,
    311                              psMaskType maskVal)
     300bool pmSourcePhotometryAper (float *apMag, pmModel *model, psImage *image, psImage *mask, psMaskType maskVal)
    312301{
    313302    PS_ASSERT_PTR_NON_NULL(apMag, false);
     
    347336
    348337// return source aperture magnitude
    349 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask,
    350                           psMaskType maskVal)
     338bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask, psMaskType maskVal)
    351339{
    352340    PS_ASSERT_PTR_NON_NULL(pixWeight, false);
  • branches/eam_branch_20080706/psModules/src/objects/pmSourcePhotometry.h

    r13898 r18472  
    44 * @author EAM, IfA; GLG, MHPCC
    55 *
    6  * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-06-20 02:22:26 $
     6 * @version $Revision: 1.10.34.1 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2008-07-11 18:35:04 $
    88 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    99 */
     
    5050
    5151bool pmSourceMagnitudesInit (psMetadata *config);
    52 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psMaskType maskVal, psMaskType mark);
     52bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psMaskType maskVal);
    5353bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask, psMaskType maskVal);
    5454bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight, psMaskType maskVal);
  • branches/eam_branch_20080706/psModules/src/objects/pmSourcePlotMoments.c

    r15562 r18472  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2007-11-10 01:09:20 $
     7 *  @version $Revision: 1.10.20.1 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2008-07-11 18:35:04 $
    99 *
    1010 *  Copyright 2006 IfA, University of Hawaii
     
    9595    graphdata.xmin = -0.05;
    9696    graphdata.ymin = -0.05;
    97     graphdata.xmax = +2.05;
    98     graphdata.ymax = +2.05;
     97    graphdata.xmax = +4.05;
     98    graphdata.ymax = +4.05;
    9999    KapaSetLimits (kapa, &graphdata);
    100100
  • branches/eam_branch_20080706/psModules/src/objects/pmSourceSky.c

    r15980 r18472  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2008-01-02 20:39:04 $
     8 *  @version $Revision: 1.16.18.1 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2008-07-11 18:35:04 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4242
    4343The source.pixels and source.mask must already exist
     44
     45This function modifies the source mask; it should only be called before the object aperture is defined
    4446*****************************************************************************/
    4547
     
    4951    psF32 Radius,
    5052    psMaskType maskVal,
    51     psMaskType mark)
     53    psMaskType markVal)
    5254{
    5355    psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     
    6971    psRegion srcRegion;
    7072
     73    // maskVal is used to test for rejected pixels, and must include markVal
     74    maskVal |= markVal;
     75
    7176    srcRegion = psRegionForSquare(peak->x, peak->y, Radius);
    7277    srcRegion = psRegionForImage(mask, srcRegion);
    7378
    74     psImageMaskRegion(mask, srcRegion, "OR", mark);
     79    psImageMaskRegion(mask, srcRegion, "OR", markVal);
    7580    psStats *myStats = psStatsAlloc(statsOptions);
    76     if (!psImageStats(myStats, image, mask, maskVal | mark)) {
     81    if (!psImageStats(myStats, image, mask, maskVal)) {
    7782        psError(PS_ERR_UNKNOWN, false, "Unable to get image statistics.\n");
    7883        psFree(myStats);
    7984        return false;
    8085    }
    81     psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_U8(mark));
     86    psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_U8(markVal));
    8287    double value = psStatsGetValue(myStats, statistic);
    8388    psFree(myStats);
     
    101106    psF32 Radius,
    102107    psMaskType maskVal,
    103     psMaskType mark
     108    psMaskType markVal
    104109)
    105110{
     
    110115    PS_ASSERT_PTR_NON_NULL(source->peak, false);
    111116    PS_ASSERT_INT_POSITIVE(Radius, false);
     117
     118    // maskVal is used to test for rejected pixels, and must include markVal
     119    maskVal |= markVal;
    112120
    113121    psStatsOptions statistic = psStatsSingleOption(statsOptions);
     
    125133    srcRegion = psRegionForImage(mask, srcRegion);
    126134
    127     psImageMaskRegion(mask, srcRegion, "OR", mark);
     135    psImageMaskRegion(mask, srcRegion, "OR", markVal);
    128136    psStats *myStats = psStatsAlloc(statsOptions);
    129     if (!psImageStats(myStats, image, mask, maskVal | mark)) {
     137    if (!psImageStats(myStats, image, mask, maskVal)) {
    130138        psError(PS_ERR_UNKNOWN, false, "Unable to get image statistics.\n");
    131139        psFree(myStats);
    132140        return false;
    133141    }
    134     psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_U8(mark));
     142    psImageMaskRegion(mask, srcRegion, "AND", PS_NOT_U8(markVal));
    135143    double value = psStatsGetValue(myStats, statistic);
    136144    psFree(myStats);
  • branches/eam_branch_20080706/psphot/doc/notes.txt

    r17396 r18472  
     1
     22008.06.25
     3
     4 timing : footprints
     5
     6 on GPC1, with FFT:
     7    pass 1 :     convolved with grow disc: 17.558344 sec
     8    pass 2 :     convolved with grow disc: 8.915036 sec
    19
    2102008.01.31
  • branches/eam_branch_20080706/psphot/src/Makefile.am

    r18467 r18472  
    1515        psphotImageLoop.c       \
    1616        psphotMosaicChip.c      \
     17        psphotSetMaskBits.c     \
    1718        psphotParseCamera.c
    1819
     
    8586        psphotAddNoise.c
    8687
     88# dropped? psphotGrowthCurve.c
     89
    8790include_HEADERS = \
    8891        psphot.h \
  • branches/eam_branch_20080706/psphot/src/psphot.h

    r18000 r18472  
    2525bool            psphotReadoutCleanup (pmConfig *config, pmReadout *readout, psMetadata *recipe, pmDetections *detections, pmPSF *psf, psArray *sources);
    2626bool            psphotDefineFiles (pmConfig *config, pmFPAfile *input);
     27bool            psphotSetMaskBits (pmConfig *config);
    2728
    2829// XXX test functions
     
    7071// functions to set the correct source pixels
    7172bool            psphotInitRadiusPSF (const psMetadata *recipe, const pmModelType type);
    72 bool            psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model);
    73 bool            psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, float dR);
     73bool            psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal);
     74bool            psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal, float dR);
    7475bool            psphotInitRadiusEXT (psMetadata *recipe, pmModelType type);
    75 bool            psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model);
     76bool            psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal);
    7677
    7778// output functions
     
    9192bool            psphotInitLimitsPSF (psMetadata *recipe, pmReadout *readout);
    9293bool            psphotInitLimitsEXT (psMetadata *recipe);
    93 bool            psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal);
    94 bool            psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf, psMaskType maskVal);
    95 bool            psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal);
    96 pmModel        *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal);
    97 psArray        *psphotFitDBL (pmReadout *readout, pmSource *source, psMaskType maskVal);
     94bool            psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal);
     95bool            psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf, psMaskType maskVal, psMaskType markVal);
     96bool            psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal);
     97pmModel        *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, psMaskType markVal);
     98psArray        *psphotFitDBL (pmReadout *readout, pmSource *source, psMaskType maskVal, psMaskType markVal);
    9899
    99100// functions to support simultaneous multi-source fitting
     
    124125bool            psphotMakeResiduals (psArray *sources, psMetadata *recipe, pmPSF *psf, psMaskType maskVal);
    125126
    126 pmModel        *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, int psfSize);
     127pmModel        *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, psMaskType markVal, int psfSize);
    127128
    128129psKernel       *psphotKernelFromPSF (pmSource *source, int nPix);
  • branches/eam_branch_20080706/psphot/src/psphotApResid.c

    r17288 r18472  
    2525    }
    2626
    27     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    28     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     27    // bit-masks to test for good/bad pixels
     28    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
    2929    assert (maskVal);
    3030
    31     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    32     psMaskType mark = psMetadataLookupU8(&status, recipe, "MASK.MARK"); // Mask value for bad pixels
    33     assert (mark);
     31    // bit-mask to mark pixels not used in analysis
     32    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     33    assert (markVal);
     34
     35    // maskVal is used to test for rejected pixels, and must include markVal
     36    maskVal |= markVal;
    3437
    3538    // S/N limit to perform full non-linear fits
     
    6568    psf->growth = pmGrowthCurveAlloc (PSF_FIT_PAD, 100.0, REF_RADIUS);
    6669
    67     if (!pmGrowthCurveGenerate (readout, psf, IGNORE_GROWTH, maskVal, mark)) {
     70    if (!pmGrowthCurveGenerate (readout, psf, IGNORE_GROWTH, maskVal, markVal)) {
    6871        psError(PSPHOT_ERR_APERTURE, false, "Fitting aperture corrections");
    6972        psFree(psf->growth); psf->growth = NULL;
     
    9295        // get growth-corrected, apTrend-uncorrected magnitudes in scaled apertures
    9396        // will fail if below S/N threshold or model is missing
    94         if (!pmSourceMagnitudes (source, psf, photMode, maskVal, mark)) {
     97        if (!pmSourceMagnitudes (source, psf, photMode, maskVal)) {
    9598            Nskip ++;
    9699            psTrace ("psphot", 3, "skip : bad source mag");
  • branches/eam_branch_20080706/psphot/src/psphotBlendFit.c

    r17396 r18472  
    1212    psTimerStart ("psphot");
    1313
    14     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    15     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     14    // bit-masks to test for good/bad pixels
     15    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
    1616    assert (maskVal);
     17
     18    // bit-mask to mark pixels not used in analysis
     19    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     20    assert (markVal);
     21
     22    // maskVal is used to test for rejected pixels, and must include markVal
     23    maskVal |= markVal;
    1724
    1825    // source analysis is done in S/N order (brightest first)
     
    8188        // I should try EXT if the source size measurement says it is large
    8289        if (source->mode & PM_SOURCE_MODE_EXT_LIMIT) {
    83             if (psphotFitBlob (readout, source, sources, psf, maskVal)) {
     90            if (psphotFitBlob (readout, source, sources, psf, maskVal, markVal)) {
    8491                source->type = PM_SOURCE_TYPE_EXTENDED;
    8592                psTrace ("psphot", 5, "source at %7.1f, %7.1f is ext", source->moments->x, source->moments->y);
     
    8895            }
    8996        } else {
    90             if (psphotFitBlend (readout, source, psf, maskVal)) {
     97            if (psphotFitBlend (readout, source, psf, maskVal, markVal)) {
    9198                source->type = PM_SOURCE_TYPE_STAR;
    9299                psTrace ("psphot", 5, "source at %7.1f, %7.1f is psf", source->moments->x, source->moments->y);
  • branches/eam_branch_20080706/psphot/src/psphotChoosePSF.c

    r18323 r18472  
    88    psTimerStart ("psphot");
    99
    10     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    11     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     10    // bit-masks to test for good/bad pixels
     11    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
    1212    assert (maskVal);
    1313
    14     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    15     psMaskType mark = psMetadataLookupU8(&status, recipe, "MASK.MARK"); // Mask value for bad pixels
    16     assert (mark);
     14    // bit-mask to mark pixels not used in analysis
     15    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     16    assert (markVal);
     17
     18    // maskVal is used to test for rejected pixels, and must include markVal
     19    maskVal |= markVal;
    1720
    1821    // examine PSF sources in S/N order (brightest first)
     
    147150    for (int i = 0; i < modelNames->n; i++) {
    148151        char *modelName = modelNames->data[i];
    149         pmPSFtry *try = pmPSFtryModel (stars, modelName, options, maskVal, mark); // Attempt at fit
     152        pmPSFtry *try = pmPSFtryModel (stars, modelName, options, maskVal, markVal); // Attempt at fit
    150153        if (!try) {
    151154            // No big deal --- we'll try another model
     
    321324            // use pmModelSub because modelFlux has not been generated
    322325            assert (source->maskObj);
    323             psImageKeepCircle (source->maskObj, x, y, options->radius, "OR", PM_MASK_MARK);
     326            psImageKeepCircle (source->maskObj, x, y, options->radius, "OR", markVal);
    324327            pmModelSub (source->pixels, source->maskObj, source->modelPSF, PM_MODEL_OP_FULL, maskVal);
    325             psImageKeepCircle (source->maskObj, x, y, options->radius, "AND", PS_NOT_U8(PM_MASK_MARK));
     328            psImageKeepCircle (source->maskObj, x, y, options->radius, "AND", PS_NOT_U8(markVal));
    326329        }
    327330
  • branches/eam_branch_20080706/psphot/src/psphotExtendedSourceFits.c

    r17396 r18472  
    1515    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    1616    assert (maskVal);
     17
     18    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT"); // Mask value for bad pixels
     19    assert (markVal);
     20
     21    // maskVal is used to test for rejected pixels, and must include markVal
     22    maskVal |= markVal;
    1723
    1824    // perform full extended source non-linear fits?
     
    155161          pmModel *modelFit = NULL;
    156162          if (convolved) {
    157               modelFit = psphotPSFConvModel (readout, source, modelType, maskVal, psfSize);
     163              modelFit = psphotPSFConvModel (readout, source, modelType, maskVal, markVal, psfSize);
    158164              if (!modelFit) {
    159165                  psTrace ("psphot", 5, "failed to fit psf-conv model for object at %f, %f", source->moments->x, source->moments->y);
     
    168174              psFree (source->modelFlux);
    169175              source->modelFlux = NULL;
    170               modelFit = psphotFitEXT (readout, source, modelType, maskVal);
     176              modelFit = psphotFitEXT (readout, source, modelType, maskVal, markVal);
    171177              if (!modelFit) {
    172178                  psTrace ("psphot", 5, "failed to fit plain model for object at %f, %f", source->moments->x, source->moments->y);
  • branches/eam_branch_20080706/psphot/src/psphotFitSourcesLinear.c

    r17516 r18472  
    1010// the analysis is performed wrt the simulated pixel values
    1111
    12 static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER);
     12static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, psMaskType markVal);
    1313
    1414bool psphotFitSourcesLinear (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final) {
     
    2222    psTimerStart ("psphot");
    2323
    24     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    25     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     24    // bit-masks to test for good/bad pixels
     25    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
    2626    assert (maskVal);
     27
     28    // bit-mask to mark pixels not used in analysis
     29    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     30    assert (markVal);
     31
     32    // maskVal is used to test for rejected pixels, and must include markVal
     33    maskVal |= markVal;
    2734
    2835    // source analysis is done in spatial order
     
    157164
    158165    // set the sky, sky_x, sky_y components of border matrix
    159     SetBorderMatrixElements (border, readout, fitSources, CONSTANT_PHOTOMETRIC_WEIGHTS, SKY_FIT_ORDER);
     166    SetBorderMatrixElements (border, readout, fitSources, CONSTANT_PHOTOMETRIC_WEIGHTS, SKY_FIT_ORDER, markVal);
    160167    psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "set border: %f (%d elements)\n", psTimerMark ("psphot"), sparse->Nelem);
    161168
     
    221228// on the pixels which correspond to all of the sources of interest.  These elements fill in
    222229// the border matrix components in the sparse matrix equation.
    223 static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER) {
     230static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, psMaskType markVal) {
    224231
    225232    // generate the image-wide weight terms
     
    227234    psRegion fullArray = psRegionSet (0, 0, 0, 0);
    228235    fullArray = psRegionForImage (readout->mask, fullArray);
    229     psImageMaskRegion (readout->mask, fullArray, "OR", PM_MASK_MARK);
     236    psImageMaskRegion (readout->mask, fullArray, "OR", markVal);
    230237    psLogMsg ("psphot.ensemble", PS_LOG_INFO, "step 1: %f sec\n", psTimerMark ("psphot"));
    231238
     
    237244        float x = model->params->data.F32[PM_PAR_XPOS];
    238245        float y = model->params->data.F32[PM_PAR_YPOS];
    239         psImageMaskCircle (source->maskView, x, y, model->radiusFit, "AND", PS_NOT_U8(PM_MASK_MARK));
     246        psImageMaskCircle (source->maskView, x, y, model->radiusFit, "AND", PS_NOT_U8(markVal));
    240247    }
    241248    psLogMsg ("psphot.ensemble", PS_LOG_INFO, "step 2: %f sec\n", psTimerMark ("psphot"));
     
    279286
    280287    // turn off MARK for all image pixels
    281     psImageMaskRegion (readout->mask, fullArray, "AND", PS_NOT_U8(PM_MASK_MARK));
     288    psImageMaskRegion (readout->mask, fullArray, "AND", PS_NOT_U8(markVal));
    282289    psLogMsg ("psphot.ensemble", PS_LOG_INFO, "step 4: %f sec\n", psTimerMark ("psphot"));
    283290
  • branches/eam_branch_20080706/psphot/src/psphotGuessModels.c

    r16820 r18472  
    2323    psTimerStart ("psphot");
    2424
    25     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    26     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     25    // bit-masks to test for good/bad pixels
     26    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
    2727    assert (maskVal);
     28
     29    // bit-mask to mark pixels not used in analysis
     30    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     31    assert (markVal);
     32
     33    // maskVal is used to test for rejected pixels, and must include markVal
     34    maskVal |= markVal;
    2835
    2936    // setup the PSF fit radius details
     
    8592        // XXX need to define the guess flux?
    8693        // set the fit radius based on the object flux limit and the model
    87         psphotCheckRadiusPSF (readout, source, modelPSF);
     94        psphotCheckRadiusPSF (readout, source, modelPSF, markVal);
    8895
    8996        // set the source PSF model
  • branches/eam_branch_20080706/psphot/src/psphotMagnitudes.c

    r16820 r18472  
    88    psTimerStart ("psphot");
    99
    10     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    11     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     10    // bit-masks to test for good/bad pixels
     11    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
    1212    assert (maskVal);
    1313
    14     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    15     psMaskType mark = psMetadataLookupU8(&status, recipe, "MASK.MARK"); // Mask value for bad pixels
    16     assert (mark);
     14    // bit-mask to mark pixels not used in analysis
     15    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     16    assert (markVal);
     17
     18    // maskVal is used to test for rejected pixels, and must include markVal
     19    maskVal |= markVal;
    1720
    1821    pmSourceMagnitudesInit (recipe);
     
    3538    for (int i = 0; i < sources->n; i++) {
    3639        pmSource *source = (pmSource *) sources->data[i];
    37         status = pmSourceMagnitudes (source, psf, photMode, maskVal, mark);
     40        status = pmSourceMagnitudes (source, psf, photMode, maskVal);
    3841        if (status) Nap ++;
    3942
  • branches/eam_branch_20080706/psphot/src/psphotMaskReadout.c

    r16820 r18472  
    77
    88    // ** Interpret the mask values:
    9 
    10     // single-bit named masks
    11     psMaskType maskMark = pmConfigMask("MARK",     config); // Mask value for marking
    12     psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.MARK", PS_META_REPLACE, "user-defined mask", maskMark);
    13 
    14     psMaskType maskSat  = pmConfigMask("SAT",      config); // Mask value for saturated pixels
     9    // XXX drop the write to recipe and move config into psphotRoughClass?
     10    psMaskType maskSat  = pmConfigMaskGet("SAT", config); // Mask value for saturated pixels
    1511    psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.SAT", PS_META_REPLACE, "user-defined mask", maskSat);
    1612
    17     psMaskType maskBad  = pmConfigMask("BAD",      config); // Mask value for bad pixels
     13    psMaskType maskBad  = pmConfigMaskGet("BAD", config); // Mask value for bad pixels
    1814    psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.BAD", PS_META_REPLACE, "user-defined mask", maskBad);
    19 
    20     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    21     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "PSPHOT"); // Mask value for bad pixels
    22     if (!maskVal) {
    23       const char *maskValStr = psMetadataLookupStr(NULL, recipe, "MASKVAL"); // String with mask names
    24       if (!maskValStr) {
    25         psError(PSPHOT_ERR_CONFIG, false, "Missing recipe item: MASKVAL(STR)");
    26         return false;
    27       }
    28       maskVal = pmConfigMask(maskValStr, config); // Mask values to mask against
    29       psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskVal);
    30       assert (maskVal);
    31     }
    3215
    3316    // generate mask & weight images if they don't already exit
  • branches/eam_branch_20080706/psphot/src/psphotModelTest.c

    r17396 r18472  
    1212    pmSourceFitMode fitMode;
    1313
    14     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    15     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
    16     psMaskType mark    = psMetadataLookupU8(&status, recipe, "MASK.MARK"); // Mask value for bad pixels
     14    // bit-masks to test for good/bad pixels
     15    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
    1716    assert (maskVal);
    18     assert (mark);
     17
     18    // bit-mask to mark pixels not used in analysis
     19    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     20    assert (markVal);
     21
     22    // maskVal is used to test for rejected pixels, and must include markVal
     23    maskVal |= markVal;
    1924
    2025    // run model fitting tests on a single source?
     
    130135
    131136    // find the local sky
    132     status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, mark);
     137    status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal);
    133138    if (!status) psAbort("pmSourceLocalSky error");
    134139
     
    195200
    196201    // define the pixels used for the fit
    197     psImageKeepCircle (source->maskObj, xObj, yObj, RADIUS, "OR", mark);
     202    psImageKeepCircle (source->maskObj, xObj, yObj, RADIUS, "OR", markVal);
    198203    psphotSaveImage (NULL, source->maskObj, "mask1.fits");
    199204
     
    213218        assert (status);
    214219
    215         model = psphotPSFConvModel (readout, source, modelType, maskVal, psfSize);
     220        model = psphotPSFConvModel (readout, source, modelType, maskVal, markVal, psfSize);
    216221        params = model->params->data.F32;
    217222    } else {
  • branches/eam_branch_20080706/psphot/src/psphotMosaicChip.c

    r13900 r18472  
    2525    }
    2626
     27    psMaskType blankMask = pmConfigMaskGet("BLANK", config);
     28
    2729    // mosaic the chip, forcing a deep copy (resulting images are not subimages)
    2830    psTrace("pmChipMosaic", 5, "mosaic chip %s to %s (xbin,ybin: %d,%d to %d,%d)\n",
    2931            in->name, out->name, in->xBin, in->yBin, out->xBin, out->yBin);
    30     status = pmChipMosaic(outChip, inChip, true, pmConfigMask("BLANK", config));
     32    status = pmChipMosaic(outChip, inChip, true, blankMask);
    3133    return status;
    3234}
  • branches/eam_branch_20080706/psphot/src/psphotPSFConvModel.c

    r17396 r18472  
    99// modelConv to contain the fitted parameters, and the modelFlux to contain the
    1010// convolved model image.
    11 pmModel *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, int psfSize) {
     11pmModel *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, psMaskType markVal, int psfSize) {
    1212   
     13    // maskVal is used to test for rejected pixels, and must include markVal
     14    maskVal |= markVal;
     15
    1316    // make sure we save a cached copy of the psf flux
    1417    pmSourceCachePSF (source, maskVal);
     
    6568    psVector *dparams = modelConv->dparams;
    6669
    67     psphotCheckRadiusEXT (readout, source, modelConv);
     70    psphotCheckRadiusEXT (readout, source, modelConv, markVal);
    6871
    6972    // create the minimization constraints
  • branches/eam_branch_20080706/psphot/src/psphotParseCamera.c

    r13528 r18472  
    1717    // if MASK or WEIGHT was supplied on command line, bind files to 'load'
    1818    // the mask and weight will be mosaicked with the image
    19     pmFPAfileBindFromArgs (&status, load, config, "PSPHOT.MASK",  "MASK");
     19    pmFPAfile *mask = pmFPAfileBindFromArgs (&status, load, config, "PSPHOT.MASK", "MASK");
    2020    if (!status) {
    2121        psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
    2222        return NULL;
    2323    }
    24 
     24    if (mask) {
     25        // XXX need to load the mask bit names from one of the headers
     26        // this grabs the first available hdu : no guarantee that it will be valid, though
     27        pmHDU *hdu = pmHDUGetFirst (mask->fpa);
     28        if (!hdu) {
     29            psError(PS_ERR_IO, true, "no valid HDU for PSPHOT.MASK");
     30            return NULL;
     31        }
     32        // XXX should this be done in pmFPAfileIO.c read functions?
     33        if (!pmConfigMaskReadHeader (config, hdu->header)) {
     34            psError(PS_ERR_IO, false, "error in mask bits");
     35            return NULL;
     36        }
     37    }
     38    if (!psphotSetMaskBits (config)) {
     39        psError (PS_ERR_UNKNOWN, false, "failed to set mask bit values");
     40        return NULL;
     41    }
     42   
    2543    pmFPAfileBindFromArgs (&status, load, config, "PSPHOT.WEIGHT", "WEIGHT");
    2644    if (!status) {
  • branches/eam_branch_20080706/psphot/src/psphotRadiusChecks.c

    r14655 r18472  
    77                                        // and a per-object radius is calculated)
    88
    9 bool psphotInitRadiusPSF(const psMetadata *recipe,
    10                          const pmModelType type)
    11 {
     9bool psphotInitRadiusPSF(const psMetadata *recipe, const pmModelType type) {
     10
    1211    bool status = true;
    1312
     
    2019
    2120// call this function whenever you (re)-define the PSF model
    22 bool psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model)
     21bool psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal)
    2322{
    2423    psF32 *PAR = model->params->data.F32;
     
    4746
    4847    // set the mask to flag the excluded pixels
    49     psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit, "OR", PM_MASK_MARK);
     48    psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit, "OR", markVal);
    5049    return status;
    5150}
    5251
    53 bool psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, float dR) {
     52bool psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal, float dR) {
    5453
    5554    psF32 *PAR = model->params->data.F32;
     
    6968
    7069    // set the mask to flag the excluded pixels
    71     psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit, "OR", PM_MASK_MARK);
     70    psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit, "OR", markVal);
    7271    return status;
    7372}
     
    8786
    8887// call this function whenever you (re)-define the EXT model
    89 bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model) {
     88bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model, psMaskType markVal) {
    9089
    9190    psF32 *PAR = model->params->data.F32;
     
    102101
    103102    // set the mask to flag the excluded pixels
    104     psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit, "OR", PM_MASK_MARK);
     103    psImageKeepCircle (source->maskObj, PAR[PM_PAR_XPOS], PAR[PM_PAR_YPOS], model->radiusFit, "OR", markVal);
    105104    return status;
    106105}
  • branches/eam_branch_20080706/psphot/src/psphotSourceFits.c

    r17396 r18472  
    2121}
    2222
    23 bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal) {
     23bool psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal) {
    2424
    2525    float x, y, dR;
     26
     27    // maskVal is used to test for rejected pixels, and must include markVal
     28    maskVal |= markVal;
    2629
    2730    // if this source is not a possible blend, just fit as PSF
    2831    if ((source->blends == NULL) || (source->mode & PM_SOURCE_MODE_SATSTAR)) {
    29         bool status = psphotFitPSF (readout, source, psf, maskVal);
     32        bool status = psphotFitPSF (readout, source, psf, maskVal, markVal);
    3033        return status;
    3134    }
     
    8083
    8184    // extend source radius as needed
    82     psphotCheckRadiusPSFBlend (readout, source, PSF, dR);
     85    psphotCheckRadiusPSFBlend (readout, source, PSF, markVal, dR);
    8386
    8487    // fit PSF model (set/unset the pixel mask)
     
    139142}
    140143
    141 bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal) {
     144bool psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf, psMaskType maskVal, psMaskType markVal) {
    142145
    143146    double chiTrend;
     147
     148    // maskVal is used to test for rejected pixels, and must include markVal
     149    maskVal |= markVal;
    144150
    145151    NfitPSF ++;
     
    150156
    151157    // extend source radius as needed
    152     psphotCheckRadiusPSF (readout, source, PSF);
     158    psphotCheckRadiusPSF (readout, source, PSF, markVal);
    153159
    154160    // fit PSF model (set/unset the pixel mask)
     
    197203}
    198204
    199 bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf, psMaskType maskVal) {
     205bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf, psMaskType maskVal, psMaskType markVal) {
    200206
    201207    bool okEXT, okDBL;
     
    215221    psTrace ("psphot", 5, "trying blob...\n");
    216222
    217     // psTraceSetLevel("psModules.objects.pmSourceFitSet", 5);
     223    // maskVal is used to test for rejected pixels, and must include markVal
     224    maskVal |= markVal;
    218225
    219226    // this temporary source is used as a place-holder by the psphotEval functions below
    220227    pmSource *tmpSrc = pmSourceAlloc ();
    221228
    222     pmModel *EXT = psphotFitEXT (readout, source, modelTypeEXT, maskVal);
     229    pmModel *EXT = psphotFitEXT (readout, source, modelTypeEXT, maskVal, markVal);
    223230    okEXT = psphotEvalEXT (tmpSrc, EXT);
    224231    chiEXT = EXT->chisq / EXT->nDOF;
    225232
    226     psArray *DBL = psphotFitDBL (readout, source, maskVal);
     233    psArray *DBL = psphotFitDBL (readout, source, maskVal, markVal);
    227234    okDBL  = psphotEvalDBL (tmpSrc, DBL->data[0]);
    228235    okDBL &= psphotEvalDBL (tmpSrc, DBL->data[1]);
     
    306313
    307314// fit a double PSF source to an extended blob
    308 psArray *psphotFitDBL (pmReadout *readout, pmSource *source, psMaskType maskVal) {
     315psArray *psphotFitDBL (pmReadout *readout, pmSource *source, psMaskType maskVal, psMaskType markVal) {
    309316
    310317    float dx, dy;
     
    317324    NfitDBL ++;
    318325
     326    // maskVal is used to test for rejected pixels, and must include markVal
     327    maskVal |= markVal;
     328
    319329    // make a guess at the position of the two sources
    320330    moments.x2 = source->moments->Sx;
     
    329339    // save the PSF model from the Ensemble fit
    330340    PSF = source->modelPSF;
    331     psphotCheckRadiusPSFBlend (readout, source, PSF, 8.0);
     341    psphotCheckRadiusPSFBlend (readout, source, PSF, markVal, 8.0);
    332342    if (isnan(PSF->params->data.F32[1])) psAbort("nan in dbl fit");
    333343
     
    351361}
    352362
    353 pmModel *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal) {
     363pmModel *psphotFitEXT (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, psMaskType markVal) {
    354364
    355365    NfitEXT ++;
     366
     367    // maskVal is used to test for rejected pixels, and must include markVal
     368    maskVal |= markVal;
    356369
    357370    // use the source moments, etc to guess basic model parameters
     
    361374    // if (isnan(EXT->params->data.F32[1])) psAbort("nan in ext fit");
    362375
    363     psphotCheckRadiusEXT (readout, source, EXT);
     376    psphotCheckRadiusEXT (readout, source, EXT, markVal);
    364377
    365378    if ((source->moments->Sx < 1e-3) || (source->moments->Sx < 1e-3)) {
  • branches/eam_branch_20080706/psphot/src/psphotSourceStats.c

    r18241 r18472  
    99    psTimerStart ("psphot");
    1010
    11     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    12     psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
     11    // bit-masks to test for good/bad pixels
     12    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT");
    1313    assert (maskVal);
    1414
    15     // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
    16     psMaskType mark = psMetadataLookupU8(&status, recipe, "MASK.MARK"); // Mask value for bad pixels
    17     assert (mark);
     15    // bit-mask to mark pixels not used in analysis
     16    psMaskType markVal = psMetadataLookupU8(&status, recipe, "MARK.PSPHOT");
     17    assert (markVal);
     18
     19    // maskVal is used to test for rejected pixels, and must include markVal
     20    maskVal |= markVal;
    1821
    1922    // determine properties (sky, moments) of initial sources
     
    6770        // measure a local sky value
    6871        // the local sky is now ignored; kept here for reference only
    69         status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, mark);
     72        status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal);
    7073        if (!status) {
    7174          psFree (source);
     
    7780        // measure the local sky variance (needed if noise is not sqrt(signal))
    7881        // XXX EAM : this should use ROBUST not SAMPLE median, but it is broken
    79         status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, mark);
     82        status = pmSourceLocalSkyVariance (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal);
    8083        if (!status) {
    8184          psFree (source);
  • branches/eam_branch_20080706/psphot/src/psphotTestPSF.c

    r13035 r18472  
    109109        // set temporary object mask and fit object
    110110        // fit model as EXT, not PSF
    111         psImageKeepCircle (source->mask, x, y, RADIUS, "OR", PM_MASK_MARK);
     111        psImageKeepCircle (source->mask, x, y, RADIUS, "OR", markVal);
    112112        status = pmSourceFitModel (source, model, PM_SOURCE_FIT_EXT);
    113         psImageKeepCircle (source->mask, x, y, RADIUS, "AND", PS_NOT_U8(PM_MASK_MARK));
     113        psImageKeepCircle (source->mask, x, y, RADIUS, "AND", PS_NOT_U8(markVal));
    114114
    115115        // write fitted parameters to file
Note: See TracChangeset for help on using the changeset viewer.