Changeset 19954
- Timestamp:
- Oct 7, 2008, 10:12:27 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmSource.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSource.c
r19906 r19954 6 6 * @author EAM, IfA: significant modifications. 7 7 * 8 * @version $Revision: 1.5 8$ $Name: not supported by cvs2svn $9 * @date $Date: 2008-10-0 6 13:05:13$8 * @version $Revision: 1.59 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2008-10-07 20:12:27 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 279 279 psTrace("psModules.objects", 5, "---- begin ----\n"); 280 280 281 # define NPIX 10 282 # define SCALE 0.1 281 // XXX This should be in the recipe 282 #define SCALE 0.1 // Scale of splane 283 283 284 284 psArray *peaks = NULL; … … 290 290 PS_ASSERT_PTR_NON_NULL(recipe, errorClump); 291 291 292 bool status = true; 293 float PSF_CLUMP_SN_LIM = psMetadataLookupF32 (&status, recipe, "PSF_CLUMP_SN_LIM");292 bool status = true; // Status of MD lookup 293 float PSF_CLUMP_SN_LIM = psMetadataLookupF32(&status, recipe, "PSF_CLUMP_SN_LIM"); 294 294 if (!status) { 295 295 PSF_CLUMP_SN_LIM = 0; … … 298 298 // find the sigmaX, sigmaY clump 299 299 { 300 psStats *stats = NULL; 301 psImage *splane = NULL; 302 int binX, binY; 303 bool status; 304 305 psF32 SX_MAX = psMetadataLookupF32 (&status, recipe, "MOMENTS_SX_MAX"); 306 if (!status) 300 psF32 SX_MAX = psMetadataLookupF32(&status, recipe, "MOMENTS_SX_MAX"); 301 if (!status) { 302 psWarning("MOMENTS_SX_MAX not set in recipe"); 307 303 SX_MAX = 10.0; 308 psF32 SY_MAX = psMetadataLookupF32 (&status, recipe, "MOMENTS_SY_MAX"); 309 if (!status) 304 } 305 psF32 SY_MAX = psMetadataLookupF32(&status, recipe, "MOMENTS_SY_MAX"); 306 if (!status) { 307 psWarning("MOMENTS_SY_MAX not set in recipe"); 310 308 SY_MAX = 10.0; 311 psF32 AR_MAX = psMetadataLookupF32 (&status, recipe, "MOMENTS_AR_MAX"); 312 if (!status) 309 } 310 psF32 AR_MAX = psMetadataLookupF32(&status, recipe, "MOMENTS_AR_MAX"); 311 if (!status) { 312 psWarning("MOMENTS_AR_MAX not set in recipe"); 313 313 AR_MAX = 3.0; 314 } 314 315 psF32 AR_MIN = 1.0 / AR_MAX; 315 316 316 317 // construct a sigma-plane image 317 splane = psImageAlloc (SX_MAX/SCALE, SY_MAX/SCALE, PS_TYPE_F32); 318 psImageInit(splane, 0); // psImageAlloc doesn't zero the data 318 int numCols = SX_MAX / SCALE, numRows = SY_MAX / SCALE; // Size of sigma-plane image 319 psTrace("psModules.objects", 10, "sigma-plane dimensions: %dx%d\n", numCols, numRows); 320 psImage *splane = psImageAlloc(numCols, numRows, PS_TYPE_F32); // sigma-plane image 321 psImageInit(splane, 0); 319 322 320 323 // place the sources in the sigma-plane image (ignore 0,0 values?) 321 int nValid = 0; 322 for (psS32 i = 0 ; i < sources->n ; i++) 323 { 324 pmSource *tmpSrc = (pmSource *) sources->data[i]; 325 if (tmpSrc == NULL) 326 continue; 327 if (tmpSrc->moments == NULL) 328 continue; 329 if (tmpSrc->moments->SN < PSF_CLUMP_SN_LIM) 330 continue; 331 332 if (tmpSrc->peak->x < region->x0) continue; 333 if (tmpSrc->peak->x > region->x1) continue; 334 if (tmpSrc->peak->y < region->y0) continue; 335 if (tmpSrc->peak->y > region->y1) continue; 324 int nValid = 0; // Number of valid sources 325 for (int i = 0; i < sources->n; i++) { 326 pmSource *src = sources->data[i]; // Source of interest 327 if (!src || !src->moments) { 328 continue; 329 } 330 331 int x = src->peak->x, y = src->peak->y; // Coordinates of peak 332 if (x < region->x0 || x > region->x1 || y < region->y0 || y > region->y1) { 333 continue; 334 } 335 336 if (src->mode & PM_SOURCE_MODE_BLEND) { 337 continue; 338 } 339 340 if (src->moments->SN < PSF_CLUMP_SN_LIM) { 341 psTrace("psModules.objects", 10, "Rejecting source from clump because of low S/N (%f)\n", 342 src->moments->SN); 343 continue; 344 } 345 346 float Mxx = src->moments->Mxx, Myy = src->moments->Myy; // Second moments 347 float ar = Mxx / Myy; // Radius 336 348 337 349 // Sx,Sy are limited at 0. a peak at 0,0 is artificial 338 if (fabs(tmpSrc->moments->Mxx) < 0.05) 339 continue; 340 if (fabs(tmpSrc->moments->Myy) < 0.05) 341 continue; 342 if ((tmpSrc->moments->Mxx / tmpSrc->moments->Myy) > AR_MAX) 343 continue; 344 if ((tmpSrc->moments->Mxx / tmpSrc->moments->Myy) < AR_MIN) 345 continue; 346 if (tmpSrc->mode & PM_SOURCE_MODE_BLEND) 347 continue; 350 if (fabs(Mxx) < 0.05 || fabs(Myy < 0.05)) { 351 psTrace("psModules.objects", 10, 352 "Rejecting source from clump because of low moments (%f,%f)\n", 353 Mxx, Myy); 354 continue; 355 } 356 if (Mxx > SX_MAX || Myy > SY_MAX) { 357 psTrace("psModules.objects", 10, 358 "Rejecting source from clump because of high moments (%f,%f)\n", 359 Mxx, Myy); 360 continue; 361 } 362 if (ar > AR_MAX || ar < AR_MIN) { 363 psTrace("psModules.objects", 10, "Rejecting source from clump because of Ar (%f)\n", ar); 364 continue; 365 } 348 366 349 367 // for the moment, force splane dimensions to be 10x10 image pix 350 binX = tmpSrc->moments->Mxx/SCALE; 351 if (binX < 0) 352 continue; 353 if (binX >= splane->numCols) 354 continue; 355 356 binY = tmpSrc->moments->Myy/SCALE; 357 if (binY < 0) 358 continue; 359 if (binY >= splane->numRows) 360 continue; 368 int binX = Mxx / SCALE, binY = Myy / SCALE; // Position on splane 369 psAssert(binX >= 0 && binX < numCols && binY >= 0 && binY < numRows, "We checked it already"); 361 370 362 371 splane->data.F32[binY][binX] += 1.0; 363 nValid ++;372 nValid++; 364 373 } 365 374 366 375 // find the peak in this image 367 stats = psStatsAlloc (PS_STAT_MAX);376 psStats *stats = psStatsAlloc (PS_STAT_MAX); 368 377 if (!psImageStats (stats, splane, NULL, 0)) { 369 378 psError(PS_ERR_UNKNOWN, false, "Unable to get image statistics.\n"); … … 433 442 continue; 434 443 435 if (tmpSrc->peak->x < region->x0) continue;436 if (tmpSrc->peak->x > region->x1) continue;437 if (tmpSrc->peak->y < region->y0) continue;438 if (tmpSrc->peak->y > region->y1) continue;444 if (tmpSrc->peak->x < region->x0) continue; 445 if (tmpSrc->peak->x > region->x1) continue; 446 if (tmpSrc->peak->y < region->y0) continue; 447 if (tmpSrc->peak->y > region->y1) continue; 439 448 440 449 if (tmpSrc->moments->Mxx < minSx) … … 521 530 pmSource *source = (pmSource *) sources->data[i]; 522 531 523 if (source->peak->x < region->x0) continue;524 if (source->peak->x > region->x1) continue;525 if (source->peak->y < region->y0) continue;526 if (source->peak->y > region->y1) continue;532 if (source->peak->x < region->x0) continue; 533 if (source->peak->x > region->x1) continue; 534 if (source->peak->y < region->y0) continue; 535 if (source->peak->y > region->y1) continue; 527 536 528 537 source->peak->type = 0; … … 721 730 vMsk++; 722 731 } 723 if (isnan(*vPix)) continue;732 if (isnan(*vPix)) continue; 724 733 725 734 psF32 xDiff = col + xOff; … … 893 902 psF32 **target = source->pixels->data.F32; 894 903 if (mode & PM_MODEL_OP_NOISE) { 895 // XXX need to scale by the gain...904 // XXX need to scale by the gain... 896 905 target = source->weight->data.F32; 897 906 } … … 967 976 return model; 968 977 969 // the 'best' extended model is saved in source->modelEXT (may be a pointer to one of970 // the elements of source->modelFits)978 // the 'best' extended model is saved in source->modelEXT (may be a pointer to one of 979 // the elements of source->modelFits) 971 980 case PM_SOURCE_TYPE_EXTENDED: 972 model = source->modelEXT;981 model = source->modelEXT; 973 982 if (!model && source->modelPSF) { 974 // XXX raise an error or warning here?983 // XXX raise an error or warning here? 975 984 if (isPSF) { 976 985 *isPSF = true;
Note:
See TracChangeset
for help on using the changeset viewer.
