Changeset 20076 for trunk/psModules/src/objects/pmPSF.c
- Timestamp:
- Oct 12, 2008, 3:56:42 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmPSF.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmPSF.c
r20000 r20076 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.3 7$ $Name: not supported by cvs2svn $9 * @date $Date: 2008-10- 08 21:53:29$8 * @version $Revision: 1.38 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2008-10-13 01:56:42 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 401 401 return psf; 402 402 } 403 404 // we generate the growth curve for the center of the image with the specified psf model405 bool pmGrowthCurveGenerate (pmReadout *readout, pmPSF *psf, bool ignore, psMaskType maskVal, psMaskType markVal)406 {407 PS_ASSERT_PTR_NON_NULL(readout, false);408 PS_ASSERT_PTR_NON_NULL(readout->image, false);409 410 // bool status;411 float xc, yc, dx, dy;412 float fitMag, apMag;413 float radius;414 415 // create template model416 pmModel *modelRef = pmModelAlloc(psf->type);417 418 // maskVal is used to test for rejected pixels, and must include markVal419 maskVal |= markVal;420 421 // XXXX A Serious hack: the psf might not be determined in the field center.422 // for the moment, just try a few locations until it is defined!423 424 pmModel *model = NULL;425 for (int ix = -1; ix <= +1; ix ++) {426 for (int iy = -1; iy <= +1; iy ++) {427 428 // use the center of the center pixel of the image429 xc = (0.5 + 0.3*ix)*readout->image->numCols + readout->image->col0 + 0.5;430 yc = (0.5 + 0.3*ix)*readout->image->numRows + readout->image->row0 + 0.5;431 dx = psf->growth->maxRadius + 1;432 dy = psf->growth->maxRadius + 1;433 434 // assign the x and y coords to the image center435 // create an object with center intensity of 1000436 modelRef->params->data.F32[PM_PAR_SKY] = 0;437 modelRef->params->data.F32[PM_PAR_I0] = 1000;438 modelRef->params->data.F32[PM_PAR_XPOS] = xc;439 modelRef->params->data.F32[PM_PAR_YPOS] = yc;440 441 // create modelPSF from this model442 model = pmModelFromPSF (modelRef, psf);443 if (model) goto got_model;444 }445 }446 psAssert (model, "cannot build growth curve (psf model is invalid everywhere)");447 448 got_model:449 // measure the fitMag for this model450 pmSourcePhotometryModel (&fitMag, model);451 psf->growth->fitMag = fitMag;452 453 // generate working image for this source454 psRegion region = {xc - dx, xc + dx, yc - dy, yc + dy};455 456 // force region to stop at dimensions of image457 region = psRegionForImage (readout->image, region);458 459 // the view, image, and mask retain col0,row0460 psImage *view = psImageSubset (readout->image, region);461 psImage *image = psImageCopy (NULL, view, PS_TYPE_F32);462 psImage *mask = psImageCopy (NULL, view, PS_TYPE_U8);463 464 psImageInit (image, 0.0);465 psImageInit (mask, 0);466 467 // place the reference object in the image center468 // no need to mask the source here469 // XXX should we measure this for the analytical model only or the full model?470 pmModelAdd (image, NULL, model, PM_MODEL_OP_FULL, maskVal);471 472 // loop over a range of source fluxes473 // no need to interpolate since we have forced the object center474 // to 0.5, 0.5 above475 bool completeGrowthCurve = true; // do we have a complete curve of growth?476 for (int i = 0; i < psf->growth->radius->n; i++) {477 478 radius = psf->growth->radius->data.F32[i];479 480 // mask the given aperture and measure the apMag481 psImageKeepCircle (mask, xc, yc, radius, "OR", markVal);482 if (!pmSourcePhotometryAper (&apMag, model, image, mask, maskVal)) {483 psError(PM_ERR_PHOTOM, false, "Measuring apMag for radius == %g", radius);484 psErrorStackPrint (stderr, "failure to get growth curve");485 psErrorClear();486 completeGrowthCurve = false;487 break;488 }489 psImageKeepCircle (mask, xc, yc, radius, "AND", PS_NOT_U8(markVal));490 491 // the 'ignore' mode is for testing492 if (ignore) {493 psf->growth->apMag->data.F32[i] = fitMag;494 } else {495 psf->growth->apMag->data.F32[i] = apMag;496 }497 }498 499 if (completeGrowthCurve) {500 psf->growth->apRef = psVectorInterpolate (psf->growth->radius, psf->growth->apMag, psf->growth->refRadius);501 psf->growth->apLoss = psf->growth->fitMag - psf->growth->apRef;502 } else {503 psf->growth->apRef = NAN;504 psf->growth->apLoss = 0;505 }506 507 psLogMsg ("psphot.growth", 4, "GrowthCurve : apLoss : %f\n", psf->growth->apLoss);508 509 psFree (view);510 psFree (image);511 psFree (mask);512 psFree (model);513 psFree (modelRef);514 515 return completeGrowthCurve ? true : false;516 }
Note:
See TracChangeset
for help on using the changeset viewer.
