Changeset 13999 for trunk/ppStats/src/ppStatsLoop.c
- Timestamp:
- Jul 3, 2007, 10:00:03 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/ppStats/src/ppStatsLoop.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStats/src/ppStatsLoop.c
r13993 r13999 1 # include "ppStatsInternal.h"1 # include "ppStatsInternal.h" 2 2 3 3 static void getMetadata(psMetadata *target, // Target for metadata … … 12 12 if (item) { 13 13 psMetadataAddItem(target, item, PS_LIST_TAIL, 0); 14 } 15 } 16 psFree(iterator); 17 return; 18 } 19 20 static 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); 14 34 } 15 35 } … … 55 75 56 76 57 static psExit cellStats(psMetadata *chipResults, // Metadata holding the chip results58 pmCell *cell,// Cell for which to get statistics59 psFits *fits,// FITS file handle60 ppStatsData *data,// The data61 const pmConfig *config // Configuration77 psExit 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 62 82 ) 63 83 { … … 73 93 return PS_EXIT_SUCCESS; 74 94 } 95 96 // select the header unit for this cell 75 97 pmHDU *hdu = pmHDUFromCell(cell); // HDU for cell 76 98 if (!hdu || hdu->blankPHU) { … … 84 106 } 85 107 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 87 125 bool mdok; // Status of MD lookup 88 126 psMetadata *cellResults = psMemIncrRefCounter(psMetadataLookupMetadata(&mdok, chipResults, cellName)); … … 91 129 } 92 130 131 // Extract Header values 93 132 if (psListLength(data->headers) > 0 && cell->hdu) { 94 133 if (fits && !pmCellReadHeader(cell, fits)) { … … 99 138 pmHDU *hdu = cell->hdu; // HDU for headers 100 139 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 102 148 if (psListLength(data->concepts) > 0) { 103 149 if (fits && cell->hdu && !pmCellReadHeader(cell, fits)) { … … 110 156 } 111 157 158 // Do we want to measure pixel statistics? 112 159 if (!data->doStats && psListLength(data->summary)) { 113 160 // Nothing further to do --- don't want to waste our time reading the data … … 115 162 } 116 163 164 // Read the image pixel data 117 165 if (fits && !pmCellRead(cell, fits, config->database)) { 118 166 psError (PS_ERR_IO, false, "trouble reading cell data\n"); … … 121 169 } 122 170 123 psArray *readouts = cell->readouts; // Array of component readouts124 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 interest133 171 if (!readout->image) { 134 172 psLogMsg(__func__, PS_LOG_WARN, "No image associated with readout in cell %s --- ignored.\n", cellName); … … 243 281 } 244 282 245 static psExit chipStats(psMetadata *fpaResults, // Metadata holding the fpa results246 pmChip *chip, // Chip for which to get statistics247 psFits *fits, // FITS file handle248 pmFPAview *view, // View for analysis249 ppStatsData *data,// The data250 const pmConfig *config // Configuration283 psExit 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 251 289 ) 252 290 { … … 301 339 if (view->cell >= 0) { 302 340 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); 304 342 if (result != PS_EXIT_SUCCESS) { 305 343 psError(PS_ERR_UNKNOWN, false, "trouble with cell stats for %d\n", view->cell); … … 316 354 for (int i = 0; i < cells->n; i++) { 317 355 pmCell *cell = cells->data[i]; // Cell of interest 318 result = cellStats(chipResults, cell, fits, data, config);356 result = ppStatsCell(chipResults, cell, fits, data, config); 319 357 if (result != PS_EXIT_SUCCESS) { 320 358 psError(PS_ERR_UNKNOWN, false, "trouble with cell stats for %d\n", i); … … 380 418 if (view->chip >= 0) { 381 419 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); 383 421 if (*result != PS_EXIT_SUCCESS) { 384 422 psError(PS_ERR_UNKNOWN, false, "trouble with stats for cell %d\n", view->cell); … … 394 432 } 395 433 396 // Iterate over c ells434 // Iterate over chips 397 435 for (int i = 0; i < chips->n; i++) { 398 436 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); 400 438 if (*result != PS_EXIT_SUCCESS) { 401 439 psError(PS_ERR_UNKNOWN, false, "trouble with stats for chip %d\n", i);
Note:
See TracChangeset
for help on using the changeset viewer.
