IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 14, 2006, 7:14:30 PM (20 years ago)
Author:
Paul Price
Message:

Incorporating ppStats into ppImage.

File:
1 edited

Legend:

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

    r7771 r8348  
    1 # include "ppImage.h"
     1#include <ppStats.h>
     2#include "ppImage.h"
    23
    34bool ppImageLoop (pmConfig *config, ppImageOptions *options) {
     
    89    pmReadout *readout;
    910
     11    bool mdok;                      // Status of MD lookup
     12    psMetadata *extraOpts = psMetadataLookupMD(&mdok, config->arguments, "PPIMAGE.OPTIONS"); // Extra options
     13    const char *statsName = psMetadataLookupStr(&mdok, extraOpts, "STATS"); // Filename for statistics
     14    psMetadata *stats = NULL;           // Container for statistics
     15    FILE *statsFile = NULL;             // File stream for statistics
     16    if (mdok && statsName && strlen(statsName) > 0) {
     17        statsFile = fopen(statsName, "w");
     18        if (!statsFile) {
     19            psError(PS_ERR_IO, true, "Unable to open statistics file %s for writing.\n", statsName);
     20        } else {
     21            stats = psMetadataAlloc();
     22        }
     23    }
     24
    1025    pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PPIMAGE.INPUT");
    1126    if (!status) {
    12         psErrorStackPrint(stderr, "Can't find input data!\n");
    13         exit(EXIT_FAILURE);
     27        psErrorStackPrint(stderr, "Can't find input data!\n");
     28        exit(EXIT_FAILURE);
    1429    }
    1530
     
    2338        if (!chip->process || !chip->file_exists) { continue; }
    2439
    25         if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) return false;
     40        if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) return false;
    2641
    27         while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
     42        while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
    2843            psLogMsg ("ppImageLoop", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    2944            if (!cell->process || !cell->file_exists) { continue; }
    30             if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) return false;
     45            if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) return false;
    3146
    32             // process each of the readouts
    33             while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
    34                 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) return false;
    35                 if (!readout->data_exists) { continue; }
     47            // process each of the readouts
     48            while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
     49                if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) return false;
     50                if (!readout->data_exists) { continue; }
    3651
    37                 // perform the detrend analysis
    38                 if (!ppImageDetrendReadout (config, options, view)) return false;
    39                
    40                 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) return false;
    41             }
    42             if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) return false;
    43         }
     52                // perform the detrend analysis
     53                if (!ppImageDetrendReadout (config, options, view)) return false;
    4454
    45         ppImageMosaicChip (config, view, "PPIMAGE.OUTPUT.CHIP", "PPIMAGE.OUTPUT");
    46         ppImageRebinChip (config, view, "PPIMAGE.BIN1", "PPIMAGE.OUTPUT.CHIP");
    47         ppImageRebinChip (config, view, "PPIMAGE.BIN2", "PPIMAGE.OUTPUT.CHIP");
     55                if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) return false;
     56            }
    4857
    49         // we perform photometry on the readouts of this chip in the output
    50         if (options->doPhotom) ppImagePhotom (config, view);
     58            // Perform statistics on the detrended cell
     59            if (stats) {
     60                ppStats(stats, input->fpa, view, config);
     61            }
    5162
    52         if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) return false;
     63            if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) return false;
     64        }
     65
     66        ppImageMosaicChip (config, view, "PPIMAGE.OUTPUT.CHIP", "PPIMAGE.OUTPUT");
     67        ppImageRebinChip (config, view, "PPIMAGE.BIN1", "PPIMAGE.OUTPUT.CHIP");
     68        ppImageRebinChip (config, view, "PPIMAGE.BIN2", "PPIMAGE.OUTPUT.CHIP");
     69
     70        // we perform photometry on the readouts of this chip in the output
     71        if (options->doPhotom) ppImagePhotom (config, view);
     72
     73        if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) return false;
     74    }
     75
     76    // Write out summary statistics
     77    if (stats) {
     78        const char *statsMDC = psMetadataConfigFormat(stats);
     79        if (!statsMDC || strlen(statsMDC) == 0) {
     80            psError(PS_ERR_IO, false, "Unable to get statistics MDC file.\n");
     81        } else {
     82            fprintf(statsFile, "%s", statsMDC);
     83        }
     84        psFree(statsMDC);
     85        fclose(statsFile);
     86
     87        psFree(stats);
    5388    }
    5489
Note: See TracChangeset for help on using the changeset viewer.