IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 1, 2011, 6:21:28 PM (15 years ago)
Author:
eugene
Message:

fix threading for psphotStack; use standard PS_ARGUMENTS_ macros for ppSub, ppStack, pswarp, ppImage, psphotStack; fix FPA.EXPOSURE in ppImageAddNoise; fix accounting for psf bad and poor weights; added flags for substantial poor masks due to each poor mask bit type; fix the measurement of the fwhm in pmPSFtoFWHM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110213/psModules/src/objects/pmSourcePhotometry.c

    r30763 r30772  
    2323#include "pmFPAMaskWeight.h"
    2424
     25#include "pmConfigMask.h"
    2526#include "pmTrend2D.h"
    2627#include "pmResiduals.h"
     
    4950static float AP_MIN_SN = 0.0;
    5051
    51 bool pmSourceMagnitudesInit (psMetadata *config)
    52 {
    53     PS_ASSERT_PTR_NON_NULL(config, false);
     52// make this a bit more clever and dynamic
     53static psImageMaskType maskSuspect  = 0;
     54static psImageMaskType maskSpike    = 0;
     55static psImageMaskType maskStarCore = 0;
     56static psImageMaskType maskBurntool = 0;
     57static psImageMaskType maskConvPoor = 0;
     58
     59bool pmSourceMagnitudesInit (pmConfig *config, psMetadata *recipe)
     60{
     61    PS_ASSERT_PTR_NON_NULL(recipe, false);
    5462    bool status;
    5563
    56     float limit = psMetadataLookupF32 (&status, config, "AP_MIN_SN");
     64    // we are going to test specially against these poor values
     65    if (config) {
     66        maskSpike    = pmConfigMaskGet("SPIKE", config);
     67        maskStarCore = pmConfigMaskGet("STARCORE", config);
     68        maskBurntool = pmConfigMaskGet("BURNTOOL", config);
     69        maskConvPoor = pmConfigMaskGet("CONV.POOR", config);
     70        maskSuspect  = maskSpike | maskStarCore | maskBurntool | maskConvPoor;
     71    }
     72
     73    float limit = psMetadataLookupF32 (&status, recipe, "AP_MIN_SN");
    5774    if (status) {
    5875        AP_MIN_SN = limit;
     
    7794// XXX masked region should be (optionally) elliptical
    7895// if mode is PM_SOURCE_PHOT_PSFONLY, we skip all other magnitudes
    79 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psImageMaskType maskVal, psImageMaskType markVal)
     96bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psImageMaskType maskVal, psImageMaskType markVal, float radius)
    8097{
    8198    PS_ASSERT_PTR_NON_NULL(source, false);
     
    166183    // measure the contribution of included pixels
    167184    if (mode & PM_SOURCE_PHOT_WEIGHT) {
    168         pmSourcePixelWeight (&source->pixWeightNotBad, &source->pixWeightNotPoor, model, source->maskObj, maskVal, markVal);
     185        pmSourcePixelWeight (source, model, source->maskObj, maskVal, radius);
    169186    }
    170187
     
    342359
    343360// return source aperture magnitude
    344 bool pmSourcePixelWeight (float *pixWeightNotBad, float *pixWeightNotPoor, pmModel *model, psImage *mask, psImageMaskType maskVal, psImageMaskType markVal)
    345 {
    346     PS_ASSERT_PTR_NON_NULL(pixWeightNotBad, false);
    347     PS_ASSERT_PTR_NON_NULL(pixWeightNotPoor, false);
     361bool pmSourcePixelWeight (pmSource *source, pmModel *model, psImage *mask, psImageMaskType maskVal, float radius)
     362{
     363    PS_ASSERT_PTR_NON_NULL(source, false);
     364    source->pixWeightNotBad = NAN;
     365    source->pixWeightNotPoor = NAN;
     366
    348367    PS_ASSERT_PTR_NON_NULL(mask, false);
    349368    PS_ASSERT_PTR_NON_NULL(model, false);
     
    355374    float value;
    356375
     376    float spikeSum = 0;
     377    float starcoreSum = 0;
     378    float burntoolSum = 0;
     379    float convpoorSum = 0;
     380
    357381    int Xo, Yo, dP;
    358382    int dX, DX, NX;
    359383    int dY, DY, NY;
    360384
    361     *pixWeightNotBad = 0.0;
    362     *pixWeightNotPoor = 0.0;
     385    float radius2 = PS_SQR(radius);
    363386
    364387    // we only care about the value of the object model, not the local sky
     
    387410    NY = mask->numRows;
    388411
     412    psImageMaskType maskBad = maskVal;
     413    maskBad &= ~maskSuspect;
     414
    389415    // measure modelSum and validSum.  this function is applied to a sources' subimage.  the
    390416    // value of DX is chosen (see above) to cover the full possible size of the subimage if it
    391417    // were not by an edge; ie, if the source is cut in half by an image edge, we correctly
    392418    // count the virtual pixels off the edge in normalizing the value of the pixWeight
     419
     420    // we skip any pixels [real or virtual] outside of the specified radius (nominally the aperture radius)
    393421    for (int ix = -DX; ix < DX + 1; ix++) {
     422        if (ix > radius) continue;
    394423        int mx = ix + dX;
    395424        for (int iy = -DY; iy < DY + 1; iy++) {
     425            if (iy > radius) continue;
     426            if (ix*ix + iy*iy > radius2) continue;
    396427            int my = iy + dY;
    397428
     
    409440            if (my >= NY) continue;
    410441
    411             if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskVal)) {
     442            // count pixels which are masked only with bad pixels
     443            if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskBad)) {
    412444                notBadSum += value;
    413445            }
    414             if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & ~markVal)) {
     446
     447            // count pixels which are masked with an mask bit (bad or poor)
     448            if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskVal)) {
    415449                notPoorSum += value;
    416450            }
     451
     452            // count pixels which are masked with an mask bit (bad or poor)
     453            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskSpike) {
     454                spikeSum += value;
     455            }
     456            // count pixels which are masked with an mask bit (bad or poor)
     457            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskStarCore) {
     458                starcoreSum += value;
     459            }
     460            // count pixels which are masked with an mask bit (bad or poor)
     461            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskBurntool) {
     462                burntoolSum += value;
     463            }
     464            // count pixels which are masked with an mask bit (bad or poor)
     465            if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskConvPoor) {
     466                convpoorSum += value;
     467            }
    417468        }
    418469    }
    419470    psFree (coord);
    420471
    421     *pixWeightNotBad  = notBadSum  / modelSum;
    422     *pixWeightNotPoor = notPoorSum / modelSum;
    423 
    424     if (false && isfinite(*pixWeightNotBad) && isfinite(*pixWeightNotPoor)) {
    425         psAssert (*pixWeightNotBad <= *pixWeightNotPoor, "error: all bad pixels should also be poor");
     472    source->pixWeightNotBad  = notBadSum  / modelSum;
     473    source->pixWeightNotPoor = notPoorSum / modelSum;
     474
     475    if ((spikeSum/modelSum) > 0.25) {
     476        source->mode2 |= PM_SOURCE_MODE2_ON_SPIKE;
     477    }
     478    if ((starcoreSum/modelSum) > 0.25) {
     479        source->mode2 |= PM_SOURCE_MODE2_ON_STARCORE;
     480    }
     481    if ((burntoolSum/modelSum) > 0.25) {
     482        source->mode2 |= PM_SOURCE_MODE2_ON_BURNTOOL;
     483    }
     484    if ((convpoorSum/modelSum) > 0.25) {
     485        source->mode2 |= PM_SOURCE_MODE2_ON_CONVPOOR;
     486    }
     487
     488    if (isfinite(source->pixWeightNotBad) && isfinite(source->pixWeightNotPoor)) {
     489        psAssert (source->pixWeightNotBad <= source->pixWeightNotPoor, "error: all bad pixels should also be poor");
    426490    }
    427491
     
    431495# define FLUX_LIMIT 3.0
    432496
    433 // measure stats that may be using in difference images for distinguishing real sources from bad residuals
     497// measure stats that may be used in difference images for distinguishing real sources from bad residuals
    434498bool pmSourceMeasureDiffStats (pmSource *source, psImageMaskType maskVal, psImageMaskType markVal)
    435499{
Note: See TracChangeset for help on using the changeset viewer.