- Timestamp:
- Oct 2, 2009, 5:10:19 PM (17 years ago)
- Location:
- branches/eam_branches/20090820
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ppStack/src/ppStackMatch.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090820
- Property svn:mergeinfo changed
-
branches/eam_branches/20090820/ppStack/src/ppStackMatch.c
r25045 r25766 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 sources17 #define FAINT_SOURCE_FRAC 1.0e-4 // Set minimum flux to this fraction of faintest source flux16 PM_SOURCE_MODE_CR_LIMIT | PM_SOURCE_MODE_EXT_LIMIT) // Mask to apply to input sources 17 #define NOISE_FRACTION 0.01 // Set minimum flux to this fraction of noise 18 18 #define COVAR_FRAC 0.01 // Truncation fraction for covariance matrix 19 19 … … 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) … … 232 266 psRegion *region = psMetadataLookupPtr(NULL, conv->analysis, 233 267 PM_SUBTRACTION_ANALYSIS_REGION); // Convolution region 234 235 pmSubtractionAnalysis(readout->analysis, kernels, region, 268 pmSubtractionKernels *kernels = psMetadataLookupPtr(NULL, conv->analysis, 269 PM_SUBTRACTION_ANALYSIS_KERNEL); 270 271 pmSubtractionAnalysis(readout->analysis, NULL, kernels, region, 236 272 readout->image->numCols, readout->image->numRows); 237 273 … … 283 319 pmReadout *fake = pmReadoutAlloc(NULL); // Fake readout with target PSF 284 320 321 psStats *bg = psStatsAlloc(PS_STAT_ROBUST_STDEV); // Statistics for background 322 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 323 if (!psImageBackground(bg, NULL, readout->image, readout->mask, maskVal | maskBad, rng)) { 324 psError(PS_ERR_UNKNOWN, false, "Can't measure background for image."); 325 psFree(fake); 326 psFree(optWidths); 327 psFree(conv); 328 psFree(bg); 329 psFree(rng); 330 return false; 331 } 332 float minFlux = NOISE_FRACTION * bg->robustStdev; // Minimum flux level for fake image 333 psFree(rng); 334 psFree(bg); 335 285 336 // For the sake of stamps, remove nearby sources 286 337 psArray *stampSources = stackSourcesFilter(options->sourceLists->data[index], … … 288 339 289 340 if (!pmReadoutFakeFromSources(fake, readout->image->numCols, readout->image->numRows, 290 stampSources, NULL, NULL, options->psf, NAN, footprint + size,291 false, true)) {341 stampSources, SOURCE_MASK, NULL, NULL, options->psf, 342 minFlux, footprint + size, false, true)) { 292 343 psError(PS_ERR_UNKNOWN, false, "Unable to generate fake image with target PSF."); 293 344 psFree(fake); … … 335 386 PM_SUBTRACTION_ANALYSIS_KERNEL); // Conv kernel 336 387 if (kernel) { 337 if (!pmSubtractionMatchPrecalc( conv, NULL, readout, fake, readout->analysis,388 if (!pmSubtractionMatchPrecalc(NULL, conv, fake, readout, readout->analysis, 338 389 stride, sysError, maskVal, maskBad, maskPoor, 339 390 poorFrac, badFrac)) { … … 349 400 } 350 401 } else { 351 if (!pmSubtractionMatch( conv, NULL, readout, fake, footprint, stride, regionSize, spacing,402 if (!pmSubtractionMatch(NULL, conv, fake, readout, footprint, stride, regionSize, spacing, 352 403 threshold, stampSources, stampsName, type, size, order, widths, 353 404 orders, inner, ringsOrder, binning, penalty, 354 405 optimum, optWidths, optOrder, optThresh, iter, rej, sysError, 355 406 maskVal, maskBad, maskPoor, poorFrac, badFrac, 356 PM_SUBTRACTION_MODE_ 1)) {407 PM_SUBTRACTION_MODE_2)) { 357 408 psError(PS_ERR_UNKNOWN, false, "Unable to match images."); 358 409 psFree(fake); … … 502 553 } 503 554 555 if (!stackRenormaliseReadout(config, readout)) { 556 psFree(rng); 557 psFree(bg); 558 return false; 559 } 504 560 505 561 // Measure the variance level for the weighting
Note:
See TracChangeset
for help on using the changeset viewer.
