IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27160


Ignore:
Timestamp:
Mar 3, 2010, 1:54:33 PM (16 years ago)
Author:
Paul Price
Message:

Reorganise so that statistics file gets written out even when we don't make it to the bottom of ppStackLoop().

Location:
trunk/ppStack/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack/src/ppStack.c

    r27135 r27160  
    2424
    2525    pmConfig *config = pmConfigRead(&argc, argv, PPSTACK_RECIPE); // Configuration
     26    ppStackOptions *options = NULL;                               // Options for stacking
    2627    if (!config) {
    2728        goto die;
     
    5455    }
    5556
    56     if (!ppStackLoop(config)) {
     57    options = ppStackOptionsAlloc();
     58    if (!ppStackLoop(config, options)) {
    5759        goto die;
    5860    }
     
    7678            }
    7779        }
     80
     81        // Write out summary statistics
     82        if (options && options->stats) {
     83
     84            psMetadataAddS32(options->stats, PS_LIST_TAIL, "QUALITY", PS_META_REPLACE,
     85                             "Bad data quality flag", options->quality);
     86            psMetadataAddF32(options->stats, PS_LIST_TAIL, "TIME_STACK", 0,
     87                             "Total time", psTimerClear("PPSTACK_TOTAL"));
     88
     89            const char *statsMDC = psMetadataConfigFormat(options->stats);
     90            if (!statsMDC || strlen(statsMDC) == 0) {
     91                psError(PS_ERR_IO, false, "Unable to get statistics MDC file.");
     92                return false;
     93            }
     94            if (fprintf(options->statsFile, "%s", statsMDC) != strlen(statsMDC)) {
     95                psError(PS_ERR_IO, false, "Unable to write statistics MDC file.");
     96                return false;
     97            }
     98            psFree(statsMDC);
     99            if (fclose(options->statsFile) == EOF) {
     100                psError(PS_ERR_IO, false, "Unable to close statistics MDC file.");
     101                return false;
     102            }
     103            options->statsFile = NULL;
     104            pmConfigRunFilenameAddWrite(config, "STATS",
     105                                        psMetadataLookupStr(NULL, config->arguments, "STATS"));
     106        }
     107        psFree(options);
    78108
    79109        // Dump configuration
  • trunk/ppStack/src/ppStackFinish.c

    r27158 r27160  
    6868    psFree(options->outRO); options->outRO = NULL;
    6969
    70     // Write out summary statistics
    71     if (options->stats) {
    72 
    73         psMetadataAddS32(options->stats, PS_LIST_TAIL, "QUALITY", PS_META_REPLACE,
    74                          "Bad data quality flag", options->quality);
    75         psMetadataAddF32(options->stats, PS_LIST_TAIL, "TIME_STACK", 0,
    76                          "Total time", psTimerClear("PPSTACK_TOTAL"));
    77 
    78         const char *statsMDC = psMetadataConfigFormat(options->stats);
    79         if (!statsMDC || strlen(statsMDC) == 0) {
    80             psError(PS_ERR_IO, false, "Unable to get statistics MDC file.");
    81             return false;
    82         }
    83         if (fprintf(options->statsFile, "%s", statsMDC) != strlen(statsMDC)) {
    84             psError(PS_ERR_IO, false, "Unable to write statistics MDC file.");
    85             return false;
    86         }
    87         psFree(statsMDC);
    88         if (fclose(options->statsFile) == EOF) {
    89             psError(PS_ERR_IO, false, "Unable to close statistics MDC file.");
    90             return false;
    91         }
    92         options->statsFile = NULL;
    93         pmConfigRunFilenameAddWrite(config, "STATS", psMetadataLookupStr(NULL, config->arguments, "STATS"));
    94     }
    95 
    9670    return true;
    9771}
  • trunk/ppStack/src/ppStackLoop.c

    r27158 r27160  
    5050
    5151
    52 bool ppStackLoop(pmConfig *config)
     52bool ppStackLoop(pmConfig *config, ppStackOptions *options)
    5353{
    5454    assert(config);
     
    5656    psTimerStart("PPSTACK_TOTAL");
    5757    psTimerStart("PPSTACK_STEPS");
    58 
    59     ppStackOptions *options = ppStackOptionsAlloc(); // Options for stacking
    6058
    6159    // Setup
     
    222220        return false;
    223221    }
    224     psLogMsg("ppStack", PS_LOG_INFO, "Stage 9: Final output: %f sec", psTimerClear("PPSTACK_STEPS"));
    225222    ppStackMemDump("finish");
    226223
  • trunk/ppStack/src/ppStackLoop.h

    r26076 r27160  
    1111// Loop over the inputs, doing the combination
    1212bool ppStackLoop(
    13     pmConfig *config                    // Configuration
     13    pmConfig *config,                    // Configuration
     14    ppStackOptions *options             // Options for stacking
    1415    );
    1516
Note: See TracChangeset for help on using the changeset viewer.