Changeset 10049
- Timestamp:
- Nov 17, 2006, 1:01:30 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmSource.c (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSource.c
r9880 r10049 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.1 7$ $Name: not supported by cvs2svn $9 * @date $Date: 2006-11- 07 09:06:21$8 * @version $Revision: 1.18 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-11-17 23:01:30 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 31 31 static void sourceFree(pmSource *tmp) 32 32 { 33 psTrace( "psModules.objects", 4, "---- %s() begin ----\n", __func__);33 psTrace(__func__, 5, "---- begin ----\n"); 34 34 psFree(tmp->peak); 35 35 psFree(tmp->pixels); … … 40 40 psFree(tmp->modelEXT); 41 41 psFree(tmp->blends); 42 psTrace( "psModules.objects", 4, "---- %s() end ----\n", __func__);42 psTrace(__func__, 5, "---- end ----\n"); 43 43 } 44 44 … … 65 65 pmSource *pmSourceAlloc() 66 66 { 67 psTrace( "psModules.objects", 3, "---- %s() begin ----\n", __func__);67 psTrace(__func__, 5, "---- begin ----\n"); 68 68 static int id = 1; 69 69 pmSource *source = (pmSource *) psAlloc(sizeof(pmSource)); … … 90 90 source->pixWeight = NAN; 91 91 92 psTrace( "psModules.objects", 3, "---- %s() end ----\n", __func__);92 psTrace(__func__, 5, "---- end ----\n"); 93 93 return(source); 94 94 } … … 198 198 199 199 /****************************************************************************** 200 pmSourcePSFClump(source, metadata): Find the likely PSF clump in the200 pmSourcePSFClump(source, recipe): Find the likely PSF clump in the 201 201 sigma-x, sigma-y plane. return 0,0 clump in case of error. 202 202 *****************************************************************************/ 203 203 204 204 // XXX EAM include a S/N cutoff in selecting the sources? 205 pmPSFClump pmSourcePSFClump(psArray *sources, psMetadata * metadata)206 { 207 psTrace( "psModules.objects", 3, "---- %s() begin ----\n", __func__);205 pmPSFClump pmSourcePSFClump(psArray *sources, psMetadata *recipe) 206 { 207 psTrace(__func__, 5, "---- begin ----\n"); 208 208 209 209 # define NPIX 10 … … 215 215 216 216 PS_ASSERT_PTR_NON_NULL(sources, emptyClump); 217 PS_ASSERT_PTR_NON_NULL( metadata, emptyClump);217 PS_ASSERT_PTR_NON_NULL(recipe, emptyClump); 218 218 219 219 // find the sigmaX, sigmaY clump … … 224 224 bool status; 225 225 226 psF32 SX_MAX = psMetadataLookupF32 (&status, metadata, "MOMENTS_SX_MAX");226 psF32 SX_MAX = psMetadataLookupF32 (&status, recipe, "MOMENTS_SX_MAX"); 227 227 if (!status) 228 228 SX_MAX = 10.0; 229 psF32 SY_MAX = psMetadataLookupF32 (&status, metadata, "MOMENTS_SY_MAX");229 psF32 SY_MAX = psMetadataLookupF32 (&status, recipe, "MOMENTS_SY_MAX"); 230 230 if (!status) 231 231 SY_MAX = 10.0; 232 psF32 AR_MAX = psMetadataLookupF32 (&status, metadata, "MOMENTS_AR_MAX");232 psF32 AR_MAX = psMetadataLookupF32 (&status, recipe, "MOMENTS_AR_MAX"); 233 233 if (!status) 234 234 AR_MAX = 3.0; … … 291 291 stats = psImageStats (stats, splane, NULL, 0); 292 292 peaks = pmFindImagePeaks (splane, stats[0].max / 2); 293 psTrace ( ".pmObjects.pmSourceRoughClass", 2, "clump threshold is %f\n", stats[0].max/2);294 295 const bool keep_psf_clump = psMetadataLookupBool(NULL, metadata, "KEEP_PSF_CLUMP");293 psTrace (__func__, 2, "clump threshold is %f\n", stats[0].max/2); 294 295 const bool keep_psf_clump = psMetadataLookupBool(NULL, recipe, "KEEP_PSF_CLUMP"); 296 296 if (keep_psf_clump) 297 297 { 298 psMetadataAdd( metadata, PS_LIST_TAIL,298 psMetadataAdd(recipe, PS_LIST_TAIL, 299 299 "PSF_CLUMP", PS_DATA_IMAGE, "Image of PSF coefficients", splane); 300 300 } … … 323 323 psArraySort (peaks, pmPeaksCompareDescend); 324 324 clump = peaks->data[0]; 325 psTrace ( ".pmObjects.pmSourceRoughClass", 2, "clump is at %d, %d (%f)\n", clump->x, clump->y, clump->counts);325 psTrace (__func__, 2, "clump is at %d, %d (%f)\n", clump->x, clump->y, clump->counts); 326 326 327 327 // define section window for clump … … 369 369 psfClump.dY = stats->clippedStdev; 370 370 371 psTrace ( ".pmObjects.pmSourceRoughClass", 2, "clump X, Y: %f, %f\n", psfClump.X, psfClump.Y);372 psTrace ( ".pmObjects.pmSourceRoughClass", 2, "clump DX, DY: %f, %f\n", psfClump.dX, psfClump.dY);373 // these values should be pushed on the metadatasomewhere371 psTrace (__func__, 2, "clump X, Y: %f, %f\n", psfClump.X, psfClump.Y); 372 psTrace (__func__, 2, "clump DX, DY: %f, %f\n", psfClump.dX, psfClump.dY); 373 // these values should be pushed on the recipe somewhere 374 374 375 375 psFree (stats); … … 379 379 } 380 380 381 psTrace( "psModules.objects", 3, "---- %s() end ----\n", __func__);381 psTrace(__func__, 5, "---- end ----\n"); 382 382 return (psfClump); 383 383 } 384 384 385 385 /****************************************************************************** 386 pmSourceRoughClass(source, metadata): make a guess at the source386 pmSourceRoughClass(source, recipe): make a guess at the source 387 387 classification. 388 389 XXX: push the clump info into the metadata?390 391 388 XXX: How can this function ever return FALSE? 392 393 EAM: I moved S/N calculation to pmSourceMoments, using weight image394 389 *****************************************************************************/ 395 390 396 bool pmSourceRoughClass(psArray *sources, psMetadata * metadata, pmPSFClump clump)397 { 398 psTrace( "psModules.objects", 3, "---- %s() begin ----\n", __func__);391 bool pmSourceRoughClass(psArray *sources, psMetadata *recipe, pmPSFClump clump) 392 { 393 psTrace(__func__, 5, "---- begin ----"); 399 394 400 395 psBool rc = true; … … 406 401 int Ncr = 0; 407 402 int Nsatstar = 0; 408 // psRegion allArray = psRegionSet (0, 0, 0, 0);409 403 psRegion inner; 410 404 … … 412 406 psVector *starsn = psVectorAllocEmpty (sources->n, PS_TYPE_F32); 413 407 414 // check return status value (do these exist?)408 // get basic parameters, or set defaults 415 409 bool status; 416 psF32 PSF_SN_LIM = psMetadataLookupF32 (&status, metadata, "PSF_SN_LIM"); 417 psF32 PSF_CLUMP_NSIGMA = psMetadataLookupF32 (&status, metadata, "PSF_CLUMP_NSIGMA"); 410 float PSF_SN_LIM = psMetadataLookupF32 (&status, recipe, "PSF_SN_LIM"); 411 if (!status) 412 PSF_SN_LIM = 20.0; 413 float PSF_CLUMP_NSIGMA = psMetadataLookupF32 (&status, recipe, "PSF_CLUMP_NSIGMA"); 418 414 if (!status) 419 415 PSF_CLUMP_NSIGMA = 1.5; 416 float INNER_RADIUS = psMetadataLookupF32 (&status, recipe, "SKY_INNER_RADIUS"); 420 417 421 418 // XXX allow clump size to be scaled relative to sigmas? … … 423 420 for (psS32 i = 0 ; i < sources->n ; i++) { 424 421 425 pmSource * tmpSrc= (pmSource *) sources->data[i];426 427 tmpSrc->peak->type = 0;428 429 psF32 sigX = tmpSrc->moments->Sx;430 psF32 sigY = tmpSrc->moments->Sy;422 pmSource *source = (pmSource *) sources->data[i]; 423 424 source->peak->type = 0; 425 426 psF32 sigX = source->moments->Sx; 427 psF32 sigY = source->moments->Sy; 431 428 432 429 // XXX EAM : can we use the value of SATURATE if mask is NULL? 433 // inner = psRegionForSquare (tmpSrc->peak->x - tmpSrc->mask->col0, tmpSrc->peak->y - tmpSrc->mask->row0, 2); 434 inner = psRegionForSquare (tmpSrc->peak->x, tmpSrc->peak->y, 2); 435 inner = psRegionForImage (tmpSrc->mask, inner); 436 int Nsatpix = psImageCountPixelMask (tmpSrc->mask, inner, PM_MASK_SAT); 430 inner = psRegionForSquare (source->peak->x, source->peak->y, 2); 431 inner = psRegionForImage (source->mask, inner); 432 int Nsatpix = psImageCountPixelMask (source->mask, inner, PM_MASK_SAT); 437 433 438 434 // saturated star (size consistent with PSF or larger) … … 441 437 big = true; 442 438 if ((Nsatpix > 1) && big) { 443 tmpSrc->type = PM_SOURCE_TYPE_STAR; 444 tmpSrc->mode |= PM_SOURCE_MODE_SATSTAR; 439 source->type = PM_SOURCE_TYPE_STAR; 440 source->mode |= PM_SOURCE_MODE_SATSTAR; 441 // recalculate moments here with larger box? 442 pmSourceMoments (source, INNER_RADIUS); 445 443 Nsatstar ++; 446 444 continue; … … 449 447 // saturated object (not a star, eg bleed trails, hot pixels) 450 448 if (Nsatpix > 1) { 451 tmpSrc->type = PM_SOURCE_TYPE_SATURATED;452 tmpSrc->mode |= PM_SOURCE_MODE_DEFAULT;449 source->type = PM_SOURCE_TYPE_SATURATED; 450 source->mode |= PM_SOURCE_MODE_DEFAULT; 453 451 Nsat ++; 454 452 continue; … … 460 458 // XXX these limits are quite arbitrary 461 459 if ((sigX < 0.05) || (sigY < 0.05)) { 462 tmpSrc->type = PM_SOURCE_TYPE_DEFECT;463 tmpSrc->mode |= PM_SOURCE_MODE_DEFAULT;460 source->type = PM_SOURCE_TYPE_DEFECT; 461 source->mode |= PM_SOURCE_MODE_DEFAULT; 464 462 Ncr ++; 465 463 continue; … … 468 466 // likely unsaturated extended source (too large to be stellar) 469 467 if ((sigX > (clump.X + 3*clump.dX)) || (sigY > (clump.Y + 3*clump.dY))) { 470 tmpSrc->type = PM_SOURCE_TYPE_EXTENDED;471 tmpSrc->mode |= PM_SOURCE_MODE_DEFAULT;468 source->type = PM_SOURCE_TYPE_EXTENDED; 469 source->mode |= PM_SOURCE_MODE_DEFAULT; 472 470 Next ++; 473 471 continue; … … 475 473 476 474 // the rest are probable stellar objects 477 starsn->data.F32[starsn->n] = tmpSrc->moments->SN;475 starsn->data.F32[starsn->n] = source->moments->SN; 478 476 starsn->n ++; 479 477 Nstar ++; … … 481 479 // PSF star (within 1.5 sigma of clump center, S/N > limit) 482 480 psF32 radius = hypot ((sigX-clump.X)/clump.dX, (sigY-clump.Y)/clump.dY); 483 if (( tmpSrc->moments->SN > PSF_SN_LIM) && (radius < PSF_CLUMP_NSIGMA)) {484 tmpSrc->type = PM_SOURCE_TYPE_STAR;485 tmpSrc->mode |= PM_SOURCE_MODE_PSFSTAR;481 if ((source->moments->SN > PSF_SN_LIM) && (radius < PSF_CLUMP_NSIGMA)) { 482 source->type = PM_SOURCE_TYPE_STAR; 483 source->mode |= PM_SOURCE_MODE_PSFSTAR; 486 484 Npsf ++; 487 485 continue; … … 489 487 490 488 // random type of star 491 tmpSrc->type = PM_SOURCE_TYPE_STAR; 492 tmpSrc->mode |= PM_SOURCE_MODE_DEFAULT; 493 } 494 495 { 496 psStats *stats = NULL; 497 stats = psStatsAlloc (PS_STAT_MIN | PS_STAT_MAX); 498 stats = psVectorStats (stats, starsn, NULL, NULL, 0); 499 psLogMsg ("pmObjects", 3, "SN range: %f - %f\n", stats[0].min, stats[0].max); 500 psFree (stats); 501 psFree (starsn); 502 } 503 504 psTrace (".pmObjects.pmSourceRoughClass", 2, "Nstar: %3d\n", Nstar); 505 psTrace (".pmObjects.pmSourceRoughClass", 2, "Npsf: %3d\n", Npsf); 506 psTrace (".pmObjects.pmSourceRoughClass", 2, "Next: %3d\n", Next); 507 psTrace (".pmObjects.pmSourceRoughClass", 2, "Nsatstar: %3d\n", Nsatstar); 508 psTrace (".pmObjects.pmSourceRoughClass", 2, "Nsat: %3d\n", Nsat); 509 psTrace (".pmObjects.pmSourceRoughClass", 2, "Ncr: %3d\n", Ncr); 510 511 psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc); 489 source->type = PM_SOURCE_TYPE_STAR; 490 source->mode |= PM_SOURCE_MODE_DEFAULT; 491 } 492 493 psStats *stats = NULL; 494 stats = psStatsAlloc (PS_STAT_MIN | PS_STAT_MAX); 495 stats = psVectorStats (stats, starsn, NULL, NULL, 0); 496 psLogMsg ("pmObjects", 3, "SN range: %f - %f\n", stats[0].min, stats[0].max); 497 psFree (stats); 498 psFree (starsn); 499 500 psTrace (__func__, 2, "Nstar: %3d\n", Nstar); 501 psTrace (__func__, 2, "Npsf: %3d\n", Npsf); 502 psTrace (__func__, 2, "Next: %3d\n", Next); 503 psTrace (__func__, 2, "Nsatstar: %3d\n", Nsatstar); 504 psTrace (__func__, 2, "Nsat: %3d\n", Nsat); 505 psTrace (__func__, 2, "Ncr: %3d\n", Ncr); 506 507 psTrace(__func__, 5, "---- end ----\n"); 512 508 return(rc); 513 509 } … … 535 531 psF32 radius) 536 532 { 537 psTrace( "psModules.objects", 3, "---- %s() begin ----\n", __func__);533 psTrace(__func__, 5, "---- begin ----\n"); 538 534 PS_ASSERT_PTR_NON_NULL(source, false); 539 535 PS_ASSERT_PTR_NON_NULL(source->peak, false); … … 641 637 // XXX EAM - the limit is a bit arbitrary. make it user defined? 642 638 if ((numPixels < 0.75*R2) || (Sum <= 0)) { 643 psTrace ( ".psModules.pmSourceMoments", 3, "no valid pixels for source\n");644 psTrace( "psModules.objects", 3, "---- %s(false) end ----\n", __func__);639 psTrace (__func__, 3, "no valid pixels for source\n"); 640 psTrace(__func__, 5, "---- end (false) ----\n"); 645 641 return (false); 646 642 } 647 643 648 psTrace (".psModules.pmSourceMoments", 5, 649 "sky: %f Sum: %f X1: %f Y1: %f X2: %f Y2: %f XY: %f Npix: %d\n", 644 psTrace (__func__, 4, "sky: %f Sum: %f X1: %f Y1: %f X2: %f Y2: %f XY: %f Npix: %d\n", 650 645 sky, Sum, X1, Y1, X2, Y2, XY, numPixels); 651 646 … … 658 653 y = Y1/Sum; 659 654 if ((fabs(x) > radius) || (fabs(y) > radius)) { 660 psTrace (".psModules.pmSourceMoments", 3, 661 "large centroid swing; invalid peak %d, %d\n", 655 psTrace (__func__, 3, "large centroid swing; invalid peak %d, %d\n", 662 656 source->peak->x, source->peak->y); 663 psTrace( "psModules.objects", 3, "---- %s(false) end ----\n", __func__);657 psTrace(__func__, 5, "---- end(false) ----\n"); 664 658 return (false); 665 659 } … … 679 673 source->moments->Sy = sqrt(PS_MAX(Y2/Sum - PS_SQR(y), 0)); 680 674 681 psTrace ( ".psModules.pmSourceMoments", 4,675 psTrace (__func__, 4, 682 676 "sky: %f Sum: %f x: %f y: %f Sx: %f Sy: %f Sxy: %f\n", 683 677 sky, Sum, source->moments->x, source->moments->y, 684 678 source->moments->Sx, source->moments->Sy, source->moments->Sxy); 685 679 686 psTrace( "psModules.objects", 3, "---- %s(true) end ----\n", __func__);680 psTrace(__func__, 5, "---- end ----\n"); 687 681 return(true); 688 682 }
Note:
See TracChangeset
for help on using the changeset viewer.
