Changeset 19231
- Timestamp:
- Aug 26, 2008, 4:56:07 PM (18 years ago)
- Location:
- trunk/ppStack/src
- Files:
-
- 2 edited
-
ppStackArguments.c (modified) (2 diffs)
-
ppStackMatch.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStack/src/ppStackArguments.c
r19172 r19231 135 135 { 136 136 assert(config); 137 // bool mdok; // Status of MD lookup 137 138 // This capability makes things much faster when debugging 139 bool debugStack = false; // Read old convolutions to debug the stacking? 140 int argNum = psArgumentGet(argc, argv, "-debug-stack"); // Argument number 141 if (argNum > 0) { 142 debugStack = true; 143 psArgumentRemove(argNum, &argc, argv); 144 } 138 145 139 146 pmConfigFileSetsMD(config->arguments, &argc, argv, "PPSTACK.SOURCES", "-sources", NULL); … … 203 210 } 204 211 212 psMetadataAddBool(arguments, PS_LIST_TAIL, "PPSTACK.DEBUG.STACK", 0, 213 "Read old convolved images to debug stack?", debugStack); 214 205 215 return true; 206 216 } -
trunk/ppStack/src/ppStackMatch.c
r19210 r19231 15 15 PM_SOURCE_MODE_CR_LIMIT) // Mask to apply to input sources 16 16 17 //#define TESTING 17 //#define TESTING // Enable debugging output 18 19 20 21 #ifdef TESTING 22 // Read a FITS image 23 static bool readImage(psImage **target, // Target for image 24 const char *name, // Name of FITS file 25 const pmConfig *config // Configuration 26 ) 27 { 28 psString resolved = pmConfigConvertFilename(name, config, false, false); // Resolved filename 29 psFits *fits = psFitsOpen(resolved, "r"); 30 psFree(resolved); 31 if (!fits) { 32 psError(PS_ERR_IO, false, "Unable to open previously produced image: %s", name); 33 return false; 34 } 35 psImage *image = psFitsReadImage(fits, psRegionSet(0,0,0,0), 0); // Image of interest 36 if (!image) { 37 psError(PS_ERR_IO, false, "Unable to read previously produced image: %s", name); 38 psFitsClose(fits); 39 return false; 40 } 41 psFitsClose(fits); 42 43 psFree(*target); 44 *target = image; 45 46 return true; 47 } 48 #endif 18 49 19 50 bool ppStackMatch(pmReadout *readout, psArray **regions, psArray **kernels, … … 25 56 assert(config); 26 57 27 pmReadout *output = pmReadoutAlloc(NULL); // Output readout, for holding results temporarily28 29 58 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe 30 59 psAssert(recipe, "We've thrown an error on this before."); … … 54 83 } 55 84 85 #ifdef TESTING 86 // Read previously produced kernel 87 static int numInput = 0; // Index of input file 88 if (psMetadataLookupBool(NULL, config->arguments, "PPSTACK.DEBUG.STACK")) { 89 const char *outName = psMetadataLookupStr(NULL, config->arguments, "OUTPUT"); // Output root 90 assert(outName); 91 // Read convolution kernel 92 { 93 psString filename = NULL; // Output filename 94 psStringAppend(&filename, "%s.%d.kernel", outName, numInput); 95 psString resolved = pmConfigConvertFilename(filename, config, false, false); // Resolved filename 96 psFree(filename); 97 psFits *fits = psFitsOpen(resolved, "r"); // FITS file for subtraction kernel 98 psFree(resolved); 99 if (!fits || !pmReadoutReadSubtractionKernels(readout, fits)) { 100 psError(PS_ERR_IO, false, "Unable to read previously produced kernel"); 101 psFitsClose(fits); 102 numInput++; 103 return false; 104 } 105 psFitsClose(fits); 106 } 107 108 // Read image, mask, weight 109 const char *tempImage = psMetadataLookupStr(NULL, recipe, "TEMP.IMAGE"); // Suffix for image 110 const char *tempMask = psMetadataLookupStr(NULL, recipe, "TEMP.MASK"); // Suffix for mask 111 const char *tempWeight = psMetadataLookupStr(NULL, recipe, "TEMP.WEIGHT"); // Suffix for weight map 112 psString imageName = NULL, maskName = NULL, weightName = NULL; // Names for convolved images 113 psStringAppend(&imageName, "%s.%d.%s", outName, numInput, tempImage); 114 psStringAppend(&maskName, "%s.%d.%s", outName, numInput, tempMask); 115 psStringAppend(&weightName, "%s.%d.%s", outName, numInput, tempWeight); 116 117 if (!readImage(&readout->image, imageName, config) || !readImage(&readout->mask, maskName, config) || 118 !readImage(&readout->weight, weightName, config)) { 119 psError(PS_ERR_IO, false, "Unable to read previously produced image."); 120 psFree(imageName); 121 psFree(maskName); 122 psFree(weightName); 123 numInput++; 124 return false; 125 } 126 psFree(imageName); 127 psFree(maskName); 128 psFree(weightName); 129 130 numInput++; 131 return true; 132 } 133 #endif 134 135 // Normal operations here 136 pmReadout *output = pmReadoutAlloc(NULL); // Output readout, for holding results temporarily 56 137 if (psMetadataLookupBool(&mdok, config->arguments, "HAVE.PSF")) { 57 138 assert(psf); … … 116 197 pmReadout *fake = pmReadoutAlloc(NULL); // Fake readout with target PSF 117 198 118 if (!pmReadoutFakeFromSources(fake, readout->image->numCols, readout->image->numRows, sources, NULL,119 NULL, psf, minFlux, 0, false)) {199 if (!pmReadoutFakeFromSources(fake, readout->image->numCols, readout->image->numRows, sources, 200 NULL, NULL, psf, minFlux, 0, false)) { 120 201 psError(PS_ERR_UNKNOWN, false, "Unable to generate fake image with target PSF."); 121 202 psFree(fake); … … 193 274 194 275 #ifdef TESTING 195 { 196 static int num = 0; // Image counter 197 psString filename = NULL; // Output filename 198 psStringAppend(&filename, "stack_kernel_%d.fits", num++); 199 psFits *fits = psFitsOpen(filename, "w"); // FITS file for subtraction kernel 200 psFree(filename); 201 pmReadoutWriteSubtractionKernels(output, fits); 202 psFitsClose(fits); 203 } 204 #endif 205 206 // Extract the regions and solutions used in the image matching 207 // This stops them from being freed when we iterate back up the FPA 276 { 277 psString filename = NULL; // Output filename 278 psStringAppend(&filename, "stack_kernel_%d.fits", numInput); 279 psFits *fits = psFitsOpen(filename, "w"); // FITS file for subtraction kernel 280 psFree(filename); 281 pmReadoutWriteSubtractionKernels(output, fits); 282 psFitsClose(fits); 283 } 284 #endif 285 286 // Extract the regions and solutions used in the image matching 287 // This stops them from being freed when we iterate back up the FPA 208 288 *regions = psArrayAllocEmpty(ARRAY_BUFFER); // Array of regions 209 289 {
Note:
See TracChangeset
for help on using the changeset viewer.
