- Timestamp:
- Aug 17, 2007, 11:01:59 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20070817/psModules/src/objects/pmModelUtils.c
r14530 r14544 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.1 $ $Name: not supported by cvs2svn $8 * @date $Date: 2007-08-1 6 18:33:37$7 * @version $Revision: 1.1.2.1 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-08-17 21:01:59 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 20 20 #include <string.h> 21 21 #include <pslib.h> 22 #include "pmHDU.h" 23 #include "pmFPA.h" 24 #include "pmGrowthCurve.h" 22 25 #include "pmResiduals.h" 23 26 #include "pmModel.h" 27 #include "pmPSF.h" 28 #include "pmErrorCodes.h" 29 #include "pmModelUtils.h" 24 30 25 // instantiate a model for the PSF at this location (normalized or not?)26 // NOTE: psf and ( x,y) are defined wrt chip coordinates27 pmModel *pmModelFromPSFforXY (pmPSF *psf, float x, float y, float flux) {31 // instantiate a model for the PSF at this location with peak flux 32 // NOTE: psf and (Xo,Yo) are defined wrt chip coordinates 33 pmModel *pmModelFromPSFforXY (pmPSF *psf, float Xo, float Yo, float Io) { 28 34 29 35 assert (psf); 30 36 31 37 // allocate a new pmModel to hold the PSF version 32 pmModel *modelEXT = pmModelAlloc (psf->type);33 34 modelEXT->params->data.F32[PM_PAR_SKY] = 0.0;35 modelEXT->params->data.F32[PM_PAR_I0] = 1.0;36 modelEXT->params->data.F32[PM_PAR_XPOS] = x;37 modelEXT->params->data.F32[PM_PAR_YPOS] = y;38 39 // find function used to set the model parameters40 pmModelFromPSFFunc modelFromPSFFunc = pmModelFromPSFFunc_GetFunction (psf->type);41 42 // allocate a new pmModel to hold the PSF version43 38 pmModel *modelPSF = pmModelAlloc (psf->type); 44 39 45 // adjust the normalization:46 pmModelFlux modelFluxFunc = pmModelFlux_GetFunction (model->type);47 normFlux = modelFluxFunc (model->params);48 assert (isfinite(normFlux));49 assert (normFlux > 0);50 51 // set the correct normalization52 modelEXT->params->data.F32[PM_PAR_I0] = flux / normFlux;53 54 40 // set model parameters for this source based on PSF information 55 if (!model FromPSFFunc (modelPSF, modelEXT, psf)) {41 if (!modelPSF->modelParamsFromPSF (modelPSF, psf, Xo, Yo, Io)) { 56 42 psError(PM_ERR_PSF, false, "Failed to set model params from PSF"); 57 43 psFree(modelPSF); 58 44 return NULL; 59 45 } 46 60 47 // XXX note that model->residuals is just a reference 61 48 modelPSF->residuals = psf->residuals; 62 psFree (modelEXT);63 49 64 50 return (modelPSF); 65 51 } 66 52 67 pmSource *pmSourceFromModel (pmModel *model, pmReadout *readout, pmSourceType type) { 53 // set this model to have the requested flux 54 bool pmModelSetFlux (pmModel *model, float flux) { 68 55 69 pmSource *source = pmSourceAlloc (); 56 // set Io to be 1.0 57 model->params->data.F32[PM_PAR_I0] = 1.0; 70 58 71 // use the model centroid for the peak 72 switch (type) { 73 case PM_SOURCE_TYPE_STAR: 74 source->modelPSF = model; 75 break; 76 case PM_SOURCE_TYPE_EXTENDED: 77 source->modelEXT = model; 78 break; 79 default: 80 psAbort ("psphot", "error"); 81 } 59 // determine the normalized flux 60 float normFlux = model->modelFlux (model->params); 61 assert (isfinite(normFlux)); 62 assert (normFlux > 0); 82 63 83 source->peak = pmPeakAlloc (); 64 // set the desired normalization 65 model->params->data.F32[PM_PAR_I0] = flux / normFlux; 84 66 85 float x = model->params->data.F32[PM_PAR_XPOS]; 86 float y = model->params->data.F32[PM_PAR_YPOS]; 87 88 // XXX need to define the radius in some rational way 89 // XXX x,y are defined wrt readout->image parent, but the model 90 // parameters are defined wrt chip coordinates 91 pmSourceDefinePixels (source, readout, x, y, radius); 92 93 return (source); 67 return true; 94 68 }
Note:
See TracChangeset
for help on using the changeset viewer.
