IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11261


Ignore:
Timestamp:
Jan 24, 2007, 11:32:19 AM (19 years ago)
Author:
magnier
Message:

adding error handling to functions

File:
1 edited

Legend:

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

    r11160 r11261  
    66 *  @author EAM, IfA: significant modifications.
    77 *
    8  *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-01-19 04:38:26 $
     8 *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-01-24 21:32:19 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    214214
    215215    psArray *peaks  = NULL;
    216     pmPSFClump emptyClump = {0.0, 0.0, 0.0, 0.0};
    217     pmPSFClump psfClump = emptyClump;
    218 
    219     PS_ASSERT_PTR_NON_NULL(sources, emptyClump);
    220     PS_ASSERT_PTR_NON_NULL(recipe, emptyClump);
     216    pmPSFClump errorClump = {-1.0, -1.0, 0.0, 0.0};
     217    pmPSFClump emptyClump = {+0.0, +0.0, 0.0, 0.0};
     218    pmPSFClump psfClump;
     219
     220    PS_ASSERT_PTR_NON_NULL(sources, errorClump);
     221    PS_ASSERT_PTR_NON_NULL(recipe, errorClump);
    221222
    222223    bool status = true;
     
    249250
    250251        // place the sources in the sigma-plane image (ignore 0,0 values?)
     252        int nValid = 0;
    251253        for (psS32 i = 0 ; i < sources->n ; i++)
    252254        {
    253255            pmSource *tmpSrc = (pmSource *) sources->data[i];
    254             if (tmpSrc == NULL) {
    255                 continue;
    256             }
    257             if (tmpSrc->moments == NULL) {
    258                 continue;
    259             }
    260 
    261             if (tmpSrc->moments->SN < PSF_CLUMP_SN_LIM) {
    262                 continue;
    263             }
     256            if (tmpSrc == NULL)
     257                continue;
     258            if (tmpSrc->moments == NULL)
     259                continue;
     260            if (tmpSrc->moments->SN < PSF_CLUMP_SN_LIM)
     261                continue;
    264262
    265263            // Sx,Sy are limited at 0.  a peak at 0,0 is artificial
    266             if (fabs(tmpSrc->moments->Sx) < 0.05) {
    267                 continue;
    268             }
    269             if (fabs(tmpSrc->moments->Sy) < 0.05) {
    270                 continue;
    271             }
    272             if ((tmpSrc->moments->Sx / tmpSrc->moments->Sy) > AR_MAX) {
    273                 continue;
    274             }
    275             if ((tmpSrc->moments->Sx / tmpSrc->moments->Sy) < AR_MIN) {
    276                 continue;
    277             }
    278             if (tmpSrc->mode & PM_SOURCE_MODE_BLEND) {
    279                 continue;
    280             }
     264            if (fabs(tmpSrc->moments->Sx) < 0.05)
     265                continue;
     266            if (fabs(tmpSrc->moments->Sy) < 0.05)
     267                continue;
     268            if ((tmpSrc->moments->Sx / tmpSrc->moments->Sy) > AR_MAX)
     269                continue;
     270            if ((tmpSrc->moments->Sx / tmpSrc->moments->Sy) < AR_MIN)
     271                continue;
     272            if (tmpSrc->mode & PM_SOURCE_MODE_BLEND)
     273                continue;
    281274
    282275            // for the moment, force splane dimensions to be 10x10 image pix
     
    294287
    295288            splane->data.F32[binY][binX] += 1.0;
     289            nValid ++;
    296290        }
    297291
     
    311305        psFree (stats);
    312306
     307        // if we failed to find a valid peak, return the empty clump (failure signal)
    313308        if (peaks == NULL)
    314309        {
    315             return (psfClump);
    316         }
    317     }
    318     // XXX EAM : possible errors:
    319     //           1) no peak in splane
    320     //           2) no significant peak in splane
     310            psLogMsg ("psphot", 3, "failed to find a peak in the PSF clump image\n");
     311            if (nValid == 0) {
     312                psLogMsg ("psphot", 3, "no valid sources kept for PSF search\n");
     313            } else {
     314                psLogMsg ("psphot", 3, "no significant peak\n");
     315            }
     316            return (emptyClump);
     317        }
     318    }
    321319
    322320    // measure statistics on Sx, Sy if Sx, Sy within range of clump
     
    408406    psTrace("psModules.objects", 5, "---- begin ----");
    409407
    410     psBool rc = true;
     408    PS_ASSERT_PTR_NON_NULL(sources, false);
     409    PS_ASSERT_PTR_NON_NULL(recipe, false);
    411410
    412411    int Nsat     = 0;
     
    538537
    539538    psTrace("psModules.objects", 5, "---- end ----\n");
    540     return(rc);
     539    return true;
    541540}
    542541
Note: See TracChangeset for help on using the changeset viewer.