Changeset 25788
- Timestamp:
- Oct 6, 2009, 1:19:44 PM (17 years ago)
- Location:
- branches/pap/ppStack/src
- Files:
-
- 8 edited
-
ppStackCleanup.c (modified) (1 diff)
-
ppStackConvolve.c (modified) (1 diff)
-
ppStackLoop.c (modified) (4 diffs)
-
ppStackOptions.c (modified) (2 diffs)
-
ppStackOptions.h (modified) (1 diff)
-
ppStackSetup.c (modified) (3 diffs)
-
ppStackThread.c (modified) (7 diffs)
-
ppStackThread.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap/ppStack/src/ppStackCleanup.c
r23341 r25788 74 74 75 75 if (tempDelete) { 76 psString imageResolved = pmConfigConvertFilename(options-> imageNames->data[i],76 psString imageResolved = pmConfigConvertFilename(options->convImages->data[i], 77 77 config, false, false); 78 psString maskResolved = pmConfigConvertFilename(options-> maskNames->data[i],78 psString maskResolved = pmConfigConvertFilename(options->convMasks->data[i], 79 79 config, false, false); 80 psString varianceResolved = pmConfigConvertFilename(options-> varianceNames->data[i],80 psString varianceResolved = pmConfigConvertFilename(options->convVariances->data[i], 81 81 config, false, false); 82 82 if (unlink(imageResolved) == -1 || unlink(maskResolved) == -1 || -
branches/pap/ppStack/src/ppStackConvolve.c
r23602 r25788 114 114 pmHDU *hdu = readout->parent->parent->parent->hdu; // HDU for convolved image 115 115 assert(hdu); 116 ppStackWriteImage(options-> imageNames->data[i], hdu->header, readout->image, config);116 ppStackWriteImage(options->convImages->data[i], hdu->header, readout->image, config); 117 117 psMetadata *maskHeader = psMetadataCopy(NULL, hdu->header); // Copy of header, for mask 118 118 pmConfigMaskWriteHeader(config, maskHeader); 119 ppStackWriteImage(options-> maskNames->data[i], maskHeader, readout->mask, config);119 ppStackWriteImage(options->convMasks->data[i], maskHeader, readout->mask, config); 120 120 psFree(maskHeader); 121 121 psImageCovarianceTransfer(readout->variance, readout->covariance); 122 ppStackWriteImage(options-> varianceNames->data[i], hdu->header, readout->variance, config);122 ppStackWriteImage(options->convVariances->data[i], hdu->header, readout->variance, config); 123 123 #ifdef TESTING 124 124 { -
branches/pap/ppStack/src/ppStackLoop.c
r25738 r25788 56 56 // Start threading 57 57 ppStackThreadInit(); 58 ppStackThreadData *stack = ppStackThreadDataSetup(options, config );58 ppStackThreadData *stack = ppStackThreadDataSetup(options, config, true); 59 59 if (!stack) { 60 60 psError(PS_ERR_IO, false, "Unable to initialise stack threads."); … … 122 122 123 123 124 #if 1 125 // Unconvolved stack --- it's cheap to calculate, compared to everything else! 126 if (options->convolve) { 127 // Start threading 128 ppStackThreadData *stack = ppStackThreadDataSetup(options, config, false); 129 if (!stack) { 130 psError(PS_ERR_IO, false, "Unable to initialise stack threads."); 131 psFree(options); 132 return false; 133 } 134 psFree(options->cells); options->cells = NULL; 135 psTrace("ppStack", 2, "Final stack of convolved images....\n"); 136 if (!ppStackCombineFinal(stack, options, config)) { 137 psError(PS_ERR_UNKNOWN, false, "Unable to perform final combination."); 138 psFree(stack); 139 psFree(options); 140 return false; 141 } 142 psLogMsg("ppStack", PS_LOG_INFO, "Stage 7: Unconvolved Stack: %f sec", psTimerClear("PPSTACK_STEPS")); 143 ppStackMemDump("unconv"); 144 145 psFree(stack); 146 } 147 #endif 148 124 149 // Photometry 125 150 psTrace("ppStack", 1, "Photometering stacked image....\n"); … … 129 154 return false; 130 155 } 131 psLogMsg("ppStack", PS_LOG_INFO, "Stage 7: Photometry Analysis: %f sec", psTimerClear("PPSTACK_STEPS"));156 psLogMsg("ppStack", PS_LOG_INFO, "Stage 8: Photometry Analysis: %f sec", psTimerClear("PPSTACK_STEPS")); 132 157 ppStackMemDump("photometry"); 133 158 … … 140 165 return false; 141 166 } 142 psLogMsg("ppStack", PS_LOG_INFO, "Stage 8: Final output: %f sec", psTimerClear("PPSTACK_STEPS"));167 psLogMsg("ppStack", PS_LOG_INFO, "Stage 9: Final output: %f sec", psTimerClear("PPSTACK_STEPS")); 143 168 ppStackMemDump("finish"); 144 169 -
branches/pap/ppStack/src/ppStackOptions.c
r25787 r25788 12 12 fclose(options->statsFile); 13 13 } 14 psFree(options->imageNames); 15 psFree(options->maskNames); 16 psFree(options->varianceNames); 14 psFree(options->origImages); 15 psFree(options->convImages); 16 psFree(options->convMasks); 17 psFree(options->convVariances); 17 18 psFree(options->psf); 18 19 psFree(options->inputMask); … … 40 41 options->stats = NULL; 41 42 options->statsFile = NULL; 42 options->imageNames = NULL; 43 options->maskNames = NULL; 44 options->varianceNames = NULL; 43 options->origImages = NULL; 44 options->convImages = NULL; 45 options->convMasks = NULL; 46 options->convVariances = NULL; 45 47 options->num = 0; 46 48 options->psf = NULL; -
branches/pap/ppStack/src/ppStackOptions.h
r25787 r25788 11 11 psMetadata *stats; // Statistics for output 12 12 FILE *statsFile; // File to which to write statistics 13 psArray *imageNames, *maskNames, *varianceNames; // Filenames for the temporary convolved images 13 psArray *origImages; // Filenames of the original images 14 psArray *convImages, *convMasks, *convVariances; // Filenames for the temporary convolved images 14 15 int num; // Number of inputs 15 16 // Prepare -
branches/pap/ppStack/src/ppStackSetup.c
r23688 r25788 46 46 } 47 47 48 // Original images 49 options->origImages = psArrayAlloc(num); 50 for (int i = 0; i < num; i++) { 51 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT", i); // File of interest 52 options->origImages->data[i] = psStringCopy(file->name); 53 } 54 48 55 // Generate temporary names for convolved images 49 56 const char *tempDir = psMetadataLookupStr(NULL, recipe, "TEMP.DIR"); // Directory for temporary images … … 72 79 } 73 80 74 options-> imageNames = psArrayAlloc(num);75 options-> maskNames = psArrayAlloc(num);76 options-> varianceNames = psArrayAlloc(num);81 options->convImages = psArrayAlloc(num); 82 options->convMasks = psArrayAlloc(num); 83 options->convVariances = psArrayAlloc(num); 77 84 for (int i = 0; i < num; i++) { 78 85 psString imageName = NULL, maskName = NULL, varianceName = NULL; // Names for convolved images … … 81 88 psStringAppend(&varianceName, "%s/%s.%d.%s", tempDir, tempName, i, tempVariance); 82 89 psTrace("ppStack", 5, "Temporary files: %s %s %s\n", imageName, maskName, varianceName); 83 options-> imageNames->data[i] = imageName;84 options-> maskNames->data[i] = maskName;85 options-> varianceNames->data[i] = varianceName;90 options->convImages->data[i] = imageName; 91 options->convMasks->data[i] = maskName; 92 options->convVariances->data[i] = varianceName; 86 93 } 87 94 psFree(outputName); -
branches/pap/ppStack/src/ppStackThread.c
r24796 r25788 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 : NULL; // Names of masks to read 66 const psArray *varianceNames = conv ? options->convVariances : NULL; // Names of variance maps to read 67 const psArray *covariances = conv ? options->covariances : NULL; // Covariance matrices (already read) 68 68 69 69 PS_ASSERT_ARRAY_NON_NULL(cells, NULL); 70 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); 71 if (conv) { 72 PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, maskNames, NULL); 73 PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, varianceNames, NULL); 74 PS_ASSERT_ARRAYS_SIZE_EQUAL(cells, covariances, NULL); 75 } 74 76 75 77 ppStackThreadData *stack = psAlloc(sizeof(ppStackThreadData)); // Thread data, to return … … 87 89 continue; 88 90 } 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 } 91 92 // Open an image 93 #define IMAGE_OPEN(NAME, FITS) \ 94 if (NAME) { \ 95 psString resolved = pmConfigConvertFilename(NAME, config, false, false); \ 96 FITS = psFitsOpen(resolved, "r"); \ 97 if (!(FITS)) { \ 98 psError(PS_ERR_IO, false, "Unable to open file %s", (char*)(NAME)); \ 99 psFree(resolved); \ 100 return NULL; \ 101 } \ 102 psFree(resolved); \ 103 } 104 105 IMAGE_OPEN(imageNames->data[i], stack->imageFits->data[i]); 106 IMAGE_OPEN(maskNames->data[i], stack->maskFits->data[i]); 107 IMAGE_OPEN(varianceNames->data[i], stack->varianceFits->data[i]); 104 108 } 105 109 … … 116 120 } 117 121 pmReadout *ro = pmReadoutAlloc(cell); // Readout for thread 118 ro->covariance = psMemIncrRefCounter(covariances->data[j]); 122 if (conv) { 123 ro->covariance = psMemIncrRefCounter(covariances->data[j]); 124 } 119 125 readouts->data[j] = ro; 120 126 } … … 187 193 188 194 189 int zMax = 0;195 int zMax = 0; 190 196 bool keepReading = false; 191 if (pmReadoutMore(ro, imageFits, 0, &zMax, rows, config)) { 197 198 if (imageFits && pmReadoutMore(ro, imageFits, 0, &zMax, rows, config)) { 192 199 keepReading = true; 193 200 if (!pmReadoutReadChunk(ro, imageFits, 0, NULL, rows, overlap, config)) { … … 199 206 } 200 207 201 if ( pmReadoutMoreMask(ro, maskFits, 0, &zMax, rows, config)) {208 if (maskFits && pmReadoutMoreMask(ro, maskFits, 0, &zMax, rows, config)) { 202 209 keepReading = true; 203 210 if (!pmReadoutReadChunkMask(ro, maskFits, 0, NULL, rows, overlap, config)) { … … 209 216 } 210 217 211 if ( pmReadoutMoreVariance(ro, varianceFits, 0, &zMax, rows, config)) {218 if (varianceFits && pmReadoutMoreVariance(ro, varianceFits, 0, &zMax, rows, config)) { 212 219 keepReading = true; 213 220 if (!pmReadoutReadChunkVariance(ro, varianceFits, 0, NULL, rows, overlap, config)) { -
branches/pap/ppStack/src/ppStackThread.h
r23341 r25788 35 35 ppStackThreadData *ppStackThreadDataSetup( 36 36 const ppStackOptions *options, // Options 37 const pmConfig *config // Configuration 37 const pmConfig *config, // Configuration 38 bool conv // Use convolved products? 38 39 ); 39 40
Note:
See TracChangeset
for help on using the changeset viewer.
