Changeset 10050 for trunk/psModules/src/objects
- Timestamp:
- Nov 17, 2006, 1:02:21 PM (20 years ago)
- Location:
- trunk/psModules/src/objects
- Files:
-
- 2 edited
-
pmSourcePhotometry.c (modified) (5 diffs)
-
pmSourcePhotometry.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSourcePhotometry.c
r10031 r10050 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-11-17 02:39:34$5 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-11-17 23:02:18 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 76 76 source->apMag = NAN; 77 77 78 // XXX these tests prevent aperture photometry without valid model. is 79 // this reasonable? probably not... 80 switch (source->type) { 81 case PM_SOURCE_TYPE_STAR: 82 model = source->modelPSF; 83 if (model == NULL) 84 return false; 85 isPSF = true; 86 break; 87 88 case PM_SOURCE_TYPE_EXTENDED: 89 model = source->modelEXT; 90 if (model == NULL) 91 return false; 92 isPSF = false; 93 break; 94 95 default: 96 return false; 97 } 78 // we must have a valid model 79 model = pmSourceGetModel (&isPSF, source); 80 if (model == NULL) 81 return false; 98 82 99 83 if (model->dparams->data.F32[PM_PAR_I0] > 0) { … … 278 262 } 279 263 264 psF32 **imData = image->data.F32; 265 psU8 **mkData = mask->data.U8; 266 280 267 // measure apMag 281 268 for (int ix = 0; ix < image->numCols; ix++) { 282 269 for (int iy = 0; iy < image->numRows; iy++) { 283 if (m ask->data.U8[iy][ix])284 continue; 285 apSum += im age->data.F32[iy][ix] - sky;270 if (mkData[iy][ix]) 271 continue; 272 apSum += imData[iy][ix] - sky; 286 273 } 287 274 } … … 487 474 } 488 475 476 double pmSourceWeight(const pmSource *Mi, 477 int term, 478 const bool unweighted_sum) // should the cross product be weighted? 479 { 480 481 int xi, yi; 482 double flux, wt, factor; 483 484 const psImage *Pi = Mi->pixels; 485 const psImage *Wi = Mi->weight; 486 const psImage *Ti = Mi->mask; 487 488 // note that this is addressing the same image pixels, 489 // though only if both are source not model images 490 flux = 0; 491 for (yi = 0; yi < Pi->numRows; yi++) { 492 for (xi = 0; xi < Pi->numCols; xi++) { 493 if (Ti->data.U8[yi][xi]) 494 continue; 495 if (!unweighted_sum) { 496 wt = Wi->data.F32[yi][xi]; 497 if (wt == 0) 498 continue; 499 } 500 501 switch (term) { 502 case 0: 503 factor = 1; 504 break; 505 case 1: 506 factor = xi + Pi->col0; 507 break; 508 case 2: 509 factor = yi + Pi->row0; 510 break; 511 default: 512 psAbort ("models/objects", "invalid term for pmSourceWeight"); 513 } 514 515 if (unweighted_sum) { 516 flux += (factor * Pi->data.F32[yi][xi]); 517 } else { 518 flux += (factor * Pi->data.F32[yi][xi]) / wt; 519 } 520 } 521 } 522 return flux; 523 } 524 489 525 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight) 490 526 { … … 507 543 return (true); 508 544 } 545 546 // given a source, which model is currently appropriate? 547 // choose PSF or EXT based on source->type, but fall back on PSF 548 // if the EXT model is NULL 549 pmModel *pmSourceGetModel (bool *isPSF, const pmSource *source) 550 { 551 552 pmModel *model; 553 554 switch (source->type) { 555 case PM_SOURCE_TYPE_STAR: 556 model = source->modelPSF; 557 if (model == NULL) 558 return NULL; 559 if (isPSF) 560 *isPSF = true; 561 return model; 562 563 case PM_SOURCE_TYPE_EXTENDED: 564 model = source->modelEXT; 565 if (isPSF) 566 *isPSF = false; 567 if (model == NULL) { 568 model = source->modelPSF; 569 if (isPSF) 570 *isPSF = true; 571 } 572 if (model == NULL) { 573 if (isPSF) 574 *isPSF = FALSE; 575 return NULL; 576 } 577 return (model); 578 break; 579 580 default: 581 if (isPSF) 582 *isPSF = false; 583 return NULL; 584 } 585 return NULL; 586 } -
trunk/psModules/src/objects/pmSourcePhotometry.h
r10031 r10050 3 3 * @author EAM, IfA; GLG, MHPCC 4 4 * 5 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $6 * @date $Date: 2006-11-17 02:39:34$5 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 6 * @date $Date: 2006-11-17 23:02:21 $ 7 7 * 8 8 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 52 52 bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask); 53 53 bool pmSourceChisq (pmModel *model, psImage *image, psImage *mask, psImage *weight); 54 pmModel *pmSourceGetModel (bool *isPSF, const pmSource *source); 54 55 56 double pmSourceWeight(const pmSource *Mi, int term, const bool unweighted_sum); 55 57 # endif /* PM_SOURCE_PHOTOMETRY_H */
Note:
See TracChangeset
for help on using the changeset viewer.
