- Timestamp:
- Mar 1, 2011, 6:21:28 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110213/psModules/src/objects/pmSourcePhotometry.c
r30763 r30772 23 23 #include "pmFPAMaskWeight.h" 24 24 25 #include "pmConfigMask.h" 25 26 #include "pmTrend2D.h" 26 27 #include "pmResiduals.h" … … 49 50 static float AP_MIN_SN = 0.0; 50 51 51 bool pmSourceMagnitudesInit (psMetadata *config) 52 { 53 PS_ASSERT_PTR_NON_NULL(config, false); 52 // make this a bit more clever and dynamic 53 static psImageMaskType maskSuspect = 0; 54 static psImageMaskType maskSpike = 0; 55 static psImageMaskType maskStarCore = 0; 56 static psImageMaskType maskBurntool = 0; 57 static psImageMaskType maskConvPoor = 0; 58 59 bool pmSourceMagnitudesInit (pmConfig *config, psMetadata *recipe) 60 { 61 PS_ASSERT_PTR_NON_NULL(recipe, false); 54 62 bool status; 55 63 56 float limit = psMetadataLookupF32 (&status, config, "AP_MIN_SN"); 64 // we are going to test specially against these poor values 65 if (config) { 66 maskSpike = pmConfigMaskGet("SPIKE", config); 67 maskStarCore = pmConfigMaskGet("STARCORE", config); 68 maskBurntool = pmConfigMaskGet("BURNTOOL", config); 69 maskConvPoor = pmConfigMaskGet("CONV.POOR", config); 70 maskSuspect = maskSpike | maskStarCore | maskBurntool | maskConvPoor; 71 } 72 73 float limit = psMetadataLookupF32 (&status, recipe, "AP_MIN_SN"); 57 74 if (status) { 58 75 AP_MIN_SN = limit; … … 77 94 // XXX masked region should be (optionally) elliptical 78 95 // if mode is PM_SOURCE_PHOT_PSFONLY, we skip all other magnitudes 79 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psImageMaskType maskVal, psImageMaskType markVal )96 bool pmSourceMagnitudes (pmSource *source, pmPSF *psf, pmSourcePhotometryMode mode, psImageMaskType maskVal, psImageMaskType markVal, float radius) 80 97 { 81 98 PS_ASSERT_PTR_NON_NULL(source, false); … … 166 183 // measure the contribution of included pixels 167 184 if (mode & PM_SOURCE_PHOT_WEIGHT) { 168 pmSourcePixelWeight ( &source->pixWeightNotBad, &source->pixWeightNotPoor, model, source->maskObj, maskVal, markVal);185 pmSourcePixelWeight (source, model, source->maskObj, maskVal, radius); 169 186 } 170 187 … … 342 359 343 360 // return source aperture magnitude 344 bool pmSourcePixelWeight (float *pixWeightNotBad, float *pixWeightNotPoor, pmModel *model, psImage *mask, psImageMaskType maskVal, psImageMaskType markVal) 345 { 346 PS_ASSERT_PTR_NON_NULL(pixWeightNotBad, false); 347 PS_ASSERT_PTR_NON_NULL(pixWeightNotPoor, false); 361 bool pmSourcePixelWeight (pmSource *source, pmModel *model, psImage *mask, psImageMaskType maskVal, float radius) 362 { 363 PS_ASSERT_PTR_NON_NULL(source, false); 364 source->pixWeightNotBad = NAN; 365 source->pixWeightNotPoor = NAN; 366 348 367 PS_ASSERT_PTR_NON_NULL(mask, false); 349 368 PS_ASSERT_PTR_NON_NULL(model, false); … … 355 374 float value; 356 375 376 float spikeSum = 0; 377 float starcoreSum = 0; 378 float burntoolSum = 0; 379 float convpoorSum = 0; 380 357 381 int Xo, Yo, dP; 358 382 int dX, DX, NX; 359 383 int dY, DY, NY; 360 384 361 *pixWeightNotBad = 0.0; 362 *pixWeightNotPoor = 0.0; 385 float radius2 = PS_SQR(radius); 363 386 364 387 // we only care about the value of the object model, not the local sky … … 387 410 NY = mask->numRows; 388 411 412 psImageMaskType maskBad = maskVal; 413 maskBad &= ~maskSuspect; 414 389 415 // measure modelSum and validSum. this function is applied to a sources' subimage. the 390 416 // value of DX is chosen (see above) to cover the full possible size of the subimage if it 391 417 // were not by an edge; ie, if the source is cut in half by an image edge, we correctly 392 418 // count the virtual pixels off the edge in normalizing the value of the pixWeight 419 420 // we skip any pixels [real or virtual] outside of the specified radius (nominally the aperture radius) 393 421 for (int ix = -DX; ix < DX + 1; ix++) { 422 if (ix > radius) continue; 394 423 int mx = ix + dX; 395 424 for (int iy = -DY; iy < DY + 1; iy++) { 425 if (iy > radius) continue; 426 if (ix*ix + iy*iy > radius2) continue; 396 427 int my = iy + dY; 397 428 … … 409 440 if (my >= NY) continue; 410 441 411 if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskVal)) { 442 // count pixels which are masked only with bad pixels 443 if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskBad)) { 412 444 notBadSum += value; 413 445 } 414 if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & ~markVal)) { 446 447 // count pixels which are masked with an mask bit (bad or poor) 448 if (!(mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskVal)) { 415 449 notPoorSum += value; 416 450 } 451 452 // count pixels which are masked with an mask bit (bad or poor) 453 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskSpike) { 454 spikeSum += value; 455 } 456 // count pixels which are masked with an mask bit (bad or poor) 457 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskStarCore) { 458 starcoreSum += value; 459 } 460 // count pixels which are masked with an mask bit (bad or poor) 461 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskBurntool) { 462 burntoolSum += value; 463 } 464 // count pixels which are masked with an mask bit (bad or poor) 465 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[my][mx] & maskConvPoor) { 466 convpoorSum += value; 467 } 417 468 } 418 469 } 419 470 psFree (coord); 420 471 421 *pixWeightNotBad = notBadSum / modelSum; 422 *pixWeightNotPoor = notPoorSum / modelSum; 423 424 if (false && isfinite(*pixWeightNotBad) && isfinite(*pixWeightNotPoor)) { 425 psAssert (*pixWeightNotBad <= *pixWeightNotPoor, "error: all bad pixels should also be poor"); 472 source->pixWeightNotBad = notBadSum / modelSum; 473 source->pixWeightNotPoor = notPoorSum / modelSum; 474 475 if ((spikeSum/modelSum) > 0.25) { 476 source->mode2 |= PM_SOURCE_MODE2_ON_SPIKE; 477 } 478 if ((starcoreSum/modelSum) > 0.25) { 479 source->mode2 |= PM_SOURCE_MODE2_ON_STARCORE; 480 } 481 if ((burntoolSum/modelSum) > 0.25) { 482 source->mode2 |= PM_SOURCE_MODE2_ON_BURNTOOL; 483 } 484 if ((convpoorSum/modelSum) > 0.25) { 485 source->mode2 |= PM_SOURCE_MODE2_ON_CONVPOOR; 486 } 487 488 if (isfinite(source->pixWeightNotBad) && isfinite(source->pixWeightNotPoor)) { 489 psAssert (source->pixWeightNotBad <= source->pixWeightNotPoor, "error: all bad pixels should also be poor"); 426 490 } 427 491 … … 431 495 # define FLUX_LIMIT 3.0 432 496 433 // measure stats that may be us ingin difference images for distinguishing real sources from bad residuals497 // measure stats that may be used in difference images for distinguishing real sources from bad residuals 434 498 bool pmSourceMeasureDiffStats (pmSource *source, psImageMaskType maskVal, psImageMaskType markVal) 435 499 {
Note:
See TracChangeset
for help on using the changeset viewer.
