IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23989 for trunk/psphot/src


Ignore:
Timestamp:
Apr 28, 2009, 11:21:56 AM (17 years ago)
Author:
eugene
Message:

always handle psVectorStats false return status (is an error); check for NAN results and handle as possible

Location:
trunk/psphot/src
Files:
6 edited

Legend:

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

    r21519 r23989  
    355355
    356356        if (j > 2) {
    357             bool status = true;
    358             status &= psVectorStats (statsS, dASubset, NULL, mkSubset, 0xff);
    359             status &= psVectorStats (statsM, dMSubset, NULL, mkSubset, 0xff);
    360             if (!status) { psErrorClear (); }
     357            if (!psVectorStats (statsS, dASubset, NULL, mkSubset, 0xff)) {
     358                psError(PS_ERR_UNKNOWN, false, "failure to measure stats");
     359                return false;
     360            }
     361            if (!psVectorStats (statsM, dMSubset, NULL, mkSubset, 0xff)) {
     362                psError(PS_ERR_UNKNOWN, false, "failure to measure stats");
     363                return false;
     364            }
    361365            dSo->data.F32[i] = statsS->robustStdev;
    362366            dMo->data.F32[i] = statsM->sampleMean;
    363367            dRo->data.F32[i] = statsS->robustStdev / statsM->sampleMean;
    364             //      fprintf (stderr, "%d (%d) : sys: %f, phot: %f, rat: %f\n", i, j, dSo->data.F32[i], dMo->data.F32[i], dRo->data.F32[i]);
    365368        } else {
    366369            dSo->data.F32[i] = NAN;
     
    375378    psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN);
    376379    if (!psVectorStats (stats, dRo, NULL, NULL, 0)) {
    377         // XXX better testing of raised error
    378         psErrorClear();
     380        psError(PS_ERR_UNKNOWN, false, "failure to measure stats");
     381        return false;
    379382    }
    380383
  • trunk/psphot/src/psphotChoosePSF.c

    r21183 r23989  
    361361
    362362    psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV | PS_STAT_SAMPLE_QUARTILE);
    363     psVectorStats (stats, fwhmMajor, NULL, NULL, 0);
     363    if (!psVectorStats (stats, fwhmMajor, NULL, NULL, 0)) {
     364        psError(PS_ERR_UNKNOWN, false, "failure to measure stats for FWHM MAJOR");
     365        return false;
     366    }
     367
    364368    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_MAJ",   PS_META_REPLACE, "PSF FWHM Major axis (mean)", stats->sampleMean);
    365369    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FW_MJ_SG",   PS_META_REPLACE, "PSF FWHM Major axis (sigma)", stats->sampleStdev);
     
    367371    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FW_MJ_UQ",   PS_META_REPLACE, "PSF FWHM Major axis (upper quartile)", stats->sampleUQ);
    368372
    369     psVectorStats (stats, fwhmMinor, NULL, NULL, 0);
     373    if (!psVectorStats (stats, fwhmMinor, NULL, NULL, 0)) {
     374        psError(PS_ERR_UNKNOWN, false, "failure to measure stats for FWHM MINOR");
     375        return false;
     376    }
    370377    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_MIN",   PS_META_REPLACE, "PSF FWHM Minor axis (mean)", stats->sampleMean);
    371378    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FW_MN_SG",   PS_META_REPLACE, "PSF FWHM Minor axis (sigma)", stats->sampleStdev);
  • trunk/psphot/src/psphotDiagnosticPlots.c

    r21108 r23989  
    4040
    4141    psStats *stats = psStatsAlloc (PS_STAT_MAX | PS_STAT_MIN);
    42     psVectorStats (stats, values, NULL, NULL, 0);
     42    if (!psVectorStats (stats, values, NULL, NULL, 0)) {
     43        psError(PS_ERR_UNKNOWN, false, "failure to measure stats for histogram");
     44        return false;
     45    }
    4346
    4447    psHistogram *histogram = psHistogramAlloc (stats->min, stats->max, 1000);
     
    6366    psStatsInit (stats);
    6467    stats->options = PS_STAT_MAX | PS_STAT_MIN;
    65     psVectorStats (stats, histogram->nums, NULL, NULL, 0);
     68    if (!psVectorStats (stats, histogram->nums, NULL, NULL, 0)) {
     69        psError(PS_ERR_UNKNOWN, false, "failure to measure stats for histogram");
     70        return false;
     71    }
    6672
    6773    // scale the plot to hold the histogram
     
    100106    psStatsInit (stats);
    101107    stats->options = PS_STAT_MAX | PS_STAT_MIN;
    102     psVectorStats (stats, histogram->nums, NULL, NULL, 0);
     108    if (!psVectorStats (stats, histogram->nums, NULL, NULL, 0)) {
     109        psError(PS_ERR_UNKNOWN, false, "failure to measure stats for histogram");
     110        return false;
     111    }
    103112
    104113    // scale the plot to hold the histogram
  • trunk/psphot/src/psphotImageQuality.c

    r20471 r23989  
    8888                     "Number of stars used for IQ measurements", M2->n);
    8989
     90// XXX make this a recipe option
    9091#if (USE_SAMPLE)
    9192    psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV | PS_STAT_SAMPLE_QUARTILE);
  • trunk/psphot/src/psphotMakeResiduals.c

    r21366 r23989  
    200200            // measure the robust median to determine a baseline reference value
    201201            *fluxClip = *fluxClipDef;
    202             psVectorStats (fluxClip, fluxes, NULL, fmasks, fmaskVal);
    203             psErrorClear();             // clear (ignore) any outstanding errors
     202            if (!psVectorStats (fluxClip, fluxes, NULL, fmasks, fmaskVal)) {
     203                psError(PSPHOT_ERR_CONFIG, false, "Error calculating residual stats");
     204                return false;
     205            }
     206            if (isnan(fluxClip->robustMedian)) {
     207                resid->Ro->data.F32[oy][ox] = 0.0;
     208                resid->Rx->data.F32[oy][ox] = 0.0;
     209                resid->Ry->data.F32[oy][ox] = 0.0;
     210                resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox] = badMask;
     211                continue;
     212            }
    204213
    205214            // mark input pixels which are more than N sigma from the median
     
    220229                // measure the desired statistic on the unclipped pixels
    221230                *fluxStats = *fluxStatsDef;
    222                 psVectorStats (fluxStats, fluxes, NULL, fmasks, fmaskVal);
    223                 psErrorClear();         // clear (ignore) any outstanding errors
     231                if (!psVectorStats (fluxStats, fluxes, NULL, fmasks, fmaskVal)) {
     232                    psError(PSPHOT_ERR_CONFIG, false, "Error calculating residual stats");
     233                    return false;
     234                }
    224235
    225236                resid->Ro->data.F32[oy][ox] = psStatsGetValue(fluxStats, statOption);
    226237                resid->Rx->data.F32[oy][ox] = resid->Ry->data.F32[oy][ox] = 0.0;
    227                 //resid->variance->data.F32[oy][ox] = fluxStats->sampleStdev;
     238
     239                if (isnan(resid->Ro->data.F32[oy][ox])) {
     240                    resid->Ro->data.F32[oy][ox] = 0.0;
     241                    resid->Rx->data.F32[oy][ox] = 0.0;
     242                    resid->Ry->data.F32[oy][ox] = 0.0;
     243                    resid->mask->data.PM_TYPE_RESID_MASK_DATA[oy][ox] = badMask;
     244                    continue;
     245                }
    228246
    229247                if (fabs(resid->Ro->data.F32[oy][ox]) < pixelSN*fluxStats->sampleStdev/sqrt(nKeep)) {
  • trunk/psphot/src/psphotRoughClass.c

    r21183 r23989  
    9191        return false;
    9292    }
    93     if (!psfClump.X || !psfClump.Y) {
     93    if (!psfClump.X || !psfClump.Y || isnan(psfClump.X) || isnan(psfClump.Y)) {
    9494        psLogMsg ("psphot", 4, "Failed to find a valid PSF clump for region %f,%f - %f,%f\n", region->x0, region->y0, region->x1, region->y1);
    9595        return false;
Note: See TracChangeset for help on using the changeset viewer.