Changeset 27649 for branches/eam_branches/stackphot.20100406/psphot/src/psphotFitSourcesLinearStack.c
- Timestamp:
- Apr 9, 2010, 4:41:16 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/stackphot.20100406/psphot/src/psphotFitSourcesLinearStack.c
r27625 r27649 3 3 // XXX define the 'good' / 'bad' flags? 4 4 5 # define COVAR_FACTOR 1.0 6 5 7 bool psphotFitSourcesLinearStack (pmConfig *config, psArray *objects, bool final) { 6 8 7 9 bool status; 8 float x;9 float y;10 10 float f; 11 11 … … 29 29 // analysis is done in spatial order (to speed up overlap search) 30 30 // sort by first element in each source list 31 objects = psArraySort (objects, pmPhotObjSortBy Y);31 objects = psArraySort (objects, pmPhotObjSortByX); 32 32 33 33 // storage array for fitSources … … 66 66 } 67 67 } 68 psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "built fitSources: %f sec (%ld objects)\n", psTimerMark ("psphot.linear"), sources->n);68 psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "built fitSources: %f sec (%ld objects)\n", psTimerMark ("psphot.linear"), objects->n); 69 69 70 70 if (fitSources->n == 0) { … … 86 86 87 87 // diagonal elements of the sparse matrix (auto-cross-product) 88 f = pmSourceModelDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor);88 f = pmSourceModelDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS, COVAR_FACTOR); 89 89 psSparseMatrixElement (sparse, i, i, f); 90 90 91 91 // the formal error depends on the weighting scheme 92 92 if (CONSTANT_PHOTOMETRIC_WEIGHTS) { 93 float var = pmSourceModelDotModel (SRCi, SRCi, false, covarFactor);93 float var = pmSourceModelDotModel (SRCi, SRCi, false, COVAR_FACTOR); 94 94 errors->data.F32[i] = 1.0 / sqrt(var); 95 95 } else { … … 98 98 99 99 // find the image x model value 100 f = pmSourceDataDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor);100 f = pmSourceDataDotModel (SRCi, SRCi, CONSTANT_PHOTOMETRIC_WEIGHTS, COVAR_FACTOR); 101 101 psSparseVectorElement (sparse, i, f); 102 102 … … 109 109 110 110 // skip over disjoint source images, break after last possible overlap 111 if (SRC i->pixels->row0 + SRCi->pixels->numRows < SRCj->pixels->row0) break;112 if (SRC j->pixels->row0 + SRCj->pixels->numRows < SRCi->pixels->row0) continue;113 if (SRC i->pixels->col0 + SRCi->pixels->numCols < SRCj->pixels->col0) continue;114 if (SRC j->pixels->col0 + SRCj->pixels->numCols < SRCi->pixels->col0) continue;111 if (SRCj->pixels->row0 + SRCj->pixels->numRows < SRCi->pixels->row0) continue; // source(i) is above source(j) 112 if (SRCi->pixels->row0 + SRCi->pixels->numRows < SRCj->pixels->row0) continue; // source(i) is below source(j) 113 if (SRCj->pixels->col0 + SRCj->pixels->numCols < SRCi->pixels->col0) continue; // source(i) is right of source(j) 114 if (SRCi->pixels->col0 + SRCi->pixels->numCols < SRCj->pixels->col0) break; // source(i) is left of source(j) [no other source(j) can overlap source(i)] 115 115 116 116 // got an overlap; calculate cross-product and add to output array 117 f = pmSourceModelDotModel (SRCi, SRCj, CONSTANT_PHOTOMETRIC_WEIGHTS, covarFactor);117 f = pmSourceModelDotModel (SRCi, SRCj, CONSTANT_PHOTOMETRIC_WEIGHTS, COVAR_FACTOR); 118 118 psSparseMatrixElement (sparse, j, i, f); 119 119 } … … 157 157 if (source->mode & PM_SOURCE_MODE_NONLINEAR_FIT) continue; 158 158 pmModel *model = pmSourceGetModel (NULL, source); 159 pmSourceChisq (model, source->pixels, source->maskObj, source->variance, maskVal, covarFactor);159 pmSourceChisq (model, source->pixels, source->maskObj, source->variance, maskVal, COVAR_FACTOR); 160 160 } 161 161 psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "get chisqs: %f sec (%d elements)\n", psTimerMark ("psphot.linear"), sparse->Nelem); … … 172 172 } 173 173 174 // sort by Y(ascending)175 int pmPhotObjSortBy SN(const void **a, const void **b)174 // sort by X (ascending) 175 int pmPhotObjSortByX (const void **a, const void **b) 176 176 { 177 177 pmPhotObj *objA = *(pmPhotObj **)a; 178 178 pmPhotObj *objB = *(pmPhotObj **)b; 179 179 180 psAssert (objA->sources, "missing sources?"); 181 psAssert (objB->sources, "missing sources?"); 182 183 psAssert (objA->sources->n, "missing sources"); 184 psAssert (objB->sources->n, "missing sources"); 185 186 psAssert (objA->sources->data[0], "missing sources"); 187 psAssert (objB->sources->data[0], "missing sources"); 188 189 pmSource *A = objA->sources->data[0]; 190 pmSource *B = objB->sources->data[0]; 191 192 psF32 fA = (A->peak == NULL) ? 0 : A->peak->y; 193 psF32 fB = (B->peak == NULL) ? 0 : B->peak->y; 180 psF32 fA = objA->x; 181 psF32 fB = objB->x; 194 182 195 183 psF32 diff = fA - fB; … … 198 186 return (0); 199 187 } 200
Note:
See TracChangeset
for help on using the changeset viewer.
