IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 4, 2007, 9:55:03 AM (19 years ago)
Author:
eugene
Message:

clean up error handling on pmFPAfileIO

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppImage/src/ppImageLoop.c

    r15137 r15216  
    44
    55#include "ppImage.h"
     6
     7# define ESCAPE(MESSAGE) { \
     8  psError(PS_ERR_UNKNOWN, false, MESSAGE); \
     9  psFree (view); \
     10  return false; \
     11}
    612
    713bool ppImageLoop (pmConfig *config, ppImageOptions *options) {
     
    2329
    2430    // files associated with the science image
    25     if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
    26         psFree (view);
    27         return false;
    28     }
     31    if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) ESCAPE ("load failure for FPA");
    2932
    3033    while ((chip = pmFPAviewNextChip(view, input->fpa, 1)) != NULL) {
     
    3336            continue;
    3437        }
    35 
    36         if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
    37             psFree (view);
    38             return false;
    39         }
     38        if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) ESCAPE ("load failure for Chip");
    4039
    4140        while ((cell = pmFPAviewNextCell(view, input->fpa, 1)) != NULL) {
     
    4443                continue;
    4544            }
    46             if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
    47                 psFree (view);
    48                 return false;
    49             }
     45            if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) ESCAPE ("load failure for Cell");
    5046
    5147            // Put version information into the header
     
    5955            // process each of the readouts
    6056            while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
    61                 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
    62                     psFree (view);
    63                     return false;
    64                 }
     57                if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) ESCAPE ("load failure for Readout");
    6558                if (!readout->data_exists) {
    6659                    continue;
     
    6861
    6962                // perform the detrend analysis
    70                 if (!ppImageDetrendReadout(config, options, view)) {
    71                     psError(PS_ERR_UNKNOWN, false, "Unable to detrend readout.\n");
    72                     psFree (view);
    73                     return false;
    74                 }
    75 
     63                if (!ppImageDetrendReadout(config, options, view))
     64                    ESCAPE ("Unable to detrend readout");
    7665            }
    7766        }
     
    7968        // Apply the fringe correction
    8069        if (options->doFringe) {
    81             if (!ppImageDetrendFringeApply (config, chip, view, options)) {
    82                 psFree (view);
    83                 return false;
    84             }
     70            if (!ppImageDetrendFringeApply (config, chip, view, options))
     71                ESCAPE ("Unable to defringe");
    8572        }
    8673       
    8774        // measure various statistics for this image
    88         if (!ppImagePixelStats (config, options, view)) {
    89             psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to measures stats for image");
    90             psFree (view);
    91             return false;
    92         }
     75        if (!ppImagePixelStats (config, options, view))
     76            ESCAPE ("Unable to measures stats for image");
    9377
    94         if (!ppImageMosaicChip(config, options, view, "PPIMAGE.CHIP", "PPIMAGE.OUTPUT")) {
    95             psError(PS_ERR_UNKNOWN, false, "Unable to mosaic chip.\n");
    96             psFree (view);
    97             return false;
    98         }
    99         if (!ppImageRebinChip(config, view, "PPIMAGE.BIN1")) {
    100             psError(PS_ERR_UNKNOWN, false, "Unable to bin chip.\n");
    101             psFree (view);
    102             return false;
    103         }
    104         if (!ppImageRebinChip(config, view, "PPIMAGE.BIN2")) {
    105             psError(PS_ERR_UNKNOWN, false, "Unable to bin chip.\n");
    106             psFree (view);
    107             return false;
    108         }
     78        if (!ppImageMosaicChip(config, options, view, "PPIMAGE.CHIP", "PPIMAGE.OUTPUT"))
     79            ESCAPE ("Unable to mosaic chip");
     80
     81        if (!ppImageRebinChip(config, view, "PPIMAGE.BIN1"))
     82            ESCAPE ("Unable to bin chip (level 1).");
     83
     84        if (!ppImageRebinChip(config, view, "PPIMAGE.BIN2"))
     85            ESCAPE ("Unable to bin chip (level 2).");
    10986
    11087        // we perform photometry on the readouts of this chip in the output
    11188        if (options->doPhotom) {
    112             if (!ppImagePhotom(config, view)) {
    113                 psError(PS_ERR_UNKNOWN, false, "error running photometry.\n");
    114                 psFree (view);
    115                 return false;
    116             }
     89            if (!ppImagePhotom(config, view)) ESCAPE ("error running photometry.");
    11790        }
    11891
     
    12396                continue;
    12497            }
    125 
    126             if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
    127                 psFree(view);
    128                 return false;
    129             }
     98            if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) ESCAPE ("save failure for Cell");
    13099        }
    131100
    132101        // Close chip
    133         if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
    134             psFree(view);
    135             return false;
    136         }
     102        if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) ESCAPE ("save failure for Chip");
    137103    }
    138104
     
    140106    // it would require us to NOT free PPIMAGE.CHIP until here
    141107    // ppImageMosaicFPA (config, "PPIMAGE.OUTPUT.FPA", "PPIMAGE.CHIP");
    142     ppImageMosaicFPA(config, options, "PPIMAGE.OUTPUT.FPA1", "PPIMAGE.BIN1");
    143     ppImageMosaicFPA(config, options, "PPIMAGE.OUTPUT.FPA2", "PPIMAGE.BIN2");
     108    if (!ppImageMosaicFPA(config, options, "PPIMAGE.OUTPUT.FPA1", "PPIMAGE.BIN1")) ESCAPE ("failure in FPA Mosaic (level 1)");
     109    if (!ppImageMosaicFPA(config, options, "PPIMAGE.OUTPUT.FPA2", "PPIMAGE.BIN2")) ESCAPE ("failure in FPA Mosaic (level 2)");
    144110
    145111    // we perform astrometry on all chips after sources have been detected
    146112    // this also performs the psastro file IO
    147113    if (options->doAstromChip || options->doAstromMosaic) {
    148         if (!ppImageAstrom(config)) {
    149             psError(PS_ERR_UNKNOWN, false, "error running astrometry.\n");
    150             psFree(view);
    151             return false;
    152         }
     114        if (!ppImageAstrom(config)) ESCAPE ("error running astrometry.");
    153115    }
    154116
     
    158120
    159121    // Write out summary statistics
    160     if (!ppImageMetadataStats (config, options)) {
    161         psError(PS_ERR_UNKNOWN, false, "Unable to write statistics file.\n");
    162         psFree (view);
    163         return false;
    164     }
     122    if (!ppImageMetadataStats (config, options)) ESCAPE ("Unable to write statistics file.");
    165123
    166124    // Write out summary statistics
    167     if (!ppImageStatsOutput (config, options)) {
    168         psError(PS_ERR_UNKNOWN, false, "Unable to write statistics file.\n");
    169         psFree (view);
    170         return false;
    171     }
     125    if (!ppImageStatsOutput (config, options)) ESCAPE ("Unable to write statistics file.");
    172126
    173127    // Output and Close FPA
    174     if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
    175         psFree(view);
    176         return false;
    177     }
     128    if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) ESCAPE ("save failure for FPA");
    178129
    179130    psFree(view);
Note: See TracChangeset for help on using the changeset viewer.