IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 30, 2007, 6:24:33 PM (19 years ago)
Author:
Paul Price
Message:

Adding statistics generation and MD5 checksums for output. Replaced lots of configure.ac code with the IPP macros. Used to be building a library (why???), which has been removed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pswarp/src/pswarpDataSave.c

    r12771 r13104  
    1 # include "pswarp.h"
     1#include <ppStats.h>
     2#include "pswarp.h"
    23
    34// this loop loads the data from the input files and selects the
     
    78
    89// all of the different astrometry analysis modes use the same data load loop
    9 bool pswarpDataSave (pmConfig *config) {
     10bool pswarpDataSave(pmConfig *config) {
    1011
    1112    pmChip *chip;
     
    1819        psError(PSWARP_ERR_CONFIG, true, "Can't find input data!\n");
    1920        return false;
     21    }
     22
     23    bool mdok;                          // Status of MD lookup
     24    const char *statsName = psMetadataLookupStr(&mdok, config->arguments, "STATS"); // Filename for statistics
     25    psMetadata *stats = NULL;           // Container for statistics
     26    FILE *statsFile = NULL;             // File stream for statistics
     27    if (mdok && statsName && strlen(statsName) > 0) {
     28        statsFile = fopen(statsName, "w");
     29        if (!statsFile) {
     30            psError(PS_ERR_IO, true, "Unable to open statistics file %s for writing.\n", statsName);
     31            return false;
     32        }
     33        stats = psMetadataAlloc();
    2034    }
    2135
     
    4054            pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
    4155
    42             // process each of the readouts
    43             while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
     56            // Perform statistics on the cell
     57            if (stats) {
     58                bool mdok;              // Status of MD lookup
     59                pmFPAfile *output = psMetadataLookupPtr(&mdok, config->files, "PSWARP.OUTPUT");
     60                if (!mdok || !output) {
     61                    psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find file PSWARP.OUTPUT.\n");
     62                    psFree(view);
     63                    psFree(stats);
     64                    return false;
     65                }
     66                ppStats(stats, output->fpa, view, config);
     67            }
     68
     69            pmHDU *hdu = pmHDUFromCell(cell); // HDU that owns the cell
     70
     71            // Process readouts
     72            while ((readout = pmFPAviewNextReadout(view, input->fpa, 1)) != NULL) {
    4473                pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
    45                 if (! readout->data_exists) { continue; }
     74                if (!readout->data_exists) {
     75                    continue;
     76                }
    4677
    4778                // pswarpConvertReadout (readout, config);
     79
     80                // Add MD5 information for readout
     81                const char *chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME");
     82                const char *cellName = psMetadataLookupStr(NULL, cell->concepts, "CELL.NAME");
     83                psString headerName = NULL; // Header name for MD5
     84                psStringAppend(&headerName, "MD5_%s_%s_%d", chipName, cellName, view->readout);
     85                psVector *md5 = psImageMD5(readout->image); // md5 hash
     86                psString md5string = psMD5toString(md5); // String
     87                psFree(md5);
     88                psMetadataAddStr(hdu->header, PS_LIST_TAIL, headerName, PS_META_REPLACE,
     89                                 "Image MD5", md5string);
     90                psFree(md5string);
     91                psFree(headerName);
    4892
    4993                pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
     
    59103    pmFPAfileActivate (config->files, true, NULL);
    60104
     105    // Write out summary statistics
     106    if (stats) {
     107        const char *statsMDC = psMetadataConfigFormat(stats);
     108        if (!statsMDC || strlen(statsMDC) == 0) {
     109            psError(PS_ERR_IO, false, "Unable to get statistics MDC file.\n");
     110            psFree(stats);
     111            fclose(statsFile);
     112            return false;
     113        }
     114        fprintf(statsFile, "%s", statsMDC);
     115        psFree((void*)statsMDC);
     116        fclose(statsFile);
     117
     118        psFree(stats);
     119    }
     120
    61121    return true;
    62122}
Note: See TracChangeset for help on using the changeset viewer.