- Timestamp:
- May 3, 2010, 8:41:49 AM (16 years ago)
- Location:
- branches/tap_branches
- Files:
-
- 4 edited
-
. (modified) (1 prop)
-
psphot (modified) (1 prop)
-
psphot/src (modified) (1 prop)
-
psphot/src/psphotFitSourcesLinear.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/tap_branches
- Property svn:mergeinfo changed
-
branches/tap_branches/psphot
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/psphot merged eligible /branches/eam_branches/stackphot.20100406/psphot 27622-27655 /branches/pap_delete/psphot 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/tap_branches/psphot/src
- Property svn:ignore
-
old new 19 19 psphotMomentsStudy 20 20 psphotPetrosianStudy 21 psphotForced 22 psphotMakePSF 23 psphotStack
-
- Property svn:ignore
-
branches/tap_branches/psphot/src/psphotFitSourcesLinear.c
r25755 r27838 12 12 static bool SetBorderMatrixElements (psSparseBorder *border, pmReadout *readout, psArray *sources, bool constant_weights, int SKY_FIT_ORDER, psImageMaskType markVal); 13 13 14 bool psphotFitSourcesLinear (pmReadout *readout, psArray *sources, const psMetadata *recipe, const pmPSF *psf, bool final) { 14 // for now, let's store the detections on the readout->analysis for each readout 15 bool psphotFitSourcesLinear (pmConfig *config, const pmFPAview *view, bool final) 16 { 17 bool status = true; 18 19 // select the appropriate recipe information 20 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 21 assert (recipe); 22 23 int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 24 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 25 26 // loop over the available readouts 27 for (int i = 0; i < num; i++) { 28 29 // find the currently selected readout 30 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PSPHOT.INPUT", i); // File of interest 31 psAssert (file, "missing file?"); 32 33 pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); 34 psAssert (readout, "missing readout?"); 35 36 pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS"); 37 psAssert (detections, "missing detections?"); 38 39 psArray *sources = detections->allSources; 40 psAssert (sources, "missing sources?"); 41 42 pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF"); 43 psAssert (psf, "missing psf?"); 44 45 if (!psphotFitSourcesLinearReadout (recipe, readout, sources, psf, final)) { 46 psError (PSPHOT_ERR_CONFIG, false, "failed to fit sources (linear) for PSPHOT.INPUT entry %d", i); 47 return false; 48 } 49 } 50 return true; 51 } 52 53 bool psphotFitSourcesLinearReadout (psMetadata *recipe, pmReadout *readout, psArray *sources, pmPSF *psf, bool final) { 15 54 16 55 bool status; … … 18 57 float y; 19 58 float f; 20 // float r; 59 60 if (!sources->n) { 61 psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping linear fit"); 62 return true; 63 } 21 64 22 65 psTimerStart ("psphot.linear"); … … 59 102 } 60 103 104 // XXX test: choose a larger-than expected radius: 105 float covarFactor = psImageCovarianceFactorForAperture(readout->covariance, 10.0); // Covariance matrix 106 psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "covariance factor: %f\n", covarFactor); 107 108 // XXX do not apply covarFactor for the moment... 109 // covarFactor = 1.0; 110 61 111 // select the sources which will be used for the fitting analysis 62 112 for (int i = 0; i < sources->n; i++) { … … 120 170 121 171 // diagonal elements of the sparse matrix (auto-cross-product) 122 f = pmSourceModelDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS );172 f = pmSourceModelDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor); 123 173 psSparseMatrixElement (sparse, i, i, f); 124 174 125 175 // the formal error depends on the weighting scheme 126 176 if (CONSTANT_PHOTOMETRIC_WEIGHTS) { 127 float var = pmSourceModelDotModel (SRCi, SRCi, false );177 float var = pmSourceModelDotModel (SRCi, SRCi, false, covarFactor); 128 178 errors->data.F32[i] = 1.0 / sqrt(var); 129 179 } else { … … 133 183 134 184 // find the image x model value 135 f = pmSourceDataDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS );185 f = pmSourceDataDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor); 136 186 psSparseVectorElement (sparse, i, f); 137 187 … … 139 189 switch (SKY_FIT_ORDER) { 140 190 case 1: 141 f = pmSourceModelWeight (SRCi, 1, CONSTANT_PHOTOMETRIC_WEIGHTS );191 f = pmSourceModelWeight (SRCi, 1, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor); 142 192 psSparseBorderElementB (border, i, 1, f); 143 f = pmSourceModelWeight (SRCi, 2, CONSTANT_PHOTOMETRIC_WEIGHTS );193 f = pmSourceModelWeight (SRCi, 2, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor); 144 194 psSparseBorderElementB (border, i, 2, f); 145 195 146 196 case 0: 147 f = pmSourceModelWeight (SRCi, 0, CONSTANT_PHOTOMETRIC_WEIGHTS );197 f = pmSourceModelWeight (SRCi, 0, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor); 148 198 psSparseBorderElementB (border, i, 0, f); 149 199 break; … … 165 215 166 216 // got an overlap; calculate cross-product and add to output array 167 f = pmSourceModelDotModel (SRCi, SRCj, CONSTANT_PHOTOMETRIC_WEIGHTS );217 f = pmSourceModelDotModel (SRCi, SRCj, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor); 168 218 psSparseMatrixElement (sparse, j, i, f); 169 219 } … … 219 269 220 270 // measure chisq for each source 221 for (int i = 0; final && (i < fitSources->n); i++) { 271 // for (int i = 0; final && (i < fitSources->n); i++) { 272 for (int i = 0; i < fitSources->n; i++) { 222 273 pmSource *source = fitSources->data[i]; 223 274 if (source->mode & PM_SOURCE_MODE_NONLINEAR_FIT) continue; 224 275 pmModel *model = pmSourceGetModel (NULL, source); 225 pmSourceChisq (model, source->pixels, source->maskObj, source->variance, maskVal );276 pmSourceChisq (model, source->pixels, source->maskObj, source->variance, maskVal, covarFactor); 226 277 } 227 278 psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "get chisqs: %f sec (%d elements)\n", psTimerMark ("psphot.linear"), sparse->Nelem); … … 238 289 239 290 psphotVisualShowResidualImage (readout); 291 psphotVisualPlotChisq (sources); 240 292 // psphotVisualShowFlags (sources); 293 294 // We have to place this visualization here because the models are not realized until 295 // psphotGuessModels or fitted until psphotFitSourcesLinear. 296 psphotVisualShowPSFStars (recipe, psf, sources); 241 297 242 298 return true; … … 244 300 245 301 // XXX do we need this? 302 // XXX disallow the simultaneous sky fit and remove this code... 246 303 247 304 // Calculate the weight terms for the sky fit component of the matrix. This function operates
Note:
See TracChangeset
for help on using the changeset viewer.
