Changeset 17316
- Timestamp:
- Apr 2, 2008, 8:05:38 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080324/psphot/src/psphotPSFConvModel.c
r14655 r17316 4 4 static psF32 PM_SOURCE_FIT_MODEL_NUM_ITERATIONS = 15; 5 5 static psF32 PM_SOURCE_FIT_MODEL_TOLERANCE = 0.1; 6 // static psF32 PM_SOURCE_FIT_MODEL_WEIGHT = 1.0;7 // static bool PM_SOURCE_FIT_MODEL_PIX_WEIGHTS = true;8 6 9 7 // input source has both modelPSF and modelEXT. on successful exit, we set the 10 8 // modelConv to contain the fitted parameters, and the modelFlux to contain the 11 9 // convolved model image. 12 bool psphotPSFConvModel (pmSource *source, psMetadata *recipe, psMaskType maskVal) {10 pmModel *psphotPSFConvModel (pmReadout *readout, pmSource *source, pmModelType modelType, psMaskType maskVal, int psfSize) { 13 11 14 12 bool status; 15 16 int psfSize = psMetadataLookupS32 (&status, recipe, "PCM_BOX_SIZE");17 if (!status) {18 psfSize = 2;19 }20 13 21 14 // make sure we save a cached copy of the psf flux … … 23 16 24 17 // convert the cached cached psf model for this source to a psKernel 25 // XXX for the moment, hard-wire the kernel to be 5x5 (2 pix radius)26 // XXX for the moment, hard-wire the kernel to be 9x9 (4 pix radius)27 18 psKernel *psf = psphotKernelFromPSF (source, psfSize); 28 19 … … 41 32 } 42 33 43 # if (0) 34 # define USE_DELTA_PSF 0 35 # if (USE_DELTA_PSF) 44 36 // XXX sanity check: convolve with delta function should behave like unconvolved version 45 37 for (int i = 0; i < psf->image->numRows; i++) { … … 54 46 // XXX we could modify the parameter values or even the model 55 47 // here based on the observed seeing (some lookup table...) 56 pmModel *modelConv = pmModelCopy (source->modelEXT); 48 49 // XXX we previously required the unconvolved version to have been fit first 50 // pmModel *modelConv = pmModelCopy (source->modelEXT); 51 52 // use the source moments, etc to guess basic model parameters 53 pmModel *modelConv = pmSourceModelGuess (source, modelType); 54 PS_ASSERT (modelConv, NULL); 55 57 56 psVector *params = modelConv->params; 58 57 psVector *dparams = modelConv->dparams; 58 59 psphotCheckRadiusEXT (readout, source, modelConv); 59 60 60 61 // create the minimization constraints … … 91 92 psTrace ("psphot", 4, "niter: %d, chisq: %f", myMin->iter, myMin->value); 92 93 93 // renormalize output model image 94 // renormalize output model image (generated by fitting process) 94 95 float Io = params->data.F32[PM_PAR_I0]; 95 96 for (int iy = 0; iy < source->modelFlux->numRows; iy++) { … … 115 116 onPic &= (params->data.F32[PM_PAR_YPOS] >= source->pixels->row0); 116 117 onPic &= (params->data.F32[PM_PAR_YPOS] < source->pixels->row0 + source->pixels->numRows); 117 if (!onPic) { 118 modelConv->flags |= PM_MODEL_STATUS_OFFIMAGE; 119 } 118 if (!onPic) modelConv->flags |= PM_MODEL_STATUS_OFFIMAGE; 120 119 121 source->mode |= PM_SOURCE_MODE_FITTED; 122 source->modelConv = modelConv; 120 source->mode |= PM_SOURCE_MODE_FITTED; // XXX is this needed? 123 121 124 122 psFree(myMin); … … 126 124 psFree(constraint); 127 125 128 bool retval = (onPic && fitStatus); 129 psTrace("psphot", 5, "---- %s(%d) end ----\n", __func__, retval); 130 return(retval); 126 return modelConv; 131 127 }
Note:
See TracChangeset
for help on using the changeset viewer.
