Changeset 25406 for branches/eam_branches/20090715/ppStack
- Timestamp:
- Sep 15, 2009, 4:02:42 PM (17 years ago)
- Location:
- branches/eam_branches/20090715/ppStack/src
- Files:
-
- 3 edited
-
ppStackCombineFinal.c (modified) (1 diff)
-
ppStackMatch.c (modified) (8 diffs)
-
ppStackSources.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090715/ppStack/src/ppStackCombineFinal.c
r23769 r25406 56 56 } 57 57 psKernel *covar = options->covariances->data[i]; // Covariance matrix 58 if (!covar) { 59 continue; 60 } 58 61 float weight = options->weightings->data.F32[i]; // Weight to apply 59 62 psBinaryOp(covar->image, covar->image, "*", psScalarAlloc(weight, PS_TYPE_F32)); 60 63 sumWeights += weight; 61 64 } 62 pmReadout *outRO = options->outRO; // Output readout 63 outRO->covariance = psImageCovarianceSum(options->covariances); 64 psBinaryOp(outRO->covariance->image, outRO->covariance->image, "/", 65 psScalarAlloc(sumWeights, PS_TYPE_F32)); 66 psFree(options->covariances); options->covariances = NULL; 67 psImageCovarianceTransfer(outRO->variance, outRO->covariance); 65 if (sumWeights > 0.0) { 66 pmReadout *outRO = options->outRO; // Output readout 67 outRO->covariance = psImageCovarianceSum(options->covariances); 68 psBinaryOp(outRO->covariance->image, outRO->covariance->image, "/", 69 psScalarAlloc(sumWeights, PS_TYPE_F32)); 70 psFree(options->covariances); options->covariances = NULL; 71 psImageCovarianceTransfer(outRO->variance, outRO->covariance); 72 } 68 73 69 74 #ifdef TESTING -
branches/eam_branches/20090715/ppStack/src/ppStackMatch.c
r25022 r25406 14 14 #define FAKE_SIZE 1 // Size of fake convolution kernel 15 15 #define SOURCE_MASK (PM_SOURCE_MODE_FAIL | PM_SOURCE_MODE_DEFECT | PM_SOURCE_MODE_SATURATED | \ 16 PM_SOURCE_MODE_CR_LIMIT ) // Mask to apply to input sources16 PM_SOURCE_MODE_CR_LIMIT | PM_SOURCE_MODE_EXT_LIMIT) // Mask to apply to input sources 17 17 #define FAINT_SOURCE_FRAC 1.0e-4 // Set minimum flux to this fraction of faintest source flux 18 18 #define COVAR_FRAC 0.01 // Truncation fraction for covariance matrix … … 87 87 x->n = y->n = numGood; 88 88 89 psTree *tree = psTreePlant(2, 2, x, y); // kd tree89 psTree *tree = psTreePlant(2, 2, PS_TREE_EUCLIDEAN, x, y); // kd tree 90 90 91 91 psArray *filtered = psArrayAllocEmpty(numGood); // Filtered list of sources … … 162 162 } 163 163 164 // Renormalise a readout's variance map 165 bool stackRenormaliseReadout(const pmConfig *config, // Configuration 166 pmReadout *readout // Readout to renormalise 167 ) 168 { 169 bool mdok; // Status of metadata lookups 170 171 psMetadata *recipe = psMetadataLookupPtr(NULL, config->recipes, PPSTACK_RECIPE); // Recipe for ppStack 172 psAssert(recipe, "Need PPSTACK recipe"); 173 174 if (!psMetadataLookupBool(&mdok, recipe, "RENORM")) return true; 175 176 int num = psMetadataLookupS32(&mdok, recipe, "RENORM.NUM"); 177 if (!mdok) { 178 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "RENORM.NUM is not set in the recipe"); 179 return false; 180 } 181 float minValid = psMetadataLookupF32(&mdok, recipe, "RENORM.MIN"); 182 if (!mdok) { 183 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "RENORM.MIN is not set in the recipe"); 184 return false; 185 } 186 float maxValid = psMetadataLookupF32(&mdok, recipe, "RENORM.MAX"); 187 if (!mdok) { 188 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "RENORM.MAX is not set in the recipe"); 189 return false; 190 } 191 192 psImageMaskType maskBad = pmConfigMaskGet("BLANK", config); // Bits to mask 193 194 return pmReadoutVarianceRenormalise(readout, maskBad, num, minValid, maxValid); 195 } 196 197 164 198 165 199 bool ppStackMatch(pmReadout *readout, ppStackOptions *options, int index, const pmConfig *config) … … 222 256 } 223 257 psFitsClose(fits); 224 225 // Add in variance factor226 pmSubtractionKernels *kernels = psMetadataLookupPtr(NULL, conv->analysis,227 PM_SUBTRACTION_ANALYSIS_KERNEL); // Kernels228 float vf = pmSubtractionVarianceFactor(kernels, 0.0, 0.0, false); // Variance factor229 psMetadataItem *vfItem = psMetadataLookup(readout->parent->concepts, "CELL.VARFACTOR");230 if (!isfinite(vf)) {231 vf = 1.0;232 }233 if (isfinite(vfItem->data.F32)) {234 vfItem->data.F32 *= vf;235 } else {236 vfItem->data.F32 = vf;237 }238 258 239 259 if (!readImage(&readout->image, options->imageNames->data[index], config) || … … 302 322 303 323 if (!pmReadoutFakeFromSources(fake, readout->image->numCols, readout->image->numRows, 304 stampSources, NULL, NULL, options->psf, NAN, footprint + size,305 false, true)) {324 stampSources, SOURCE_MASK, NULL, NULL, options->psf, 325 NAN, footprint + size, false, true)) { 306 326 psError(PS_ERR_UNKNOWN, false, "Unable to generate fake image with target PSF."); 307 327 psFree(fake); … … 413 433 } 414 434 415 // Set the variance factor416 psMetadataItem *vfItem = psMetadataLookup(readout->parent->concepts, "CELL.VARFACTOR");417 float vf = psMetadataLookupF32(NULL, conv->analysis, PM_SUBTRACTION_ANALYSIS_VARFACTOR_1);418 if (!isfinite(vf)) {419 vf = 1.0;420 }421 if (isfinite(vfItem->data.F32)) {422 vfItem->data.F32 *= vf;423 } else {424 vfItem->data.F32 = vf;425 }426 427 435 // Replace original images with convolved 428 436 psFree(readout->image); … … 512 520 psBinaryOp(readout->variance, readout->variance, "*", psScalarAlloc(PS_SQR(norm), PS_TYPE_F32)); 513 521 } 514 522 515 523 // Ensure the background value is zero 516 524 psStats *bg = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics for background … … 521 529 } else { 522 530 if (!psMetadataLookupBool(NULL, config->arguments, "PPSTACK.SKIP.BG.SUB")) { 523 psLogMsg("ppStack", PS_LOG_INFO, "Correcting convolved image background by %lf (+/- %lf)",524 psStatsGetValue(bg, PS_STAT_ROBUST_MEDIAN), psStatsGetValue(bg, PS_STAT_ROBUST_STDEV));525 (void)psBinaryOp(readout->image, readout->image, "-",526 psScalarAlloc(psStatsGetValue(bg, PS_STAT_ROBUST_MEDIAN), PS_TYPE_F32));531 psLogMsg("ppStack", PS_LOG_INFO, "Correcting convolved image background by %lf (+/- %lf)", 532 psStatsGetValue(bg, PS_STAT_ROBUST_MEDIAN), psStatsGetValue(bg, PS_STAT_ROBUST_STDEV)); 533 (void)psBinaryOp(readout->image, readout->image, "-", 534 psScalarAlloc(psStatsGetValue(bg, PS_STAT_ROBUST_MEDIAN), PS_TYPE_F32)); 527 535 } 528 536 } 529 537 538 if (!stackRenormaliseReadout(config, readout)) { 539 psFree(rng); 540 psFree(bg); 541 return false; 542 } 530 543 531 544 // Measure the variance level for the weighting -
branches/eam_branches/20090715/ppStack/src/ppStackSources.c
r23573 r25406 123 123 pmReadout *fake = pmReadoutAlloc(NULL); // Fake readout 124 124 pmPSF *psf = psMetadataLookupPtr(NULL, config->arguments, "PSF.TARGET"); // PSF for fake image 125 pmReadoutFakeFromSources(fake, FAKE_COLS, FAKE_ROWS, sourceLists->data[i], 125 pmReadoutFakeFromSources(fake, FAKE_COLS, FAKE_ROWS, sourceLists->data[i], 0, 126 126 NULL, NULL, psf, 5, 0, false, true); 127 127 psString name = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.
