Changeset 23602 for trunk/ppStack/src/ppStackSetup.c
- Timestamp:
- Mar 30, 2009, 12:04:02 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ppStack/src/ppStackSetup.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStack/src/ppStackSetup.c
r23601 r23602 12 12 13 13 #define BUFFER 16 // Buffer for name array 14 15 // Generate an array of input filenames16 static psArray *stackNameArray(const ppStackOptions *options, // Stack options17 pmConfig *config, // Configuration18 const char *name // Name of file19 )20 {21 psAssert(config, "Require configuration");22 psAssert(config, "Require file name");23 24 psArray *array = psArrayAllocEmpty(options->num); // Array with filenames25 pmFPAview *view = pmFPAviewAlloc(0);// View to readout26 view->chip = view->cell = view->readout = -1;27 28 for (int i = 0; i < options->num; i++) {29 pmFPAfile *file = pmFPAfileSelectSingle(config->files, name, i); // File of interest30 31 psString filename = pmFPAfileName(file, view, config); // Filename of interest32 psAssert(filename, "Can't determine filename");33 psArrayAdd(array, array->n, filename);34 psFree(filename); // Drop reference35 }36 37 return array;38 }39 14 40 15 … … 71 46 72 47 // Generate temporary names for convolved images 73 if (options->convolve) { 74 const char *tempDir = psMetadataLookupStr(NULL, recipe, "TEMP.DIR"); // Directory for temporary images 75 if (!tempDir) { 76 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find TEMP.DIR in recipe"); 77 return false; 78 } 48 const char *tempDir = psMetadataLookupStr(NULL, recipe, "TEMP.DIR"); // Directory for temporary images 49 if (!tempDir) { 50 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find TEMP.DIR in recipe"); 51 return false; 52 } 79 53 80 psString outputName = psStringCopy(psMetadataLookupStr(NULL, config->arguments,81 "OUTPUT")); // Name for temporary files82 const char *tempName = basename(outputName);83 if (!tempName) {84 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to construct basename for temporary files.");85 psFree(outputName);86 return false;87 }54 psString outputName = psStringCopy(psMetadataLookupStr(NULL, config->arguments, 55 "OUTPUT")); // Name for temporary files 56 const char *tempName = basename(outputName); 57 if (!tempName) { 58 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to construct basename for temporary files."); 59 psFree(outputName); 60 return false; 61 } 88 62 89 const char *tempImage = psMetadataLookupStr(NULL, recipe, "TEMP.IMAGE"); // Suffix for images90 const char *tempMask = psMetadataLookupStr(NULL, recipe, "TEMP.MASK"); // Suffix for masks91 const char *tempVariance = psMetadataLookupStr(NULL, recipe, "TEMP.VARIANCE"); // Suffix for var maps92 if (!tempImage || !tempMask || !tempVariance) {93 psError(PS_ERR_BAD_PARAMETER_VALUE, false,94 "Unable to find TEMP.IMAGE, TEMP.MASK and TEMP.VARIANCE in recipe");95 psFree(outputName);96 return false;97 }63 const char *tempImage = psMetadataLookupStr(NULL, recipe, "TEMP.IMAGE"); // Suffix for images 64 const char *tempMask = psMetadataLookupStr(NULL, recipe, "TEMP.MASK"); // Suffix for masks 65 const char *tempVariance = psMetadataLookupStr(NULL, recipe, "TEMP.VARIANCE"); // Suffix for var maps 66 if (!tempImage || !tempMask || !tempVariance) { 67 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 68 "Unable to find TEMP.IMAGE, TEMP.MASK and TEMP.VARIANCE in recipe"); 69 psFree(outputName); 70 return false; 71 } 98 72 99 options->imageNames = psArrayAlloc(num); 100 options->maskNames = psArrayAlloc(num); 101 options->varianceNames = psArrayAlloc(num); 102 for (int i = 0; i < num; i++) { 103 psString imageName = NULL, maskName = NULL, varianceName = NULL; // Names for convolved images 104 psStringAppend(&imageName, "%s/%s.%d.%s", tempDir, tempName, i, tempImage); 105 psStringAppend(&maskName, "%s/%s.%d.%s", tempDir, tempName, i, tempMask); 106 psStringAppend(&varianceName, "%s/%s.%d.%s", tempDir, tempName, i, tempVariance); 107 psTrace("ppStack", 5, "Temporary files: %s %s %s\n", imageName, maskName, varianceName); 108 options->imageNames->data[i] = imageName; 109 options->maskNames->data[i] = maskName; 110 options->varianceNames->data[i] = varianceName; 111 } 112 psFree(outputName); 113 } else { 114 options->imageNames = stackNameArray(options, config, "PPSTACK.INPUT"); 115 options->maskNames = stackNameArray(options, config, "PPSTACK.INPUT.MASK"); 116 options->varianceNames = stackNameArray(options, config, "PPSTACK.INPUT.VARIANCE"); 73 options->imageNames = psArrayAlloc(num); 74 options->maskNames = psArrayAlloc(num); 75 options->varianceNames = psArrayAlloc(num); 76 for (int i = 0; i < num; i++) { 77 psString imageName = NULL, maskName = NULL, varianceName = NULL; // Names for convolved images 78 psStringAppend(&imageName, "%s/%s.%d.%s", tempDir, tempName, i, tempImage); 79 psStringAppend(&maskName, "%s/%s.%d.%s", tempDir, tempName, i, tempMask); 80 psStringAppend(&varianceName, "%s/%s.%d.%s", tempDir, tempName, i, tempVariance); 81 psTrace("ppStack", 5, "Temporary files: %s %s %s\n", imageName, maskName, varianceName); 82 options->imageNames->data[i] = imageName; 83 options->maskNames->data[i] = maskName; 84 options->varianceNames->data[i] = varianceName; 117 85 } 86 psFree(outputName); 118 87 119 88 if (!pmConfigMaskSetBits(NULL, NULL, config)) {
Note:
See TracChangeset
for help on using the changeset viewer.
