Changeset 31154 for trunk/psphot/src/psphotExtendedSourceFits.c
- Timestamp:
- Apr 4, 2011, 1:12:39 PM (15 years ago)
- Location:
- trunk/psphot
- Files:
-
- 2 edited
-
. (modified) (2 props)
-
src/psphotExtendedSourceFits.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot
- Property svn:ignore
-
old new 19 19 psphot-config 20 20 Doxyfile 21 a.out.dSYM
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
trunk/psphot/src/psphotExtendedSourceFits.c
r30624 r31154 43 43 int NplainPass = 0; 44 44 int Nfaint = 0; 45 int Nfail = 0; 45 46 46 47 psTimerStart ("psphot.extended"); … … 145 146 146 147 // source analysis is done in S/N order (brightest first) 147 sources = psArraySort (sources, pmSourceSortBy SN);148 sources = psArraySort (sources, pmSourceSortByFlux); 148 149 149 150 // choose Cx, Cy (see psphotThreadTools.c for overview of the concepts) … … 176 177 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nplain 177 178 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for NplainPass 178 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfain 179 180 if (false && !psThreadJobAddPending(job)) { 179 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfaint 180 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail 181 182 // set this to 0 to run without threading 183 # if (1) 184 if (!psThreadJobAddPending(job)) { 181 185 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 182 186 psFree(AnalysisRegion); 183 187 return false; 184 } else { 185 if (!psphotExtendedSourceFits_Threaded(job)) { 186 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 187 psFree(AnalysisRegion); 188 return false; 189 } 190 psScalar *scalar = NULL; 191 scalar = job->args->data[7]; 192 Next += scalar->data.S32; 193 scalar = job->args->data[8]; 194 Nconvolve += scalar->data.S32; 195 scalar = job->args->data[9]; 196 NconvolvePass += scalar->data.S32; 197 scalar = job->args->data[10]; 198 Nplain += scalar->data.S32; 199 scalar = job->args->data[11]; 200 NplainPass += scalar->data.S32; 201 scalar = job->args->data[12]; 202 Nfaint += scalar->data.S32; 203 psFree(job); 188 } 189 # else 190 if (!psphotExtendedSourceFits_Threaded(job)) { 191 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 192 psFree(AnalysisRegion); 193 return false; 204 194 } 205 } 195 psScalar *scalar = NULL; 196 scalar = job->args->data[7]; 197 Next += scalar->data.S32; 198 scalar = job->args->data[8]; 199 Nconvolve += scalar->data.S32; 200 scalar = job->args->data[9]; 201 NconvolvePass += scalar->data.S32; 202 scalar = job->args->data[10]; 203 Nplain += scalar->data.S32; 204 scalar = job->args->data[11]; 205 NplainPass += scalar->data.S32; 206 scalar = job->args->data[12]; 207 Nfaint += scalar->data.S32; 208 scalar = job->args->data[13]; 209 Nfail += scalar->data.S32; 210 psFree(job); 211 # endif 212 } 206 213 207 214 // wait for the threads to finish and manage results … … 231 238 scalar = job->args->data[12]; 232 239 Nfaint += scalar->data.S32; 240 scalar = job->args->data[13]; 241 Nfail += scalar->data.S32; 233 242 } 234 243 psFree(job); … … 238 247 psFree(AnalysisRegion); 239 248 240 psLogMsg ("psphot", PS_LOG_INFO, "extended source analysis: %f sec for %d objects\n", psTimerMark ("psphot.extended"), Next);249 psLogMsg ("psphot", PS_LOG_INFO, "extended source model fits: %f sec for %d objects\n", psTimerMark ("psphot.extended"), Next); 241 250 psLogMsg ("psphot", PS_LOG_INFO, " %d convolved models (%d passed)\n", Nconvolve, NconvolvePass); 242 251 psLogMsg ("psphot", PS_LOG_INFO, " %d plain models (%d passed)\n", Nplain, NplainPass); 243 psLogMsg ("psphot", PS_LOG_INFO, " %d too faint to fit \n", Nfaint);252 psLogMsg ("psphot", PS_LOG_INFO, " %d too faint to fit, %d failed\n", Nfaint, Nfail); 244 253 return true; 245 254 } … … 250 259 bool status; 251 260 int Next = 0; 261 int Nfaint = 0; 262 int Nfail = 0; 252 263 int Nconvolve = 0; 253 264 int NconvolvePass = 0; 254 265 int Nplain = 0; 255 int Nfaint = 0;256 266 int NplainPass = 0; 257 267 bool savePics = false; … … 268 278 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[6],PS_TYPE_IMAGE_MASK_DATA); 269 279 280 // pthread_t tid = pthread_self(); // Thread identifier 281 270 282 // Define source fitting parameters for extended source fits 271 283 pmSourceFitOptions *fitOptions = pmSourceFitOptionsAlloc(); 272 fitOptions->mode = PM_SOURCE_FIT_EXT; 284 fitOptions->mode = PM_SOURCE_FIT_EXT; 285 fitOptions->saveCovariance = true; // XXX make this a user option? 286 fitOptions->covarFactor = psImageCovarianceFactorForAperture(readout->covariance, 10.0); // Covariance matrix 287 273 288 // XXX for now, use the defaults for the rest: 274 289 // fitOptions->nIter = fitIter; … … 296 311 // XXX use the parameters guessed from moments 297 312 // if (source->modelEXT == NULL) continue; 313 314 // fprintf (stderr, "fit %d,%d in thread %d\n", source->peak->x, source->peak->y, (int) tid); 298 315 299 316 // replace object in image … … 366 383 // limit selection to some SN limit 367 384 assert (source->peak); // how can a source not have a peak? 368 if (s ource->peak->SN< SNlim) {385 if (sqrt(source->peak->detValue) < SNlim) { 369 386 Nfaint ++; 370 387 continue; … … 388 405 if (!modelFit) { 389 406 psTrace ("psphot", 5, "failed to fit psf-conv model for object at %f, %f", source->moments->Mx, source->moments->My); 407 Nfail ++; 390 408 continue; 391 409 } … … 402 420 if (!modelFit) { 403 421 psTrace ("psphot", 5, "failed to fit plain model for object at %f, %f", source->moments->Mx, source->moments->My); 422 Nfail ++; 404 423 continue; 405 424 } … … 519 538 scalar->data.S32 = Nfaint; 520 539 540 scalar = job->args->data[13]; 541 scalar->data.S32 = Nfail; 542 521 543 return true; 522 544 }
Note:
See TracChangeset
for help on using the changeset viewer.
