IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16911


Ignore:
Timestamp:
Mar 10, 2008, 2:49:14 PM (18 years ago)
Author:
Paul Price
Message:

The NANs in the pmPSFtry->metric vector were coming from
pmSourceMagnitudes with mode=PM_SOURCE_PHOT_INTERP, and some bad
pixels in the source postage stamp. The NANs were effectively grown
by the call to psImageShift, while the mask was not grown. This
results in NAN pixels being accumulated in pmSourcePhotometryAper,
resulting in a NAN aperMag, so that the metric is also NAN.

Another possible error I found while debugging is that
pmSourcePixelWeight and pmSourcePhotometryAper should be run with the
mask value set to "maskVal | mark", so that only the circular aperture
is used.

Location:
trunk/psModules/src/objects
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmPSFtry.c

    r16909 r16911  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.54 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2008-03-10 21:03:30 $
     7 *  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2008-03-11 00:49:14 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    193193        psfTry->metric->data.F32[i] = source->apMag - source->psfMag;
    194194        psfTry->metricErr->data.F32[i] = source->errMag;
     195
    195196        Npsf ++;
    196197    }
     
    281282
    282283    for (int i = 0; i < psfTry->sources->n; i++) {
    283         if (!isfinite(psfTry->metric->data.F32[i]) || !isfinite(psfTry->metricErr->data.F32[i])) {
    284             psfTry->mask->data.U8[i] = PSFTRY_MASK_ALL;
    285             continue;
    286         }
    287284        if (psfTry->mask->data.U8[i] & PSFTRY_MASK_ALL)
    288285            continue;
  • trunk/psModules/src/objects/pmSourcePhotometry.c

    r16292 r16911  
    33 *  @author EAM, IfA; GLG, MHPCC
    44 *
    5  *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2008-02-03 21:58:56 $
     5 *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2008-03-11 00:49:14 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8585    model = pmSourceGetModel (&isPSF, source);
    8686    if (model == NULL) {
    87         psTrace ("psModules.objects", 3, "fail mag : no valid model");
     87        psTrace ("psModules.objects", 3, "fail mag : no valid model");
    8888        return false;
    8989    }
     
    101101    // measure PSF model photometry
    102102    if (psf->FluxScale) {
    103         // the source peak pixel is guaranteed to be on the image, and only minimally different from the source center
    104         double fluxScale = pmTrend2DEval (psf->FluxScale, (float)source->peak->x, (float)source->peak->y);
    105         if (!isfinite(fluxScale)) {
    106             // XXX objects on the edge can be slightly outside -- if we get an
    107             // error, use the full fit.
    108             psErrorClear();
    109             status = pmSourcePhotometryModel (&source->psfMag, source->modelPSF);
    110         } else {
    111             if (isfinite(fluxScale) && (fluxScale > 0.0)) {
    112                 source->psfMag = -2.5*log10(fluxScale * source->modelPSF->params->data.F32[PM_PAR_I0]);
    113             } else {
    114                 source->psfMag = NAN;
    115             }
    116         }
     103        // the source peak pixel is guaranteed to be on the image, and only minimally different from the source center
     104        double fluxScale = pmTrend2DEval (psf->FluxScale, (float)source->peak->x, (float)source->peak->y);
     105        if (!isfinite(fluxScale)) {
     106            // XXX objects on the edge can be slightly outside -- if we get an
     107            // error, use the full fit.
     108            psErrorClear();
     109            status = pmSourcePhotometryModel (&source->psfMag, source->modelPSF);
     110        } else {
     111            if (isfinite(fluxScale) && (fluxScale > 0.0)) {
     112                source->psfMag = -2.5*log10(fluxScale * source->modelPSF->params->data.F32[PM_PAR_I0]);
     113            } else {
     114                source->psfMag = NAN;
     115            }
     116        }
    117117    } else {
    118         status = pmSourcePhotometryModel (&source->psfMag, source->modelPSF);
     118        status = pmSourcePhotometryModel (&source->psfMag, source->modelPSF);
    119119    }
    120120
     
    124124    // for PSFs, correct both apMag and psfMag to same system, consistent with infinite flux star in aperture RADIUS
    125125    if ((mode & PM_SOURCE_PHOT_APCORR) && isPSF && psf && psf->ApTrend) {
    126         // the source peak pixel is guaranteed to be on the image, and only minimally different from the source center
    127         double apTrend = pmTrend2DEval (psf->ApTrend, (float)source->peak->x, (float)source->peak->y);
     126        // the source peak pixel is guaranteed to be on the image, and only minimally different from the source center
     127        double apTrend = pmTrend2DEval (psf->ApTrend, (float)source->peak->x, (float)source->peak->y);
    128128        source->psfMag += apTrend;
    129129    }
    130130
    131131    if (!isfinite(SN) || (SN < AP_MIN_SN)) {
    132         psTrace ("psModules.objects", 3, "fail mag : bad SN: %f (limit: %f)", SN, AP_MIN_SN);
     132        psTrace ("psModules.objects", 3, "fail mag : bad SN: %f (limit: %f)", SN, AP_MIN_SN);
    133133        return false;
    134134    }
     
    145145    // we need to shift the flux in the selected pixels (but not the mask)
    146146    // psImageShift ();
    147     psImage *flux;
     147    psImage *flux = NULL, *mask = NULL; // Star flux and mask images, to photometer
    148148    if (mode & PM_SOURCE_PHOT_INTERP) {
    149149        float dx = 0.5 - x + (int)x;
     
    151151        x += dx;
    152152        y += dy;
    153         flux = psImageShift (NULL, source->pixels, dx, dy, 0.0, PS_INTERPOLATE_BICUBE);
    154         // flux = psImageShift (NULL, source->pixels, dx, dy, 0.0, PS_INTERPOLATE_BILINEAR);
     153
     154        if (!psImageShiftMask(&flux, &mask, source->pixels, source->maskObj, maskVal, dx, dy,
     155                              NAN, 0xff, PS_INTERPOLATE_BICUBE)) {
     156            // Not much we can do about it
     157            psErrorClear();
     158            psTrace ("psModules.objects", 3, "fail shift");
     159            return false;
     160        }
    155161
    156162        // XXX this is test code to verify the shift is doing the right thing (seems to be)
     
    209215    } else {
    210216        flux = source->pixels;
     217        mask = source->maskObj;
    211218    }
    212219    // set aperture mask circle to model radius
     
    219226    // XXX is this supposed to use the weight or the flux?
    220227    if (mode & PM_SOURCE_PHOT_WEIGHT) {
    221         pmSourcePixelWeight (&source->pixWeight, model, source->pixels, source->maskObj, maskVal);
     228        pmSourcePixelWeight (&source->pixWeight, model, source->pixels, source->maskObj, maskVal | mark);
    222229    }
    223230
    224231    // measure object aperture photometry
    225     status = pmSourcePhotometryAper  (&source->apMag, model, flux, source->maskObj, maskVal);
     232    status = pmSourcePhotometryAper  (&source->apMag, model, flux, mask, maskVal | mark);
    226233    if (!status) {
    227         psTrace ("psModules.objects", 3, "fail mag : bad Ap Mag");
     234        psTrace ("psModules.objects", 3, "fail mag : bad Ap Mag");
    228235        psErrorCode last = psErrorCodeLast();
    229         // XXX flag the object?
     236        // XXX flag the object?
    230237        if (last == PM_ERR_PHOTOM) {
    231238            // the aper mag was undefined (flux < 0).  bad object, but
     
    246253    }
    247254    if (mode & PM_SOURCE_PHOT_INTERP) {
    248         psFree (flux);
     255        psFree(flux);
     256        psFree(mask);
    249257    }
    250258
Note: See TracChangeset for help on using the changeset viewer.