Changeset 14000 for trunk/ppImage/src/ppImageStats.c
- Timestamp:
- Jul 3, 2007, 10:01:23 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/ppImage/src/ppImageStats.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/ppImageStats.c
r13970 r14000 3 3 #endif 4 4 5 #include <stdio.h>6 #include <pslib.h>7 #include <psmodules.h>8 9 5 #include "ppImage.h" 10 #include "ppStats.h"11 6 12 7 // calculate stats, including MD5 … … 42 37 if (options->doStats) { 43 38 44 pmFPAfile *output = psMetadataLookupPtr(&mdok, config->files, "PPIMAGE.OUTPUT"); 45 if (!mdok || !output) { 46 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find file PPIMAGE.OUTPUT."); 39 pmFPAfile *outImage = psMetadataLookupPtr(&mdok, config->files, "PPIMAGE.OUTPUT"); 40 pmFPAfile *outPhotom = psMetadataLookupPtr(&mdok, config->files, "PSPHOT.OUTPUT"); 41 pmFPAfile *outAstrom = psMetadataLookupPtr(&mdok, config->files, "PSASTRO.OUTPUT"); 42 43 if (!outImage && !outPhotom && !outAstrom) { 44 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find any output file (PPIMAGE.OUTPUT, PSPHOT.OUTPUT, PSASTRO.OUTPUT)."); 47 45 psFree (view); 48 46 psFree(stats); … … 50 48 } 51 49 52 if (!ppStats(stats, output->fpa, view, 50 // get the latest output product available 51 pmFPAfile *output = outAstrom; 52 if (!output) { 53 output = outPhotom; 54 } 55 if (!output) { 56 output = outImage; 57 } 58 59 if (!ppStatsFPA(stats, output->fpa, view, 53 60 options->satMask | options->badMask | options->maskValue, 54 61 config)) { … … 98 105 return true; 99 106 } 100 101 // write stats to output file102 bool ppImageStatsOutput (pmConfig *config, pmFPA *fpa, const ppImageOptions *options) {103 104 bool mdok;105 106 // measure statistics, or ignore?107 if (!options->doStats) return true;108 109 // get the output stats filename110 const char *statsName = psMetadataLookupStr(&mdok, config->arguments, "STATS"); // Filename for statistics111 if (!statsName && !strlen(statsName)) {112 psError (PS_ERR_UNEXPECTED_NULL, false, "missing STATS entry in arguments list.");113 return false;114 }115 116 // convert to a real UNIX filename117 psString resolved = pmConfigConvertFilename(statsName, config, true); // Resolved filename118 FILE *statsFile = fopen (resolved, "w");119 if (!statsFile) {120 psError(PS_ERR_IO, true, "Unable to open statistics file %s for writing.\n", resolved);121 psFree(resolved);122 return false;123 }124 psFree(resolved);125 126 // select the fpa-level analysis stats metadata:127 psMetadata *stats = psMetadataLookupPtr (&mdok, fpa->analysis, "PPIMAGE.STATS");128 if (!stats) {129 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find PPIMAGE.STATS entry in fpa analysis.\n");130 return false;131 }132 133 // convert the stats MDC to a string134 char *statsMDC = psMetadataConfigFormat(stats);135 if (!statsMDC || strlen(statsMDC) == 0) {136 psError(PS_ERR_IO, false, "Unable to serialize stats metadata.\n");137 return false;138 }139 140 // write the stats MDC to a file141 // XXX why does this not call psMetadataConfigPrint?142 fprintf(statsFile, "%s", statsMDC);143 144 psFree(statsMDC);145 fclose(statsFile);146 return true;147 }
Note:
See TracChangeset
for help on using the changeset viewer.
