Changeset 23573 for trunk/ppStack/src/ppStackSetup.c
- Timestamp:
- Mar 27, 2009, 11:49:17 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/ppStack/src/ppStackSetup.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStack/src/ppStackSetup.c
r23341 r23573 11 11 #include "ppStackLoop.h" 12 12 13 #define BUFFER 16 // Buffer for name array 14 15 // Generate an array of input filenames 16 static psArray *stackNameArray(pmConfig *config, // Configuration 17 const char *name // Name of file 18 ) 19 { 20 psAssert(config, "Require configuration"); 21 psAssert(config, "Require file name"); 22 23 psString regex = NULL; // Regular expression for selecting file 24 psStringAppend(®ex, "^%s$", name); 25 psMetadataIterator *iter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, regex); // Iterator 26 psFree(regex); 27 psMetadataItem *item; // Item from iteration 28 psArray *array = psArrayAlloc(BUFFER); // Array of file names 29 while ((item = psMetadataGetAndIncrement(iter))) { 30 psAssert(item->type == PS_DATA_UNKNOWN, "Should be this type"); 31 pmFPAfile *file = item->data.V; // An input file 32 33 psString filename = psStringCopy(file->filename); // Filename of interest 34 psArrayAdd(array, array->n, filename); 35 psFree(filename); // Drop reference 36 } 37 psFree(iter); 38 39 return array; 40 } 41 42 13 43 bool ppStackSetup(ppStackOptions *options, pmConfig *config) 14 44 { … … 18 48 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe 19 49 psAssert(recipe, "We've thrown an error on this before."); 50 51 options->convolve = psMetadataLookupBool(NULL, config->arguments, "CONVOLVE"); // Convolve images? 52 if (!psMetadataLookupBool(NULL, config->arguments, "HAVE.PSF")) { 53 psWarning("No PSFs provided --- unable to convolve to common PSF."); 54 options->convolve = false; 55 } 20 56 21 57 int num = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); // Number of inputs … … 36 72 } 37 73 38 const char *tempDir = psMetadataLookupStr(NULL, recipe, "TEMP.DIR"); // Directory for temporary images 39 if (!tempDir) { 40 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find TEMP.DIR in recipe"); 41 return false; 74 // Generate temporary names for convolved images 75 if (options->convolve) { 76 const char *tempDir = psMetadataLookupStr(NULL, recipe, "TEMP.DIR"); // Directory for temporary images 77 if (!tempDir) { 78 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find TEMP.DIR in recipe"); 79 return false; 80 } 81 82 psString outputName = psStringCopy(psMetadataLookupStr(NULL, config->arguments, 83 "OUTPUT")); // Name for temporary files 84 const char *tempName = basename(outputName); 85 if (!tempName) { 86 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to construct basename for temporary files."); 87 psFree(outputName); 88 return false; 89 } 90 91 const char *tempImage = psMetadataLookupStr(NULL, recipe, "TEMP.IMAGE"); // Suffix for images 92 const char *tempMask = psMetadataLookupStr(NULL, recipe, "TEMP.MASK"); // Suffix for masks 93 const char *tempVariance = psMetadataLookupStr(NULL, recipe, "TEMP.VARIANCE"); // Suffix for var maps 94 if (!tempImage || !tempMask || !tempVariance) { 95 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 96 "Unable to find TEMP.IMAGE, TEMP.MASK and TEMP.VARIANCE in recipe"); 97 psFree(outputName); 98 return false; 99 } 100 101 options->imageNames = psArrayAlloc(num); 102 options->maskNames = psArrayAlloc(num); 103 options->varianceNames = psArrayAlloc(num); 104 for (int i = 0; i < num; i++) { 105 psString imageName = NULL, maskName = NULL, varianceName = NULL; // Names for convolved images 106 psStringAppend(&imageName, "%s/%s.%d.%s", tempDir, tempName, i, tempImage); 107 psStringAppend(&maskName, "%s/%s.%d.%s", tempDir, tempName, i, tempMask); 108 psStringAppend(&varianceName, "%s/%s.%d.%s", tempDir, tempName, i, tempVariance); 109 psTrace("ppStack", 5, "Temporary files: %s %s %s\n", imageName, maskName, varianceName); 110 options->imageNames->data[i] = imageName; 111 options->maskNames->data[i] = maskName; 112 options->varianceNames->data[i] = varianceName; 113 } 114 psFree(outputName); 115 } else { 116 options->imageNames = stackNameArray(config, "PPSTACK.INPUT"); 117 options->maskNames = stackNameArray(config, "PPSTACK.INPUT.MASK"); 118 options->varianceNames = stackNameArray(config, "PPSTACK.INPUT.VARIANCE"); 42 119 } 43 44 psString outputName = psStringCopy(psMetadataLookupStr(NULL, config->arguments,45 "OUTPUT")); // Name for temporary files46 const char *tempName = basename(outputName);47 if (!tempName) {48 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to construct basename for temporary files.");49 psFree(outputName);50 return false;51 }52 53 const char *tempImage = psMetadataLookupStr(NULL, recipe, "TEMP.IMAGE"); // Suffix for temporary images54 const char *tempMask = psMetadataLookupStr(NULL, recipe, "TEMP.MASK"); // Suffix for temporary masks55 const char *tempVariance = psMetadataLookupStr(NULL, recipe, "TEMP.VARIANCE"); // Suffix for temp var maps56 if (!tempImage || !tempMask || !tempVariance) {57 psError(PS_ERR_BAD_PARAMETER_VALUE, false,58 "Unable to find TEMP.IMAGE, TEMP.MASK and TEMP.VARIANCE in recipe");59 psFree(outputName);60 return false;61 }62 63 options->imageNames = psArrayAlloc(num);64 options->maskNames = psArrayAlloc(num);65 options->varianceNames = psArrayAlloc(num);66 for (int i = 0; i < num; i++) {67 psString imageName = NULL, maskName = NULL, varianceName = NULL; // Names for convolved images68 psStringAppend(&imageName, "%s/%s.%d.%s", tempDir, tempName, i, tempImage);69 psStringAppend(&maskName, "%s/%s.%d.%s", tempDir, tempName, i, tempMask);70 psStringAppend(&varianceName, "%s/%s.%d.%s", tempDir, tempName, i, tempVariance);71 psTrace("ppStack", 5, "Temporary files: %s %s %s\n", imageName, maskName, varianceName);72 options->imageNames->data[i] = imageName;73 options->maskNames->data[i] = maskName;74 options->varianceNames->data[i] = varianceName;75 }76 psFree(outputName);77 120 78 121 if (!pmConfigMaskSetBits(NULL, NULL, config)) {
Note:
See TracChangeset
for help on using the changeset viewer.
