- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
ppStack/src (modified) (1 prop)
-
ppStack/src/ppStackThread.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/ppStack/src
- Property svn:ignore
-
old new 10 10 stamp-h1 11 11 ppStackVersionDefinitions.h 12 ppStackErrorCodes.c 13 ppStackErrorCodes.h
-
- Property svn:ignore
-
branches/simtest_nebulous_branches/ppStack/src/ppStackThread.c
r24796 r27840 56 56 } 57 57 58 ppStackThreadData *ppStackThreadDataSetup(const ppStackOptions *options, const pmConfig *config )58 ppStackThreadData *ppStackThreadDataSetup(const ppStackOptions *options, const pmConfig *config, bool conv) 59 59 { 60 60 psAssert(options, "Require options"); … … 62 62 63 63 const psArray *cells = options->cells; // Array of input cells 64 const psArray *imageNames = options->imageNames; // Names of images to read65 const psArray *maskNames = options->maskNames; // Names of masks to read66 const psArray *varianceNames = options->varianceNames; // Names of variance maps to read67 const psArray *covariances = options->covariances; // Covariance matrices (already read)64 const psArray *imageNames = conv ? options->convImages : options->origImages; // Names of images to read 65 const psArray *maskNames = conv ? options->convMasks : options->origMasks; // Names of masks to read 66 const psArray *varianceNames = conv ? options->convVariances : options->origVariances; // Variance names 67 const psArray *covariances = conv ? options->convCovars : options->origCovars; // Covariance matrices 68 68 69 69 PS_ASSERT_ARRAY_NON_NULL(cells, NULL); 70 PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, imageNames, NULL); 71 PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, maskNames, NULL); 72 PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, varianceNames, NULL); 73 PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, covariances, NULL); 70 if (imageNames) { 71 PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, imageNames, NULL); 72 } 73 if (maskNames) { 74 PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, maskNames, NULL); 75 } 76 if (varianceNames) { 77 PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, varianceNames, NULL); 78 } 79 if (covariances) { 80 PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, covariances, NULL); 81 } 74 82 75 83 ppStackThreadData *stack = psAlloc(sizeof(ppStackThreadData)); // Thread data, to return … … 87 95 continue; 88 96 } 89 // Resolved names 90 psString imageResolved = pmConfigConvertFilename(imageNames->data[i], config, false, false); 91 psString maskResolved = pmConfigConvertFilename(maskNames->data[i], config, false, false); 92 psString varianceResolved = pmConfigConvertFilename(varianceNames->data[i], config, false, false); 93 stack->imageFits->data[i] = psFitsOpen(imageResolved, "r"); 94 stack->maskFits->data[i] = psFitsOpen(maskResolved, "r"); 95 stack->varianceFits->data[i] = psFitsOpen(varianceResolved, "r"); 96 psFree(imageResolved); 97 psFree(maskResolved); 98 psFree(varianceResolved); 99 if (!stack->imageFits->data[i] || !stack->maskFits->data[i] || !stack->varianceFits->data[i]) { 100 psError(PS_ERR_UNKNOWN, false, "Unable to open convolved files %s, %s, %s", 101 (char*)imageNames->data[i], (char*)maskNames->data[i], (char*)varianceNames->data[i]); 102 return NULL; 103 } 97 98 // Open an image 99 #define IMAGE_OPEN(NAMES, FITS, INDEX) \ 100 if (NAMES) { \ 101 psString resolved = pmConfigConvertFilename((NAMES)->data[INDEX], config, false, false); \ 102 (FITS)->data[INDEX] = psFitsOpen(resolved, "r"); \ 103 if (!(FITS)->data[INDEX]) { \ 104 psError(PPSTACK_ERR_IO, false, "Unable to open file %s", (char*)(NAMES)->data[INDEX]); \ 105 psFree(resolved); \ 106 return NULL; \ 107 } \ 108 psFree(resolved); \ 109 } 110 111 IMAGE_OPEN(imageNames, stack->imageFits, i); 112 IMAGE_OPEN(maskNames, stack->maskFits, i); 113 IMAGE_OPEN(varianceNames, stack->varianceFits, i); 104 114 } 105 115 … … 116 126 } 117 127 pmReadout *ro = pmReadoutAlloc(cell); // Readout for thread 118 ro->covariance = psMemIncrRefCounter(covariances->data[j]); 128 if (covariances) { 129 ro->covariance = psMemIncrRefCounter(covariances->data[j]); 130 } 119 131 readouts->data[j] = ro; 120 132 } … … 140 152 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // Recipe 141 153 if (!recipe) { 142 psError(P S_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSTACK_RECIPE);154 psError(PPSTACK_ERR_CONFIG, false, "Unable to find recipe %s", PPSTACK_RECIPE); 143 155 return NULL; 144 156 } 145 157 int rows = psMetadataLookupS32(NULL, recipe, "ROWS"); // Number of rows to read per chunk 146 158 if (rows <= 0) { 147 psError(P S_ERR_BAD_PARAMETER_VALUE, false, "ROWS is not set in the recipe.");159 psError(PPSTACK_ERR_CONFIG, false, "ROWS is not set in the recipe."); 148 160 return NULL; 149 161 } … … 186 198 psFits *varianceFits = stack->varianceFits->data[i]; // FITS file for variance 187 199 188 189 int zMax = 0; 200 int zMax = 0; 190 201 bool keepReading = false; 191 if (pmReadoutMore(ro, imageFits, 0, &zMax, rows, config)) { 202 203 if (imageFits && pmReadoutMore(ro, imageFits, 0, &zMax, rows, config)) { 192 204 keepReading = true; 193 205 if (!pmReadoutReadChunk(ro, imageFits, 0, NULL, rows, overlap, config)) { 194 psError(PS_ERR_IO, false, "Unable to read chunk %d for file PPSTACK.INPUT %d", 206 psError(PPSTACK_ERR_IO, false, 207 "Unable to read chunk %d for file PPSTACK.INPUT %d", 195 208 numChunk, i); 196 209 *status = false; … … 199 212 } 200 213 201 if ( pmReadoutMoreMask(ro, maskFits, 0, &zMax, rows, config)) {214 if (maskFits && pmReadoutMoreMask(ro, maskFits, 0, &zMax, rows, config)) { 202 215 keepReading = true; 203 216 if (!pmReadoutReadChunkMask(ro, maskFits, 0, NULL, rows, overlap, config)) { 204 psError(PS_ERR_IO, false, "Unable to read chunk %d for file PPSTACK.INPUT.MASK %d", 217 psError(PPSTACK_ERR_IO, false, 218 "Unable to read chunk %d for file PPSTACK.INPUT.MASK %d", 205 219 numChunk, i); 206 220 *status = false; … … 209 223 } 210 224 211 if ( pmReadoutMoreVariance(ro, varianceFits, 0, &zMax, rows, config)) {225 if (varianceFits && pmReadoutMoreVariance(ro, varianceFits, 0, &zMax, rows, config)) { 212 226 keepReading = true; 213 227 if (!pmReadoutReadChunkVariance(ro, varianceFits, 0, NULL, rows, overlap, config)) { 214 psError(P S_ERR_IO, false,228 psError(PPSTACK_ERR_IO, false, 215 229 "Unable to read chunk %d for file PPSTACK.INPUT.VARIANCE %d", 216 230 numChunk, i); … … 263 277 264 278 { 265 psThreadTask *task = psThreadTaskAlloc("PPSTACK_INSPECT", 2);279 psThreadTask *task = psThreadTaskAlloc("PPSTACK_INSPECT", 3); 266 280 task->function = &ppStackInspect; 267 281 psThreadTaskAdd(task); … … 270 284 271 285 { 272 psThreadTask *task = psThreadTaskAlloc("PPSTACK_FINAL_COMBINE", 3);286 psThreadTask *task = psThreadTaskAlloc("PPSTACK_FINAL_COMBINE", 6); 273 287 task->function = &ppStackReadoutFinalThread; 274 288 psThreadTaskAdd(task);
Note:
See TracChangeset
for help on using the changeset viewer.
