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/ppImagePixelStats.c

    r18556 r19928  
    66
    77// calculate stats, including MD5
    8 bool ppImagePixelStats (pmConfig *config, const ppImageOptions *options, const pmFPAview *inputView) {
    9 
     8bool ppImagePixelStats(pmConfig *config, psMetadata *stats, const ppImageOptions *options,
     9                       const pmFPAview *inputView)
     10{
    1011    bool mdok;              // Status of MD lookup
    1112
     
    1314    pmFPAview *view = pmFPAviewAlloc(0); // View for local processing
    1415    *view = *inputView;
    15    
     16
    1617    // perform the analysis of for this FPA
    1718    pmFPAfile *output = psMetadataLookupPtr(&mdok, config->files, "PPIMAGE.OUTPUT");
    1819    if (!output) {
    19         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find output file (PPIMAGE.OUTPUT).");
    20         psFree (view);
    21         return false;
     20        psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find output file (PPIMAGE.OUTPUT).");
     21        psFree(view);
     22        return false;
    2223    }
    2324
    2425    // select the corresponding chip
    25     pmChip *chip = pmFPAviewThisChip (view, output->fpa);
     26    pmChip *chip = pmFPAviewThisChip(view, output->fpa);
    2627    if (!chip) {
    27         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find requested chip.");
    28         psFree (view);
    29         return false;
     28        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find requested chip.");
     29        psFree(view);
     30        return false;
    3031    }
    31    
     32
    3233    // Perform statistics for this chip
    3334    if (options->doStats) {
     35        if (!ppStatsPixels(stats, output->fpa, view, options->maskValue, config)) {
     36            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to generate stats for image.");
     37            psFree(view);
     38            return false;
     39        }
    3440
    35         // select or create the fpa-level analysis stats metadata (save on PPIMAGE.OUPUT:PPIMAGE.STATS)
    36         psMetadata *stats = psMetadataLookupPtr (&mdok, output->fpa->analysis, "PPIMAGE.STATS");
    37         psMemIncrRefCounter (stats);
    38         if (!stats) {
    39             stats = psMetadataAlloc ();
    40             if (!psMetadataAdd (output->fpa->analysis, PS_LIST_TAIL, "PPIMAGE.STATS", PS_DATA_METADATA, "stats container", stats)) {
    41                 psError(PS_ERR_UNKNOWN, false, "Unable to push stats on fpa.analysis.");
    42                 psFree (view);
    43                 psFree (stats);
    44                 return false;
    45             }
    46         }
     41        // extract the fringe amplitude from the analysis
     42        if (options->doFringe && !ppStatsFringe(stats, chip, "FRINGE", "FRINGE.SOLUTION")) {
     43            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to extract fringe solution for image.");
     44            psFree(view);
     45            return false;
     46        }
    4747
    48         if (!ppStatsPixels(stats, output->fpa, view, options->maskValue, config)) {
    49             psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to generate stats for image.");
    50             psFree (view);
    51             psFree (stats);
    52             return false;
    53         }
    54 
    55         // extract the fringe amplitude from the analysis
    56         if (options->doFringe && !ppStatsFringe(stats, chip, "FRINGE", "FRINGE.SOLUTION")) {
    57             psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to extract fringe solution for image.");
    58             psFree (view);
    59             psFree (stats);
    60             return false;
    61         }
    62 
    63         // extract the fringe residual amplitude from the analysis
    64         if (options->doFringe && !ppStatsFringe(stats, chip, "FRINGE_RESID", "FRINGE.RESIDUAL.SOLUTION")) {
    65             psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to extract fringe solution for image.");
    66             psFree (view);
    67             psFree (stats);
    68             return false;
    69         }
    70        
    71         psFree (stats);
     48        // extract the fringe residual amplitude from the analysis
     49        if (options->doFringe && !ppStatsFringe(stats, chip, "FRINGE_RESID", "FRINGE.RESIDUAL.SOLUTION")) {
     50            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to extract fringe solution for image.");
     51            psFree(view);
     52            return false;
     53        }
    7254    }
    7355
    74     pmCell *cell = NULL;
    75     pmReadout *readout = NULL;
    7656
    7757    view->cell = view->readout = -1;
     58    pmCell *cell = NULL;                // Cell from iteration
    7859    while ((cell = pmFPAviewNextCell(view, output->fpa, 1)) != NULL) {
    79         if (!cell->process || !cell->file_exists) {
    80             continue;
    81         }
     60        if (!cell->process || !cell->file_exists) {
     61            continue;
     62        }
    8263
    83         // Add MD5 information for cell
    84         pmHDU *hdu = pmHDUFromCell(cell); // HDU that owns the cell
    85         while ((readout = pmFPAviewNextReadout(view, output->fpa, 1)) != NULL) {
    86             const char *chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME");
    87             const char *cellName = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME");
     64        // Add MD5 information for cell
     65        pmHDU *hdu = pmHDUFromCell(cell); // HDU that owns the cell
     66        pmReadout *readout = NULL;      // Readout from iteration
     67        while ((readout = pmFPAviewNextReadout(view, output->fpa, 1)) != NULL) {
     68            const char *chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME");
     69            const char *cellName = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME");
    8870
    89             psString headerName = NULL; // Header name for MD5
    90             psStringAppend(&headerName, "MD5_%s_%s_%d", chipName, cellName, view->readout);
     71            psString headerName = NULL; // Header name for MD5
     72            psStringAppend(&headerName, "MD5_%s_%s_%d", chipName, cellName, view->readout);
    9173
    92             psVector *md5 = psImageMD5(readout->image); // md5 hash
    93             psString md5string = psMD5toString(md5); // String
    94             psFree (md5);
    95             psMetadataAddStr(hdu->header, PS_LIST_TAIL, headerName, PS_META_REPLACE,
    96                              "Image MD5", md5string);
    97             psFree (md5string);
    98             psFree (headerName);
    99         }
     74            psVector *md5 = psImageMD5(readout->image); // md5 hash
     75            psString md5string = psMD5toString(md5); // String
     76            psFree(md5);
     77            psMetadataAddStr(hdu->header, PS_LIST_TAIL, headerName, PS_META_REPLACE, "Image MD5", md5string);
     78            psFree(md5string);
     79            psFree(headerName);
     80        }
    10081    }
    10182
Note: See TracChangeset for help on using the changeset viewer.