IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 6, 2008, 12:24:10 PM (18 years ago)
Author:
Paul Price
Message:

Don't put statistics on an FPA: too troublesome to get to, and it's ok to just carry around a psMetadata in ppImageLoop, passing it to functions that need it. Updated times for output statistics.

File:
1 edited

Legend:

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

    r19399 r19928  
    55#include "ppImage.h"
    66
    7 # define ESCAPE(MESSAGE) { \
     7#define ESCAPE(MESSAGE) { \
    88  psError(PS_ERR_UNKNOWN, false, MESSAGE); \
    9   psFree (view); \
     9  psFree(view); \
    1010  return false; \
    1111}
    1212
    13 bool ppImageLoop (pmConfig *config, ppImageOptions *options)
     13bool ppImageLoop(pmConfig *config, ppImageOptions *options)
    1414{
    15     bool status;
    16     pmChip *chip;
    17     pmCell *cell;
    18     pmReadout *readout;
    19 
    20     // measure the total elapsed time in ppImageLoop.
    21     psTimerStart ("ppImageLoop");
    22 
     15    psMetadata *stats = options->doStats ? psMetadataAlloc() : NULL; // Statistics to output
     16    float timeDetrend = 0;              // Amount of time spent in detrend
     17    float timePhot = 0;                 // Amount of time spent in photometry
     18
     19    bool status;                        // Status of MD lookup
    2320    pmFPAfile *input = psMetadataLookupPtr(&status, config->files, "PPIMAGE.INPUT");
    2421    if (!status) {
     
    4037
    4138    // files associated with the science image
    42     if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) ESCAPE ("load failure for FPA");
    43 
     39    if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
     40        ESCAPE("load failure for FPA");
     41    }
     42
     43    pmChip *chip;                       // Chip from FPA
    4444    while ((chip = pmFPAviewNextChip(view, input->fpa, 1)) != NULL) {
    4545        psLogMsg ("ppImageLoop", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
     
    4747            continue;
    4848        }
    49         if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) ESCAPE ("load failure for Chip");
    50 
     49        if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
     50            ESCAPE("load failure for Chip");
     51        }
     52
     53        psTimerStart(TIMER_DETREND);
     54        pmCell *cell;                   // Cell from chip
    5155        while ((cell = pmFPAviewNextCell(view, input->fpa, 1)) != NULL) {
    5256            psLogMsg ("ppImageLoop", 5, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
     
    5458                continue;
    5559            }
    56             if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) ESCAPE ("load failure for Cell");
     60            if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
     61                ESCAPE("load failure for Cell");
     62            }
    5763
    5864            // Put version information into the header
     
    7076
    7177            // process each of the readouts
     78            pmReadout *readout;         // Readout from cell
    7279            while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
    73                 if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) ESCAPE ("load failure for Readout");
     80                if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
     81                    ESCAPE("load failure for Readout");
     82                }
    7483                if (!readout->data_exists) {
    7584                    continue;
     
    7887                // XXX set the options->*Mask values here (after the mask images have been loaded
    7988                // and before any of the value are used)
    80                 if (!ppImageSetMaskBits (config, options))
    81                     ESCAPE ("Unable to set bit masks");
     89                if (!ppImageSetMaskBits(config, options)) {
     90                    ESCAPE("Unable to set bit masks");
     91                }
    8292
    8393                // perform the detrend analysis
    84                 if (!ppImageDetrendReadout(config, options, view))
    85                     ESCAPE ("Unable to detrend readout");
     94                if (!ppImageDetrendReadout(config, options, view)) {
     95                    ESCAPE("Unable to detrend readout");
     96                }
    8697            }
    8798        }
     
    89100        // Apply the fringe correction
    90101        if (options->doFringe) {
    91             if (!ppImageDetrendFringeApply (config, chip, view, options))
    92                 ESCAPE ("Unable to defringe");
     102            if (!ppImageDetrendFringeApply(config, chip, view, options)) {
     103                ESCAPE("Unable to defringe");
     104            }
    93105        }
    94106
    95107        // measure various statistics for this image
    96         if (!ppImagePixelStats (config, options, view))
    97             ESCAPE ("Unable to measures stats for image");
    98 
    99         if (!ppImageMosaicChip(config, options, view, "PPIMAGE.CHIP", "PPIMAGE.OUTPUT"))
    100             ESCAPE ("Unable to mosaic chip");
     108        if (!ppImagePixelStats(config, stats, options, view)) {
     109            ESCAPE("Unable to measures stats for image");
     110        }
     111        if (!ppImageMosaicChip(config, options, view, "PPIMAGE.CHIP", "PPIMAGE.OUTPUT")) {
     112            ESCAPE("Unable to mosaic chip");
     113        }
     114        timeDetrend += psTimerClear(TIMER_DETREND);
     115
    101116
    102117        // we perform photometry on the readouts of this chip in the output
     118        psTimerStart(TIMER_PHOT);
    103119        if (options->doPhotom) {
    104             if (!ppImagePhotom(config, view)) ESCAPE ("error running photometry.");
    105         }
     120            if (!ppImagePhotom(config, view)) {
     121                ESCAPE("error running photometry.");
     122            }
     123        }
     124        timePhot += psTimerClear(TIMER_PHOT);
    106125
    107126        // replace the masked pixels with the background level
    108127        if (options->replaceMasked) {
    109             if (!ppImageReplaceBackground (config, view, options))
    110                 ESCAPE ("Unable to replace masked pixels with background level");
     128            if (!ppImageReplaceBackground(config, view, options)) {
     129                ESCAPE("Unable to replace masked pixels with background level");
     130            }
    111131        }
    112132
    113133        // binning (used for display) must take place after the background is replaced, if desired
    114         if (!ppImageRebinChip(config, view, options, "PPIMAGE.BIN1"))
    115             ESCAPE ("Unable to bin chip (level 1).");
    116 
    117         if (!ppImageRebinChip(config, view, options, "PPIMAGE.BIN2"))
    118             ESCAPE ("Unable to bin chip (level 2).");
     134        if (!ppImageRebinChip(config, view, options, "PPIMAGE.BIN1")) {
     135            ESCAPE("Unable to bin chip (level 1).");
     136        }
     137        if (!ppImageRebinChip(config, view, options, "PPIMAGE.BIN2")) {
     138            ESCAPE("Unable to bin chip (level 2).");
     139        }
    119140
    120141        // Close cells (XXX shouldn't pmFPAfileClose iterate down as needed?)
     
    124145                continue;
    125146            }
    126             if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) ESCAPE ("save failure for Cell");
     147            if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
     148                ESCAPE("save failure for Cell");
     149            }
    127150        }
    128151
    129152        // Close chip
    130         if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) ESCAPE ("save failure for Chip");
     153        if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
     154            ESCAPE("save failure for Chip");
     155        }
    131156    }
    132157
    133158    // generate the full-scale FPA mosaic
    134     if (!ppImageMosaicFPA(config, options, "PPIMAGE.OUTPUT.FPA1", "PPIMAGE.BIN1")) ESCAPE ("failure in FPA Mosaic (level 1)");
    135     if (!ppImageMosaicFPA(config, options, "PPIMAGE.OUTPUT.FPA2", "PPIMAGE.BIN2")) ESCAPE ("failure in FPA Mosaic (level 2)");
     159    if (!ppImageMosaicFPA(config, options, "PPIMAGE.OUTPUT.FPA1", "PPIMAGE.BIN1")) {
     160        ESCAPE("failure in FPA Mosaic (level 1)");
     161    }
     162    if (!ppImageMosaicFPA(config, options, "PPIMAGE.OUTPUT.FPA2", "PPIMAGE.BIN2")) {
     163        ESCAPE("failure in FPA Mosaic (level 2)");
     164    }
    136165
    137166    // we perform astrometry on all chips after sources have been detected
    138167    // this also performs the psastro file IO
    139168    if (options->doAstromChip || options->doAstromMosaic) {
    140         if (!ppImageAstrom(config)) ESCAPE ("error running astrometry.");
     169        if (!ppImageAstrom(config)) {
     170            ESCAPE("error running astrometry.");
     171        }
    141172    }
    142173
    143174    if (psTraceGetLevel("ppImage") >= 3) {
    144         ppImageFileCheck (config);
     175        ppImageFileCheck(config);
    145176    }
    146177
    147178    // Write out summary statistics
    148     if (!ppImageMetadataStats (config, options)) ESCAPE ("Unable to write statistics file.");
     179    if (!ppImageMetadataStats(config, stats, options)) {
     180        ESCAPE("Unable to write statistics file.");
     181    }
     182
     183    // Output and Close FPA
     184    if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
     185        ESCAPE("save failure for FPA");
     186    }
     187
     188    psFree(view);
    149189
    150190    // Write out summary statistics
    151     if (!ppImageStatsOutput (config, options)) ESCAPE ("Unable to write statistics file.");
    152 
    153     // Output and Close FPA
    154     if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) ESCAPE ("save failure for FPA");
    155 
    156     psFree(view);
     191    if (options->doStats) {
     192        psMetadataAddF32(stats, PS_LIST_TAIL, "DT_DET", 0, "Time spent detrending (sec)", timeDetrend);
     193        psMetadataAddF32(stats, PS_LIST_TAIL, "DT_PHOT", 0, "Time spent photometering (sec)", timePhot);
     194        psMetadataAddF32(stats, PS_LIST_TAIL, "DT_TOTAL", 0, "Total time (sec)", psTimerMark(TIMER_TOTAL));
     195        if (!ppImageStatsOutput(config, stats, options)) {
     196            ESCAPE("Unable to write statistics file.");
     197        }
     198    }
     199
    157200    return true;
    158201}
Note: See TracChangeset for help on using the changeset viewer.