IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18554


Ignore:
Timestamp:
Jul 15, 2008, 10:25:00 AM (18 years ago)
Author:
eugene
Message:

re-organization of the named mask bit handling: pmConfigMaskSetBits now assigns the bits to names and make the recipe consistent

Location:
trunk/psModules/src
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPAMaskWeight.h

    r17732 r18554  
    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.14 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2008-07-15 20:25:00 $
    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
  • trunk/psModules/src/camera/pmFPAfileDefine.c

    r18061 r18554  
    1010#include "pmErrorCodes.h"
    1111#include "pmConfig.h"
     12#include "pmConfigMask.h"
    1213#include "pmDetrendDB.h"
    1314
     
    489490        psFree(realName);
    490491        return NULL;
     492    }
     493
     494    if (file->type == PM_FPA_FILE_MASK) {
     495        if (!pmConfigMaskReadHeader (config, phu)) {
     496            psError(PS_ERR_IO, false, "error in mask bits");
     497            return NULL;
     498        }
    491499    }
    492500
     
    660668    file->fileLevel = input->fileLevel;
    661669
     670
    662671    // define the rule to identify these files in the file->names data
    663672    psFree (file->filerule);
     
    735744        psMetadataAddStr (file->names, PS_LIST_TAIL, name, 0, "", infiles->data[i]);
    736745
     746        if ((i == 0) && (file->type == PM_FPA_FILE_MASK)) {
     747            if (!pmConfigMaskReadHeader (config, phu)) {
     748                psError(PS_ERR_IO, false, "error in mask bits");
     749                return NULL;
     750            }
     751        }
     752
    737753        psFree(view);
    738754        psFree(name);
     
    806822        psFree(formatName);
    807823        return NULL;
     824    }
     825
     826    if (file->type == PM_FPA_FILE_MASK) {
     827        if (!pmConfigMaskReadHeader (config, phu)) {
     828            psError(PS_ERR_IO, false, "error in mask bits");
     829            return NULL;
     830        }
    808831    }
    809832
  • trunk/psModules/src/camera/pmFPAfileFitsIO.c

    r18330 r18554  
    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:
  • trunk/psModules/src/camera/pmFPAfileIO.c

    r18330 r18554  
    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
     
    792802          }
    793803
     804          // XXX if we have a mask file, then we need to read the mask bit names
     805          // defined for this file
     806          if (file->type == PM_FPA_FILE_MASK) {
     807            if (!pmConfigMaskReadHeader (config, phu)) {
     808                psError(PS_ERR_IO, false, "error in mask bits");
     809                return false;
     810            }
     811          }
     812
    794813          // determine the current format from the header
    795814          // determine camera if not specified already
  • trunk/psModules/src/camera/pmHDUUtils.c

    r12768 r18554  
    99#include "pmFPA.h"
    1010#include "pmHDUUtils.h"
     11
     12pmHDU *pmHDUGetFirst (const pmFPA *fpa) {
     13
     14    // XXX we probably should have an indicator in pmFPA about the depths.
     15
     16    if (!fpa) return NULL;
     17    if (fpa->hdu) return fpa->hdu;
     18
     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        }
     29    }
     30    return NULL;
     31}
    1132
    1233pmHDU *pmHDUFromFPA(const pmFPA *fpa)
  • trunk/psModules/src/camera/pmHDUUtils.h

    r12696 r18554  
    44 * @author Paul Price, IfA
    55 *
    6  * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-03-30 21:12:56 $
     6 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2008-07-15 20:25:00 $
    88 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii
    99 */
     
    1414/// @addtogroup Camera Camera Layout
    1515/// @{
     16
     17/// Get the first HDU encountered in the hierarchy
     18pmHDU *pmHDUGetFirst (const pmFPA *fpa);
    1619
    1720/// Get the lowest HDU in the hierarchy
  • trunk/psModules/src/config/pmConfigMask.c

    r16815 r18554  
    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);
     
    3939    return mask;
    4040}
     41
     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
     58// replace the named masks in the recipe with values in the header:
     59// replace only the names in the header in the recipe
     60bool pmConfigMaskReadHeader (pmConfig *config, psMetadata *header) {
     61
     62    bool status = false;
     63    char namekey[80];
     64    char valuekey[80];
     65
     66    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe
     67    if (!recipe) {
     68        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe.");
     69        return false;
     70    }
     71
     72    int nMask = psMetadataLookupS32 (&status, header, "MSKNUM");
     73    if (!status) {
     74        psError(PS_ERR_UNKNOWN, true, "Unable to find MSKNUM in header.");
     75        return false;
     76    }
     77
     78    for (int i = 0; i < nMask; i++) {
     79
     80        snprintf (namekey,  64, "MSKNAM%02d", i);
     81        snprintf (valuekey, 64, "MSKVAL%02d", i);
     82
     83        char *name = psMetadataLookupStr (&status, header, namekey);
     84        psU8 bit = psMetadataLookupU8 (&status, header, valuekey);
     85
     86        // XXX validate that bit is a 2^n value?
     87
     88        psMetadataItem *item = psMetadataLookup (header, name);
     89        if (!item) {
     90            psWarning("mask recipe entry %s not in recipe\n", name);
     91            psMetadataAddU8 (recipe, PS_LIST_TAIL, name, 0, "Bitmask bit value", bit);
     92        } else {
     93            item->data.U8 = bit;
     94        }
     95    }
     96   
     97    return true;
     98}
     99
     100// write the named mask bits to the header
     101bool pmConfigMaskWriteHeader (pmConfig *config, psMetadata *header) {
     102
     103    char namekey[80];
     104    char valuekey[80];
     105
     106    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "MASKS"); // The recipe
     107    if (!recipe) {
     108        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find MASKS recipe.");
     109        return false;
     110    }
     111
     112    int nMask = 0;
     113
     114    psMetadataIterator *iter = psMetadataIteratorAlloc(recipe, PS_LIST_HEAD, NULL); // Iterator
     115
     116    psMetadataItem *item;               // Item from iteration
     117    while ((item = psMetadataGetAndIncrement(iter))) {
     118
     119        if (item->type != PS_DATA_U8) {
     120            psWarning("mask recipe entry %s is not a bit value\n", item->name);
     121            continue;
     122        }
     123
     124        snprintf (namekey,  64, "MSKNAM%02d", nMask);
     125        snprintf (valuekey, 64, "MSKVAL%02d", nMask);
     126
     127        psMetadataAddStr (header, PS_LIST_TAIL, namekey, 0, "Bitmask bit name", item->name);
     128        psMetadataAddU8 (header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.U8);
     129        nMask ++;
     130    }
     131   
     132    psMetadataAddS32 (header, PS_LIST_TAIL, "MSKNUM", 0, "Bitmask bit count", nMask);
     133    return true;
     134}
     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}
  • trunk/psModules/src/config/pmConfigMask.h

    r16816 r18554  
    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.3 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2008-07-15 20:25:00 $
    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
  • trunk/psModules/src/detrend/pmMaskBadPixels.c

    r18364 r18554  
    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{
  • trunk/psModules/src/objects/pmPSF.c

    r15983 r18554  
    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.36 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2008-07-15 20:25:00 $
    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
  • trunk/psModules/src/objects/pmPSFtry.c

    r18040 r18554  
    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.57 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2008-07-15 20:25:00 $
    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;
  • trunk/psModules/src/objects/pmSource.c

    r18042 r18554  
    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.55 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2008-07-15 20:25:00 $
    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);
  • trunk/psModules/src/objects/pmSourcePhotometry.c

    r17998 r18554  
    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.43 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2008-07-15 20:25:00 $
    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);
  • trunk/psModules/src/objects/pmSourcePhotometry.h

    r13898 r18554  
    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.11 $ $Name: not supported by cvs2svn $
     7 * @date $Date: 2008-07-15 20:25:00 $
    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);
  • trunk/psModules/src/objects/pmSourcePlotMoments.c

    r15562 r18554  
    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.11 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2008-07-15 20:25:00 $
    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
  • trunk/psModules/src/objects/pmSourceSky.c

    r15980 r18554  
    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.17 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2008-07-15 20:25:00 $
    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);
Note: See TracChangeset for help on using the changeset viewer.