Changeset 25536
- Timestamp:
- Sep 23, 2009, 7:19:31 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090715/psphot/src/psphotApResid.c
r25022 r25536 192 192 mask->data.PS_TYPE_VECTOR_MASK_DATA[Npsf] = 0; 193 193 194 // XXX don't I have errMag at this point?? 194 195 dMag->data.F32[Npsf] = model->dparams->data.F32[PM_PAR_I0] / model->params->data.F32[PM_PAR_I0]; 195 196 … … 410 411 int Nx, Ny; 411 412 413 // XXX use the psf trend scale? 412 414 if (readout->image->numCols > readout->image->numRows) { 413 415 Nx = scale; … … 422 424 } 423 425 424 // require at least 10 stars per spatial bin425 if (Npsf < 10*Nx*Ny) {426 return false;427 }428 429 426 // the mask marks the values not used to calculate the ApTrend 430 427 psVectorInit (mask, 0); 431 428 432 429 // XXX stats structure for use by ApTrend : make parameters user setable 430 // XXX another stat? 433 431 psStats *stats = psStatsAlloc (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); 434 432 stats->min = 2.0; … … 514 512 } 515 513 516 # if (0) 517 bool psphotApResidMags_Unthreaded (int *nskip, int *nfail, psArray *sources, pmPSF *psf, pmSourcePhotometryMode photMode, psImageMaskType maskVal) { 518 519 int Nskip = 0; 520 int Nfail = 0; 521 522 for (int i = 0; i < sources->n; i++) { 523 pmSource *source = (pmSource *) sources->data[i]; 524 525 if (source->type != PM_SOURCE_TYPE_STAR) SKIPSTAR ("NOT STAR"); 526 if (source->mode & PM_SOURCE_MODE_SATSTAR) SKIPSTAR ("SATSTAR"); 527 if (source->mode & PM_SOURCE_MODE_BLEND) SKIPSTAR ("BLEND"); 528 if (source->mode & PM_SOURCE_MODE_FAIL) SKIPSTAR ("FAIL STAR"); 529 if (source->mode & PM_SOURCE_MODE_POOR) SKIPSTAR ("POOR STAR"); 530 531 if (!pmSourceMagnitudes (source, psf, photMode, maskVal)) { 532 Nskip ++; 533 psTrace ("psphot", 3, "skip : bad source mag"); 534 continue; 535 } 536 537 if (!isfinite(source->apMag) || !isfinite(source->psfMag)) { 538 Nfail ++; 539 psTrace ("psphot", 3, "fail : nan mags : %f %f", source->apMag, source->psfMag); 540 continue; 541 } 542 } 543 544 // change the value of a scalar on the array (wrap this and put it in psArray.h) 545 *nskip = Nskip; 546 *nfail = Nfail; 514 bool psphotApResidTrend_old (pmReadout *readout, pmPSF *psf, int Npsf, int scale, float *errorScale, float *errorFloor, psVector *mask, psVector *xPos, psVector *yPos, psVector *apResid, psVector *dMag) { 515 516 int Nx, Ny; 517 518 if (readout->image->numCols > readout->image->numRows) { 519 Nx = scale; 520 float AR = readout->image->numRows / (float) readout->image->numCols; 521 Ny = (int) (Nx * AR + 0.5); 522 Ny = PS_MAX (1, Ny); 523 } else { 524 Ny = scale; 525 float AR = readout->image->numRows / (float) readout->image->numCols; 526 Nx = (int) (Ny * AR + 0.5); 527 Nx = PS_MAX (1, Nx); 528 } 529 530 // require at least 10 stars per spatial bin 531 if (Npsf < 10*Nx*Ny) { 532 return false; 533 } 534 535 // the mask marks the values not used to calculate the ApTrend 536 psVectorInit (mask, 0); 537 538 // XXX stats structure for use by ApTrend : make parameters user setable 539 psStats *stats = psStatsAlloc (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); 540 stats->min = 2.0; 541 stats->max = 3.0; 542 543 // measure Trend2D for the current spatial scale 544 psFree (psf->ApTrend); 545 psf->ApTrend = pmTrend2DAlloc (PM_TREND_MAP, readout->image, Nx, Ny, stats); 546 547 // XXX somewhat arbitrary: soften the errors so the few bright stars do not totally dominate: 548 psVector *dMagSoft = psVectorAlloc (dMag->n, PS_TYPE_F32); 549 for (int i = 0; i < dMag->n; i++) { 550 dMagSoft->data.F32[i] = hypot(dMag->data.F32[i], 0.01); 551 } 552 553 // XXX test for errors here 554 pmTrend2DFit (psf->ApTrend, mask, 0xff, xPos, yPos, apResid, dMagSoft); 555 556 // construct the fitted values and the residuals 557 psVector *apResidFit = pmTrend2DEvalVector (psf->ApTrend, mask, 0xff, xPos, yPos); 558 psVector *apResidRes = (psVector *) psBinaryOp (NULL, (void *) apResid, "-", (void *) apResidFit); 559 560 // measure systematic errorFloor & systematic / photon scale factor 561 // XXX this is a bit arbitrary, but it forces ~3 stars from the bright bin per spatial bin 562 int nGroup = PS_MAX (3*Nx*Ny, 10); 563 psphotMagErrorScale (errorScale, errorFloor, dMag, apResidRes, mask, nGroup); 564 565 psLogMsg ("psphot.apresid", PS_LOG_INFO, "result of %d x %d grid (%d stars per bin)\n", Nx, Ny, nGroup); 566 psLogMsg ("psphot.apresid", PS_LOG_INFO, "systematic error / photon error: %f\n", *errorScale); 567 psLogMsg ("psphot.apresid", PS_LOG_INFO, "systematic scatter floor: %f\n", *errorFloor); 568 569 psFree (stats); 570 psFree (dMagSoft); 571 psFree (apResidFit); 572 psFree (apResidRes); 547 573 548 574 return true; 549 575 } 550 # endif 576
Note:
See TracChangeset
for help on using the changeset viewer.
