- Timestamp:
- Dec 6, 2012, 6:32:19 PM (14 years ago)
- Location:
- branches/czw_branch/20120906/psphot
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20120906/psphot
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20120905/psphot (added) merged: 34408-34409,34415-34416,34428,34466,34565,34570,34575,34735,34747
- Property svn:mergeinfo changed
-
branches/czw_branch/20120906/psphot/src
- Property svn:mergeinfo changed
-
branches/czw_branch/20120906/psphot/src/psphotBlendFit.c
r34404 r34772 1 1 # include "psphotInternal.h" 2 2 bool psphotBlendFitSetSource(pmSource *source, psImage *IDimage, float sigSigma); 3 bool psphotBlendSetSourceSatstar (psImage *image, pmSource *source); 4 float InterpolateValues (float X0, float Y0, float X1, float Y1, float X); 3 5 4 6 // for now, let's store the detections on the readout->analysis for each readout … … 256 258 257 259 int TEST_ON = false; 258 # if ( 1)260 # if (0) 259 261 # define TEST_X 653 260 262 # define TEST_Y 466 261 263 if ((fabs(source->peak->xf - TEST_X) < 5) && (fabs(source->peak->yf - TEST_Y) < 5)) { 262 264 fprintf (stderr, "test object\n"); 263 //psTraceSetLevel("psLib.math.psMinimizeLMChi2", 5);265 psTraceSetLevel("psLib.math.psMinimizeLMChi2", 5); 264 266 TEST_ON = true; 265 267 } … … 377 379 if (!source) return false; 378 380 if (!source->peak) return false; // XXX how can we have a peak-less source? 381 382 # if (0) 383 # define TEST_X 653 384 # define TEST_Y 466 385 if ((fabs(source->peak->xf - TEST_X) < 5) && (fabs(source->peak->yf - TEST_Y) < 5)) { 386 fprintf (stderr, "test object\n"); 387 } 388 # undef TEST_X 389 # undef TEST_Y 390 # endif 391 379 392 if (!source->moments) return false; 380 393 if (source->type == PM_SOURCE_TYPE_DEFECT) return false; … … 385 398 if (source->mode2 & PM_SOURCE_MODE2_SATSTAR_PROFILE) { 386 399 // find the radius at which we hit something like 0.1*SATURATION 387 return false; 400 psphotBlendSetSourceSatstar (IDimage, source); 401 return true; 388 402 } 389 403 … … 431 445 float rMxx = 0.5 / PS_SQR(shape.sx); 432 446 float rMyy = 0.5 / PS_SQR(shape.sy); 433 float Sxy = -1. *shape.sxy; // factor of -1 is included to match the previous window function434 // implementation. XXX: Is this correct?447 float Sxy = shape.sxy; // factor of -1 is included to match the previous window function 448 // implementation. XXX: Is this correct? 435 449 436 450 int ID = source->id; … … 443 457 444 458 float z = rMxx * PS_SQR(dX) + rMyy * PS_SQR(dY) + Sxy*dX*dY; 459 if (z > 2.311) continue; 445 460 446 461 float f = Io*exp(-z); … … 453 468 return true; 454 469 } 470 471 bool psphotBlendSetSourceSatstar (psImage *IDimage, pmSource *source) { 472 473 float Xo = source->satstar->Xo; 474 float Yo = source->satstar->Yo; 475 psVector *logRmodel = source->satstar->logRmodel; 476 psVector *logFmodel = source->satstar->logFmodel; 477 478 float lPeak = logFmodel->data.F32[0]; 479 float fPeak = pow(10.0, lPeak); 480 float threshold = 0.1*fPeak; 481 float logThresh = log10(threshold); 482 483 float radius = NAN; 484 485 // what is the radius for a specific peak fraction? 486 for (int i = 1; i < logFmodel->n; i++) { 487 float logF = logFmodel->data.F32[i]; 488 if (!isfinite(logF)) continue; 489 490 float flux = pow(10.0, logF); 491 if (flux > threshold) continue; 492 493 float logF0 = logFmodel->data.F32[i - 1]; 494 float logR0 = logRmodel->data.F32[i - 1]; 495 496 float logF1 = logFmodel->data.F32[i]; 497 float logR1 = logRmodel->data.F32[i]; 498 499 float logR = InterpolateValues (logF0, logR0, logF1, logR1, logThresh); 500 radius = pow(10.0, logR); 501 break; 502 } 503 504 if (!isfinite(radius)) { 505 for (int i = logFmodel->n - 1; i >= 0; i--) { 506 if (!isfinite(logFmodel->data.F32[i])) continue; 507 float logR = logRmodel->data.F32[i]; 508 radius = pow(10.0, logR); 509 break; 510 } 511 } 512 513 if (!isfinite(radius)) return false; 514 515 int Nx = IDimage->numCols; 516 int Ny = IDimage->numRows; 517 518 // region to mask 519 int minX = PS_MIN(PS_MAX(Xo - radius, 0), Nx - 1); 520 int maxX = PS_MIN(PS_MAX(Xo + radius, 0), Nx - 1); 521 int minY = PS_MIN(PS_MAX(Yo - radius, 0), Ny - 1); 522 int maxY = PS_MIN(PS_MAX(Yo + radius, 0), Ny - 1); 523 524 int ID = source->id; 525 526 fprintf (stderr, "Xo,Yo: %f,%f; radius: %f\n", Xo, Yo, radius); 527 528 for (int iy = minY; iy < maxY; iy++) { 529 for (int ix = minX; ix < maxX; ix++) { 530 531 float dX = (ix - Xo); 532 float dY = (iy - Yo); 533 float R = hypot (dX, dY) ; 534 if (R > radius) continue; 535 536 IDimage->data.S32[iy][ix] = ID; 537 } 538 } 539 return true; 540 } 541
Note:
See TracChangeset
for help on using the changeset viewer.
