- Timestamp:
- Jul 9, 2010, 10:56:32 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100621/psphot/src/psphotBlendFit.c
r28405 r28643 75 75 76 76 // Define source fitting parameters for extended source fits 77 pmSourceFitModelInit(fitIter, fitTol, PS_SQR(skySig), poisson); 77 pmSourceFitOptions *fitOptions = pmSourceFitOptionsAlloc(); 78 fitOptions->nIter = fitIter; 79 fitOptions->tol = fitTol; 80 fitOptions->poissonErrors = poisson; 81 fitOptions->weight = PS_SQR(skySig); 82 fitOptions->mode = PM_SOURCE_FIT_PSF; 78 83 79 84 psphotInitLimitsPSF (recipe, readout); … … 88 93 if (!sources->n) { 89 94 psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping blend"); 95 psFree (fitOptions); 90 96 return true; 91 97 } … … 112 118 psArrayAdd(job->args, 1, psf); 113 119 psArrayAdd(job->args, 1, newSources); // return for new sources 120 psArrayAdd(job->args, 1, fitOptions); // default fit options 114 121 psFree (newSources); 115 122 … … 121 128 if (!psThreadJobAddPending(job)) { 122 129 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 130 psFree (fitOptions); 123 131 return NULL; 124 132 } 125 126 # if (0)127 {128 int nfit = 0;129 int npsf = 0;130 int next = 0;131 int nfail = 0;132 psArray *newSources = psArrayAllocEmpty(16);133 134 if (!psphotBlendFit_Unthreaded (&nfit, &npsf, &next, &nfail, readout, recipe, cells->data[j], psf, newSources)) {135 psError(PS_ERR_UNKNOWN, false, "Unable to guess model.");136 return NULL;137 }138 Nfit += nfit;139 Npsf += npsf;140 Next += next;141 Nfail += nfail;142 143 // add these back onto sources144 for (int k = 0; k < newSources->n; k++) {145 psArrayAdd (sources, 16, newSources->data[k]);146 }147 psFree (newSources);148 }149 # endif150 133 } 151 134 … … 153 136 if (!psThreadPoolWait (false)) { 154 137 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 138 psFree (fitOptions); 155 139 return NULL; 156 140 } … … 163 147 } else { 164 148 psScalar *scalar = NULL; 165 scalar = job->args->data[ 5];149 scalar = job->args->data[6]; 166 150 Nfit += scalar->data.S32; 167 scalar = job->args->data[ 6];151 scalar = job->args->data[7]; 168 152 Npsf += scalar->data.S32; 169 scalar = job->args->data[ 7];153 scalar = job->args->data[8]; 170 154 Next += scalar->data.S32; 171 scalar = job->args->data[ 8];155 scalar = job->args->data[9]; 172 156 Nfail += scalar->data.S32; 173 157 … … 186 170 psphotSaveImage (NULL, readout->image, "image.v2.fits"); 187 171 } 172 psFree (fitOptions); 188 173 189 174 psLogMsg ("psphot.psphotBlendFit", PS_LOG_INFO, "fit models: %f sec for %d objects (%d psf, %d ext, %d failed, %ld skipped)\n", psTimerMark ("psphot.fit.nonlinear"), Nfit, Npsf, Next, Nfail, sources->n - Nfit); … … 204 189 psScalar *scalar = NULL; 205 190 206 pmReadout *readout = job->args->data[0]; 207 psMetadata *recipe = job->args->data[1]; 208 psArray *sources = job->args->data[2]; 209 pmPSF *psf = job->args->data[3]; 210 psArray *newSources = job->args->data[4]; 191 pmReadout *readout = job->args->data[0]; 192 psMetadata *recipe = job->args->data[1]; 193 psArray *sources = job->args->data[2]; 194 pmPSF *psf = job->args->data[3]; 195 psArray *newSources = job->args->data[4]; 196 pmSourceFitOptions *fitOptions = job->args->data[5]; 211 197 212 198 // bit-masks to test for good/bad pixels … … 269 255 Nfit ++; 270 256 257 if (0) { 258 psF32 Mxx = source->moments->Mxx; 259 psF32 Myy = source->moments->Myy; 260 fprintf (stderr, "1: Mxx: %f, Myy: %f\n", Mxx, Myy); 261 } 262 271 263 // try fitting PSFs or extended sources depending on source->mode 272 264 // these functions subtract the resulting fitted source 273 265 if (source->mode & PM_SOURCE_MODE_EXT_LIMIT) { 274 if (psphotFitBlob (readout, source, newSources, psf, maskVal, markVal)) {266 if (psphotFitBlob (readout, source, newSources, psf, fitOptions, maskVal, markVal)) { 275 267 source->type = PM_SOURCE_TYPE_EXTENDED; 276 268 psTrace ("psphot", 5, "source at %7.1f, %7.1f is ext", source->peak->xf, source->peak->yf); … … 280 272 } 281 273 } else { 282 if (psphotFitBlend (readout, source, psf, maskVal, markVal)) {274 if (psphotFitBlend (readout, source, psf, fitOptions, maskVal, markVal)) { 283 275 source->type = PM_SOURCE_TYPE_STAR; 284 276 psTrace ("psphot", 5, "source at %7.1f, %7.1f is psf", source->peak->xf, source->peak->yf); … … 289 281 } 290 282 283 if (0) { 284 psF32 Mxx = source->moments->Mxx; 285 psF32 Myy = source->moments->Myy; 286 fprintf (stderr, "2: Mxx: %f, Myy: %f\n", Mxx, Myy); 287 } 288 291 289 psTrace ("psphot", 5, "source at %7.1f, %7.1f failed", source->peak->xf, source->peak->yf); 292 290 Nfail ++; … … 298 296 299 297 // change the value of a scalar on the array (wrap this and put it in psArray.h) 300 scalar = job->args->data[ 5];298 scalar = job->args->data[6]; 301 299 scalar->data.S32 = Nfit; 302 300 303 scalar = job->args->data[ 6];301 scalar = job->args->data[7]; 304 302 scalar->data.S32 = Npsf; 305 303 306 scalar = job->args->data[ 7];304 scalar = job->args->data[8]; 307 305 scalar->data.S32 = Next; 308 306 309 scalar = job->args->data[ 8];307 scalar = job->args->data[9]; 310 308 scalar->data.S32 = Nfail; 311 309
Note:
See TracChangeset
for help on using the changeset viewer.
