IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11263


Ignore:
Timestamp:
Jan 24, 2007, 11:41:08 AM (19 years ago)
Author:
eugene
Message:

updating error handling to distinguish data errors from fatal errors

Location:
trunk/psphot/src
Files:
15 edited

Legend:

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

    r10791 r11263  
    33static void usage (void) {
    44    fprintf (stderr, "USAGE: psphot [-file image(s)] [-list imagelist] (output)\n");
    5     exit (2);
     5    exit (PS_EXIT_CONFIG_ERROR);
    66}
    77
     
    99
    1010    psTimerStart ("complete");
    11 
    1211    psphotErrorRegister();              // register our error codes/messages
    13 
    14     // load implementation-specific models
    15     psphotModelGroupInit ();
     12    psphotModelGroupInit ();            // load implementation-specific models
    1613
    1714    // load command-line arguments, options, and system config data
     
    2118    // load input data (config and images (signal, noise, mask)
    2219    if (!psphotParseCamera (config)) {
    23         psErrorStackPrint(stderr, "error setting up the camera");
    24         exit(1);
     20        psErrorStackPrint(stderr, "Error setting up the camera");
     21        exit (psphotGetExitStatus());
    2522    }
    26 
    27     // XXX for test checking of the config system
    28     // psphotDumpConfig (config);
    2923
    3024    // call psphot for each readout
    3125    if (!psphotImageLoop (config)) {
    32         psErrorStackPrint(stderr, " ");
    33         exit(1);
     26        psErrorStackPrint(stderr, "Error in the psphot image loop");
     27        exit (psphotGetExitStatus());
    3428    }
    3529
    3630    psLogMsg ("psphot", 3, "complete psphot run: %f sec\n", psTimerMark ("complete"));
    3731
     32    psErrorCode exit_status = psphotGetExitStatus();
    3833    psphotCleanup (config);
    39     exit (EXIT_SUCCESS);
     34    exit (exit_status);
    4035}
     36
     37// all functions which return to this level must raise one of the top-level error codes if they
     38// exit with an error.  these error codes are used to specify the program exit status
  • trunk/psphot/src/psphot.h

    r11230 r11263  
    9999bool psphotMergeSources (psArray *oldSources, psArray *newSources);
    100100bool psphotLoadExtSources (pmConfig *config, pmFPAview *view, psArray *sources);
     101psExit psphotGetExitStatus ();
  • trunk/psphot/src/psphotBlendFit.c

    r11165 r11263  
    9191
    9292    psLogMsg ("psphot.psphotBlendFit", PS_LOG_INFO, "fit models: %f sec for %d objects (%d psf, %d ext, %d failed, %ld skipped)\n", psTimerMark ("psphot"), Nfit, Npsf, Next, Nfail, sources->n - Nfit);
    93     return (true);
     93    return true;
    9494}
  • trunk/psphot/src/psphotChoosePSF.c

    r11200 r11263  
    256256}
    257257
     258// measure average parameters of the PSF model
    258259bool psphotPSFstats (pmReadout *readout, psMetadata *recipe, pmPSF *psf) {
    259260
     
    295296    psF64 FWHM_Y = FWHM_X * (axes.minor / axes.major);
    296297
    297     psMetadataAdd (recipe, PS_LIST_TAIL, "FWHM_X", PS_DATA_F32 | PS_META_REPLACE, "PSF FWHM Major axis", FWHM_X);
    298     psMetadataAdd (recipe, PS_LIST_TAIL, "FWHM_Y", PS_DATA_F32 | PS_META_REPLACE, "PSF FWHM Minor axis", FWHM_Y);
    299     psMetadataAdd (recipe, PS_LIST_TAIL, "ANGLE",  PS_DATA_F32 | PS_META_REPLACE, "PSF angle",           axes.theta);
    300     psMetadataAdd (recipe, PS_LIST_TAIL, "NPSFSTAR", PS_DATA_S32 | PS_META_REPLACE, "number of stars used to make PSF", psf->nPSFstars);
     298    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_X",   PS_META_REPLACE, "PSF FWHM Major axis", FWHM_X);
     299    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_Y",   PS_META_REPLACE, "PSF FWHM Minor axis", FWHM_Y);
     300    psMetadataAddF32 (recipe, PS_LIST_TAIL, "ANGLE",    PS_META_REPLACE, "PSF angle",           axes.theta);
     301    psMetadataAddS32 (recipe, PS_LIST_TAIL, "NPSFSTAR", PS_META_REPLACE, "Number of stars used to make PSF", psf->nPSFstars);
     302    psMetadataAddBool(recipe, PS_LIST_TAIL, "PSFMODEL", PS_META_REPLACE, "Valid PSF Model?", true);
    301303
    302304    psFree (modelEXT);
     
    306308}
    307309
    308 // XXX fix this wrt re-definition of PM_PAR_SXX
     310// determine approximate PSF shape parameters based on the moments
    309311bool psphotMomentsStats (pmReadout *readout, psMetadata *recipe, psArray *sources) {
    310312
     
    347349    FWHM_T /= FWHM_N;
    348350
    349     psMetadataAdd (recipe, PS_LIST_TAIL, "FWHM_X", PS_DATA_F32 | PS_META_REPLACE, "PSF FWHM Major axis", FWHM_X);
    350     psMetadataAdd (recipe, PS_LIST_TAIL, "FWHM_Y", PS_DATA_F32 | PS_META_REPLACE, "PSF FWHM Minor axis", FWHM_Y);
    351     psMetadataAdd (recipe, PS_LIST_TAIL, "ANGLE",  PS_DATA_F32 | PS_META_REPLACE, "PSF angle",           FWHM_T);
     351    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_X",   PS_META_REPLACE, "PSF FWHM Major axis (from moments)", FWHM_X);
     352    psMetadataAddF32 (recipe, PS_LIST_TAIL, "FWHM_Y",   PS_META_REPLACE, "PSF FWHM Minor axis (from moments)", FWHM_Y);
     353    psMetadataAddF32 (recipe, PS_LIST_TAIL, "ANGLE",    PS_META_REPLACE, "PSF angle",           FWHM_T);
     354    psMetadataAddS32 (recipe, PS_LIST_TAIL, "NPSFSTAR", PS_META_REPLACE, "Number of stars used to make PSF", 0);
     355    psMetadataAddBool(recipe, PS_LIST_TAIL, "PSFMODEL", PS_META_REPLACE, "Valid PSF Model?", false);
    352356
    353357    return true;
  • trunk/psphot/src/psphotCleanup.c

    r9270 r11263  
    1515    return;
    1616}
     17
     18psExit psphotGetExitStatus () {
     19
     20    psErrorCode err = psErrorCodeLast ();
     21    switch (err) {
     22      case PSPHOT_ERR_SYS:
     23        return PS_EXIT_SYS_ERROR;
     24      case PSPHOT_ERR_CONFIG:
     25        return PS_EXIT_CONFIG_ERROR;
     26      case PSPHOT_ERR_PROG:
     27        return PS_EXIT_PROG_ERROR;
     28      case PSPHOT_ERR_DATA:
     29        return PS_EXIT_DATA_ERROR;
     30      default:
     31        return PS_EXIT_UNKNOWN_ERROR;
     32    }   
     33    return PS_EXIT_UNKNOWN_ERROR;
     34}
  • trunk/psphot/src/psphotErrorCodes.dat

    r10135 r11263  
    22# This file is used to generate psphotErrorClasses.h
    33#
    4 BASE = 512              First value we use; lower values belong to psLib
     4BASE = 200              First value we use; lower values belong to psLib
    55UNKNOWN                 Unknown PM error code
    66NOT_IMPLEMENTED         Desired feature is not yet implemented
    7 ARGUMENTS               Incorrect arguments
    8 CONFIG                  Problem in configure files
    97FITS                    Problem in FITS I/O
    108FITS_WCS                Error interpreting FITS WCS information
     
    1311APERTURE                Problem with aperture photometry
    1412SKY                     Problem in sky determination
     13# these errors correspond to standard exit conditions
     14ARGUMENTS               Incorrect arguments
     15SYS                     System error
     16CONFIG                  Problem in configure files
     17PROG                    Programming error
     18DATA                    invalid data
  • trunk/psphot/src/psphotFindPeaks.c

    r11186 r11263  
    1717        float FWHM_X = psMetadataLookupF32 (&status_x, recipe, "FWHM_X");
    1818        float FWHM_Y = psMetadataLookupF32 (&status_y, recipe, "FWHM_Y");
    19         if (!status_x | !status_y) psAbort ("psphotFindPeaks", "FWHM_X or FWHM_Y not defined");
     19        if (!status_x | !status_y) {
     20            psError(PSPHOT_ERR_CONFIG, false, "FWHM_X or FWHM_Y not defined");
     21            return false;
     22        }
    2023        SIGMA_SMTH  = 0.5*(FWHM_X + FWHM_Y) / (2.0*sqrt(2.0*log(2.0)));
    2124        NSIGMA_SMTH = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_NSIGMA");
     
    8386    // find the peaks in the smoothed image
    8487    psArray *peaks = pmFindImagePeaks (smooth_im, threshold);
    85     if (peaks == NULL) psAbort ("find peaks", "no peaks found");
     88    if (peaks == NULL) {
     89        // XXX this may also be due to a programming or config error
     90        // XXX do we need to set something in the readout->analysis to indicate that
     91        // we tried and failed to find peaks (something in the header data)
     92        psError(PSPHOT_ERR_DATA, false, "no peaks found in this image");
     93        return false;
     94    }
    8695   
    8796    // correct the peak values to S/N = sqrt(value*effArea)
  • trunk/psphot/src/psphotImageLoop.c

    r9566 r11263  
    11# include "psphot.h"
    22
    3 // XXX where do we load optional mask and weight input images?
     3// XXX the errors in the pmFPAfileIOChecks could also be due to a programming or config error
     4// XXX we need to either handle those errors or handle the error in pmFPAfileIOChecks and exit
    45bool psphotImageLoop (pmConfig *config) {
    56
     
    1112    pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PSPHOT.INPUT");
    1213    if (!status) {
    13         psError(PS_ERR_IO, false, "Can't find input data!");
     14        psError(PSPHOT_ERR_PROG, false, "Can't find input data!");
    1415        return false;
    1516    }
     
    1920    // files associated with the science image
    2021    if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
    21         psError(PS_ERR_UNKNOWN, false, "failed IO for fpa in psphot\n");
     22        psError(PSPHOT_ERR_DATA, false, "failed IO for fpa in psphot\n");
    2223        psFree(view);
    2324        return false;
     
    2829        if (! chip->process || ! chip->file_exists) { continue; }
    2930        if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
    30             psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d in psphot\n", view->chip);
     31            psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in psphot\n", view->chip);
    3132            psFree (view);
    3233            return false;
     
    3738            if (! cell->process || ! cell->file_exists) { continue; }
    3839            if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
    39                 psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d, cell %d in psphot\n", view->chip, view->cell);
     40                psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d in psphot\n", view->chip, view->cell);
    4041                psFree (view);
    4142                return false;
     
    4546            while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
    4647                if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
    47                     psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d, cell %d, readout %d in psphot\n", view->chip, view->cell, view->readout);
     48                    psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d, readout %d in psphot\n", view->chip, view->cell, view->readout);
    4849                    psFree (view);
    4950                    return false;
     
    5455                // run the actual photometry analysis
    5556                if (!psphotReadout (config, view)) {
    56                     psError(PS_ERR_UNKNOWN, false, "failed psphotReadout for chip %d, cell %d, readout %d\n", view->chip, view->cell, view->readout);
     57                    psError(psErrorCodeLast(), false, "failure in psphotReadout for chip %d, cell %d, readout %d\n", view->chip, view->cell, view->readout);
    5758                    psFree (view);
    5859                    return false;
     
    6061
    6162                if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
    62                     psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d, cell %d, readout %d in psphot\n", view->chip, view->cell, view->readout);
     63                    psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d, readout %d in psphot\n", view->chip, view->cell, view->readout);
    6364                    psFree (view);
    6465                    return false;
     
    6667            }
    6768            if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
    68                 psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d, cell %d in psphot\n", view->chip, view->cell);
     69                psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d in psphot\n", view->chip, view->cell);
    6970                psFree (view);
    7071                return false;
     
    7273        }
    7374        if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
    74             psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d in psphot\n", view->chip);
     75            psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in psphot\n", view->chip);
    7576            psFree (view);
    7677            return false;
     
    7879    }
    7980    if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
    80         psError(PS_ERR_UNKNOWN, false, "failed IO for fpa in psphot\n");
     81        psError(PSPHOT_ERR_DATA, false, "failed IO for fpa in psphot\n");
    8182        psFree (view);
    8283        return false;
  • trunk/psphot/src/psphotImageMedian.c

    r11200 r11263  
    9999            pmFPAfileCopyStructureView (file->fpa, inFPA, DX, DY, view);
    100100            model = pmFPAviewThisReadout (view, file->fpa);
    101             if (nx != model->image->numCols) psAbort ("psphot", "inconsistent size");
    102             if (ny != model->image->numRows) psAbort ("psphot", "inconsistent size");
     101            if ((nx != model->image->numCols) || (ny != model->image->numRows)) {
     102                psError (PSPHOT_ERR_PROG, true, "inconsistent sizes for model dimensions");
     103                return false;
     104            }
    103105        }
    104106    }
     
    230232            pmFPAfileCopyStructureView (file->fpa, inFPA, 1, 1, view);
    231233            background = pmFPAviewThisReadout (view, file->fpa);
    232             if (Nx != background->image->numCols) psAbort ("psphot", "inconsistent size");
    233             if (Ny != background->image->numRows) psAbort ("psphot", "inconsistent size");
     234            if ((Nx != background->image->numCols) || (Ny != background->image->numRows)) {
     235                psError (PSPHOT_ERR_PROG, true, "inconsistent sizes for background dimensions");
     236                return false;
     237            }
    234238        }
    235239    } else {
  • trunk/psphot/src/psphotMergeSources.c

    r11230 r11263  
    1616
    1717    // find the currently selected readout
    18     pmReadout  *readout = pmFPAfileThisReadout (config->files, view, "INPUT.SRC");
     18    pmReadout  *readout = pmFPAfileThisReadout (config->files, view, "PSPHOT.SRC");
    1919    if (!readout) {
    2020        psLogMsg ("psphot", 3, "no external sources supplied");
  • trunk/psphot/src/psphotParseCamera.c

    r11230 r11263  
    1313    }
    1414
     15    // if we have requested PSPHOT.SRC, attempt to resolve it
     16    if (psMetadataLookupPtr(NULL, config->arguments, "SRC")) {
     17        pmFPAfileDefineFromArgs (&status, config, "PSPHOT.SRC", "SRC");
     18        if (!status) {
     19            psError(PSPHOT_ERR_CONFIG, false, "Failed to find/build PSPHOT.SRC");
     20            return status;
     21        }
     22    }
     23
    1524    // select recipe options supplied on command line
    1625    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
     
    1827    // if MASK or WEIGHT was supplied on command line, bind files to input fpa
    1928    // XXX these do not quite yet work: pmFPAAddSourceFromHeader is not appropriate
    20     pmFPAfileBindFromArgs (NULL, input, config, "INPUT.MASK", "MASK");
    21     pmFPAfileBindFromArgs (NULL, input, config, "INPUT.WEIGHT", "WEIGHT");
     29    pmFPAfileBindFromArgs (NULL, input, config, "PSPHOT.MASK", "MASK");
     30    pmFPAfileBindFromArgs (NULL, input, config, "PSPHOT.WEIGHT", "WEIGHT");
    2231
    2332    // optionally load the PSF Model and/or fixed stars
    24     pmFPAfileBindFromArgs (NULL, input, config, "INPUT.PSF", "PSF");
    25     pmFPAfile *srcInput = pmFPAfileDefineFromArgs (NULL, config, "INPUT.SRC", "SRC");
    26     if (!srcInput) {
    27         fprintf (stderr, "!");
    28     }
     33    pmFPAfileBindFromArgs (NULL, input, config, "PSPHOT.PSF", "PSF");
    2934
    3035    // set default recipe values here
     
    4752    if (!status || saveOutput) {
    4853        if (!pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.OUTPUT")) {
    49             psError(PS_ERR_IO, false, "Cannot find a rule for PSPHOT.OUTPUT");
     54            psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.OUTPUT");
    5055            return false;
    5156        }
     
    5560    if (psMetadataLookupBool(NULL, recipe, "SAVE.RESID")) {
    5661        if (!pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.RESID")) {
    57             psError(PS_ERR_IO, false, "Cannot find a rule for PSPHOT.BACKMDL");
     62            psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKMDL");
    5863            return false;
    5964        }
     
    6873    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKMDL")) {
    6974        if (!pmFPAfileDefineFromFPA (config, input->fpa, DX, DY, "PSPHOT.BACKMDL")) {
    70             psError(PS_ERR_IO, false, "Cannot find a rule for PSPHOT.BACKMDL");
     75            psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKMDL");
    7176            return false;
    7277        }
     
    7580    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKGND")) {
    7681        if (!pmFPAfileDefineFromFPA (config, input->fpa,  1,  1, "PSPHOT.BACKGND")) {
    77             psError(PS_ERR_IO, false, "Cannot find a rule for PSPHOT.BACKGND");
     82            psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKGND");
    7883            return false;
    7984        }
     
    8287    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKSUB")) {
    8388        if (!pmFPAfileDefineFromFPA (config, input->fpa,  1,  1, "PSPHOT.BACKSUB")) {
    84             psError(PS_ERR_IO, false, "Cannot find a rule for PSPHOT.");
     89            psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.");
    8590            return false;
    8691        }
     
    8994    if (psMetadataLookupBool(NULL, recipe, "SAVE.PSF")) {
    9095        if (!pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.PSF.SAVE")) {
    91             psError(PS_ERR_IO, false, "Cannot find a rule for PSPHOT.PSF.SAVE");
     96            psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.PSF.SAVE");
    9297            return false;
    9398        }
     
    115120            int chipNum = atoi(chips->data[i]);
    116121            if (! pmFPASelectChip(input->fpa, chipNum, false)) {
    117                 psError(PS_ERR_IO, false, "Chip number %d doesn't exist in camera.\n", chipNum);
     122                psError(PSPHOT_ERR_CONFIG, false, "Chip number %d doesn't exist in camera.\n", chipNum);
    118123                return false;
    119124            }
     
    121126    }
    122127    psFree (chips);
    123 
    124128    psTrace("psphot", 1, "Done with psphotParseCamera...\n");
    125129
    126130    psErrorClear();                     // some metadata lookup may have failed
    127 
    128131    return true;
    129132}
  • trunk/psphot/src/psphotReadout.c

    r11230 r11263  
    55    // select the current recipe
    66    psMetadata *recipe  = psMetadataLookupPtr (NULL, config->recipes, PSPHOT_RECIPE);
     7    if (!recipe) {
     8        psError(PSPHOT_ERR_CONFIG, false, "missing recipe %s", PSPHOT_RECIPE);
     9        return false;
     10    }
    711
    812    // find the currently selected readout
    913    pmReadout  *readout = pmFPAfileThisReadout (config->files, view, "PSPHOT.INPUT");
     14    PS_ASSERT_PTR_NON_NULL (readout, false);
    1015
    1116    // optional break-point for processing
    1217    char *breakPt = psMetadataLookupStr (NULL, recipe, "BREAK_POINT");
     18    PS_ASSERT_PTR_NON_NULL (breakPt, false);
    1319
    1420    // generate mask & weight images if they don't already exit
    1521    if (!pmReadoutGenerateMaskWeight (readout, true)) {
     22        psError (PSPHOT_ERR_CONFIG, false, "trouble creating mask and/or weight");
    1623        return false;
    1724    }
     
    3441
    3542    // generate a background model (median, smoothed image)
    36     psphotImageMedian (config, view);
     43    if (!psphotImageMedian (config, view)) {
     44        return psphotReadoutCleanup (config, readout, recipe, NULL, NULL);
     45    }
    3746
    3847    if (!strcasecmp (breakPt, "BACKMDL")) {
     
    4049    }
    4150
    42     pmReadout *background = psphotSelectBackground (config, view);
    43 
    4451    // find the peaks in the image
    4552    psArray *peaks = psphotFindPeaks (readout, recipe, 1);
     53    if (!peaks) {
     54        psLogMsg ("psphot", 3, "unable to find peaks in this image");
     55        return psphotReadoutCleanup (config, readout, recipe, NULL, NULL);
     56    }
    4657
    4758    // construct sources and measure basic stats
    48     // limit moments analysis by S/N?
    4959    psArray *sources = psphotSourceStats (readout, recipe, peaks);
     60    if (!sources) return false;
    5061    psFree (peaks);
    5162
     
    5566
    5667    // mark blended peaks PS_SOURCE_BLEND
    57     psphotBasicDeblend (sources, recipe);
     68    if (!psphotBasicDeblend (sources, recipe)) {
     69        psLogMsg ("psphot", 3, "failed on deblend analysis");
     70        return psphotReadoutCleanup (config, readout, recipe, NULL, sources);
     71    }
    5872
    5973    // classify sources based on moments, brightness
    6074    if (!psphotRoughClass (sources, recipe)) {
    61         psFree (sources);
    62         psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image");
    63         pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL");
    64         pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND");
    65         return false;
     75        psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image");
     76        return psphotReadoutCleanup (config, readout, recipe, NULL, sources);
    6677    }
    6778    if (!strcasecmp (breakPt, "MOMENTS")) {
     
    7283    pmPSF *psf = psphotChoosePSF (readout, sources, recipe);
    7384    if (psf == NULL) {
    74         psError(PSPHOT_ERR_UNKNOWN, false, "failure to construct a psf model");
    75         return false;
     85        psLogMsg ("psphot", 3, "failure to construct a psf model");
     86        return psphotReadoutCleanup (config, readout, recipe, psf, sources);
    7687    }
    7788    if (!strcasecmp (breakPt, "PSFMODEL")) {
    78         return psphotReadoutCleanup(config, readout, recipe, psf, sources);
     89        return psphotReadoutCleanup (config, readout, recipe, psf, sources);
    7990    }
    8091
     
    142153
    143154    // calculate source magnitudes
     155    // XXX modify this API to take config, view?
     156    pmReadout *background = psphotSelectBackground (config, view);
    144157    psphotMagnitudes(sources, recipe, psf, background);
    145158
  • trunk/psphot/src/psphotReadoutCleanup.c

    r11184 r11263  
    11# include "psphot.h"
    22
     3// psphotReadoutCleanup is called on exit from psphotReadout if the last raised
     4// error is not a DATA error, then there was a serious problem.  only in this
     5// case, or if the fail on the stats measurement, do we return false
    36bool psphotReadoutCleanup (pmConfig *config, pmReadout *readout, psMetadata *recipe, pmPSF *psf, psArray *sources) {
     7
     8    psErrorCode err = psErrorCodeLast();
     9    if (err != PSPHOT_ERR_DATA) {
     10        return false;
     11    }
    412
    513    // use the psf-model to measure FWHM stats
    614    if (psf) {
     15        // don't call psphotPSFstats unless we have a valid pdf
     16        // if it fails, there is probably a programming error
    717        if (!psphotPSFstats (readout, recipe, psf)) {
    8             psError(PS_ERR_IO, true, "Failed to measure PSF shape parameters");
     18            psError(PSPHOT_ERR_PROG, false, "Failed to measure PSF shape parameters");
    919            return false;
    1020        }
    11     } else if (sources) {
     21    }
     22    if (!psf && sources) {
    1223        if (!psphotMomentsStats (readout, recipe, sources)) {
    13             psError(PS_ERR_IO, true, "Failed to measure Moment shape parameters");
     24            psError(PSPHOT_ERR_PROG, false, "Failed to measure Moment shape parameters");
    1425            return false;
    1526        }
  • trunk/psphot/src/psphotRoughClass.c

    r10803 r11263  
    99
    1010    psfClump = pmSourcePSFClump (sources, recipe);
     11    if (psfClump.X < 0) {
     12        psError(PSPHOT_ERR_PROG, false, "programming error calling pmSourcePSFClump");
     13        return false;
     14    }
     15    if (!psfClump.X || !psfClump.Y) {
     16        psError(PSPHOT_ERR_DATA, true, "Failed to find a valid PSF clump");
     17        return false;
     18    }
    1119    psLogMsg ("psphot", 3, "psf clump  X,  Y: %f, %f\n", psfClump.X, psfClump.Y);
    1220    psLogMsg ("psphot", 3, "psf clump DX, DY: %f, %f\n", psfClump.dX, psfClump.dY);
    1321
    14     // did we find a valid psfClump?
    15     if (!psfClump.X || !psfClump.Y) {
    16         psError(PSPHOT_ERR_PSF, true, "Failed to find a valid PSF clump");
     22    // group into STAR, COSMIC, EXTENDED, SATURATED, etc.
     23    if (!pmSourceRoughClass (sources, recipe, psfClump)) {
     24        psError(PSPHOT_ERR_PROG, false, "programming error calling pmSourceRoughClass");
    1725        return false;
    1826    }
    19 
    20     // group into STAR, COSMIC, EXTENDED, SATURATED, etc.
    21     pmSourceRoughClass (sources, recipe, psfClump);
    2227
    2328    // optional printout of source moments only
  • trunk/psphot/src/psphotSourceStats.c

    r11177 r11263  
    1111    // determine properties (sky, moments) of initial sources
    1212    float INNER    = psMetadataLookupF32 (&status, recipe, "SKY_INNER_RADIUS");
     13    if (!status) return NULL;
    1314    float OUTER    = psMetadataLookupF32 (&status, recipe, "SKY_OUTER_RADIUS");
     15    if (!status) return NULL;
    1416    float RADIUS   = psMetadataLookupF32 (&status, recipe, "PSF_MOMENTS_RADIUS");
     17    if (!status) return NULL;
    1518    float MIN_SN   = psMetadataLookupF32 (&status, recipe, "MOMENTS_SN_MIN");
     19    if (!status) return NULL;
    1620    char *breakPt  = psMetadataLookupStr (&status, recipe, "BREAK_POINT");
     21    if (!status) return NULL;
    1722
    1823    sources = psArrayAllocEmpty (peaks->n);
Note: See TracChangeset for help on using the changeset viewer.