Changeset 13104 for trunk/pswarp/src/pswarpDataSave.c
- Timestamp:
- Apr 30, 2007, 6:24:33 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/pswarp/src/pswarpDataSave.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pswarp/src/pswarpDataSave.c
r12771 r13104 1 # include "pswarp.h" 1 #include <ppStats.h> 2 #include "pswarp.h" 2 3 3 4 // this loop loads the data from the input files and selects the … … 7 8 8 9 // all of the different astrometry analysis modes use the same data load loop 9 bool pswarpDataSave (pmConfig *config) {10 bool pswarpDataSave(pmConfig *config) { 10 11 11 12 pmChip *chip; … … 18 19 psError(PSWARP_ERR_CONFIG, true, "Can't find input data!\n"); 19 20 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(); 20 34 } 21 35 … … 40 54 pmFPAfileIOChecks (config, view, PM_FPA_BEFORE); 41 55 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) { 44 73 pmFPAfileIOChecks (config, view, PM_FPA_BEFORE); 45 if (! readout->data_exists) { continue; } 74 if (!readout->data_exists) { 75 continue; 76 } 46 77 47 78 // 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); 48 92 49 93 pmFPAfileIOChecks (config, view, PM_FPA_AFTER); … … 59 103 pmFPAfileActivate (config->files, true, NULL); 60 104 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 61 121 return true; 62 122 }
Note:
See TracChangeset
for help on using the changeset viewer.
