Changeset 36086 for trunk/psphot/src/psphotExtendedSourceFits.c
- Timestamp:
- Aug 31, 2013, 6:02:26 AM (13 years ago)
- Location:
- trunk/psphot
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20130711/psphot (added) merged: 35844,35972-35973,36025,36028-36029,36031-36033,36053-36054,36062-36064,36074
- Property svn:mergeinfo changed
-
trunk/psphot/src
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20130711/psphot/src (added) merged: 35844,35972,36025,36028,36031-36033,36062-36064,36074
- Property svn:mergeinfo changed
-
trunk/psphot/src/psphotExtendedSourceFits.c
r35769 r36086 65 65 psphotVisualShowImage(readout); 66 66 67 // psphotSaveImage (NULL, readout->image, "test.01.fits"); 68 67 69 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 68 70 psAssert (detections, "missing detections?"); … … 123 125 } 124 126 127 // perform full extended source non-linear fits? 128 bool isInteractive = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_FITS_INTERACTIVE"); 129 if (!status) isInteractive = false; 130 125 131 // Define source fitting parameters for extended source fits 126 132 pmSourceFitOptions *fitOptions = pmSourceFitOptionsAlloc(); 127 fitOptions->mode = PM_SOURCE_FIT_EXT ;133 fitOptions->mode = PM_SOURCE_FIT_EXT_AND_SKY; 128 134 fitOptions->saveCovariance = true; // XXX make this a user option? 129 135 fitOptions->covarFactor = psImageCovarianceFactorForAperture(readout->covariance, 10.0); // Covariance matrix … … 134 140 fitOptions->gainFactorMode = gainFactorMode; 135 141 fitOptions->chisqConvergence = chisqConvergence; 142 fitOptions->isInteractive = isInteractive; 136 143 137 144 // maskVal is used to test for rejected pixels, and must include markVal … … 296 303 PS_ARRAY_ADD_SCALAR(job->args, 0, PS_TYPE_S32); // this is used as a return value for Nfail 297 304 298 // set this to 0 to run without threading 299 # if (1) 300 if (!psThreadJobAddPending(job)) { 301 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 302 psFree(AnalysisRegion); 303 psFree (fitOptions); 304 psFree (models); 305 psphotSersicModelClassCleanup(); 306 return false; 307 } 308 # else 309 if (!psphotExtendedSourceFits_Threaded(job)) { 310 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 311 psFree(AnalysisRegion); 312 psFree (fitOptions); 313 psFree (models); 314 psphotSersicModelClassCleanup(); 315 return false; 305 // XXX TEST 306 if (!isInteractive) { 307 if (!psThreadJobAddPending(job)) { 308 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 309 psFree(AnalysisRegion); 310 psFree (fitOptions); 311 psFree (models); 312 psphotSersicModelClassCleanup(); 313 return false; 314 } 315 } else { 316 // run without threading 317 if (!psphotExtendedSourceFits_Threaded(job)) { 318 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 319 psFree(AnalysisRegion); 320 psFree (fitOptions); 321 psFree (models); 322 psphotSersicModelClassCleanup(); 323 return false; 324 } 325 psScalar *scalar = NULL; 326 scalar = job->args->data[9]; 327 Next += scalar->data.S32; 328 scalar = job->args->data[10]; 329 Nconvolve += scalar->data.S32; 330 scalar = job->args->data[11]; 331 NconvolvePass += scalar->data.S32; 332 scalar = job->args->data[12]; 333 Nplain += scalar->data.S32; 334 scalar = job->args->data[13]; 335 NplainPass += scalar->data.S32; 336 scalar = job->args->data[14]; 337 Nfaint += scalar->data.S32; 338 scalar = job->args->data[15]; 339 Nfail += scalar->data.S32; 340 psFree(job->args->data[3]); // iterator allocated above 341 psFree(job); 316 342 } 317 psScalar *scalar = NULL;318 scalar = job->args->data[9];319 Next += scalar->data.S32;320 scalar = job->args->data[10];321 Nconvolve += scalar->data.S32;322 scalar = job->args->data[11];323 NconvolvePass += scalar->data.S32;324 scalar = job->args->data[12];325 Nplain += scalar->data.S32;326 scalar = job->args->data[13];327 NplainPass += scalar->data.S32;328 scalar = job->args->data[14];329 Nfaint += scalar->data.S32;330 scalar = job->args->data[15];331 Nfail += scalar->data.S32;332 psFree(job->args->data[3]); // iterator allocated above333 psFree(job);334 # endif335 343 } 336 344 … … 378 386 psphotSersicModelClassCleanup(); 379 387 388 // psphotSaveImage (NULL, readout->image, "test.02.fits"); 389 380 390 psphotVisualShowResidualImage (readout, false); 381 391 … … 521 531 psFree (source->modelFlux); 522 532 source->modelFlux = NULL; 533 // if ((fabs(source->peak->xf - 2572) < 20) && (fabs(source->peak->yf - 5874) < 20)) { 534 // fprintf (stderr, "test object\n"); 535 // } 536 523 537 modelFit = psphotFitEXT (modelFit, readout, source, fitOptions, modelType, maskVal, markVal); 524 538 if (!modelFit) { … … 544 558 float Ymax = PAR[PM_PAR_YPOS] + 0.5*PAR[PM_PAR_LENGTH]*cos(PAR[PM_PAR_THETA]); 545 559 546 if (false && (source->peak->xf > 1100) && 547 (source->peak->xf < 1400) && 548 (source->peak->yf < 245)) { 560 if ((fabs(source->peak->xf - 2572) < 20) && (fabs(source->peak->yf - 5874) < 20)) { 549 561 fprintf (stderr, "src vs fit : %d %d - %d %d | %f %f - %f %f\n", 550 562 source->pixels->col0, source->pixels->row0, … … 579 591 580 592 if (model->flags & (PM_MODEL_STATUS_BADARGS)) continue; 581 if (model->flags & (PM_MODEL_STATUS_NONCONVERGE)) continue;593 // if (model->flags & (PM_MODEL_STATUS_NONCONVERGE)) continue; 582 594 if (model->flags & (PM_MODEL_STATUS_OFFIMAGE)) continue; 583 595 … … 598 610 pmSourceCacheModel (source, maskVal); 599 611 612 pmModel *model = source->modelFits->data[0]; 613 int flags = 0xffffffff; 614 if (model) { 615 flags = model->flags; 616 } 617 618 fprintf (stderr, "failed to fit extended source model to object %d @ %f, %f (%x)\n", source->id, source->moments->Mx, source->moments->My, flags); 600 619 pmSourceSub (source, PM_MODEL_OP_FULL, maskVal); 601 620 … … 615 634 // cache the model flux 616 635 if (source->modelEXT->isPCM) { 636 // fprintf (stderr, "subtract PCM extended source model for object %d @ %f, %f\n", source->id, source->moments->Mx, source->moments->My); 617 637 pmPCMCacheModel (source, maskVal, psfSize); 618 638 } else { 639 // fprintf (stderr, "subtract non-PCM extended source model for object %d @ %f, %f\n", source->id, source->moments->Mx, source->moments->My); 619 640 pmSourceCacheModel (source, maskVal); 620 641 }
Note:
See TracChangeset
for help on using the changeset viewer.
