Return to Software Development Page

psVectorStats traditionally raised a psError for cases where the input data simply resulted in an invalid statistic. For example, if all input data points were masked or if the vector length was 0 (or in some cases 1). Since IPP programs bail out if any errors were not handled, this ended up in lots of places where psErrorClear was used gratuitously to hide problems.

I've changed the handling of psVectorStats to raise an error only in cases of serious programming or resource problems: unexpected NULL vectors, unallowed vector types, and so forth. In cases where valid vectors are supplied (even if zero length), a result of NAN is perfectly acceptable, and now does not raise an error.

I've also gone through all of the instances where psVectorStats is called and have added code to handle 'false' return status, and where possible to handle a NAN result as well. Not all of these were immediately obvious, so at the bottom of this page I have a list of the files for which more work to handle the NANs could be added.

There are a couple of unclear choices in the programming remaining: currently, any stats function which successfully calculates a non-NAN result raises its bit(s) in the psStats->result field. These could be raised even if a NAN is calculated. Also, it might be useful to have a bit somewhere that implies that the stats calculation failed: ie, it did not produce finite results for all of the desired output fields.

psModules/src/objects/pmGrowthCurveGenerate.c -- XXX does a poor job of handling NANs
psModules/src/objects/pmPSFtry.c -- XXX does a poor job of handling NANs
ppMerge/src/ppMergeMask.c -- XXX results are not handled well
ppStats/src/ppStatsReadout.c -- XXX results are not handled well
psLib/src/imageops/psImageBackground.c -- XXX results are not handled well
psLib/src/imageops/psImageGeomManip.c -- XXX results are not handled well
psLib/src/imageops/psImageMap.c -- XXX results are not handled well
psLib/src/imageops/psImageMapFit.c -- XXX results are not handled well
psLib/src/imageops/psImagePixelExtract.c -- XXX results are not handled well
psLib/src/imageops/psImageStats.c -- XXX results are not handled well
psLib/src/math/psClip.c -- XXX results are not handled well
psLib/src/math/psMinimizePolyFit.c -- XXX results are not handled well
psLib/src/math/psPolynomialUtils.c -- XXX results are not handled well
psModules/src/astrom/pmAstrometryDistortion.c -- XXX results are not handled well
psModules/src/camera/pmFPAMaskWeight.c -- XXX results are not handled well
psModules/src/detrend/pmFringeStats.c -- XXX results are not handled well
psModules/src/detrend/pmOverscan.c -- XXX results are not handled well
ppImage/src/ppImageMeasureCrosstalk.c -- NAN results are data
ppStats/src/ppStatsFromMetadataStats.c -- NAN results are data
psastro/src/psastroAstromGuess.c -- NAN results are data
psastro/src/psastroFixChipsTest.c -- NAN results are data
psastro/src/psastroModelAnalysis.c -- NAN results are data
psastro/src/psastroModelFitBoresite.c -- NAN results are data
psastro/src/psastroZeroPoint.c -- NAN results are data
psModules/src/concepts/pmConceptsStandard.c -- NAN results are data
psModules/src/objects/pmSource.c -- NAN results are data
psphot/src/psphotApResid.c -- NAN results are data
psphot/src/psphotChoosePSF.c -- NAN results are data
psphot/src/psphotDiagnosticPlots.c -- NAN results are data
psphot/src/psphotImageQuality.c -- NAN results are data
psModules/src/detrend/pmRemnance.c -- results are checked
psModules/src/detrend/pmShutterCorrection.c -- results are checked
psModules/src/extras/pmVisual.c -- results are checked
psModules/src/imcombine/pmImageCombine.c -- results are checked
psModules/src/imcombine/pmReadoutCombine.c -- results are checked
psModules/src/imcombine/pmSubtraction.c -- results are checked
psModules/src/imcombine/pmSubtractionMatch.c -- results are checked
psphot/src/psphotMakeResiduals.c -- results checked
psModules/src/objects/pmSourceMatch.c -- results checked (could handle nan better)
psModules/src/detrend/pmSkySubtract.c -- unused code
psModules/src/objects/models/pmModel_SGAUSS.c -- unused code