IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.