IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 19, 2007, 4:40:44 PM (19 years ago)
Author:
Paul Price
Message:

Extensive changes to APIs to allow use of a nominated value to mask
against (the maskVal). Previously, the mask values were either
hard-coded (e.g., PM_MASK_SAT) or taken as anything non-zero. The
code is tested with psModules (which has similar changes) and does not
crash, but neither is it successful in marking all bad pixels. For
this reason, I have left the "gutter" pixels (cell gaps) set to 0
instead of NAN in pmFPAMosaic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotApResid.c

    r13864 r13900  
    66
    77// measure the aperture residual statistics
    8 bool psphotApResid (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf)
     8bool psphotApResid (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, psMaskType maskVal, psMaskType mark)
    99{
    1010    int Nfail = 0;
     
    3131    bool INTERPOLATE_AP = psMetadataLookupBool (&status, recipe, "INTERPOLATE_AP");
    3232    int NSTAR_APERTURE_CORRECTION_MIN =
    33         psMetadataLookupS32(&status, recipe, "NSTAR_APERTURE_CORRECTION_MIN");
     33        psMetadataLookupS32(&status, recipe, "NSTAR_APERTURE_CORRECTION_MIN");
    3434    if (!status) {
    35         NSTAR_APERTURE_CORRECTION_MIN = 5;
     35        NSTAR_APERTURE_CORRECTION_MIN = 5;
    3636    }
    3737
     
    4747    psf->growth = pmGrowthCurveAlloc (PSF_FIT_PAD, 100.0, REF_RADIUS);
    4848
    49     if (!pmGrowthCurveGenerate (readout, psf, IGNORE_GROWTH)) {
    50         psError(PSPHOT_ERR_APERTURE, false, "Fitting aperture corrections");
    51         psFree(psf->growth); psf->growth = NULL;
    52         return false;
     49    if (!pmGrowthCurveGenerate (readout, psf, IGNORE_GROWTH, maskVal, mark)) {
     50        psError(PSPHOT_ERR_APERTURE, false, "Fitting aperture corrections");
     51        psFree(psf->growth); psf->growth = NULL;
     52        return false;
    5353    }
    5454
     
    8080        // get growth-corrected, apTrend-uncorrected magnitudes in scaled apertures
    8181        // will fail if below S/N threshold or model is missing
    82         if (!pmSourceMagnitudes (source, psf, photMode)) {
     82        if (!pmSourceMagnitudes (source, psf, photMode, maskVal, mark)) {
    8383            Nskip ++;
    8484            continue;
     
    135135    if (Npsf < NSTAR_APERTURE_CORRECTION_MIN) {
    136136        psError(PSPHOT_ERR_APERTURE, true, "Only %d valid aperture residual sources (need %d), giving up",
    137                 Npsf, NSTAR_APERTURE_CORRECTION_MIN);
     137                Npsf, NSTAR_APERTURE_CORRECTION_MIN);
    138138        return false;
    139139    }
     
    154154    stats->max = 3.0;
    155155
    156 #define P_APTREND_SWITCH_CLEANUP        /* Cleanup memory on error in ApTrendOption switch */ \
     156#define P_APTREND_SWITCH_CLEANUP        /* Cleanup memory on error in ApTrendOption switch */ \
    157157    psFree(psf->growth); psf->growth = NULL; \
    158158    psFree(mask); \
     
    172172        break;
    173173      case PM_PSF_APTREND_CONSTANT:
    174         stats->clipIter = 2;
    175         pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT);
    176         if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
    177             psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing");
    178             P_APTREND_SWITCH_CLEANUP;
    179             return false;
    180         }
    181         // apply the fit
    182         stats->clipIter = 3;
    183         pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT);
    184         if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
    185             psError(PSPHOT_ERR_PHOTOM, false, "Fitting aperture correction");
    186             P_APTREND_SWITCH_CLEANUP;
    187             return false;
    188         }
    189         break;
     174        stats->clipIter = 2;
     175        pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT);
     176        if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
     177            psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing");
     178            P_APTREND_SWITCH_CLEANUP;
     179            return false;
     180        }
     181        // apply the fit
     182        stats->clipIter = 3;
     183        pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT);
     184        if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
     185            psError(PSPHOT_ERR_PHOTOM, false, "Fitting aperture correction");
     186            P_APTREND_SWITCH_CLEANUP;
     187            return false;
     188        }
     189        break;
    190190      case PM_PSF_APTREND_SKYBIAS:
    191         // first clip out objects which are too far from the median
    192         stats->clipIter = 2;
    193         pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT);
    194         if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
    195             psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing");
    196             P_APTREND_SWITCH_CLEANUP;
    197             return false;
    198         }
    199         // apply the fit
    200         stats->clipIter = 3;
    201         pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYBIAS);
    202         if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
    203             psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting sky bias");
    204             P_APTREND_SWITCH_CLEANUP;
    205             return false;
    206         }
    207         break;
     191        // first clip out objects which are too far from the median
     192        stats->clipIter = 2;
     193        pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT);
     194        if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
     195            psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing");
     196            P_APTREND_SWITCH_CLEANUP;
     197            return false;
     198        }
     199        // apply the fit
     200        stats->clipIter = 3;
     201        pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYBIAS);
     202        if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
     203            psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting sky bias");
     204            P_APTREND_SWITCH_CLEANUP;
     205            return false;
     206        }
     207        break;
    208208      case PM_PSF_APTREND_SKYSAT:
    209         // first clip out objects which are too far from the median
    210         stats->clipIter = 2;
    211         pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT);
    212         if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
    213             psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing");
    214             P_APTREND_SWITCH_CLEANUP;
    215             return false;
    216         }
    217         // apply the fit
    218         stats->clipIter = 2;
    219         pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYBIAS);
    220         if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
    221             psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting sky bias");
    222             P_APTREND_SWITCH_CLEANUP;
    223             return false;
    224         }
    225         // apply the fit
    226         stats->clipIter = 3;
    227         pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYSAT);
    228         if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
    229             psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting skysat");
    230             P_APTREND_SWITCH_CLEANUP;
    231             return false;
    232         }
    233         break;
     209        // first clip out objects which are too far from the median
     210        stats->clipIter = 2;
     211        pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT);
     212        if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
     213            psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing");
     214            P_APTREND_SWITCH_CLEANUP;
     215            return false;
     216        }
     217        // apply the fit
     218        stats->clipIter = 2;
     219        pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYBIAS);
     220        if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
     221            psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting sky bias");
     222            P_APTREND_SWITCH_CLEANUP;
     223            return false;
     224        }
     225        // apply the fit
     226        stats->clipIter = 3;
     227        pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYSAT);
     228        if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
     229            psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting skysat");
     230            P_APTREND_SWITCH_CLEANUP;
     231            return false;
     232        }
     233        break;
    234234      case PM_PSF_APTREND_XY_LIN:
    235         // first clip out objects which are too far from the median
    236         stats->clipIter = 2;
    237         pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT);
    238         if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
    239             psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing");
    240             P_APTREND_SWITCH_CLEANUP;
    241             return false;
    242         }
    243         // apply the fit
    244         stats->clipIter = 3;
    245         pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_XY_LIN);
    246         if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
    247             psError(PSPHOT_ERR_PHOTOM, false, "fitting, XY_LIN");
    248             P_APTREND_SWITCH_CLEANUP;
    249             return false;
    250         }
    251         break;
     235        // first clip out objects which are too far from the median
     236        stats->clipIter = 2;
     237        pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT);
     238        if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
     239            psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing");
     240            P_APTREND_SWITCH_CLEANUP;
     241            return false;
     242        }
     243        // apply the fit
     244        stats->clipIter = 3;
     245        pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_XY_LIN);
     246        if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
     247            psError(PSPHOT_ERR_PHOTOM, false, "fitting, XY_LIN");
     248            P_APTREND_SWITCH_CLEANUP;
     249            return false;
     250        }
     251        break;
    252252      case PM_PSF_APTREND_XY_QUAD:
    253         // first clip out objects which are too far from the median
    254         stats->clipIter = 2;
    255         pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT);
    256         if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
    257             psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing");
    258             P_APTREND_SWITCH_CLEANUP;
    259             return false;
    260         }
    261         // apply the fit
    262         stats->clipIter = 3;
    263         pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_XY_QUAD);
    264         if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
    265             psError(PSPHOT_ERR_PHOTOM, false, "Fitting XY_QUAD");
    266             P_APTREND_SWITCH_CLEANUP;
    267             return false;
    268         }
    269         break;
     253        // first clip out objects which are too far from the median
     254        stats->clipIter = 2;
     255        pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT);
     256        if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
     257            psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing");
     258            P_APTREND_SWITCH_CLEANUP;
     259            return false;
     260        }
     261        // apply the fit
     262        stats->clipIter = 3;
     263        pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_XY_QUAD);
     264        if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
     265            psError(PSPHOT_ERR_PHOTOM, false, "Fitting XY_QUAD");
     266            P_APTREND_SWITCH_CLEANUP;
     267            return false;
     268        }
     269        break;
    270270      case PM_PSF_APTREND_SKY_XY_LIN:
    271         // first clip out objects which are too far from the median
    272         stats->clipIter = 2;
    273         pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT);
    274         if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
    275             psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing");
    276             P_APTREND_SWITCH_CLEANUP;
    277             return false;
    278         }
    279         // apply the fit
    280         stats->clipIter = 3;
    281         pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKY_XY_LIN);
    282         if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
    283             psError(PSPHOT_ERR_PHOTOM, false, "Fitting sky xy_lin");
    284             P_APTREND_SWITCH_CLEANUP;
    285             return false;
    286         }
    287         break;
     271        // first clip out objects which are too far from the median
     272        stats->clipIter = 2;
     273        pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT);
     274        if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
     275            psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing");
     276            P_APTREND_SWITCH_CLEANUP;
     277            return false;
     278        }
     279        // apply the fit
     280        stats->clipIter = 3;
     281        pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKY_XY_LIN);
     282        if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
     283            psError(PSPHOT_ERR_PHOTOM, false, "Fitting sky xy_lin");
     284            P_APTREND_SWITCH_CLEANUP;
     285            return false;
     286        }
     287        break;
    288288      case PM_PSF_APTREND_SKYSAT_XY_LIN:
    289         // first clip out objects which are too far from the median
    290         stats->clipIter = 2;
    291         pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT);
    292         if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
    293             psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing");
    294             P_APTREND_SWITCH_CLEANUP;
    295             return false;
    296         }
    297         // apply the fit
    298         stats->clipIter = 3;
    299         pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYBIAS);
    300         if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
    301             psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting sky bias");
    302             P_APTREND_SWITCH_CLEANUP;
    303             return false;
    304         }
    305         // apply the fit
    306         stats->clipIter = 3;
    307         pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYSAT_XY_LIN);
    308         if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
    309             psError(PSPHOT_ERR_PHOTOM, false, "Fitting skyset xy_lin");
    310             P_APTREND_SWITCH_CLEANUP;
    311             return false;
    312         }
    313         break;
     289        // first clip out objects which are too far from the median
     290        stats->clipIter = 2;
     291        pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT);
     292        if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
     293            psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting nothing");
     294            P_APTREND_SWITCH_CLEANUP;
     295            return false;
     296        }
     297        // apply the fit
     298        stats->clipIter = 3;
     299        pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYBIAS);
     300        if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
     301            psError(PSPHOT_ERR_PHOTOM, false, "clipping, fitting sky bias");
     302            P_APTREND_SWITCH_CLEANUP;
     303            return false;
     304        }
     305        // apply the fit
     306        stats->clipIter = 3;
     307        pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYSAT_XY_LIN);
     308        if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
     309            psError(PSPHOT_ERR_PHOTOM, false, "Fitting skyset xy_lin");
     310            P_APTREND_SWITCH_CLEANUP;
     311            return false;
     312        }
     313        break;
    314314      case PM_PSF_APTREND_ALL:
    315         // first clip out objects which are too far from the median
    316         stats->clipIter = 2;
    317         pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT);
    318         if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
    319             psError(PSPHOT_ERR_PHOTOM, false, "Failed to measure apTrend");
    320             P_APTREND_SWITCH_CLEANUP;
    321             return false;
    322         }
    323         // fit just SkyBias and clip out objects which are too far from the median
    324         stats->clipIter = 2;
    325         pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYBIAS);
    326         if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
    327             psError(PSPHOT_ERR_PHOTOM, false, "fitting skyBias");
    328             P_APTREND_SWITCH_CLEANUP;
    329             return false;
    330         }
    331         // finally, fit x, y, SkyBias and clip out objects which are too far from the median
    332         stats->clipIter = 3;
    333         pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_ALL);
    334         if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
    335             psError(PSPHOT_ERR_PHOTOM, false, "fitting all");
    336             P_APTREND_SWITCH_CLEANUP;
    337             return false;
    338         }
    339         break;
     315        // first clip out objects which are too far from the median
     316        stats->clipIter = 2;
     317        pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_CONSTANT);
     318        if (!psVectorClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
     319            psError(PSPHOT_ERR_PHOTOM, false, "Failed to measure apTrend");
     320            P_APTREND_SWITCH_CLEANUP;
     321            return false;
     322        }
     323        // fit just SkyBias and clip out objects which are too far from the median
     324        stats->clipIter = 2;
     325        pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_SKYBIAS);
     326        if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
     327            psError(PSPHOT_ERR_PHOTOM, false, "fitting skyBias");
     328            P_APTREND_SWITCH_CLEANUP;
     329            return false;
     330        }
     331        // finally, fit x, y, SkyBias and clip out objects which are too far from the median
     332        stats->clipIter = 3;
     333        pmPSFMaskApTrend (psf->ApTrend, PM_PSF_APTREND_ALL);
     334        if (!psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux)) {
     335            psError(PSPHOT_ERR_PHOTOM, false, "fitting all");
     336            P_APTREND_SWITCH_CLEANUP;
     337            return false;
     338        }
     339        break;
    340340      default:
    341341        psError(PSPHOT_ERR_PHOTOM, true, "Unknown APTREND value: %s", optionName);
     
    343343    }
    344344#undef P_APTREND_SWITCH_CLEANUP
    345    
     345
    346346    // construct the fitted values and the residuals
    347347    psVector *fit   = psPolynomial4DEvalVector (psf->ApTrend, xPos, yPos, r2rflux, flux);
     
    376376    psMetadataAdd (recipe, PS_LIST_TAIL, "NAPMIFIT", PS_DATA_S32 | PS_META_REPLACE, "ap residual scatter", psf->nApResid);
    377377
    378     psLogMsg ("psphot.apresid", PS_LOG_INFO, "measure full-frame aperture residuals for %d of %d objects: %f sec\n", 
    379               Nkeep, Npsf, psTimerMark ("psphot"));
     378    psLogMsg ("psphot.apresid", PS_LOG_INFO, "measure full-frame aperture residuals for %d of %d objects: %f sec\n",
     379              Nkeep, Npsf, psTimerMark ("psphot"));
    380380    psLogMsg ("psphot.apresid", PS_LOG_DETAIL, "aperture residual: %f +/- %f : %f bias, %f skysat\n",
    381381              psf->ApResid, psf->dApResid, psf->skyBias, psf->skySat);
Note: See TracChangeset for help on using the changeset viewer.