IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 27, 2009, 10:40:16 AM (17 years ago)
Author:
eugene
Message:

ifdef-out the test data dumps; careful to mask the desired aperture only

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090715/psModules/src/objects/pmPSFtryFitPSF.c

    r25526 r25596  
    1 /** @file  pmPSFtry.c
    2  *
    3  *  XXX: need description of file purpose
     1/** @file  pmPSFtryFitPSF.c
     2 *  @brief Fit the PSF model to the candidate PSF stars (part of PSF model generation)
    43 *
    54 *  @author EAM, IfA
     
    87 *  @date $Date: 2009-01-27 06:39:38 $
    98 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
    10  *
    119 */
    1210
     
    4846    maskVal |= markVal;
    4947
     48    // DEBUG code: save the PSF model fit data in detail
     49# ifdef DEBUG
     50    char filename[64];
     51    snprintf (filename, 64, "psffit.%dx%d.dat", psfTry->psf->trendNx, psfTry->psf->trendNy);
     52    FILE *f = fopen (filename, "w");
     53    psAssert (f, "failed open");
     54# endif
     55
    5056    int Npsf = 0;
    5157    for (int i = 0; i < psfTry->sources->n; i++) {
     
    8086        // skip poor fits
    8187        if (!status) {
    82             psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->fitRadius, "AND", PS_NOT_IMAGE_MASK(markVal));
     88            psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask
    8389            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_PSF_FAIL;
    8490            psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : failed PSF fit\n", i, source->peak->x, source->peak->y);
     
    8793
    8894        // set object mask to define valid pixels for APERTURE magnitude
    89         if (options->fitRadius < options->apRadius) {
    90             // this is not really a recommended situation...
    91             psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->fitRadius, "AND", PS_NOT_IMAGE_MASK(markVal));
    92             psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->apRadius, "OR", markVal);
    93         }
    94         if (options->fitRadius > options->apRadius) {
    95             // ensure the aperture is defined
     95        if (options->fitRadius != options->apRadius) {
     96            psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask
    9697            psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->apRadius, "OR", markVal);
    9798        }
    9899
    99100        // This function calculates the psf and aperture magnitudes
    100         status = pmSourceMagnitudes (source, psfTry->psf, PM_SOURCE_PHOT_INTERP, maskVal);
     101        status = pmSourceMagnitudes (source, psfTry->psf, PM_SOURCE_PHOT_INTERP, maskVal); // raw PSF mag, AP mag
    101102        if (!status || isnan(source->apMag)) {
    102             psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->apRadius, "AND", PS_NOT_IMAGE_MASK(markVal));
     103            psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask
    103104            psfTry->mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PSFTRY_MASK_BAD_PHOT;
    104105            psTrace ("psModules.objects", 4, "dropping %d (%d,%d) : poor photometry\n", i, source->peak->x, source->peak->y);
     
    107108
    108109        // clear object mask to define valid pixels
    109         psImageKeepCircle (source->maskObj, source->peak->x, source->peak->y, options->apRadius, "AND", PS_NOT_IMAGE_MASK(markVal));
     110        psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); // clear the circular mask
    110111
    111112        psfTry->fitMag->data.F32[i] = source->psfMag;
    112         // psfTry->metric->data.F32[i] = -2.5*log10(source->moments->Sum) - source->psfMag;
    113113        psfTry->metric->data.F32[i] = source->apMag - source->psfMag;
    114114        psfTry->metricErr->data.F32[i] = source->errMag;
     115
     116        // XXX this did not work: modifies shape of psf too much
     117        // psfTry->metric->data.F32[i] = -2.5*log10(source->moments->Sum) - source->psfMag;
     118
     119# ifdef DEBUG
     120        fprintf (f, "%6.1f %6.1f : %6.1f %6.1f : %8.3f %8.3f %8.3f : %f : %f %f %f : %f\n",
     121                 source->peak->xf, source->peak->yf,
     122                 source->modelPSF->params->data.F32[PM_PAR_XPOS], source->modelPSF->params->data.F32[PM_PAR_YPOS],
     123                 source->psfMag, source->apMag, source->errMag,
     124                 source->modelPSF->params->data.F32[PM_PAR_I0],
     125                 source->modelPSF->params->data.F32[PM_PAR_SXX], source->modelPSF->params->data.F32[PM_PAR_SXY],
     126                 source->modelPSF->params->data.F32[PM_PAR_SYY], source->modelPSF->params->data.F32[PM_PAR_7]);
     127# endif
    115128
    116129        psTrace ("psModules.object", 6, "keeping source %d (%d) of %ld\n", i, Npsf, psfTry->sources->n);
     
    119132    psfTry->psf->nPSFstars = Npsf;
    120133
    121     // XXX test code:
     134# ifdef DEBUG
     135    fclose (f);
     136# endif
     137
    122138    pmSourceVisualShowModelFits (psfTry->psf, psfTry->sources, maskVal);
    123139
Note: See TracChangeset for help on using the changeset viewer.