Changeset 8337 for trunk/ppStats
- Timestamp:
- Aug 14, 2006, 4:55:08 PM (20 years ago)
- Location:
- trunk/ppStats
- Files:
-
- 7 added
- 13 edited
-
. (modified) (1 prop)
-
.cvsignore (modified) (1 diff)
-
Makefile.am (modified) (1 diff)
-
autogen.sh (modified) (2 diffs)
-
configure.ac (modified) (2 diffs)
-
ppStats.pc.in (added)
-
src (modified) (1 prop)
-
src/.cvsignore (modified) (1 diff)
-
src/Makefile.am (modified) (1 diff)
-
src/ppStats.c (modified) (1 diff)
-
src/ppStats.h (modified) (1 diff)
-
src/ppStatsData.c (modified) (2 diffs)
-
src/ppStatsData.h (modified) (1 diff)
-
src/ppStatsLoop.c (modified) (9 diffs)
-
src/ppStatsLoop.h (added)
-
src/ppStatsSetupFromArgs.c (added)
-
src/ppStatsSetupFromArgs.h (added)
-
src/ppStatsSetupFromRecipe.c (added)
-
src/ppStatsSetupFromRecipe.h (added)
-
src/ppStatsStandAlone.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStats
- Property svn:ignore
-
old new 10 10 install-sh 11 11 missing 12 config.guess 13 config.sub 14 libtool 15 ltmain.sh 16 ppStats.pc
-
- Property svn:ignore
-
trunk/ppStats/.cvsignore
r7903 r8337 10 10 install-sh 11 11 missing 12 config.guess 13 config.sub 14 libtool 15 ltmain.sh 16 ppStats.pc -
trunk/ppStats/Makefile.am
r7902 r8337 2 2 3 3 CLEANFILES = *~ core core.* 4 5 pkgconfigdir = $(libdir)/pkgconfig 6 pkgconfig_DATA= ppStats.pc 7 8 EXTRA_DIST = \ 9 ppStats.pc.in -
trunk/ppStats/autogen.sh
r7902 r8337 21 21 AUTOCONF=autoconf 22 22 23 #($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 || {24 #echo25 #echo "You must have $LIBTOOlIZE installed to compile $PROJECT."26 #echo "Download the appropriate package for your distribution,"27 #echo "or get the source tarball at http://ftp.gnu.org/gnu/libtool/"28 #DIE=129 #}23 ($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 || { 24 echo 25 echo "You must have $LIBTOOlIZE installed to compile $PROJECT." 26 echo "Download the appropriate package for your distribution," 27 echo "or get the source tarball at http://ftp.gnu.org/gnu/libtool/" 28 DIE=1 29 } 30 30 31 31 ($ACLOCAL --version) < /dev/null > /dev/null 2>&1 || { … … 75 75 fi 76 76 77 #$LIBTOOLIZE --copy --force || echo "$LIBTOOlIZE failed"77 $LIBTOOLIZE --copy --force || echo "$LIBTOOlIZE failed" 78 78 $ACLOCAL || echo "$ACLOCAL failed" 79 79 #$AUTOHEADER || echo "$AUTOHEADER failed" -
trunk/ppStats/configure.ac
r7902 r8337 12 12 AC_PROG_CC 13 13 AC_PROG_INSTALL 14 dnlAC_PROG_LIBTOOL14 AC_PROG_LIBTOOL 15 15 16 16 dnl handle debug building … … 59 59 Makefile 60 60 src/Makefile 61 ppStats.pc 61 62 ]) 62 63 AC_OUTPUT -
trunk/ppStats/src
- Property svn:ignore
-
old new 2 2 Makefile 3 3 Makefile.in 4 .libs 5 *.lo 6 *.la 4 7 ppStats
-
- Property svn:ignore
-
trunk/ppStats/src/.cvsignore
r7903 r8337 2 2 Makefile 3 3 Makefile.in 4 .libs 5 *.lo 6 *.la 4 7 ppStats -
trunk/ppStats/src/Makefile.am
r7993 r8337 1 lib_LTLIBRARIES = libppStats.la 2 libppStats_la_CPPFLAGS = $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) $(ppStats_CFLAGS) 3 1 4 bin_PROGRAMS = ppStats 2 5 3 6 ppStats_CFLAGS += $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 4 7 ppStats_LDFLAGS += $(PSMODULE_LIBS) $(PSLIB_LIBS) -Wl,-Bdynamic 8 ppStats_LDADD = libppStats.la 5 9 6 ppStats_SOURCES =\10 libppStats_la_SOURCES = \ 7 11 ppStats.c \ 8 12 ppStatsData.c \ 9 13 ppStatsLoop.c \ 10 ppStatsSetup .c14 ppStatsSetupFromRecipe.c 11 15 12 noinst_HEADERS = \ 16 ppStats_SOURCES = \ 17 ppStatsData.c \ 18 ppStatsLoop.c \ 19 ppStatsSetupFromArgs.c \ 20 ppStatsStandAlone.c 21 22 include_HEADERS = \ 23 ppStats.h \ 13 24 ppStatsData.h \ 14 ppStats.h 25 ppStatsLoop.h \ 26 ppStatsSetupFromRecipe.h 27 28 noinst_HEADERS = \ 29 ppStats.h \ 30 ppStatsSetupFromArgs.h 15 31 16 32 CLEANFILES = *~ -
trunk/ppStats/src/ppStats.c
r7902 r8337 5 5 #include "ppStats.h" 6 6 7 int main(int argc, char *argv[]) 7 psMetadata *ppStats(psMetadata *out, // Output metadata 8 pmFPA *fpa, // FPA for which to get statistics 9 pmConfig *config // Configuration 10 ) 8 11 { 12 // Get the options, open the files 13 ppStatsData *data = ppStatsSetupFromRecipe(NULL, config); 9 14 10 psLibInit(NULL); 11 psTimerStart(TIMERNAME); 12 13 // Parse the configuration and arguments 14 pmConfig *config = pmConfigRead(&argc, argv); 15 16 // Get the options, open the files 17 ppStatsData *data = ppStatsSetup(config); 15 if (data->fpa) { 16 psFree(data->fpa); 17 } 18 data->fpa = psMemIncrRefCounter(fpa); 18 19 19 20 // Go through the FPA and do the hard work 20 ppStatsLoop(data, config);21 out = ppStatsLoop(out, data, config); 21 22 22 23 psFree(data); 23 psFree(config);24 pmConceptsDone();25 pmConfigDone();26 psLibFinalize();27 24 28 return EXIT_SUCCESS;25 return out; 29 26 } -
trunk/ppStats/src/ppStats.h
r7988 r8337 3 3 4 4 #define RECIPENAME "PPSTATS" 5 #define TIMERNAME "PPSTATS"6 5 7 6 #include <psmodules.h> 7 8 8 #include "ppStatsData.h" 9 10 // Set up the options and input/output files 11 ppStatsData *ppStatsSetup(pmConfig *config // Configuration 12 ); 13 14 // Loop over the input image and do all the hard work 15 void ppStatsLoop(ppStatsData *data, // The data 16 const pmConfig *config // Configuration 17 ); 9 #include "ppStatsSetupFromRecipe.h" 10 #include "ppStatsLoop.h" 18 11 19 12 #endif -
trunk/ppStats/src/ppStatsData.c
r7910 r8337 8 8 { 9 9 // inName and region are not on the psLib memory system (they are from argv). 10 psFree(data->inFPA); 11 if (data->inFile) { 12 psFitsClose(data->inFile); 13 data->inFile = NULL; 14 } 15 if (data->outFile) { 16 fclose(data->outFile); 17 data->outFile = NULL; 10 psFree(data->fpa); 11 if (data->fits) { 12 psFitsClose(data->fits); 13 data->fits = NULL; 18 14 } 19 15 psFree(data->headers); … … 33 29 psMemSetDeallocator(data, (psFreeFunc)statsDataFree); 34 30 35 data->inName = NULL; 36 data->inFile = NULL; 37 data->outName = NULL; 38 data->outFile = NULL; 39 data->inFPA = NULL; 31 data->fpa = NULL; 32 data->fits = NULL; 40 33 41 34 data->headers = psListAlloc(NULL); -
trunk/ppStats/src/ppStatsData.h
r7910 r8337 7 7 typedef struct { 8 8 // Inputs 9 const char *inName; // Input FITS image file 10 const char *outName; // Output filename 11 psFits *inFile; // Input file handle 12 FILE *outFile; // Output file handle 13 pmFPA *inFPA; // Input FPA 9 psFits *fits; // Input file handle 10 pmFPA *fpa; // FPA to analyse 14 11 // Stuff to output 15 12 psStats *stats; // Statistics to calculate -
trunk/ppStats/src/ppStatsLoop.c
r8195 r8337 5 5 6 6 #include "ppStats.h" 7 #include "ppStatsLoop.h" 7 8 8 9 … … 47 48 48 49 49 void ppStatsLoop(ppStatsData *data, // The data 50 const pmConfig *config // Configuration 50 psMetadata *ppStatsLoop(psMetadata *fpaResults, // Metadata to hold the FPA results 51 ppStatsData *data, // The data 52 const pmConfig *config // Configuration 51 53 ) 52 54 { 53 psMetadata *fpaResults = psMetadataAlloc(); // Metadata to hold the FPA results 55 PS_ASSERT_PTR_NON_NULL(data, NULL); 56 pmFPA *fpa = data->fpa; // FPA to analyse 57 psFits *fits = data->fits; // FITS file handle 58 PS_ASSERT_PTR_NON_NULL(fpa, NULL); 59 60 if (!fpaResults) { 61 fpaResults = psMetadataAlloc(); 62 } 63 64 bool mdok; // Status of MD lookup 54 65 55 66 // Iterators for the headers and concepts … … 58 69 59 70 // Iterate through the FPA 60 pmFPA *fpa = data->inFPA; // The FPA of interest61 71 if (psListLength(data->headers) > 0 && fpa->hdu) { 62 pmFPAReadHeader(fpa, data->inFile); 72 if (fits) { 73 pmFPAReadHeader(fpa, fits); 74 } 63 75 pmHDU *hdu = fpa->hdu; // HDU for headers 64 76 getMetadata(fpaResults, hdu->header, headersIter); 65 77 } 66 78 if (psListLength(data->concepts) > 0) { 67 pmFPAReadHeader(fpa, data->inFile); 79 if (fits) { 80 pmFPAReadHeader(fpa, fits); 81 } 68 82 pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_ALL, false, config->database); 69 83 getMetadata(fpaResults, fpa->concepts, conceptsIter); … … 82 96 } 83 97 84 psMetadata *chipResults = psMetadataAlloc(); // Metadata to hold the chip-level results 98 psMetadata *chipResults = psMetadataLookupMD(&mdok, fpaResults, chipName); // Chip-level results 99 if (!mdok || !chipResults) { 100 chipResults = psMetadataAlloc(); 101 } 85 102 86 103 if (psListLength(data->headers) > 0 && chip->hdu) { 87 if ( !pmChipReadHeader(chip, data->inFile)) {104 if (fits && !pmChipReadHeader(chip, fits)) { 88 105 continue; 89 106 } … … 92 109 } 93 110 if (psListLength(data->concepts) > 0) { 94 if ( !pmChipReadHeader(chip, data->inFile)) {111 if (fits && !pmChipReadHeader(chip, fits)) { 95 112 continue; 96 113 } … … 112 129 } 113 130 114 psMetadata *cellResults = psMetadataAlloc(); // Metadata to hold the cell-level results 131 psMetadata *cellResults = psMetadataLookupMD(&mdok, chipResults, cellName); // Cell-level results 132 if (!mdok || !cellResults) { 133 cellResults = psMetadataAlloc(); 134 } 115 135 116 136 if (psListLength(data->headers) > 0 && cell->hdu) { 117 if ( !pmCellReadHeader(cell, data->inFile)) {137 if (fits && !pmCellReadHeader(cell, fits)) { 118 138 continue; 119 139 } … … 122 142 } 123 143 if (psListLength(data->concepts) > 0) { 124 if ( !pmCellReadHeader(cell, data->inFile)) {144 if (fits && !pmCellReadHeader(cell, fits)) { 125 145 continue; 126 146 } … … 143 163 } 144 164 145 if ( !pmCellRead(cell, data->inFile, config->database)) {165 if (fits && !pmCellRead(cell, fits, config->database)) { 146 166 psLogMsg(__func__, PS_LOG_WARN, "Unable to read chip %s cell %s\n", chipName, cellName); 147 167 pmCellFreeData(cell); … … 229 249 230 250 // Add the cell results to the chip 231 psMetadataAdd(chipResults, PS_LIST_TAIL, cellName, PS_DATA_METADATA, 232 "Results for cell", cellResults); 233 234 psFree(cellResults); 235 pmCellFreeData(cell); 236 } 237 pmChipFreeData(chip); 238 if (psListLength(chipResults->list) > 0) { 251 if (psListLength(cellResults->list) > 0 && !psMetadataLookup(chipResults, cellName)) { 252 psMetadataAdd(chipResults, PS_LIST_TAIL, cellName, PS_DATA_METADATA, 253 "Results for cell", cellResults); 254 psFree(cellResults); 255 } 256 257 if (fits) { 258 pmCellFreeData(cell); 259 } 260 } 261 if (fits) { 262 pmChipFreeData(chip); 263 } 264 265 if (psListLength(chipResults->list) > 0 && !psMetadataLookup(fpaResults, chipName)) { 239 266 psMetadataAdd(fpaResults, PS_LIST_TAIL, chipName, PS_DATA_METADATA, 240 267 "Results for chip", chipResults); 241 } 242 psFree(chipResults); 243 } 244 pmFPAFreeData(fpa); 268 psFree(chipResults); 269 } 270 } 271 if (fits) { 272 pmFPAFreeData(fpa); 273 } 274 245 275 psFree(headersIter); 246 276 psFree(conceptsIter); 247 277 248 if (psListLength(fpaResults->list) == 0) { 249 psError(PS_ERR_UNKNOWN, true, "No output.\n"); 250 return; 251 } 252 253 psString output = psMetadataConfigFormat(fpaResults); 254 psFree(fpaResults); 255 if (!output) { 256 psError(PS_ERR_UNKNOWN, false, "Unable to generate configuration file with result.\n"); 257 return; 258 } 259 fprintf(data->outFile, "%s", output); 260 psFree(output); 261 262 return; 278 return fpaResults; 263 279 }
Note:
See TracChangeset
for help on using the changeset viewer.
