IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 3, 2007, 10:00:03 AM (19 years ago)
Author:
eugene
Message:

adding functions to get stats on pixels and metadata independently; adding ability to get header data from readout->analysis

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStats/src/ppStatsLoop.c

    r13993 r13999  
    1 #include "ppStatsInternal.h"
     1# include "ppStatsInternal.h"
    22
    33static void getMetadata(psMetadata *target, // Target for metadata
     
    1212        if (item) {
    1313            psMetadataAddItem(target, item, PS_LIST_TAIL, 0);
     14        }
     15    }
     16    psFree(iterator);
     17    return;
     18}
     19
     20static void getAnalysis(psMetadata *target, // Output Target for metadata
     21                        psList *headers,    // List containing desired keywords
     22                        psMetadata *source, // Input Source for metadata
     23                        psList *list        // List containing analysis blocks
     24    )
     25{
     26    bool status;
     27
     28    psListIterator *iterator = psListIteratorAlloc(list, PS_LIST_HEAD, false); // Iterator
     29    psString name;                      // Name from iteration
     30    while ((name = psListGetAndIncrement(iterator))) {
     31        psMetadata *folder = psMetadataLookupMetadata(&status, source, name); // Item of interest, or NULL
     32        if (folder) {
     33            getMetadata (target, folder, headers);
    1434        }
    1535    }
     
    5575
    5676
    57 static psExit cellStats(psMetadata *chipResults, // Metadata holding the chip results
    58                         pmCell *cell,     // Cell for which to get statistics
    59                         psFits *fits,     // FITS file handle
    60                         ppStatsData *data,// The data
    61                         const pmConfig *config // Configuration
     77psExit ppStatsCell(psMetadata *chipResults, // Metadata holding the chip results
     78                   pmCell *cell,        // Cell for which to get statistics
     79                   psFits *fits,        // FITS file handle
     80                   ppStatsData *data,   // The data
     81                   const pmConfig *config // Configuration
    6282    )
    6383{
     
    7393        return PS_EXIT_SUCCESS;
    7494    }
     95
     96    // select the header unit for this cell
    7597    pmHDU *hdu = pmHDUFromCell(cell); // HDU for cell
    7698    if (!hdu || hdu->blankPHU) {
     
    84106    }
    85107
    86     // Cell-level results
     108    /*** psphot and psastro put their results on the readout->analysis metadata (PSPHOT.HEADER,
     109         PSASTRO.HEADER).  we need to pull quantities of interest from those locations. to do
     110         this, we need to select the appropriate readout.  ***/
     111
     112    // Select the readout
     113    psArray *readouts = cell->readouts; // Array of component readouts
     114    if (readouts->n == 0) {
     115        psLogMsg(__func__, PS_LOG_WARN, "No readouts present in cell %s --- skipping\n", cellName);
     116        goto cellDone;
     117    }
     118    if (readouts->n > 1) {
     119        psLogMsg(__func__, PS_LOG_WARN, "Multiple readouts (%ld) present in cell %s --- "
     120                 "using only the first.\n", readouts->n, cellName);
     121    }
     122    pmReadout *readout = readouts->data[0]; // The readout of interest
     123
     124    // Extract Header and Concept values from the Cell and Readout->analysis level
    87125    bool mdok;                          // Status of MD lookup
    88126    psMetadata *cellResults = psMemIncrRefCounter(psMetadataLookupMetadata(&mdok, chipResults, cellName));
     
    91129    }
    92130
     131    // Extract Header values
    93132    if (psListLength(data->headers) > 0 && cell->hdu) {
    94133        if (fits && !pmCellReadHeader(cell, fits)) {
     
    99138        pmHDU *hdu = cell->hdu;     // HDU for headers
    100139        getMetadata(cellResults, hdu->header, data->headers);
    101     }
     140
     141        // search in the readout->analysis metadata blocks listed in data->analysis
     142        if (psListLength(data->analysis) > 0) {
     143            getAnalysis (cellResults, data->headers, readout->analysis, data->analysis);
     144        }
     145    }
     146
     147    // Extract Concept values
    102148    if (psListLength(data->concepts) > 0) {
    103149        if (fits && cell->hdu && !pmCellReadHeader(cell, fits)) {
     
    110156    }
    111157
     158    // Do we want to measure pixel statistics?
    112159    if (!data->doStats && psListLength(data->summary)) {
    113160        // Nothing further to do --- don't want to waste our time reading the data
     
    115162    }
    116163
     164    // Read the image pixel data
    117165    if (fits && !pmCellRead(cell, fits, config->database)) {
    118166        psError (PS_ERR_IO, false, "trouble reading cell data\n");
     
    121169    }
    122170
    123     psArray *readouts = cell->readouts; // Array of component readouts
    124     if (readouts->n == 0) {
    125         psLogMsg(__func__, PS_LOG_WARN, "No readouts present in cell %s --- skipping\n", cellName);
    126         goto cellDone;
    127     }
    128     if (readouts->n > 1) {
    129         psLogMsg(__func__, PS_LOG_WARN, "Multiple readouts (%ld) present in cell %s --- "
    130                  "using only the first.\n", readouts->n, cellName);
    131     }
    132     pmReadout *readout = readouts->data[0]; // The readout of interest
    133171    if (!readout->image) {
    134172        psLogMsg(__func__, PS_LOG_WARN, "No image associated with readout in cell %s --- ignored.\n", cellName);
     
    243281}
    244282
    245 static psExit chipStats(psMetadata *fpaResults, // Metadata holding the fpa results
    246                         pmChip *chip,     // Chip for which to get statistics
    247                         psFits *fits,     // FITS file handle
    248                         pmFPAview *view,  // View for analysis
    249                         ppStatsData *data,// The data
    250                         const pmConfig *config // Configuration
     283psExit ppStatsChip(psMetadata *fpaResults, // Metadata holding the fpa results
     284                   pmChip *chip,     // Chip for which to get statistics
     285                   psFits *fits,     // FITS file handle
     286                   pmFPAview *view,  // View for analysis
     287                   ppStatsData *data,// The data
     288                   const pmConfig *config // Configuration
    251289    )
    252290{
     
    301339    if (view->cell >= 0) {
    302340        pmCell *cell = cells->data[view->cell]; // Cell of interest
    303         result = cellStats(chipResults, cell, fits, data, config);
     341        result = ppStatsCell(chipResults, cell, fits, data, config);
    304342        if (result != PS_EXIT_SUCCESS) {
    305343            psError(PS_ERR_UNKNOWN, false, "trouble with cell stats for %d\n", view->cell);
     
    316354    for (int i = 0; i < cells->n; i++) {
    317355        pmCell *cell = cells->data[i];  // Cell of interest
    318         result = cellStats(chipResults, cell, fits, data, config);
     356        result = ppStatsCell(chipResults, cell, fits, data, config);
    319357        if (result != PS_EXIT_SUCCESS) {
    320358            psError(PS_ERR_UNKNOWN, false, "trouble with cell stats for %d\n", i);
     
    380418    if (view->chip >= 0) {
    381419        pmChip *chip = chips->data[view->chip]; // Chip of interest
    382         *result = chipStats(newResults, chip, fits, view, data, config);
     420        *result = ppStatsChip(newResults, chip, fits, view, data, config);
    383421        if (*result != PS_EXIT_SUCCESS) {
    384422            psError(PS_ERR_UNKNOWN, false, "trouble with stats for cell %d\n", view->cell);
     
    394432    }
    395433
    396     // Iterate over cells
     434    // Iterate over chips
    397435    for (int i = 0; i < chips->n; i++) {
    398436        pmChip *chip = chips->data[i];  // Chip of interest
    399         *result = chipStats(newResults, chip, fits, view, data, config);
     437        *result = ppStatsChip(newResults, chip, fits, view, data, config);
    400438        if (*result != PS_EXIT_SUCCESS) {
    401439            psError(PS_ERR_UNKNOWN, false, "trouble with stats for chip %d\n", i);
Note: See TracChangeset for help on using the changeset viewer.