Changeset 18289 for trunk/ppSub/src/ppSubReadout.c
- Timestamp:
- Jun 23, 2008, 12:43:11 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ppSub/src/ppSubReadout.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSub/src/ppSubReadout.c
r17835 r18289 12 12 13 13 #define WCS_TOLERANCE 0.001 // Tolerance for WCS 14 //#define TESTING // For test output14 #define TESTING // For test output 15 15 16 16 … … 73 73 int ringsOrder = psMetadataLookupS32(NULL, config->arguments, "RINGS.ORDER"); // RINGS polynomial order 74 74 int binning = psMetadataLookupS32(NULL, config->arguments, "SPAM.BINNING"); // Binning for SPAM kernel 75 float penalty = psMetadataLookupF32(NULL, config->arguments, "PENALTY"); // Penalty for wideness 75 76 psMaskType maskBad = pmConfigMask(psMetadataLookupStr(NULL, config->arguments, "MASK.BAD"), 76 77 config); // Value to mask … … 131 132 132 133 if (!pmSubtractionMatch(inConv, refConv, inRO, refRO, footprint, regionSize, spacing, threshold, sources, 133 stampsName, type, size, order, widths, orders, inner, ringsOrder, 134 binning, optimum, optWidths, optOrder, optThresh, iter, rej, maskBad,134 stampsName, type, size, order, widths, orders, inner, ringsOrder, binning, 135 penalty, optimum, optWidths, optOrder, optThresh, iter, rej, maskBad, 135 136 maskBlank, badFrac, mode)) { 136 137 psError(PS_ERR_UNKNOWN, false, "Unable to match images."); … … 184 185 #endif 185 186 186 // "Subtract" the mask and weight map 187 // Subtraction is: minuend - subtrahend 188 pmReadout *minuend = inConv; 189 pmReadout *subtrahend = refConv; 190 191 if (reverse) { 192 pmReadout *temp = subtrahend; 193 subtrahend = minuend; 194 minuend = temp; 195 } 196 197 #ifdef TESTING 198 { 199 pmReadoutMaskApply(minuend, maskBlank); 200 psFits *fits = psFitsOpen("minuend.fits", "w"); 201 psFitsWriteImage(fits, NULL, minuend->image, 0, NULL); 202 psFitsClose(fits); 203 } 204 { 205 pmReadoutMaskApply(subtrahend, maskBlank); 206 psFits *fits = psFitsOpen("subtrahend.fits", "w"); 207 psFitsWriteImage(fits, NULL, subtrahend->image, 0, NULL); 208 psFitsClose(fits); 209 } 210 #endif 211 187 212 outRO->mask = (psImage*)psBinaryOp(outRO->mask, inConv->mask, "|", refConv->mask); 188 if (inConv->weight && refConv->weight) { 189 outRO->weight = (psImage*)psBinaryOp(outRO->weight, inConv->weight, "+", refConv->weight); 190 } 191 outRO->data_exists = outCell->data_exists = outCell->parent->data_exists = true; 213 outRO->data_exists = outCell->data_exists = outCell->parent->data_exists = true; // It'll be there soon 192 214 193 215 // Photometry is to be performed in two stages: … … 198 220 pmPSF *psf = NULL; // PSF for photometry 199 221 if (psMetadataLookupBool(NULL, config->arguments, "PHOTOMETRY")) { 200 // We use a summed image as the basis for the PSF: this will have the maximum S/N. 201 outRO->image = (psImage*)psBinaryOp(outRO->image, inConv->image, "+", refConv->image); 222 outRO->image = psImageCopy(outRO->image, minuend->image, PS_TYPE_F32); 223 if (minuend->weight) { 224 outRO->weight = psImageCopy(outRO->weight, minuend->weight, PS_TYPE_F32); 225 } 202 226 203 227 pmFPAfile *photFile = psMetadataLookupPtr(NULL, config->files, "PSPHOT.INPUT"); … … 244 268 } 245 269 246 // Do the subtraction 247 { 248 // Subtraction is: minuend - subtrahend 249 pmReadout *minuend = inConv; 250 pmReadout *subtrahend = refConv; 251 252 if (reverse) { 253 pmReadout *temp = subtrahend; 254 subtrahend = minuend; 255 minuend = temp; 256 } 257 258 outRO->image = (psImage*)psBinaryOp(outRO->image, minuend->image, "-", subtrahend->image); 259 260 #ifdef TESTING 261 { 262 psFits *fits = psFitsOpen("minuend.fits", "w"); 263 psFitsWriteImage(fits, NULL, minuend->image, 0, NULL); 264 psFitsClose(fits); 265 } 266 { 267 psFits *fits = psFitsOpen("subtrahend.fits", "w"); 268 psFitsWriteImage(fits, NULL, subtrahend->image, 0, NULL); 269 psFitsClose(fits); 270 } 271 #endif 272 273 pmReadoutMaskApply(outRO, maskBlank); 274 } 270 // Do the actual subtraction 271 outRO->image = (psImage*)psBinaryOp(outRO->image, minuend->image, "-", subtrahend->image); 272 if (inConv->weight && refConv->weight) { 273 outRO->weight = (psImage*)psBinaryOp(outRO->weight, inConv->weight, "+", refConv->weight); 274 } 275 outRO->data_exists = outCell->data_exists = outCell->parent->data_exists = true; 276 277 pmReadoutMaskApply(outRO, maskBlank); 275 278 276 279 psFree(inConv); … … 304 307 } 305 308 306 psTraceSetLevel("psphot", 6);307 308 309 // Photometry stage 2: find and measure sources on the subtracted image 309 310 if (psMetadataLookupBool(NULL, config->arguments, "PHOTOMETRY")) { … … 314 315 pmReadout *psfRO = pmFPAfileThisReadout(config->files, view, "PSPHOT.PSF.LOAD"); 315 316 if (!psfRO) { 316 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find file PSPHOT.PSF.LOAD");317 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find readout for file PSPHOT.PSF.LOAD"); 317 318 return false; 318 319 }
Note:
See TracChangeset
for help on using the changeset viewer.
