Changeset 13993
- Timestamp:
- Jul 2, 2007, 10:35:53 AM (19 years ago)
- Location:
- trunk/ppStats/src
- Files:
-
- 2 added
- 7 deleted
- 9 edited
-
Makefile.am (modified) (2 diffs)
-
ppStats.c (modified) (1 diff)
-
ppStats.h (modified) (2 diffs)
-
ppStatsData.c (modified) (1 diff)
-
ppStatsData.h (deleted)
-
ppStatsFPA.c (added)
-
ppStatsFringe.c (modified) (1 diff)
-
ppStatsFringe.h (deleted)
-
ppStatsInternal.h (added)
-
ppStatsLoop.c (modified) (1 diff)
-
ppStatsLoop.h (deleted)
-
ppStatsSetupFromArgs.c (modified) (1 diff)
-
ppStatsSetupFromArgs.h (deleted)
-
ppStatsSetupFromRecipe.c (modified) (1 diff)
-
ppStatsSetupFromRecipe.h (deleted)
-
ppStatsStandAlone.c (deleted)
-
ppStatsVersion.c (modified) (1 diff)
-
ppStatsVersion.h (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStats/src/Makefile.am
r13923 r13993 1 1 2 lib_LTLIBRARIES = libppStats.la 2 3 libppStats_la_CPPFLAGS = $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) … … 8 9 ppStats_LDADD = libppStats.la 9 10 11 ppStats_SOURCES = \ 12 ppStats.c 13 10 14 libppStats_la_SOURCES = \ 11 ppStats .c \15 ppStatsFPA.c \ 12 16 ppStatsData.c \ 13 17 ppStatsFringe.c \ 14 18 ppStatsLoop.c \ 15 19 ppStatsSetupFromRecipe.c \ 16 ppStatsVersion.c 17 18 ppStats_SOURCES = \ 19 ppStatsData.c \ 20 ppStatsLoop.c \ 21 ppStatsSetupFromArgs.c \ 22 ppStatsStandAlone.c \ 20 ppStatsSetupFromArgs.c \ 23 21 ppStatsVersion.c 24 22 25 23 include_HEADERS = \ 26 ppStats.h \ 27 ppStatsData.h \ 28 ppStatsFringe.h \ 29 ppStatsLoop.h \ 30 ppStatsSetupFromRecipe.h \ 31 ppStatsVersion.h 24 ppStats.h 32 25 33 26 noinst_HEADERS = \ 34 ppStats.h \ 35 ppStatsSetupFromArgs.h 27 ppStatsInternal.h 36 28 37 29 CLEANFILES = *~ -
trunk/ppStats/src/ppStats.c
r13677 r13993 1 #ifdef HAVE_CONFIG_H 2 #include <config.h> 3 #endif 1 # include "ppStatsInternal.h" 4 2 5 #include <stdio.h> 6 #include <pslib.h> 7 #include <psmodules.h> 3 int main(int argc, char **argv) { 8 4 9 #include "ppStats.h" 5 psExit status = PS_EXIT_SUCCESS; 10 6 11 psMetadata *ppStats(psMetadata *out, 12 pmFPA *fpa, // FPA for which to get statistics 13 pmFPAview *view, // View for analysis 14 psMaskType maskVal, // Value to mask 15 pmConfig *config // Configuration 16 ) 17 { 18 PS_ASSERT_PTR_NON_NULL(fpa, NULL) 19 PS_ASSERT_PTR_NON_NULL(view, NULL); 20 PS_ASSERT_PTR_NON_NULL(config, NULL); 7 psLibInit(NULL); 8 psTimerStart("PPSTATS"); 21 9 22 ppStatsData *data = ppStatsDataAlloc(); // All the input data 10 // Parse the configuration and arguments 11 pmConfig *config = pmConfigRead(&argc, argv, PPSTATS_RECIPE); 12 if (!config) { 13 psErrorStackPrint(stderr, "Unable to read configuration.\n"); 14 exit(PS_EXIT_CONFIG_ERROR); 15 } 23 16 24 17 // Get the options, open the files 25 if (!ppStatsSetupFromRecipe(data, config)) {26 psError(PS_ERR_UNKNOWN, false, "Unable to get ppStats options from recipe.");27 ps Free(data);28 return NULL;18 ppStatsData *data = ppStatsSetupFromArgs(&argc, argv, config); 19 if (!data) { 20 psErrorStackPrint(stderr, "Unable to parse command-line arguments.\n"); 21 exit(PS_EXIT_CONFIG_ERROR); 29 22 } 30 23 31 // Override recipe mask value if one is provided 32 if (maskVal != 0) { 33 data->maskVal = maskVal; 24 // Output filename is optional 25 const char *outName = NULL; // Output file name 26 FILE *outFile = stdout; // Output file 27 if (argc == 2) { 28 outName = argv[1]; 29 psString resolved = pmConfigConvertFilename(outName, config, true); // Resolved filename 30 31 if (resolved && strlen(resolved) > 0) { 32 outFile = fopen(resolved, "w"); 33 if (!outFile) { 34 psLogMsg("ppStats", PS_LOG_ERROR, "Unable to open output file %s\n", resolved); 35 psFree(resolved); 36 // XXX this could be a system or config error, but not a data error 37 status = PS_EXIT_CONFIG_ERROR; 38 goto die; 39 } 40 } else { 41 psErrorStackPrint(stderr, "Unable to open output file %s.\n", resolved); 42 exit(PS_EXIT_CONFIG_ERROR); 43 } 44 psFree(resolved); 34 45 } 35 46 36 if (data->fpa) { 37 psFree(data->fpa); 47 // Go through the FPA and do the hard work 48 psMetadata *results = ppStatsLoop(&status, data, config); 49 if (status != PS_EXIT_SUCCESS) { 50 psErrorStackPrint(stderr, "Error in stats loop.\n"); 51 exit (status); 38 52 } 39 data->fpa = psMemIncrRefCounter(fpa); 40 41 if (data->view) { 42 psFree(data->view); 43 } 44 data->view = psMemIncrRefCounter(view); 45 46 // Go through the FPA and do the hard work 47 psExit status; // Status of statistics loop 48 psMetadata *result = ppStatsLoop(&status, data, config); 49 if (status != PS_EXIT_SUCCESS) { 50 psError (PS_ERR_UNKNOWN, false, "Not able to measure FPA statistics.\n"); 51 psFree(result); 52 psFree(data); 53 return (NULL); 53 if (psListLength(results->list) == 0) { 54 psErrorStackPrint(stderr, "No output.\n"); 55 exit (status); 54 56 } 55 57 56 if (out != NULL) { 57 psMetadataCopy (out, result); 58 psFree(result); 59 psFree(data); 60 return out; 58 if (data->fileLevel) { 59 const char *level = pmFPALevelToName(pmFPAPHULevel(config->format)); // Level for file 60 psMetadataAddStr(results, PS_LIST_HEAD, "FILE.LEVEL", 0, "File level", level); 61 61 } 62 62 63 // Format and print the output 64 psString output = psMetadataConfigFormat(results); 65 if (!output) { 66 psErrorStackPrint(stderr, "Unable to generate configuration file with result.\n"); 67 psFree(results); 68 exit(PS_EXIT_CONFIG_ERROR); 69 } 70 fprintf(outFile, "%s", output); 71 psFree(output); 72 73 // Clean up 74 psFree(results); 75 if (outName) { 76 fclose(outFile); 77 } 78 79 // Common code for the death. 80 die: 81 if (status) { 82 psErrorStackPrint (stderr, "failure in %s", __func__); 83 } 63 84 psFree(data); 64 return result; 85 psFree(config); 86 pmConceptsDone(); 87 pmConfigDone(); 88 psLibFinalize(); 89 90 return status; 65 91 } -
trunk/ppStats/src/ppStats.h
r13923 r13993 1 1 2 #ifndef PP_STATS_H 2 3 #define PP_STATS_H … … 4 5 #define PPSTATS_RECIPE "PPSTATS" 5 6 6 #include <psmodules.h> 7 typedef struct { 8 // Inputs 9 psFits *fits; // Input file handle 10 pmFPA *fpa; // FPA to analyse 11 pmFPAview *view; // View to analyse 12 // Stuff to output 13 psStats *stats; // Statistics to calculate 14 bool doStats; // Do statistics? 15 bool fileLevel; // Output file level? 16 psList *headers; // Headers to read 17 psList *concepts; // Concepts to read 18 psList *summary; // Summary statistics to calculate 19 // Options for input data 20 float sample; // Fraction of cell to sample for statistics 21 psMaskType maskVal; // Mask value for images 22 psList *chips; // Chips to look at 23 psList *cells; // Cells to look at 24 } ppStatsData; 7 25 8 #include "ppStatsData.h" 9 #include "ppStatsSetupFromRecipe.h" 10 #include "ppStatsLoop.h" 11 #include "ppStatsVersion.h" 12 #include "ppStatsFringe.h" 26 // Allocator 27 ppStatsData *ppStatsDataAlloc(void); 13 28 14 // Perform the ppStats steps15 psMetadata *ppStats (psMetadata *out,16 pmFPA *fpa, // FPA for which to get statistics17 pmFPAview *view, // View for analysis18 psMaskType maskVal, // Value to mask19 pmConfig *config // Configuration29 /// Perform the ppStats steps on the given FPA (optionally for specified view) 30 psMetadata *ppStatsFPA(psMetadata *out, 31 pmFPA *fpa, // FPA for which to get statistics 32 pmFPAview *view, // View for analysis 33 psMaskType maskVal, // Value to mask 34 pmConfig *config // Configuration 20 35 ); 21 36 37 /// Supplement the statistics with the fringe solution 38 bool ppStatsFringe(psMetadata *stats, ///< Statistics metadata to supplement 39 const pmChip *chip, ///< The chip containing the solution 40 const char *root, ///< Name of output entry 41 const char *fringeName ///< Name of the solution in the chip->analysis 42 ); 43 44 45 /// Loop over the input image and do all the hard work 46 psMetadata *ppStatsLoop(psExit *result, 47 ppStatsData *data, // The data 48 const pmConfig *config // Configuration 49 ); 50 51 /// Set up the options and input/output files 52 ppStatsData *ppStatsSetupFromArgs(int *argc, char *argv[], // Command-line arguments 53 pmConfig *config // Configuration 54 ); 55 56 bool ppStatsSetupFromRecipe(ppStatsData *data, // Data for running ppStats 57 pmConfig *config // Configuration 58 ); 59 60 61 /// Return short version information 62 psString ppStatsVersion(void); 63 64 /// Return long version information 65 psString ppStatsVersionLong(void); 66 22 67 #endif -
trunk/ppStats/src/ppStatsData.c
r13602 r13993 1 #ifdef HAVE_CONFIG_H 2 #include <config.h> 3 #endif 4 5 #include <stdio.h> 6 #include <pslib.h> 7 8 #include "ppStatsData.h" 1 #include "ppStatsInternal.h" 9 2 10 3 static void statsDataFree(ppStatsData *data // Data to free -
trunk/ppStats/src/ppStatsFringe.c
r13971 r13993 1 #ifdef HAVE_CONFIG_H 2 #include <config.h> 3 #endif 4 5 #include <string.h> 6 #include <pslib.h> 7 #include <psmodules.h> 8 9 #include "ppStatsFringe.h" 1 #include "ppStatsInternal.h" 10 2 11 3 bool ppStatsFringe(psMetadata *stats, const pmChip *chip, const char *root, const char *fringeName) -
trunk/ppStats/src/ppStatsLoop.c
r13797 r13993 1 #ifdef HAVE_CONFIG_H 2 #include <config.h> 3 #endif 4 5 #include <stdio.h> 6 #include <assert.h> 7 #include <string.h> 8 #include <pslib.h> 9 #include <psmodules.h> 10 11 #include "ppStats.h" 12 #include "ppStatsLoop.h" 13 1 #include "ppStatsInternal.h" 14 2 15 3 static void getMetadata(psMetadata *target, // Target for metadata -
trunk/ppStats/src/ppStatsSetupFromArgs.c
r13658 r13993 1 #ifdef HAVE_CONFIG_H 2 #include <config.h> 3 #endif 4 5 #include <stdio.h> 6 #include <pslib.h> 7 #include <psmodules.h> 8 #include <string.h> 9 10 #include "ppStats.h" 11 #include "ppStatsData.h" 12 #include "ppStatsSetupFromArgs.h" 1 #include "ppStatsInternal.h" 13 2 14 3 // This file is for setting up the required inputs from the command-line -
trunk/ppStats/src/ppStatsSetupFromRecipe.c
r13658 r13993 1 #ifdef HAVE_CONFIG_H 2 #include <config.h> 3 #endif 4 5 #include <stdio.h> 6 #include <pslib.h> 7 #include <psmodules.h> 8 #include <string.h> 9 10 #include "ppStats.h" 11 #include "ppStatsData.h" 12 #include "ppStatsSetupFromRecipe.h" 1 #include "ppStatsInternal.h" 13 2 14 3 // Strings in a recipe may be defined multiply (with MULTI) or listed on a single line -
trunk/ppStats/src/ppStatsVersion.c
r10292 r13993 1 #ifdef HAVE_CONFIG_H 2 #include <config.h> 3 #endif 4 5 #include <stdio.h> 6 #include <pslib.h> 7 #include <psmodules.h> 8 #include "ppStatsVersion.h" 1 #include "ppStatsInternal.h" 9 2 10 3 static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name
Note:
See TracChangeset
for help on using the changeset viewer.
