- Timestamp:
- Jun 20, 2012, 12:22:52 PM (14 years ago)
- Location:
- branches/eam_branches/ipp-20120601
- Files:
-
- 4 edited
-
. (modified) (1 prop)
-
psphot (modified) (1 prop)
-
psphot/src (modified) (1 prop)
-
psphot/src/psphotFitSourcesLinear.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20120601
- Property svn:mergeinfo changed
/trunk (added) merged: 33979-33980,33986-33991,33993-33994,34006-34008,34010-34018
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20120601/psphot
- Property svn:mergeinfo changed
/trunk/psphot (added) merged: 33980,33993-33994
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20120601/psphot/src
- Property svn:mergeinfo changed
/trunk/psphot/src (added) merged: 33980,33993-33994
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20120601/psphot/src/psphotFitSourcesLinear.c
r33963 r34049 12 12 static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, psImageMaskType markVal); 13 13 14 # if (HAVE_MODEL_VAR) 14 15 bool psphotGenerateModelVariance (pmConfig *config, const pmFPAview *view, pmFPAfile *file, int index, psMetadata *recipe, pmReadout *readout, psArray *sources); 15 16 pmSourceFitVarMode psphotGetFitVarMode (psMetadata *recipe); 16 17 bool psphotFreeModelVariance (pmReadout *readout, psArray *sources); 18 # endif 17 19 18 20 // for now, let's store the detections on the readout->analysis for each readout … … 28 30 assert (recipe); 29 31 32 # if (HAVE_MODEL_VAR) 30 33 pmSourceFitVarMode fitVarMode = psphotGetFitVarMode (recipe); 31 34 if (!fitVarMode) { … … 37 40 // do a single pass. 38 41 pmSourceFitVarMode fitVarModePass1 = (fitVarMode == PM_SOURCE_PHOTFIT_MODEL_VAR) ? PM_SOURCE_PHOTFIT_CONST : fitVarMode; 42 # endif 39 43 40 44 int num = psphotFileruleCount(config, filerule); … … 64 68 psAssert (psf, "missing psf?"); 65 69 66 if (!psphotFitSourcesLinearReadout (recipe, readout, sources, psf, final, fitVarModePass1)) { 70 # if (HAVE_MODEL_VAR) 71 if (!psphotFitSourcesLinearReadout (recipe, readout, sources, psf, final, fitVarModePass1)) 72 # else 73 if (!psphotFitSourcesLinearReadout (recipe, readout, sources, psf, final)) 74 # endif 75 { 67 76 psError (PSPHOT_ERR_CONFIG, false, "failed to fit sources (linear) for %s entry %d", filerule, i); 68 77 return false; 69 78 } 70 79 80 # if (HAVE_MODEL_VAR) 71 81 // the MODEL_VAR weighting scheme requires knowledge of the model fluxes to generate the variance 72 82 // after we have determined the initial set of fits, then we can generate the variance image and … … 94 104 } 95 105 } 106 # endif 96 107 97 108 psphotVisualShowResidualImage (readout, (num > 0)); … … 102 113 } 103 114 115 # if (HAVE_MODEL_VAR) 104 116 // look up the fit variance mode from the recipe; older recipes do not have the value 105 117 // 'LINEAR_FIT_VARIANCE_MODE'; in those cases, look for 'CONSTANT_PHOTOMETRIC_WEIGHTS' as a boolean and … … 130 142 return PM_SOURCE_PHOTFIT_NONE; 131 143 } 132 133 bool psphotFitSourcesLinearReadout (psMetadata *recipe, pmReadout *readout, psArray *sources, pmPSF *psf, bool final, pmSourceFitVarMode fitVarMode) { 134 144 # endif 145 146 # if (HAVE_MODEL_VAR) 147 bool psphotFitSourcesLinearReadout (psMetadata *recipe, pmReadout *readout, psArray *sources, pmPSF *psf, bool final, pmSourceFitVarMode fitVarMode) 148 # else 149 bool psphotFitSourcesLinearReadout (psMetadata *recipe, pmReadout *readout, psArray *sources, pmPSF *psf, bool final) 150 # endif 151 { 135 152 bool status; 136 153 float x; … … 168 185 if (psRegionIsNaN (AnalysisRegion)) psAbort("analysis region mis-defined"); 169 186 187 # if (!HAVE_MODEL_VAR) 188 bool CONSTANT_PHOTOMETRIC_WEIGHTS = 189 psMetadataLookupBool(&status, recipe, "CONSTANT_PHOTOMETRIC_WEIGHTS"); 190 if (!status) { 191 psAbort("You must provide a value for the BOOL recipe CONSTANT_PHOTOMETRIC_WEIGHTS"); 192 } 193 # endif 170 194 int SKY_FIT_ORDER = psMetadataLookupS32(&status, recipe, "SKY_FIT_ORDER"); 171 195 if (!status) { … … 295 319 psSparseBorder *border = psSparseBorderAlloc (sparse, nBorder); 296 320 321 # if (HAVE_MODEL_VAR) 297 322 // if fitVarMode is MODEL_VAR, then we need to generate the model image variance 298 323 // XXX we have two possibilities here: … … 302 327 303 328 // 2) do a single pass, and use the model guess to define the model variance (but do I trust the Model Guess?) 329 # endif 304 330 305 331 // fill out the sparse matrix elements and border elements (B) … … 310 336 311 337 // diagonal elements of the sparse matrix (auto-cross-product) 338 # if (HAVE_MODEL_VAR) 312 339 f = pmSourceModelDotModel (SRCi, SRCi, fitVarMode, covarFactor, maskVal); 340 # else 341 f = pmSourceModelDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor, maskVal); 342 # endif 313 343 psSparseMatrixElement (sparse, i, i, f); 314 344 345 # if (HAVE_MODEL_VAR) 315 346 // if we have used CONSTANT errors, then we need to calculate the value of the parameter error 316 347 if (fitVarMode != PM_SOURCE_PHOTFIT_IMAGE_VAR) { … … 320 351 errors->data.F32[i] = 1.0 / sqrt(f); 321 352 } 322 353 # else 354 // the formal error depends on the weighting scheme 355 if (CONSTANT_PHOTOMETRIC_WEIGHTS) { 356 float var = pmSourceModelDotModel (SRCi, SRCi, false, covarFactor, maskVal); 357 errors->data.F32[i] = 1.0 / sqrt(var); 358 } else { 359 errors->data.F32[i] = 1.0 / sqrt(f); 360 } 361 # endif 323 362 324 363 // find the image x model value 364 # if (HAVE_MODEL_VAR) 325 365 f = pmSourceDataDotModel (SRCi, SRCi, fitVarMode, covarFactor, maskVal); 366 # else 367 f = pmSourceDataDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor, maskVal); 368 # endif 326 369 psSparseVectorElement (sparse, i, f); 327 370 … … 329 372 switch (SKY_FIT_ORDER) { 330 373 case 1: 374 # if (HAVE_MODEL_VAR) 331 375 f = pmSourceModelWeight (SRCi, 1, fitVarMode, covarFactor, maskVal); 332 376 psSparseBorderElementB (border, i, 1, f); 333 377 f = pmSourceModelWeight (SRCi, 2, fitVarMode, covarFactor, maskVal); 334 378 psSparseBorderElementB (border, i, 2, f); 379 # else 380 f = pmSourceModelWeight (SRCi, 1, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor, maskVal); 381 psSparseBorderElementB (border, i, 1, f); 382 f = pmSourceModelWeight (SRCi, 2, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor, maskVal); 383 psSparseBorderElementB (border, i, 2, f); 384 # endif 335 385 336 386 case 0: 387 # if (HAVE_MODEL_VAR) 337 388 f = pmSourceModelWeight (SRCi, 0, fitVarMode, covarFactor, maskVal); 389 # else 390 f = pmSourceModelWeight (SRCi, 0, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor, maskVal); 391 # endif 338 392 psSparseBorderElementB (border, i, 0, f); 339 393 break; … … 355 409 356 410 // got an overlap; calculate cross-product and add to output array 411 # if (HAVE_MODEL_VAR) 357 412 f = pmSourceModelDotModel (SRCi, SRCj, fitVarMode, covarFactor, maskVal); 413 # else 414 f = pmSourceModelDotModel (SRCi, SRCj, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor, maskVal); 415 # endif 358 416 psSparseMatrixElement (sparse, j, i, f); 359 417 } … … 393 451 394 452 // set the sky, sky_x, sky_y components of border matrix 453 # if (HAVE_MODEL_VAR) 395 454 SetBorderMatrixElements (border, readout, fitSources, (fitVarMode == PM_SOURCE_PHOTFIT_CONST), SKY_FIT_ORDER, markVal); 455 # else 456 SetBorderMatrixElements (border, readout, fitSources, CONSTANT_PHOTOMETRIC_WEIGHTS, SKY_FIT_ORDER, markVal); 457 # endif 396 458 397 459 psSparseConstraint constraint; … … 552 614 } 553 615 616 # if (HAVE_MODEL_VAR) 554 617 bool psphotModelBackgroundReadout(psImage *model, // Model image 555 618 psImage *modelStdev, // Model stdev image … … 661 724 return true; 662 725 } 726 # endif
Note:
See TracChangeset
for help on using the changeset viewer.
