Changeset 24144
- Timestamp:
- May 12, 2009, 7:21:07 AM (17 years ago)
- Location:
- trunk/psphot/src
- Files:
-
- 3 edited
-
psphot.c (modified) (2 diffs)
-
psphotArguments.c (modified) (12 diffs)
-
psphotCleanup.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphot.c
r23195 r24144 1 1 # include "psphotStandAlone.h" 2 3 static void usage (void) {4 fprintf (stderr, "USAGE: psphot [-file image(s)] [-list imagelist] (output)\n");5 exit (PS_EXIT_CONFIG_ERROR);6 }7 2 8 3 int main (int argc, char **argv) { … … 14 9 // load command-line arguments, options, and system config data 15 10 pmConfig *config = psphotArguments (argc, argv); 16 if (!config) { 17 psErrorStackPrint(stderr, "Error reading arguments\n"); 18 usage (); 19 } 11 assert(config); 20 12 21 13 psphotVersionPrint(); -
trunk/psphot/src/psphotArguments.c
r23242 r24144 1 1 # include "psphotStandAlone.h" 2 3 static void writeHelpInfo(const char* program, pmConfig* config, FILE* ofile) 4 { 5 fprintf(ofile, 6 "Usage: one of the following\n" 7 "%s -file fname1[,fname2,...] -mask maskfile1[,maskfile2,...]\n" 8 " -variance varfile1[,varfile2,...] OutFileBaseName\n" 9 "\n" 10 "%s -list FileNameList [-masklist MaskFileNameList] \n" 11 " -variancelist VarFileNameList OutFileBaseName\n" 12 "\n" 13 "%s -help\n" 14 "\n" 15 "%s -version\n" 16 "\n" 17 "where:\n" 18 " FileNameList is a text file containing filenames, one per line\n" 19 " MaskFileNameList is a text file of mask filenames, one per line\n" 20 " VarFileNameList is a text file of variance filenames, one per line\n" 21 " OutFileBaseName is the 'root name' for output files\n" 22 "\n" 23 "additional options:\n" 24 " -modeltest xObj yObj [-model DEFAULT|ModelName] \n" 25 " [-fitmode DEFAULT|PSF|CONV] [-fitset FitFileName]\n" 26 " Test fit for object at the given coordinates. ModelName\n" 27 " is one of PS_MODEL_GAUSS, PS_MODEL_PGAUSS, PS_MODEL_QGAUSS,\n" 28 " PS_MODEL_RGAUSS, PS_MODEL_PS1_V1, or PS_MODEL_SERSIC.\n" 29 " FitFileName is a file of x,y,Io triples.\n" 30 " -psf PsfFile1[,PsfFile2,...] or -psflist PsfFileNameList\n" 31 " specify PSF rather than letting %s estimate it\n" 32 " -src SrcFile1[,SrcFile2,...] or -srclist SrcFileNameList\n" 33 " specify additional sources for PSF generation\n" 34 " -chip nn[,nn,...]\n" 35 " select detector chips to process; default is all.\n" 36 " Indices correspond to zero-based offset in the FPA metadata table.\n" 37 " -photcode PhotoCodeName\n" 38 " specify photocode\n" 39 " -region RegionString\n" 40 " specify analysis region. String is of form '[x0:x1,y0:y1]'\n" 41 " To use this option you must define a default in psphot.config\n" 42 " -visual\n" 43 " turns on interactive display mode\n" 44 " -dumpconfig CfgFileName\n" 45 " causes config info to be dumped to the named file.\n" 46 " -break NOTHING|BACKMDL|PEAKS|MOMENTS|PSFMODEL|ENSEMBLE|PASS1\n" 47 " choose a point at which to exit processing early\n" 48 " -nthreads n\n" 49 " set number of parallel threads of execution\n" 50 " -F OldFileRule ReplacementFileRule\n" 51 " change file naming rule; e.g. '-F PSPHOT.OUTPUT PSPHOT.OUT.CMF.MEF'\n" 52 " -D name stringval\n" 53 " set a string-valued config parameter\n" 54 " -Di name intval\n" 55 " set an integer-valued config parameter\n" 56 " -Df name fval\n" 57 " set a float-valued config parameter\n" 58 " -Db name boolval\n" 59 " set a boolean-valued config parameter\n" 60 " -v, -vv, -vvv\n" 61 " set increasing levels of verbosity\n" 62 " -logfmt FormatString\n" 63 " set format string used for log messages\n" 64 " -trace Fac Lvl\n" 65 " set tracing for facility Fac to integer Lvl, e.g. '-trace err 10'\n" 66 " -trace-levels\n" 67 " print current trace levels\n", 68 program,program,program,program,program); 69 psFree(config); 70 pmConfigDone(); 71 psLibFinalize(); 72 exit(PS_EXIT_SUCCESS); 73 } 74 75 static void usage(const char *program, // Name of the program 76 psMetadata *arguments, // Command-line arguments 77 pmConfig *config, // Configuration 78 int exitCode 79 ) 80 { 81 fprintf(stderr, 82 "Usage: one of the following\n" 83 "%s -file fname1[,fname2,...] -mask maskfile1[,maskfile2,...]\n" 84 " -variance varfile1[,varfile2,...] OutFileBaseName\n" 85 "\n" 86 "%s -list FileNameList [-masklist MaskFileNameList] \n" 87 " -variancelist VarFileNameList OutFileBaseName\n" 88 "\n" 89 "Try '%s -help' for more options and explanation\n", 90 program,program,program); 91 if (exitCode != PS_EXIT_SUCCESS) 92 psErrorStackPrint(stderr, "Error reading arguments\n"); 93 psFree(config); 94 pmConfigDone(); 95 psLibFinalize(); 96 exit(exitCode); 97 } 2 98 3 99 pmConfig *psphotArguments(int argc, char **argv) { … … 5 101 int N; 6 102 bool status; 7 8 if (argc == 1) {9 psError(PSPHOT_ERR_ARGUMENTS, true, "Too few arguments: %d", argc);10 return NULL;11 }12 13 if ((N = psArgumentGet (argc, argv, "-version"))) {14 psString version;15 version = psphotVersionLong(); fprintf (stdout, "%s\n", version); psFree (version);16 version = psModulesVersionLong(); fprintf (stdout, "%s\n", version); psFree (version);17 version = psLibVersionLong(); fprintf (stdout, "%s\n", version); psFree (version);18 exit (0);19 }20 103 21 104 // load config data from default locations … … 23 106 if (config == NULL) { 24 107 psError(PSPHOT_ERR_CONFIG, false, "Can't read site configuration"); 25 return NULL; 26 } 108 exit(PS_EXIT_CONFIG_ERROR); 109 } 110 111 PSARGUMENTS_INSTANTIATE_GENERICS( psphot, config, argc, argv ); 27 112 28 113 // save the following additional recipe values based on command-line options … … 30 115 psMetadata *options = pmConfigRecipeOptions (config, PSPHOT_RECIPE); 31 116 32 // Number of threads 33 if ((N = psArgumentGet(argc, argv, "-threads"))) { 34 psArgumentRemove(N, &argc, argv); 35 int nThreads = atoi(argv[N]); 36 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "NTHREADS", 0, "number of psphot threads", nThreads); 37 psArgumentRemove(N, &argc, argv); 38 39 // create the thread pool with number of desired threads, supplying our thread launcher function 40 psThreadPoolInit (nThreads); 41 } 42 psphotSetThreads(); 117 // Number of threads is handled 118 PSARGUMENTS_INSTANTIATE_THREADSARG( psphot, config, argc, argv ) 43 119 44 120 // run the test model (requires X,Y coordinate) 45 121 if ((N = psArgumentGet (argc, argv, "-modeltest"))) { 122 if (argc<=N+2) { 123 psError(PSPHOT_ERR_ARGUMENTS, true, 124 "Expected to see 2 more arguments; saw %d", argc - 1); 125 exit(PS_EXIT_CONFIG_ERROR); 126 } 127 46 128 psMetadataAddBool (options, PS_LIST_TAIL, "TEST_FIT", 0, "", true); 47 129 psMetadataAddF32 (options, PS_LIST_TAIL, "TEST_FIT_X", 0, "", atof(argv[N+1])); … … 54 136 // specify the modeltest model 55 137 if ((N = psArgumentGet (argc, argv, "-model"))) { 138 if (argc<=N+1) { 139 psError(PSPHOT_ERR_ARGUMENTS, true, 140 "Expected to see 1 more argument; saw %d", argc - 1); 141 exit(PS_EXIT_CONFIG_ERROR); 142 } 56 143 psArgumentRemove (N, &argc, argv); 57 144 psMetadataAddStr (options, PS_LIST_TAIL, "TEST_FIT_MODEL", 0, "", argv[N]); … … 61 148 // specify the test fit mode 62 149 if ((N = psArgumentGet (argc, argv, "-fitmode"))) { 150 if (argc<=N+1) { 151 psError(PSPHOT_ERR_ARGUMENTS, true, 152 "Expected to see 1 more argument; saw %d", argc - 1); 153 exit(PS_EXIT_CONFIG_ERROR); 154 } 63 155 psArgumentRemove (N, &argc, argv); 64 156 psMetadataAddStr (options, PS_LIST_TAIL, "TEST_FIT_MODE", 0, "", argv[N]); … … 66 158 } 67 159 if ((N = psArgumentGet (argc, argv, "-fitset"))) { 160 if (argc<=N+1) { 161 psError(PSPHOT_ERR_ARGUMENTS, true, 162 "Expected to see 1 more argument; saw %d", argc - 1); 163 exit(PS_EXIT_CONFIG_ERROR); 164 } 68 165 psArgumentRemove (N, &argc, argv); 69 166 psMetadataAddStr (options, PS_LIST_TAIL, "TEST_FIT_SET", 0, "", argv[N]); … … 74 171 // photcode : used in output to supplement header data (argument or recipe?) 75 172 if ((N = psArgumentGet (argc, argv, "-photcode"))) { 173 if (argc<=N+1) { 174 psError(PSPHOT_ERR_ARGUMENTS, true, 175 "Expected to see 1 more argument; saw %d", argc - 1); 176 exit(PS_EXIT_CONFIG_ERROR); 177 } 76 178 psArgumentRemove (N, &argc, argv); 77 179 psMetadataAddStr (options, PS_LIST_TAIL, "PHOTCODE", PS_META_REPLACE, "", argv[N]); … … 87 189 // break : used from recipe throughout psphotReadout 88 190 if ((N = psArgumentGet (argc, argv, "-break"))) { 191 if (argc<=N+1) { 192 psError(PSPHOT_ERR_ARGUMENTS, true, 193 "Expected to see 1 more argument; saw %d", argc - 1); 194 exit(PS_EXIT_CONFIG_ERROR); 195 } 89 196 psArgumentRemove (N, &argc, argv); 90 197 psMetadataAddStr (options, PS_LIST_TAIL, "BREAK_POINT", PS_META_REPLACE, "", argv[N]); 91 psArgumentRemove (N, &argc, argv);92 }93 94 // fitmode : used from recipe throughout psphotReadout95 if ((N = psArgumentGet (argc, argv, "-fitmode"))) {96 psArgumentRemove (N, &argc, argv);97 psMetadataAddStr (options, PS_LIST_TAIL, "FITMODE", PS_META_REPLACE, "", argv[N]);98 198 psArgumentRemove (N, &argc, argv); 99 199 } … … 101 201 // analysis region : overrides recipe value, used in psphotReadout/psphotEnsemblePSF 102 202 if ((N = psArgumentGet (argc, argv, "-region"))) { 203 if (argc<=N+1) { 204 psError(PSPHOT_ERR_ARGUMENTS, true, 205 "Expected to see 1 more argument; saw %d", argc - 1); 206 exit(PS_EXIT_CONFIG_ERROR); 207 } 103 208 psArgumentRemove (N, &argc, argv); 104 209 psMetadataAddStr (options, PS_LIST_TAIL, "ANALYSIS_REGION", 0, "", argv[N]); … … 108 213 // chip selection is used to limit chips to be processed 109 214 if ((N = psArgumentGet (argc, argv, "-chip"))) { 215 if (argc<=N+1) { 216 psError(PSPHOT_ERR_ARGUMENTS, true, 217 "Expected to see 1 more argument; saw %d", argc - 1); 218 exit(PS_EXIT_CONFIG_ERROR); 219 } 110 220 psArgumentRemove (N, &argc, argv); 111 221 psMetadataAddStr (config->arguments, PS_LIST_TAIL, "CHIP_SELECTIONS", PS_DATA_STRING, "", argv[N]); … … 121 231 pmConfigFileSetsMD (config->arguments, &argc, argv, "SRC", "-src", "-srclist"); 122 232 233 if (argc == 1) { 234 psError(PSPHOT_ERR_ARGUMENTS, true, "Too few arguments: %d", argc); 235 usage(argv[0], config->arguments, config, PS_EXIT_CONFIG_ERROR); 236 } 237 238 if (psArgumentGet(argc, argv, "-help") 239 || psArgumentGet(argc, argv, "-h")) 240 writeHelpInfo(argv[0], config, stdout); 241 123 242 // the input file is a required argument; if not found, we will exit 124 243 status = pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list"); 125 244 if (!status) { 126 245 psError(PSPHOT_ERR_ARGUMENTS, false, "pmConfigFileSetsMD failed to parse arguments"); 127 return NULL;246 usage(argv[0], config->arguments, config, PS_EXIT_CONFIG_ERROR); 128 247 } 129 248 130 249 if (argc != 2) { 131 250 psError(PSPHOT_ERR_ARGUMENTS, true, "Expected to see one more argument; saw %d", argc - 1); 132 return NULL;251 usage(argv[0], config->arguments, config, PS_EXIT_CONFIG_ERROR); 133 252 } 134 253 -
trunk/psphot/src/psphotCleanup.c
r23487 r24144 2 2 3 3 void psphotCleanup (pmConfig *config) { 4 5 // Dump configuration if requested 6 bool status; 7 psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG"); 8 if (dump_file) { 9 (void)pmConfigCamerasCull(config,NULL); 10 (void)pmConfigRecipesCull(config,NULL); 11 pmConfigDump(config, dump_file); 12 } 4 13 5 14 psFree (config);
Note:
See TracChangeset
for help on using the changeset viewer.
