IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15216


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

clean up error handling on pmFPAfileIO

Location:
trunk
Files:
4 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);
  • trunk/psastro/src/psastroDataLoad.c

    r12806 r15216  
    55// into the correct fpa structure locations (readout.analysis:PSPHOT.SOURCES)
    66
     7# define ESCAPE { \
     8  psError(PS_ERR_UNKNOWN, false, "Failure in psastroDataSave"); \
     9  psFree (view); \
     10  return false; \
     11}
     12 
    713// all of the different astrometry analysis modes use the same data load loop
    814bool psastroDataLoad (pmConfig *config) {
     
    3339
    3440    // files associated with the science image
    35     pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
     41    if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
    3642
    3743    while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) {
    3844        psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
    3945        if (!chip->process || !chip->file_exists) { continue; }
    40         pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
     46        if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
    4147
    4248        while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
    4349            psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    4450            if (!cell->process || !cell->file_exists) { continue; }
    45             pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
     51            if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
    4652
    4753            // process each of the readouts
    4854            while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
    49                 pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
    50                 if (! readout->data_exists) { continue; }
     55                if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
     56                if (!readout->data_exists) { continue; }
    5157
    52                 psastroConvertReadout (readout, recipe);
     58                if (!psastroConvertReadout (readout, recipe)) ESCAPE;
    5359
    54                 pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
     60                if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
    5561            }
    56             pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
     62            if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
    5763        }
    58         pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
     64        if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
    5965    }
    60     pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
     66    if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
     67
    6168    psFree (view);
    6269    return true;
  • trunk/psastro/src/psastroDataSave.c

    r12806 r15216  
    22// XXX leak free 2006.04.27
    33
     4# define ESCAPE { \
     5  psError(PS_ERR_UNKNOWN, false, "Failure in psastroDataSave"); \
     6  psFree (view); \
     7  return false; \
     8}
     9 
    410// this loop saves the photometry/astrometry data files
    511bool psastroDataSave (pmConfig *config) {
     
    3036
    3137    // open/load files as needed
    32     pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
     38    if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
    3339
    3440    while ((chip = pmFPAviewNextChip (view, output->fpa, 1)) != NULL) {
    3541        psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
    3642        if (!chip->process || !chip->file_exists) { continue; }
    37         pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
     43        if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
    3844
    3945        while ((cell = pmFPAviewNextCell (view, output->fpa, 1)) != NULL) {
    4046            psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    4147            if (!cell->process || !cell->file_exists) { continue; }
    42             pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
     48            if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
    4349
    4450            // process each of the readouts
    4551            while ((readout = pmFPAviewNextReadout (view, output->fpa, 1)) != NULL) {
    46                 pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
    47                 if (! readout->data_exists) { continue; }
     52                if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE;
     53                if (!readout->data_exists) { continue; }
    4854
    49                 pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
     55                if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
    5056            }
    51             pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
     57            if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
    5258        }
    53         pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
     59        if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
    5460    }
    55     pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
     61    if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE;
    5662
    5763    // activate all files except PSASTRO.OUTPUT
    58     pmFPAfileActivate (config->files, true, NULL);
    59     pmFPAfileActivate (config->files, false, "PSASTRO.OUTPUT");
     64    if (!pmFPAfileActivate (config->files, true, NULL)) ESCAPE;
     65    if (!pmFPAfileActivate (config->files, false, "PSASTRO.OUTPUT")) ESCAPE;
    6066
    6167    psFree (view);
  • trunk/psphot/src/psphotImageLoop.c

    r12805 r15216  
    11# include "psphotStandAlone.h"
     2
     3# define ESCAPE(MESSAGE) { \
     4  psError(PSPHOT_ERR_DATA, false, MESSAGE); \
     5  psFree (view); \
     6  return false; \
     7}
    28
    39bool psphotImageLoop (pmConfig *config) {
     
    2228   
    2329    // files associated with the science image
    24     if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
    25         psError(PSPHOT_ERR_DATA, false, "failed IO for fpa in psphot\n");
    26         psFree(view);
    27         return false;
    28     }
     30    if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE ("failed input for fpa in psphot.");
    2931
    3032    // for psphot, we force data to be read at the chip level
     
    3840        pmFPAfileActivate (config->files, true, "PSPHOT.MASK");
    3941        pmFPAfileActivate (config->files, true, "PSPHOT.WEIGHT");
    40         if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
    41             psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in psphot\n", view->chip);
    42             psFree (view);
    43             return false;
    44         }
     42        if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE ("failed input for Chip in psphot.");
    4543
    4644        // mosaic the cells of a chip into a single contiguous (trimmed) chip
    47         if (!psphotMosaicChip(config, view, "PSPHOT.INPUT", "PSPHOT.LOAD")) {
    48             psError(PS_ERR_UNKNOWN, false, "Unable to mosaic chip.\n");
    49             return false;
    50         }
     45        if (!psphotMosaicChip(config, view, "PSPHOT.INPUT", "PSPHOT.LOAD")) ESCAPE ("Unable to mosaic chip.");
    5146
    5247        // try to load other supporting data (PSF, SRC, etc).
     
    5651        pmFPAfileActivate (config->files, false, "PSPHOT.MASK");
    5752        pmFPAfileActivate (config->files, false, "PSPHOT.WEIGHT");
    58         if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
    59             psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in psphot\n", view->chip);
    60             psFree (view);
    61             return false;
    62         }
     53        if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE ("failed input for Chip in psphot.");
     54
    6355        // re-activate files so they will be closed and freed below
    6456        pmFPAfileActivate (config->files, true, NULL);
     
    8375
    8476        // save output which is saved at the chip level
    85         if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
    86             psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in psphot\n", view->chip);
    87             psFree (view);
    88             return false;
    89         }
     77        if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE ("failed output for Chip in psphot.");
    9078    }
    9179    // save output which is saved at the fpa level
    92     if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
    93         psError(PSPHOT_ERR_DATA, false, "failed IO for fpa in psphot\n");
    94         psFree (view);
    95         return false;
    96     }
     80    if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE ("failed ouput for FPA in psphot.");
     81
     82    // fail if we failed to handle an error
     83    if (psErrorCodeLast() != PS_ERR_NONE) psAbort ("failed to handle an error!");
    9784
    9885    psFree (view);
    99 
    100     // fail if we failed to handle an error
    101     if (psErrorCodeLast() != PS_ERR_NONE) return false;
    10286    return true;
    10387}
Note: See TracChangeset for help on using the changeset viewer.