IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 23, 2009, 2:54:27 PM (17 years ago)
Author:
Paul Price
Message:

Catching bad source models (using flags) and ejecting these from the fitting of the PSF envelope.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/imcombine/pmPSFEnvelope.c

    r23242 r23955  
    3333
    3434
    35 //#define TESTING                         // Enable test output
     35#define TESTING                         // Enable test output
    3636#define PEAK_FLUX 1.0e4                 // Peak flux for each source
    3737#define SKY_VALUE 0.0e0                 // Sky value for fake image
     
    113113    pmReadout *fakeRO = pmReadoutAlloc(NULL); // Fake readout
    114114    float maxRadius = 0.0;              // Maximum radius of sources
     115    psVector *numbers = psVectorAlloc(numFakes, PS_TYPE_S32); // Number of detections for each source
     116    psVectorInit(numbers, 0);
    115117    for (int i = 0; i < inputs->n; i++) {
    116118        pmPSF *psf = inputs->data[i];   // PSF of interest
     
    127129            psFree(xOffset);
    128130            psFree(fakes);
     131            psFree(numbers);
    129132            psf->residuals = resid;
    130133            return NULL;
     
    140143
    141144            double flux = fakeRO->image->data.F32[(int)y][(int)x];
     145            if (flux > 0) {
     146                // The source is present
     147                numbers->data.S32[j]++;
     148            }
    142149            float norm = PEAK_FLUX / flux; // Normalisation for source
    143150            psRegion region = psRegionSet(x - radius, x + radius, y - radius, y + radius); // PSF region
     
    190197
    191198    // Put the fake sources onto a full-size image
     199    psArray *goodFakes = psArrayAllocEmpty(numFakes); // Good fake sources
    192200    pmReadout *readout = pmReadoutAlloc(NULL); // Readout to contain envelope pixels
    193201    readout->image = psImageAlloc(numCols, numRows, PS_TYPE_F32);
     
    195203    for (int i = 0; i < numFakes; i++) {
    196204        pmSource *source = fakes->data[i]; // Fake source
     205        if (numbers->data.S32[i] > 0) {
     206            psArrayAdd(goodFakes, goodFakes->n, source);
     207        }
     208
    197209        // Position of source on fake image
    198210        int xFake = source->peak->x + xOffset->data.S32[i];
     
    213225            psFree(yOffset);
    214226            psFree(fakes);
     227            psFree(numbers);
    215228            return NULL;
    216229        }
     
    220233    psFree(yOffset);
    221234    psFree(envelope);
     235    psFree(numbers);
     236
     237    psFree(fakes);
     238    fakes = goodFakes;
     239    numFakes = fakes->n;
    222240
    223241    // XXX Setting the variance seems to be an art
Note: See TracChangeset for help on using the changeset viewer.