IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30066


Ignore:
Timestamp:
Dec 16, 2010, 12:03:55 PM (15 years ago)
Author:
bills
Message:

make sure that internal files are dropped in case of error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSub/src/ppSubLoop.c

    r30040 r30066  
    3636    psAssert(config, "Require configuration.");
    3737
     38    bool success = true;
     39
    3840    pmConfigCamerasCull(config, NULL);
    3941    pmConfigRecipesCull(config, "PPSUB,PPSTATS,PSPHOT,PSASTRO,MASKS,JPEG");
     
    6163        if (!ppSubInputDetections(&foundDetections, "PPSUB.POS1.SOURCES", "PPSUB.INPUT", data)) {
    6264            psError(psErrorCodeLast(), false, "Unable to measure positive detections (1)");
    63             return false;
     65            success = false;
     66            goto ESCAPE;
    6467        }
    6568        // if nothing was found, don't bother doing the forced photometry below
     
    9093            psMetadataAddF32(recipe, PS_LIST_TAIL, "PEAKS_NSIGMA_LIMIT", PS_META_REPLACE, "", nsigma_peak_save);
    9194            psMetadataAddStr(recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_REPLACE, "", breakPt_save);
    92             return false;
     95            success = false;
     96            goto ESCAPE;
    9397        }
    9498        psMetadataAddF32(recipe, PS_LIST_TAIL, "PEAKS_NSIGMA_LIMIT", PS_META_REPLACE, "", nsigma_peak_save);
     
    101105    }
    102106
    103     // XXX if it exists, use the POS1, POS2 results for the FWHMs
     107    // XXX if it exists, use the POS1, POS2 successs for the FWHMs
    104108    if (!ppSubMatchPSFs(data)) {
    105109        psError(psErrorCodeLast(), false, "Unable to match PSFs.");
    106         return false;
     110        success = false;
     111        goto ESCAPE;
    107112    }
    108113    if (data->quality) {
    109114        // Can't do anything at all
    110         return true;
     115        success = false;
     116        goto ESCAPE;
    111117    }
    112118    // generate the residual stamp grid for visualization
    113119    if (!ppSubResidualSampleJpeg(config)) {
    114120        psError(psErrorCodeLast(), false, "Unable to update.");
    115         return false;
     121        success = false;
     122        goto ESCAPE;
    116123    }
    117124
     
    125132    if (!ppSubFilesIterateUp(config, PPSUB_FILES_INPUT)) {
    126133        psError(PPSUB_ERR_IO, false, "Unable to close input files.");
    127         return false;
     134        success = false;
     135        goto ESCAPE;
    128136    }
    129137
    130138    if (!ppSubLowThreshold(data)) {
    131139        psError(psErrorCodeLast(), false, "Unable to threshold images.");
    132         return false;
     140        success = false;
     141        goto ESCAPE;
    133142    }
    134143
     
    136145    if (!ppSubFilesIterateDown(config, PPSUB_FILES_SUB)) {
    137146        psError(PPSUB_ERR_IO, false, "Unable to set up subtraction files.");
    138         return false;
     147        success = false;
     148        goto ESCAPE;
    139149    }
    140150
    141151    if (!ppSubDefineOutput("PPSUB.OUTPUT", config)) {
    142152        psError(psErrorCodeLast(), false, "Unable to define output.");
    143         return false;
     153        success = false;
     154        goto ESCAPE;
    144155    }
    145156
    146157    if (!data->quality && !ppSubMakePSF(data)) {
    147158        psError(psErrorCodeLast(), false, "Unable to generate PSF.");
    148         return false;
     159        success = false;
     160        goto ESCAPE;
    149161    }
    150162
     
    161173    if (!ppSubReadoutSubtract(config)) {
    162174        psError(psErrorCodeLast(), false, "Unable to subtract images.");
    163         return false;
     175        success = false;
     176        goto ESCAPE;
    164177    }
    165178    // dumpout(config, "diff.1.fits");
     
    168181    if (!ppSubFilesIterateUp(config, PPSUB_FILES_PSF | PPSUB_FILES_CONV)) {
    169182        psError(PPSUB_ERR_IO, false, "Unable to close input files.");
    170         return false;
     183        success = false;
     184        goto ESCAPE;
    171185    }
    172186    // dumpout(config, "diff.2a.fits");
     
    175189    if (!ppSubBackground(config)) {
    176190        psError(psErrorCodeLast(), false, "Unable to subtract background.");
    177         return false;
     191        success = false;
     192        goto ESCAPE;
    178193    }
    179194    // dumpout(config, "diff.2b.fits");
     
    182197    if (!ppSubVarianceRescale(config, data)) {
    183198        psError(psErrorCodeLast(), false, "Unable to rescale variance.");
    184         return false;
     199        success = false;
     200        goto ESCAPE;
    185201    }
    186202    // dumpout(config, "diff.2c.fits");
     
    188204    if (data->quality) {
    189205        // Done all we can do up to this point
    190         return true;
     206        success = false;
     207        goto ESCAPE;
    191208    }
    192209
    193210    if (!ppSubFilesIterateDown(config, PPSUB_FILES_PHOT_SUB)) {
    194211        psError(PPSUB_ERR_IO, false, "Unable to set up photometry files.");
    195         return false;
     212        success = false;
     213        goto ESCAPE;
    196214    }
    197215
    198216    if (!data->quality && !ppSubReadoutPhotometry("PPSUB.OUTPUT", data)) {
    199217        psError(psErrorCodeLast(), false, "Unable to perform photometry.");
    200         return false;
     218        success = false;
     219        goto ESCAPE;
    201220    }
    202221    // dumpout(config, "diff.3.fits");
     
    206225        if (!ppSubReadoutForcedPhot("PPSUB.FORCED1.SOURCES", "PPSUB.OUTPUT", "PPSUB.POS1.SOURCES", data)) {
    207226            psError(psErrorCodeLast(), false, "Unable to perform photometry.");
    208             return false;
     227            success = false;
     228            goto ESCAPE;
    209229        }
    210230    }
     
    214234        if (!ppSubReadoutForcedPhot("PPSUB.FORCED2.SOURCES", "PPSUB.OUTPUT", "PPSUB.POS2.SOURCES", data)) {
    215235            psError(psErrorCodeLast(), false, "Unable to perform photometry.");
    216             return false;
     236            success = false;
     237            goto ESCAPE;
    217238        }
    218239    }
     
    220241    if (!ppSubFilesIterateUp(config, PPSUB_FILES_PHOT_SUB)) {
    221242        psError(PPSUB_ERR_IO, false, "Unable to set up photometry files.");
    222         return false;
     243        success = false;
     244        goto ESCAPE;
    223245    }
    224246
     
    226248    if (!ppSubReadoutStats(data)) {
    227249        psError(psErrorCodeLast(), false, "Unable to collect statistics");
    228         return false;
     250        success = false;
     251        goto ESCAPE;
    229252    }
    230253    // Do Mask Stats
     
    233256      if (!ppSubMaskStats(config, view,data->stats)) {
    234257        psError(psErrorCodeLast(), false, "Unable to generate mask statistics");
    235         return(false);
     258        success = false;
     259        goto ESCAPE;
    236260      }
    237261    }
     
    241265    if (!ppSubReadoutJpeg(config)) {
    242266        psError(psErrorCodeLast(), false, "Unable to update.");
    243         return false;
     267        success = false;
     268        goto ESCAPE;
    244269    }
    245270
     
    248273        if (!ppSubFilesIterateDown(config, PPSUB_FILES_INV)) {
    249274            psError(PPSUB_ERR_IO, false, "Unable to set up inverse files.");
    250             return false;
     275            success = false;
     276            goto ESCAPE;
    251277        }
    252278
    253279        if (data->inverse && !ppSubDefineOutput("PPSUB.INVERSE", config)) {
    254280            psError(psErrorCodeLast(), false, "Unable to define inverse.");
    255             return false;
     281            success = false;
     282            goto ESCAPE;
    256283        }
    257284
    258285        if (!ppSubReadoutInverse(config)) {
    259286            psError(psErrorCodeLast(), false, "Unable to invert images.");
    260             return false;
     287            success = false;
     288            goto ESCAPE;
    261289        }
    262290
     
    264292        if (!ppSubFilesIterateUp(config, PPSUB_FILES_SUB)) {
    265293            psError(PPSUB_ERR_IO, false, "Unable to close subtraction files.");
    266             return false;
     294            success = false;
     295            goto ESCAPE;
    267296        }
    268297
    269298        if (!ppSubFilesIterateDown(config, PPSUB_FILES_PHOT_INV)) {
    270299            psError(PPSUB_ERR_IO, false, "Unable to set up inverse files.");
    271             return false;
     300            success = false;
     301            goto ESCAPE;
    272302        }
    273303
    274304        if (!data->quality && !ppSubReadoutPhotometry("PPSUB.INVERSE", data)) {
    275305            psError(psErrorCodeLast(), false, "Unable to perform photometry.");
    276             return false;
     306            success = false;
     307            goto ESCAPE;
    277308        }
    278309
     
    280311        if (!ppSubFilesIterateUp(config, PPSUB_FILES_INV | PPSUB_FILES_PHOT_INV)) {
    281312            psError(PPSUB_ERR_IO, false, "Unable to close subtraction files.");
    282             return false;
     313            success = false;
     314            goto ESCAPE;
    283315        }
    284316    } else {
     
    287319        if (!ppSubFilesIterateUp(config, PPSUB_FILES_SUB)) {
    288320            psError(PPSUB_ERR_IO, false, "Unable to close subtraction files.");
    289             return false;
    290         }
    291     }
    292 
     321            success = false;
     322            goto ESCAPE;
     323        }
     324    }
     325
     326ESCAPE:
    293327    pmFPAfileDropInternal(config->files, "PSPHOT.BACKGND");
    294328    pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL");
    295329    pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL.STDEV");
    296330
    297     return true;
     331    return success;
    298332}
Note: See TracChangeset for help on using the changeset viewer.