- Timestamp:
- Mar 29, 2009, 6:15:31 PM (17 years ago)
- Location:
- branches/cnb_branches/cnb_branch_20090301
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branches/cnb_branch_20090301
-
branches/cnb_branches/cnb_branch_20090301/ppStack
- Property svn:mergeinfo changed
/trunk/ppStack merged: 23357,23360,23362,23364,23367-23368,23371-23373,23379,23462,23573,23575-23577
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090301/ppStack/src/ppStackSetup.c
r23352 r23594 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(const ppStackOptions *options, // Stack options 17 pmConfig *config, // Configuration 18 const char *name // Name of file 19 ) 20 { 21 psAssert(config, "Require configuration"); 22 psAssert(config, "Require file name"); 23 24 psArray *array = psArrayAllocEmpty(options->num); // Array with filenames 25 pmFPAview *view = pmFPAviewAlloc(0);// View to readout 26 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 interest 30 31 psString filename = pmFPAfileName(file, view, config); // Filename of interest 32 psAssert(filename, "Can't determine filename"); 33 psArrayAdd(array, array->n, filename); 34 psFree(filename); // Drop reference 35 } 36 37 return array; 38 } 39 40 13 41 bool ppStackSetup(ppStackOptions *options, pmConfig *config) 14 42 { … … 18 46 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe 19 47 psAssert(recipe, "We've thrown an error on this before."); 48 49 options->convolve = psMetadataLookupBool(NULL, config->arguments, "CONVOLVE"); // Convolve images? 50 if (!psMetadataLookupBool(NULL, config->arguments, "HAVE.PSF")) { 51 psWarning("No PSFs provided --- unable to convolve to common PSF."); 52 options->convolve = false; 53 } 20 54 21 55 int num = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); // Number of inputs … … 36 70 } 37 71 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; 72 // 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 } 79 80 psString outputName = psStringCopy(psMetadataLookupStr(NULL, config->arguments, 81 "OUTPUT")); // Name for temporary files 82 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 } 88 89 const char *tempImage = psMetadataLookupStr(NULL, recipe, "TEMP.IMAGE"); // Suffix for images 90 const char *tempMask = psMetadataLookupStr(NULL, recipe, "TEMP.MASK"); // Suffix for masks 91 const char *tempVariance = psMetadataLookupStr(NULL, recipe, "TEMP.VARIANCE"); // Suffix for var maps 92 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 } 98 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"); 42 117 } 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 118 78 119 if (!pmConfigMaskSetBits(NULL, NULL, config)) {
Note:
See TracChangeset
for help on using the changeset viewer.
