Changeset 19399
- Timestamp:
- Sep 5, 2008, 12:41:58 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
ppImage/src/ppImageArguments.c (modified) (1 diff)
-
ppImage/src/ppImageLoop.c (modified) (1 diff)
-
ppStack/src/ppStackArguments.c (modified) (2 diffs)
-
ppSub/src/ppSubArguments.c (modified) (2 diffs)
-
psModules/src/config/pmConfigDump.c (modified) (2 diffs)
-
psModules/src/config/pmConfigDump.h (modified) (2 diffs)
-
pswarp/src/pswarpArguments.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/ppImageArguments.c
r18895 r19399 132 132 } 133 133 134 if ((argnum = psArgumentGet(argc, argv, "-dumpconfig"))) { 135 psArgumentRemove(argnum, &argc, argv); 136 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "DUMP_CONFIG", PS_META_REPLACE, 137 "Filename for configuration dump", argv[argnum]); 138 psArgumentRemove(argnum, &argc, argv); 139 } 140 134 141 if (argc != 2) usage (); 135 142 -
trunk/ppImage/src/ppImageLoop.c
r19044 r19399 28 28 } 29 29 30 { 30 psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG"); 31 if (dump_file) { 31 32 pmConfigCamerasCull(config, NULL); 32 33 pmConfigRecipesCull(config, "PPIMAGE,PPSTATS,PSPHOT,MASKS,PSASTRO"); 33 34 34 const char *outroot = psMetadataLookupStr(NULL, config->arguments, "OUTPUT"); // Output root name 35 psAssert(outroot, "Should be there, we put it there!"); 36 pmConfigDump(config, input->fpa, outroot); 35 pmConfigDump(config, input->fpa, dump_file); 37 36 } 38 37 -
trunk/ppStack/src/ppStackArguments.c
r19283 r19399 145 145 146 146 pmConfigFileSetsMD(config->arguments, &argc, argv, "PPSTACK.SOURCES", "-sources", NULL); 147 148 if ((argNum = psArgumentGet(argc, argv, "-dumpconfig"))) { 149 psArgumentRemove(argNum, &argc, argv); 150 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "DUMP_CONFIG", PS_META_REPLACE, 151 "Filename for configuration dump", argv[argNum]); 152 psArgumentRemove(argNum, &argc, argv); 153 } 154 155 147 156 148 157 psMetadata *arguments = config->arguments; // Command-line arguments … … 288 297 289 298 // Dump configuration, now that's it's settled 290 { 299 bool status; 300 psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG"); 301 if (dump_file) { 291 302 pmConfigCamerasCull(config, NULL); 292 303 pmConfigRecipesCull(config, "PPSTACK,PPSUB,PPSTATS,PSPHOT,MASKS"); 293 304 294 const char *outroot = psMetadataLookupStr(NULL, arguments, "OUTPUT"); // Output root name295 psAssert(outroot, "Should be there, we put it there!");296 297 305 pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPSTACK.INPUT"); // Input file 298 pmConfigDump(config, input->fpa, outroot);306 pmConfigDump(config, input->fpa, dump_file); 299 307 } 300 308 -
trunk/ppSub/src/ppSubArguments.c
r19165 r19399 219 219 psMetadataAddBool(arguments, PS_LIST_TAIL, "-photometry", 0, "Perform photometry?", false); 220 220 psMetadataAddS32(arguments, PS_LIST_TAIL, "-threads", 0, "Number of threads", 0); 221 psMetadataAddStr(arguments, PS_LIST_TAIL, "-dumpconfig", 0, "file to dump configuration to", NULL); 221 222 222 223 if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 4) { … … 345 346 346 347 // Dump configuration, now that's it's settled 347 { 348 psBool status; 349 psString dump_file = psMetadataLookupStr(&status, config->arguments, "-dumpconfig"); 350 if (dump_file) { 348 351 pmConfigCamerasCull(config, NULL); 349 352 pmConfigRecipesCull(config, "PPSUB,PPSTATS,PSPHOT,MASKS"); 350 353 351 const char *outroot = psMetadataLookupStr(NULL, arguments, "OUTPUT"); // Output root name352 psAssert(outroot, "Should be there, we put it there!");353 354 354 pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPSUB.INPUT"); // Input file 355 pmConfigDump(config, input->fpa, outroot);355 pmConfigDump(config, input->fpa, dump_file); 356 356 } 357 357 -
trunk/psModules/src/config/pmConfigDump.c
r19047 r19399 106 106 107 107 108 bool pmConfigDump(const pmConfig *config, const pmFPA *source, const char * outroot)108 bool pmConfigDump(const pmConfig *config, const pmFPA *source, const char *filename) 109 109 { 110 110 PS_ASSERT_PTR_NON_NULL(config, false); 111 PS_ASSERT_STRING_NON_EMPTY(outroot, false); 112 113 pmFPAview *view = source ? pmFPAviewTop(source) : pmFPAviewAlloc(0);// View to top level 114 if (!view) { 115 psError(PS_ERR_UNKNOWN, false, "Unable to determine top view for FPA."); 116 return false; 117 } 118 119 pmFPALevel level = pmFPAviewLevel(view); // Level for view 120 const char *levelString; // String for level 121 switch (level) { 122 case PM_FPA_LEVEL_FPA: 123 levelString = "FPA"; 124 break; 125 case PM_FPA_LEVEL_CHIP: 126 levelString = "CHIP"; 127 break; 128 case PM_FPA_LEVEL_CELL: 129 levelString = "CELL"; 130 break; 131 default: 132 psError(PS_ERR_UNKNOWN, false, "Bad FPA level: %x", level); 133 psFree(view); 134 return false; 135 } 136 137 psMetadata *dumpRules = psMetadataLookupMetadata(NULL, config->system, "CONFIG.DUMP"); // Name rules 138 if (!dumpRules) { 139 psError(PS_ERR_UNKNOWN, false, "Unable to find CONFIG.DUMP in system configuration"); 140 psFree(view); 141 return false; 142 } 143 144 const char *rule = psMetadataLookupStr(NULL, dumpRules, levelString); // Rule for output file name 145 if (!rule) { 146 psError(PS_ERR_UNKNOWN, false, "Unable to find %s in CONFIG.DUMP in system configuration", 147 levelString); 148 psFree(view); 149 return false; 150 } 151 152 psString ruleCopy = psStringCopy(rule); // Copy of rule, so we can have our way with it 153 154 psStringSubstitute(&ruleCopy, outroot, "{OUTPUT}"); 155 156 if (strstr(ruleCopy, "{PROGRAM}")) { 157 // basename() is allowed to muck with the values, so need to copy 158 psString program = psStringCopy(config->program); // Copy of program name 159 const char *progName = basename(program); // Basename of program 160 psStringSubstitute(&ruleCopy, progName, "{PROGRAM}"); 161 psFree(program); 162 } 163 164 if (strstr(ruleCopy, "{TIMESTAMP}")) { 165 psTime *time = psTimeGetNow(PS_TIME_UTC); // Current time 166 psString timeString = psTimeToISO(time); // ISO-formatted time 167 psFree(time); 168 psStringSubstitute(&ruleCopy, timeString, "{TIMESTAMP}"); 169 psFree(timeString); 170 } 171 172 psString filename = pmFPANameFromRule(ruleCopy, source, view); // Filename for dump 173 psFree(ruleCopy); 174 psFree(view); 175 if (!filename) { 176 psError(PS_ERR_UNKNOWN, false, "Unable to determine dump filename"); 177 return false; 178 } 111 PS_ASSERT_STRING_NON_EMPTY(filename, false); 179 112 180 113 psString resolved = pmConfigConvertFilename(filename, config, true, false); // Resolved filename … … 182 115 if (!psMetadataConfigWrite(config->user, resolved)) { 183 116 psError(PS_ERR_IO, false, "Unable to dump configuration to %s", filename); 184 psFree(filename);185 117 psFree(resolved); 186 118 return false; 187 119 } 188 120 189 psFree(filename);190 121 psFree(resolved); 191 122 -
trunk/psModules/src/config/pmConfigDump.h
r19042 r19399 4 4 * @author Paul Price, IfA 5 5 * 6 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $7 * @date $Date: 2008-0 8-13 02:32:35$6 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2008-09-05 22:41:58 $ 8 8 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii 9 9 */ … … 30 30 /// Dump the configuration to a file 31 31 /// 32 /// The output file is designated by the CONFIG.DUMP metadata in the system configuration, keyed by the FPA33 /// level of the supplied source. In addition to the standard concept interpolation, additional34 /// interpolations are defined: "{PROGRAM}" is interpolated to the program name, "{TIMESTAMP}" is interpolated35 /// to the current time (ISO format).36 32 bool pmConfigDump(const pmConfig *config, ///< Configuration to dump 37 const pmFPA *source, ///< Source FPA, defines the level for the file rule38 const char * outroot ///< Output rootname33 const pmFPA *source, ///< Source FPA, defines the level for the file rule 34 const char *filename ///< Output file name 39 35 ); 40 36 -
trunk/pswarp/src/pswarpArguments.c
r19043 r19399 59 59 psMetadataAddBool(config->arguments, PS_LIST_TAIL, "PSF", 0, "Do PSF determination?", true); 60 60 } 61 if ((N = psArgumentGet(argc, argv, "-dumpconfig"))) { 62 psArgumentRemove(N, &argc, argv); 63 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "DUMP_CONFIG", PS_META_REPLACE, 64 "Filename for configuration dump", argv[N]); 65 psArgumentRemove(N, &argc, argv); 66 } 67 61 68 62 69 if (!pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list")) { … … 166 173 167 174 // Dump configuration, now that's it's settled 168 { 175 psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG"); 176 if (dump_file) { 169 177 const char *skyCamera = psMetadataLookupStr(NULL, config->arguments, 170 178 "SKYCELL.CAMERA"); // Name of camera for skycell … … 172 180 pmConfigRecipesCull(config, "PSWARP,PPSTATS,PSPHOT,MASKS"); 173 181 174 const char *outroot = psMetadataLookupStr(NULL, config->arguments, "OUTPUT"); // Output root name175 psAssert(outroot, "Should be there, we put it there!");176 177 182 pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PSWARP.INPUT"); // Input file 178 pmConfigDump(config, input->fpa, outroot);183 pmConfigDump(config, input->fpa, dump_file); 179 184 } 180 185
Note:
See TracChangeset
for help on using the changeset viewer.
