Changeset 24557 for branches/eam_branches/20090522/psModules/src/camera
- Timestamp:
- Jun 25, 2009, 2:00:56 PM (17 years ago)
- Location:
- branches/eam_branches/20090522
- Files:
-
- 7 edited
-
. (modified) (1 prop)
-
psModules (modified) (1 prop)
-
psModules/src/camera/pmFPABin.c (modified) (1 diff)
-
psModules/src/camera/pmFPACopy.c (modified) (3 diffs)
-
psModules/src/camera/pmFPAMaskWeight.c (modified) (7 diffs)
-
psModules/src/camera/pmFPAMaskWeight.h (modified) (4 diffs)
-
psModules/src/camera/pmHDU.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090522
- Property svn:mergeinfo changed
-
branches/eam_branches/20090522/psModules
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/eam_branches/20090522/psModules/src/camera/pmFPABin.c
r24003 r24557 65 65 } 66 66 67 float imageValue, maskValue;// Values to set 67 // Values to set 68 float imageValue; 69 psImageMaskType maskValue; 68 70 if (numPix > 0) { 69 71 imageValue = sum / numPix; -
branches/eam_branches/20090522/psModules/src/camera/pmFPACopy.c
r23761 r24557 70 70 psImageBinningSetRuffSize(binning, PS_IMAGE_BINNING_CENTER); 71 71 *target = psImageAlloc(binning->nXruff, binning->nYruff, source->type.type); 72 psImageInit (*target, 0.0); 72 73 return; 73 74 } … … 221 222 psTrace("psModules.camera", 3, "xFlip: %d; yFlip: %d\n", xFlip, yFlip); 222 223 224 // Blow away extant readouts 225 for (int i = 0; i < target->readouts->n; i++) { 226 psFree(target->readouts->data[i]); 227 target->readouts->data[i] = NULL; 228 } 229 target->readouts->n = 0; 230 223 231 // Perform deep copy of the images. I would prefer *not* to do a deep copy, in the interests of speed (we 224 232 // still need to do another deep copy into the HDU for when we write out), but this is the only way I can … … 242 250 readoutCopyComponent(&targetReadout->variance, sourceReadout->variance, binning, xFlip, yFlip, 243 251 pixels); 252 // Copy covariance matrix: doesn't care about flips, etc. 253 if (sourceReadout->covariance) { 254 if (targetReadout->covariance) { 255 psFree(targetReadout->covariance); 256 } 257 targetReadout->covariance = psKernelCopy(sourceReadout->covariance); 258 #if 0 259 if (binning) { 260 // XXX This isn't strictly correct, but we don't have a function that bins covariance matrices 261 // with unequal binning factors. 262 psKernel *covar = psImageCovarianceBin(PS_MAX(binning->nXbin, binning->nYbin), 263 targetReadout->covariance); 264 psFree(targetReadout->covariance); 265 targetReadout->covariance = covar; 266 } 267 #endif 268 } 244 269 245 270 // Copy bias -
branches/eam_branches/20090522/psModules/src/camera/pmFPAMaskWeight.c
r23989 r24557 199 199 } 200 200 201 bool pmReadoutSetVariance(pmReadout *readout, bool poisson)201 bool pmReadoutSetVariance(pmReadout *readout, const psImage *noiseMap, bool poisson) 202 202 { 203 203 PS_ASSERT_PTR_NON_NULL(readout, false); 204 // check that the noiseMap (if it exists) matches the readout variance size) 204 205 205 206 pmCell *cell = readout->parent; // The parent cell … … 228 229 229 230 // a negative variance is non-sensical. if the image value drops below 1, the variance must be 1. 231 // XXX this calculation is wrong: limit is 1 e-, but this is in DN 230 232 readout->variance = (psImage*)psUnaryOp(readout->variance, readout->variance, "abs"); 231 233 readout->variance = (psImage*)psBinaryOp(readout->variance, readout->variance, "max", … … 239 241 } 240 242 241 readout->variance = (psImage*)psBinaryOp(readout->variance, readout->variance, "+", 242 psScalarAlloc(readnoise*readnoise/gain/gain, PS_TYPE_F32)); 243 // apply a supplied readnoise map (NOTE: in DN, not electrons): 244 if (noiseMap) { 245 psImage *rdVar = (psImage*)psBinaryOp(NULL, (const psPtr) noiseMap, "*", (const psPtr) noiseMap); 246 readout->variance = (psImage*)psBinaryOp(readout->variance, readout->variance, "+", rdVar); 247 psFree (rdVar); 248 } else { 249 readout->variance = (psImage*)psBinaryOp(readout->variance, readout->variance, "+", psScalarAlloc(readnoise*readnoise/gain/gain, PS_TYPE_F32)); 250 } 243 251 244 252 return true; … … 247 255 // this function creates the variance pixels, or uses the existing variance pixels. it will set 248 256 // the noise pixel values only if the variance image is not supplied 249 bool pmReadoutGenerateVariance(pmReadout *readout, bool poisson)257 bool pmReadoutGenerateVariance(pmReadout *readout, const psImage *noiseMap, bool poisson) 250 258 { 251 259 PS_ASSERT_PTR_NON_NULL(readout, false); … … 291 299 readout->variance = variance; 292 300 293 return pmReadoutSetVariance(readout, poisson);294 } 295 296 bool pmReadoutGenerateMaskVariance(pmReadout *readout, psImageMaskType satMask, psImageMaskType badMask, bool poisson)301 return pmReadoutSetVariance(readout, noiseMap, poisson); 302 } 303 304 bool pmReadoutGenerateMaskVariance(pmReadout *readout, psImageMaskType satMask, psImageMaskType badMask, const psImage *noiseMap, bool poisson) 297 305 { 298 306 PS_ASSERT_PTR_NON_NULL(readout, false); … … 301 309 302 310 success &= pmReadoutGenerateMask(readout, satMask, badMask); 303 success &= pmReadoutGenerateVariance(readout, poisson);311 success &= pmReadoutGenerateVariance(readout, noiseMap, poisson); 304 312 305 313 return success; 306 314 } 307 315 308 bool pmCellGenerateMaskVariance(pmCell *cell, psImageMaskType satMask, psImageMaskType badMask, bool poisson)316 bool pmCellGenerateMaskVariance(pmCell *cell, psImageMaskType satMask, psImageMaskType badMask, const psImage *noiseMap, bool poisson) 309 317 { 310 318 PS_ASSERT_PTR_NON_NULL(cell, false); … … 314 322 for (int i = 0; i < readouts->n; i++) { 315 323 pmReadout *readout = readouts->data[i]; // The readout 316 success &= pmReadoutGenerateMaskVariance(readout, poisson, satMask, badMask);324 success &= pmReadoutGenerateMaskVariance(readout, satMask, badMask, noiseMap, poisson); 317 325 } 318 326 -
branches/eam_branches/20090522/psModules/src/camera/pmFPAMaskWeight.h
r21363 r24557 54 54 /// can't be generated. 55 55 bool pmReadoutSetVariance(pmReadout *readout, ///< Readout for which to set variance 56 const psImage *noiseMap, ///< 2D image of the read noise in DN 56 57 bool poisson ///< Include poisson variance (in addition to read noise)? 57 58 ); … … 72 73 /// with HDU entry). This is intended for most operations. 73 74 bool pmReadoutGenerateVariance(pmReadout *readout, ///< Readout for which to generate variance 75 const psImage *noiseMap, ///< 2D image of the read noise in DN 74 76 bool poisson ///< Include poisson variance (in addition to read noise)? 75 77 ); … … 81 83 psImageMaskType sat, ///< Mask value to give saturated pixels 82 84 psImageMaskType bad, ///< Mask value to give bad (low) pixels 85 const psImage *noiseMap, ///< 2D image of the read noise in DN 83 86 bool poisson ///< Include poisson variance (in addition to read noise)? 84 87 ); … … 90 93 psImageMaskType sat, ///< Mask value to give saturated pixels 91 94 psImageMaskType bad, ///< Mask value to give bad (low) pixels 95 const psImage *noiseMap, ///< 2D image of the read noise in DN 92 96 bool poisson ///< Include poisson variance (in addition to read noise)? 93 97 ); -
branches/eam_branches/20090522/psModules/src/camera/pmHDU.c
r21363 r24557 93 93 } 94 94 95 psTrace("psModules.camera", 5, "Reading the header...\n"); 96 97 // The header may already exist (e.g., from doing concept writing at the PHU level) so we need to be 98 // careful. We read into a separate container and copy that over the top of anything that's already read. 99 psMetadata *header = psFitsReadHeader(NULL, fits); 100 if (!header) { 101 psError(PS_ERR_IO, false, "Unable to read header for extension %s\n", hdu->extname); 102 return false; 103 } 104 95 105 if (!hdu->header) { 96 psTrace("psModules.camera", 5, "Reading the header...\n"); 97 hdu->header = psFitsReadHeader(hdu->header, fits); 98 if (! hdu->header) { 99 psError(PS_ERR_IO, false, "Unable to read header for extension %s\n", hdu->extname); 100 return false; 101 } 102 } 106 hdu->header = header; 107 return true; 108 } 109 110 psMetadataIterator *iter = psMetadataIteratorAlloc(header, PS_LIST_HEAD, NULL); // Iterator 111 psMetadataItem *item; // Item from iteration 112 while ((item = psMetadataGetAndIncrement(iter))) { 113 const char *name = item->name; // Name of item 114 if (psMetadataLookup(hdu->header, name)) { 115 // It exists; clobber 116 psMetadataRemoveKey(hdu->header, name); 117 } 118 psMetadataAddItem(hdu->header, item, PS_LIST_TAIL, 0); 119 } 120 psFree(iter); 121 psFree(header); 103 122 104 123 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
