IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 15, 2010, 11:25:46 AM (15 years ago)
Author:
bills
Message:

Fix checking of good fit. Changed name to pGoodFit to emphasize that it is a pointer.
Fix a segv in trace code by checking for null pointers

File:
1 edited

Legend:

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

    r30031 r30044  
    5050Note: some of the array entries may be NULL (failed fits); ignore them.
    5151 *****************************************************************************/
    52 bool pmPSFtryMakePSF (bool *goodFit, pmPSFtry *psfTry)
     52bool pmPSFtryMakePSF (bool *pGoodFit, pmPSFtry *psfTry)
    5353{
    5454    PS_ASSERT_PTR_NON_NULL(psfTry, false);
     
    7474
    7575    // fit the shape parameters (SXX, SYY, SXY) as a function of position
    76     if (!pmPSFFitShapeParams (goodFit, psf, psfTry->sources, x, y, srcMask)) {
     76    if (!pmPSFFitShapeParams (pGoodFit, psf, psfTry->sources, x, y, srcMask)) {
    7777        psFree(x);
    7878        psFree(y);
    7979        return false;
    8080    }
    81     if (!goodFit) {
     81    if (!*pGoodFit) {
    8282        psWarning ("poor fit to PSF shape parameters for trend order %d, %d, skipping\n", psf->trendNx, psf->trendNy);
    8383        psFree(x);
     
    121121        // the mask is carried from previous steps and updated with this operation
    122122        // the weight is either the flux error or NULL, depending on 'psf->poissonErrorParams'
    123         if (!pmTrend2DFit (goodFit, trend, srcMask, 0xff, x, y, z, NULL)) {
     123        if (!pmTrend2DFit (pGoodFit, trend, srcMask, 0xff, x, y, z, NULL)) {
    124124            psError(PS_ERR_UNKNOWN, false, "failed to build psf model for parameter %d", i);
    125125            psFree(x);
     
    128128            return false;
    129129        }
    130         if (!goodFit) {
     130        if (!*pGoodFit) {
    131131            // if we do not get a good fit (but do not actually hit an error),
    132132            // tell the calling program to try something else
     
    154154
    155155            pmModel *modelPSF = pmModelFromPSF (source->modelEXT, psf);
     156            if (!modelPSF) {
     157                fprintf(f, "modelPSF is NULL\n");
     158                break;
     159            }
     160            if (!source->modelEXT) {
     161                fprintf(f, "source->modelEXT is NULL\n");
     162                break;
     163            }
    156164
    157165            fprintf (f, "%f %f : ", source->modelEXT->params->data.F32[PM_PAR_XPOS], source->modelEXT->params->data.F32[PM_PAR_YPOS]);
     
    178186
    179187// fit the shape parameters using the supplied order (pmPSF->trendNx,trendNy)
    180 bool pmPSFFitShapeParams (bool *goodFit, pmPSF *psf, psArray *sources, psVector *x, psVector *y, psVector *srcMask) {
     188bool pmPSFFitShapeParams (bool *pGoodFit, pmPSF *psf, psArray *sources, psVector *x, psVector *y, psVector *srcMask) {
    181189
    182190    // we are doing a robust fit.  after each pass, we drop points which are more deviant than
     
    234242        trend = psf->params->data[PM_PAR_E0];
    235243        trend->stats->clipIter = 1; // in allocation, this value is set to the value of nIter, but we should use 1 here
    236         status &= pmTrend2DFit (goodFit, trend, srcMask, 0xff, x, y, e0, NULL);
    237         if (!goodFit) {
     244        status &= pmTrend2DFit (pGoodFit, trend, srcMask, 0xff, x, y, e0, NULL);
     245        if (!*pGoodFit) {
    238246            psFree (e0);
    239247            psFree (e1);
     
    249257        trend = psf->params->data[PM_PAR_E1];
    250258        trend->stats->clipIter = 1; // in allocation, this value is set to the value of nIter, but we should use 1 here
    251         status &= pmTrend2DFit (goodFit, trend, srcMask, 0xff, x, y, e1, NULL);
    252         if (!goodFit) {
     259        status &= pmTrend2DFit (pGoodFit, trend, srcMask, 0xff, x, y, e1, NULL);
     260        if (!*pGoodFit) {
    253261            psFree (e0);
    254262            psFree (e1);
     
    264272        trend = psf->params->data[PM_PAR_E2];
    265273        trend->stats->clipIter = 1; // in allocation, this value is set to the value of nIter, but we should use 1 here
    266         status &= pmTrend2DFit (goodFit, trend, srcMask, 0xff, x, y, e2, NULL);
    267         if (!goodFit) {
     274        status &= pmTrend2DFit (pGoodFit, trend, srcMask, 0xff, x, y, e2, NULL);
     275        if (!*pGoodFit) {
    268276            psFree (e0);
    269277            psFree (e1);
Note: See TracChangeset for help on using the changeset viewer.