IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13837


Ignore:
Timestamp:
Jun 14, 2007, 2:47:06 PM (19 years ago)
Author:
eugene
Message:

catch errors from psphot, psastro; fix mem leaks

File:
1 edited

Legend:

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

    r13830 r13837  
    4242    // files associated with the science image
    4343    if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
     44        psFree (view);
    4445        return false;
    4546    }
     
    5253
    5354        if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
     55            psFree (view);
    5456            return false;
    5557        }
     
    6163            }
    6264            if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
     65                psFree (view);
    6366                return false;
    6467            }
     
    7578            while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
    7679                if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
     80                    psFree (view);
    7781                    return false;
    7882                }
     
    8488                if (!ppImageDetrendReadout(config, options, view)) {
    8589                    psError(PS_ERR_UNKNOWN, false, "Unable to detrend readout.\n");
     90                    psFree (view);
    8691                    return false;
    8792                }
     
    9499            pmChip *fringe = pmFPAfileThisChip(config->files, view, "PPIMAGE.FRINGE");
    95100            if (!ppImageDetrendFringeSolve(chip, fringe, options)) {
     101                psFree (view);
    96102                return false;
    97103            }
     
    110116                pmCell *fringeCell = pmFPAfileThisCell(config->files, view, "PPIMAGE.FRINGE");
    111117                if (!ppImageDetrendFringeGenerate(cell, fringeCell)) {
     118                    psFree (view);
    112119                    return false;
    113120                }
     
    120127                if (!mdok || !output) {
    121128                    psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find file PPIMAGE.OUTPUT.\n");
     129                    psFree (view);
    122130                    return false;
    123131                }
    124132
    125133                if (!ppStats(stats,
    126                             output->fpa,
    127                             view,
    128                             options->satMask | options->badMask | options->maskValue,
    129                             config)) {
     134                             output->fpa,
     135                             view,
     136                             options->satMask | options->badMask | options->maskValue,
     137                             config)) {
    130138                    psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to generate stats for image.\n");
    131139                    psFree (stats);
     140                    psFree (view);
    132141                    return false;
    133142                }
     
    151160                psFree(headerName);
    152161            }
    153 
    154 #if 0
    155             if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
    156                 return false;
    157             }
    158 #endif
    159 
    160162        }
    161163
    162164        if (!ppImageMosaicChip(config, view, "PPIMAGE.OUTPUT.CHIP", "PPIMAGE.OUTPUT")) {
    163165            psError(PS_ERR_UNKNOWN, false, "Unable to mosaic chip.\n");
     166            psFree (view);
    164167            return false;
    165168        }
    166169        if (!ppImageRebinChip(config, view, "PPIMAGE.BIN1")) {
    167170            psError(PS_ERR_UNKNOWN, false, "Unable to bin chip.\n");
     171            psFree (view);
    168172            return false;
    169173        }
    170174        if (!ppImageRebinChip(config, view, "PPIMAGE.BIN2")) {
    171175            psError(PS_ERR_UNKNOWN, false, "Unable to bin chip.\n");
     176            psFree (view);
    172177            return false;
    173178        }
     
    175180        // we perform photometry on the readouts of this chip in the output
    176181        if (options->doPhotom) {
    177             ppImagePhotom(config, view);
     182            if (!ppImagePhotom(config, view)) {
     183                psError(PS_ERR_UNKNOWN, false, "error running photometry.\n");
     184                psFree (view);
     185                return false;
     186            }
    178187        }
    179188
     
    186195
    187196            if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
     197                psFree(view);
    188198                return false;
    189199            }
     
    192202        // Close chip
    193203        if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
     204            psFree(view);
    194205            return false;
    195206        }
     
    198209    // Write out summary statistics
    199210    if (stats) {
    200         const char *statsMDC = psMetadataConfigFormat(stats);
     211        char *statsMDC = psMetadataConfigFormat(stats);
    201212        if (!statsMDC || strlen(statsMDC) == 0) {
    202213            psError(PS_ERR_IO, false, "Unable to get statistics MDC file.\n");
     
    204215            fprintf(statsFile, "%s", statsMDC);
    205216        }
    206         psFree((void *)statsMDC);
     217        psFree(statsMDC);
    207218        fclose(statsFile);
    208219        psFree(stats);
     
    217228    // we perform astrometry on all chips after sources have been detected
    218229    if (options->doAstromChip || options->doAstromMosaic) {
    219         ppImageAstrom(config);
    220     }
    221     // XXX should we keep the addstar command as an option, or just run it externally?
    222     // XXX if we included direct Ohana/DVO API calls, we could send the data from within ppImage.
    223 # if (0)   
    224     if (options->doAddstar) {
    225         ppImageAddstar(config);
    226     }
    227 # endif
    228 
     230        if (!ppImageAstrom(config)) {
     231            psError(PS_ERR_UNKNOWN, false, "error running astrometry.\n");
     232            psFree(view);
     233            return false;
     234        }
     235    }
     236
     237    // Close FPA
    229238    if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
     239        psFree(view);
    230240        return false;
    231241    }
    232242
    233243    psFree(view);
    234 
    235244    return true;
    236245}
Note: See TracChangeset for help on using the changeset viewer.