- Timestamp:
- Mar 19, 2013, 2:50:27 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130307/psphot/src/psphotModelTestReadout.c
r32348 r35322 5 5 6 6 bool status; 7 8 psTimerStart ("modelTest"); 7 9 8 10 pmModelClassSetLimits(PM_MODEL_LIMITS_LAX); … … 41 43 } 42 44 45 // load the psf model, if suppled. FWHM_MAJ,FWHM_MIN,etc are determined and saved on 46 // readout->analysis. NOTE: this function currently only loads from PSPHOT.PSF.LOAD 47 if (!psphotLoadPSF (config, view, filerule)) { // ??? need to supply 2 ? 48 psError (PSPHOT_ERR_UNKNOWN, false, "error loading psf model"); 49 return psphotReadoutCleanup (config, view, filerule); 50 } 51 43 52 float MIN_KRON_RADIUS = 5.0; 44 53 … … 53 62 // maskVal is used to test for rejected pixels, and must include markVal 54 63 maskVal |= markVal; 64 65 // what fraction of the PSF is used? (radius in pixels : 2 -> 5x5 box) 66 int psfSize = psMetadataLookupS32 (&status, recipe, "PCM_BOX_SIZE"); 67 assert (status); 55 68 56 69 // find the currently selected readout … … 84 97 85 98 // define the source of interest 86 float xObj = psMetadataLookupF32 (&status, recipe, "TEST_FIT_X");99 float xObj = psMetadataLookupF32 (&status, recipe, "TEST_FIT_X"); 87 100 float yObj = psMetadataLookupF32 (&status, recipe, "TEST_FIT_Y"); 88 101 if (!isfinite(xObj) || !isfinite(yObj)) psAbort ("object position is not defined"); … … 99 112 source->type = PM_SOURCE_TYPE_EXTENDED; 100 113 114 bool TEST_FIT_CONVOLVED = psMetadataLookupBool (&status, recipe, "TEST_FIT_CONVOLVED"); 115 101 116 // find the local sky 102 117 status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, markVal); 103 118 if (!status) psAbort("pmSourceLocalSky error"); 104 119 105 { 120 bool testMomentsRadius = psMetadataLookupBool (&status, config->arguments, "TEST_MOMENTS_RADIUS"); 121 if (testMomentsRadius) { 106 122 // XXX I want to test an iterative aperture for brighter sources 107 123 float radius = mRADIUS; … … 109 125 110 126 // get the source moments 111 status = pmSourceMoments (source, radius, 0. 0, 0.0, MIN_KRON_RADIUS, maskVal);127 status = pmSourceMoments (source, radius, 0.25*radius, 0.0, MIN_KRON_RADIUS, maskVal); 112 128 if (!status) psAbort("psSourceMoments error"); 113 129 … … 121 137 122 138 // get the source moments 123 status = pmSourceMoments (source, mRADIUS, 0. 0, 0.0, MIN_KRON_RADIUS, maskVal);139 status = pmSourceMoments (source, mRADIUS, 0.25*mRADIUS, 0.0, MIN_KRON_RADIUS, maskVal); 124 140 if (!status) psAbort("psSourceMoments error"); 125 141 … … 135 151 fprintf (stderr, "axes: %f @ (%f, %f)\n", axes.theta*180/M_PI, axes.major, axes.minor); 136 152 153 pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF"); 154 if (psf) { 155 // set PSF parameters for this model (apply 2D shape model to coordinates Xo, Yo) 156 source->peak->rawFlux = source->moments->Peak; 157 float Io = source->moments->Peak; 158 source->modelPSF = pmModelFromPSFforXY(psf, xObj, yObj, Io); 159 } 160 137 161 // get the initial model parameter guess 138 pmModel *model = pmSourceModelGuess (source, modelType );162 pmModel *model = pmSourceModelGuess (source, modelType, maskVal, markVal); 139 163 source->modelEXT = model; 140 164 … … 159 183 fprintf (stderr, "peak: %f @ (%f, %f)\n", source->moments->Sum*area, (double)source->peak->x, (double)source->peak->y); 160 184 161 // list model input shape 162 psEllipseShape shape; 163 shape.sx = 1.4 / model->params->data.F32[4]; 164 shape.sy = 1.4 / model->params->data.F32[5]; 165 shape.sxy = model->params->data.F32[6]; 166 axes = psEllipseShapeToAxes (shape, 20.0); 167 168 fprintf (stderr, "guess: %f @ (%f, %f)\n", axes.theta*180/M_PI, axes.major, axes.minor); 185 if (modelType == pmModelClassGetType("PS_MODEL_TRAIL")) { 186 fprintf (stderr, "guess: %f @ (%f, %f)\n", params[6]*180/M_PI, params[4], params[5]); 187 } else { 188 // list model input shape 189 psEllipseShape shape; 190 shape.sx = 1.4 / model->params->data.F32[4]; 191 shape.sy = 1.4 / model->params->data.F32[5]; 192 shape.sxy = model->params->data.F32[6]; 193 axes = psEllipseShapeToAxes (shape, 20.0); 194 fprintf (stderr, "guess: %f @ (%f, %f)\n", axes.theta*180/M_PI, axes.major, axes.minor); 195 } 169 196 170 197 fprintf (stderr, "input parameters: \n"); … … 190 217 fitOptions->covarFactor = psImageCovarianceFactorForAperture(readout->covariance, 10.0); // Covariance matrix 191 218 192 status = pmSourceFitModel (source, model, fitOptions, maskVal); 219 if (modelType == pmModelClassGetType("PS_MODEL_SERSIC")) { 220 fitOptions->mode = PM_SOURCE_FIT_NO_INDEX; 221 } 222 if (modelType == pmModelClassGetType("PS_MODEL_TRAIL")) { 223 fitOptions->mode = PM_SOURCE_FIT_TRAIL; 224 } 225 226 if (TEST_FIT_CONVOLVED) { 227 pmPCMdata *pcm = pmPCMinit (source, fitOptions, model, maskVal, psfSize); 228 if (modelType == pmModelClassGetType("PS_MODEL_SERSIC")) { 229 psphotSersicModelClassGuessPCM (pcm, source); 230 } else { 231 pmSourceModelGuessPCM (pcm, source, maskVal, markVal); 232 } 233 pmPCMupdate(pcm, source, fitOptions, model); 234 pmSourceFitPCM (pcm, source, fitOptions, maskVal, markVal, psfSize); 235 psFree (pcm); 236 } else { 237 status = pmSourceFitModel (source, model, fitOptions, maskVal); 238 } 193 239 194 240 // measure the source mags
Note:
See TracChangeset
for help on using the changeset viewer.
