Changeset 19928 for trunk/ppImage/src/ppImagePixelStats.c
- Timestamp:
- Oct 6, 2008, 12:24:10 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ppImage/src/ppImagePixelStats.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/ppImagePixelStats.c
r18556 r19928 6 6 7 7 // calculate stats, including MD5 8 bool ppImagePixelStats (pmConfig *config, const ppImageOptions *options, const pmFPAview *inputView) { 9 8 bool ppImagePixelStats(pmConfig *config, psMetadata *stats, const ppImageOptions *options, 9 const pmFPAview *inputView) 10 { 10 11 bool mdok; // Status of MD lookup 11 12 … … 13 14 pmFPAview *view = pmFPAviewAlloc(0); // View for local processing 14 15 *view = *inputView; 15 16 16 17 // perform the analysis of for this FPA 17 18 pmFPAfile *output = psMetadataLookupPtr(&mdok, config->files, "PPIMAGE.OUTPUT"); 18 19 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; 22 23 } 23 24 24 25 // select the corresponding chip 25 pmChip *chip = pmFPAviewThisChip (view, output->fpa);26 pmChip *chip = pmFPAviewThisChip(view, output->fpa); 26 27 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; 30 31 } 31 32 32 33 // Perform statistics for this chip 33 34 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 } 34 40 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 } 47 47 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 } 72 54 } 73 55 74 pmCell *cell = NULL;75 pmReadout *readout = NULL;76 56 77 57 view->cell = view->readout = -1; 58 pmCell *cell = NULL; // Cell from iteration 78 59 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 } 82 63 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"); 88 70 89 psString headerName = NULL; // Header name for MD590 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); 91 73 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 } 100 81 } 101 82
Note:
See TracChangeset
for help on using the changeset viewer.
