Changeset 14348
- Timestamp:
- Jul 20, 2007, 2:05:10 PM (19 years ago)
- Location:
- trunk/psphot/src
- Files:
-
- 2 edited
-
psphotModelTest.c (modified) (9 diffs)
-
psphotPSFConvModel.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotModelTest.c
r14338 r14348 15 15 if (!psMetadataLookupBool (&status, recipe, "TEST_FIT")) return false; 16 16 17 psTimerStart ("modelTest"); 18 17 19 // find the currently selected readout 18 20 pmReadout *readout = pmFPAfileThisReadout (config->files, view, "PSPHOT.INPUT"); … … 54 56 if (fitModeWord && !strcasecmp (fitModeWord, "DEFAULT")) fitMode = PM_SOURCE_FIT_EXT; 55 57 58 // construct the source structures 59 pmSource *source = pmSourceAlloc(); 60 source->peak = pmPeakAlloc (xObj, yObj, 0, 0); 61 pmSourceDefinePixels (source, readout, xObj, yObj, OUTER); 62 56 63 // in fitMode, psf sets the model type 57 64 if (fitMode == PM_SOURCE_FIT_PSF) { … … 59 66 if (!psf) psAbort("PSF_INPUT_FILE not supplied"); 60 67 modelType = psf->type; 68 source->type = PM_SOURCE_TYPE_STAR; 61 69 } 62 70 if (fitMode == PM_SOURCE_FIT_EXT) { … … 83 91 modelType = pmModelSetType (modelName); 84 92 if (modelType < 0) psAbort("unknown model %s", modelName); 93 source->type = PM_SOURCE_TYPE_EXTENDED; 85 94 } 86 95 if (fitMode == PM_SOURCE_FIT_PSF_X_EXT) { … … 111 120 modelType = pmModelSetType (modelName); 112 121 if (modelType < 0) psAbort("unknown model %s", modelName); 113 } 114 115 // construct the source structures 116 pmSource *source = pmSourceAlloc(); 117 source->peak = pmPeakAlloc (xObj, yObj, 0, 0); 118 pmSourceDefinePixels (source, readout, xObj, yObj, OUTER); 122 source->type = PM_SOURCE_TYPE_EXTENDED; 123 } 119 124 120 125 // find the local sky … … 140 145 // get the initial model parameter guess 141 146 pmModel *model = pmSourceModelGuess (source, modelType); 147 source->modelEXT = model; 142 148 143 149 // if any parameters are defined by the user, take those values … … 162 168 // for PSF fitting, set the shape parameters based on the PSF & source position 163 169 if (fitMode == PM_SOURCE_FIT_PSF) { 164 pmModel *modelPSF = pmModelFromPSF (model, psf);170 source->modelPSF = pmModelFromPSF (model, psf); 165 171 psFree (model); 166 model = modelPSF;172 model = source->modelPSF; 167 173 params = model->params->data.F32; 168 174 } … … 212 218 213 219 // subtract object, leave local sky 214 pmModelSub (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL, maskVal); 220 // pmModelSub (source->pixels, source->maskObj, model, PM_MODEL_OP_FULL, maskVal); 221 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 215 222 216 223 fprintf (stderr, "output parameters: \n"); … … 223 230 psphotSaveImage (NULL, source->maskObj, "mask.fits"); 224 231 232 psLogMsg ("psphot", PS_LOG_INFO, "model test : %f sec\n", psTimerMark ("modelTest")); 233 225 234 exit (0); 226 235 } -
trunk/psphot/src/psphotPSFConvModel.c
r14338 r14348 12 12 bool psphotPSFConvModel (pmSource *source, psMetadata *recipe, psMaskType maskVal) { 13 13 14 bool status; 15 16 int psfSize = psMetadataLookupS32 (&status, recipe, "PCM_BOX_SIZE"); 17 if (!status) { 18 psfSize = 2; 19 } 20 14 21 // make sure we save a cached copy of the psf flux 15 22 pmSourceCachePSF (source, maskVal); … … 17 24 // convert the cached cached psf model for this source to a psKernel 18 25 // XXX for the moment, hard-wire the kernel to be 5x5 (2 pix radius) 19 psKernel *psf = psphotKernelFromPSF (source, 2); 26 // XXX for the moment, hard-wire the kernel to be 9x9 (4 pix radius) 27 psKernel *psf = psphotKernelFromPSF (source, psfSize); 28 29 // psf must be normalized (integral = 1.0) 30 double sum = 0.0; 31 for (int i = 0; i < psf->image->numRows; i++) { 32 for (int j = 0; j < psf->image->numCols; j++) { 33 sum += psf->image->data.F32[i][j]; 34 } 35 } 36 assert (sum > 0.0); 37 for (int i = 0; i < psf->image->numRows; i++) { 38 for (int j = 0; j < psf->image->numCols; j++) { 39 psf->image->data.F32[i][j] /= sum; 40 } 41 } 42 43 # if (0) 44 // XXX sanity check: convolve with delta function should behave like unconvolved version 45 for (int i = 0; i < psf->image->numRows; i++) { 46 for (int j = 0; j < psf->image->numCols; j++) { 47 psf->image->data.F32[i][j] = 0.0; 48 } 49 } 50 psf->image->data.F32[2][2] = 1.0; 51 # endif 20 52 21 53 // generate copy of the model … … 69 101 psTrace ("psphot", 4, "niter: %d, chisq: %f", myMin->iter, myMin->value); 70 102 103 // renormalize output model image 104 float Io = params->data.F32[PM_PAR_I0]; 105 for (int iy = 0; iy < source->modelFlux->numRows; iy++) { 106 for (int ix = 0; ix < source->modelFlux->numCols; ix++) { 107 source->modelFlux->data.F32[iy][ix] /= Io; 108 } 109 } 110 71 111 // save the resulting chisq, nDOF, nIter 72 112 modelConv->chisq = myMin->value;
Note:
See TracChangeset
for help on using the changeset viewer.
