Changeset 31153 for trunk/psModules/src/objects/pmSource.c
- Timestamp:
- Apr 4, 2011, 1:04:41 PM (15 years ago)
- Location:
- trunk/psModules
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/objects/pmSource.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules
- Property svn:ignore
-
old new 28 28 ChangeLog 29 29 psmodules-*.tar.* 30 a.out.dSYM
-
- Property svn:ignore
-
trunk/psModules/src/objects/pmSource.c
r30621 r31153 171 171 // peak has the same values as the original 172 172 if (in->peak != NULL) { 173 source->peak = pmPeakAlloc (in->peak->x, in->peak->y, in->peak-> value, in->peak->type);173 source->peak = pmPeakAlloc (in->peak->x, in->peak->y, in->peak->detValue, in->peak->type); 174 174 source->peak->xf = in->peak->xf; 175 175 source->peak->yf = in->peak->yf; 176 source->peak->flux = in->peak->flux; 177 source->peak->SN = in->peak->SN; 176 source->peak->rawFlux = in->peak->rawFlux; 177 source->peak->rawFluxStdev = in->peak->rawFluxStdev; 178 source->peak->smoothFlux = in->peak->smoothFlux; 179 source->peak->smoothFluxStdev = in->peak->smoothFluxStdev; 180 // source->peak->SN = in->peak->SN; 178 181 } 179 182 … … 328 331 *****************************************************************************/ 329 332 330 // XXX EAM include a S/N cutoff in selecting the sources?331 // XXX this function should probably accept the values, not a recipe. wrap with a332 // psphot-specific function which applies the recipe values333 // only apply selection to sources within specified region334 333 pmPSFClump pmSourcePSFClump(psImage **savedImage, psRegion *region, psArray *sources, float PSF_SN_LIM, float PSF_CLUMP_GRID_SCALE, psF32 SX_MAX, psF32 SY_MAX, psF32 AR_MAX) 335 334 { … … 429 428 430 429 psfClump.nSigma = stats->sampleStdev; 430 psfClump.nTotal = nValid; 431 431 432 432 if (savedImage) { … … 465 465 psStats *stats = NULL; 466 466 467 // select the single highest peak 468 psArraySort (peaks, pmPeaks CompareDescend);467 // select the single highest peak (note that we only have detValue, not rawFlux, etc 468 psArraySort (peaks, pmPeaksSortByDetValueDescend); 469 469 clump = peaks->data[0]; 470 psTrace ("psModules.objects", 2, "clump is at %d, %d (%f)\n", clump->x, clump->y, clump-> value);470 psTrace ("psModules.objects", 2, "clump is at %d, %d (%f)\n", clump->x, clump->y, clump->detValue); 471 471 472 472 // XXX store the mean sigma? 473 473 float meanSigma = psfClump.nSigma; 474 psfClump.nStars = clump-> value;475 psfClump.nSigma = clump-> value / meanSigma;474 psfClump.nStars = clump->detValue; 475 psfClump.nSigma = clump->detValue / meanSigma; 476 476 477 477 // define section window for clump … … 643 643 } 644 644 645 // check for insignificant sources or excessively low-surface brightness 646 float coreSN = source->moments->KronCore / source->moments->KronCoreErr; 647 float coreKR = source->moments->KronCore / source->moments->KronFlux; 648 649 // XXX these values need to be in the recipe... 650 if (false && isfinite(coreSN) && (coreSN < 5.0)) { 651 source->type = PM_SOURCE_TYPE_DEFECT; 652 source->mode |= PM_SOURCE_MODE_DEFECT; 653 Ncr ++; 654 continue; 655 } 656 if (false && isfinite(coreKR) && (coreKR < 0.1)) { 657 source->type = PM_SOURCE_TYPE_DEFECT; 658 source->mode |= PM_SOURCE_MODE_DEFECT; 659 Ncr ++; 660 continue; 661 } 662 645 663 // likely unsaturated extended source (too large to be stellar) 646 664 if (sigX > clump.X + 3*clump.dX || sigY > clump.Y + 3*clump.dY) { … … 651 669 652 670 // the rest are probable stellar objects 671 // the vectors below are accumulated to give user feedback on the S/N ranges 653 672 starsn_moments->data.F32[starsn_moments->n] = source->moments->SN; 654 673 starsn_moments->n ++; 655 starsn_peaks->data.F32[starsn_peaks->n] = s ource->peak->SN;674 starsn_peaks->data.F32[starsn_peaks->n] = sqrt(source->peak->detValue); 656 675 starsn_peaks->n ++; 657 676 Nstar ++; … … 1149 1168 } 1150 1169 1170 // this function decides if the source position should be based on the peak or the moments. 1171 // this is only used if we know we should not use a model fit position (eg, no model, or no 1172 // model yet) 1173 bool pmSourcePositionUseMoments(pmSource *source) { 1174 1175 if (!source->moments) return false; // can't if there are no moments 1176 if (!source->moments->nPixels) return false; // can't if the moments were not measured 1177 if (source->mode && PM_SOURCE_MODE_MOMENTS_FAILURE) return false; // can't if the moments failed... 1178 1179 if (source->mode & PM_SOURCE_MODE_SATSTAR) return true; // moments are best for SATSTARs 1180 1181 float dX = source->moments->Mx - source->peak->xf; 1182 float dY = source->moments->My - source->peak->yf; 1183 float dR = hypot(dX, dY); 1184 1185 // only use the moments position if the moment-peak offset is small or the star is saturated 1186 if (dR > 1.5) return false; 1187 1188 return true; 1189 } 1190 1151 1191 // sort by SN (descending) 1152 int pmSourceSortBy SN(const void **a, const void **b)1192 int pmSourceSortByFlux (const void **a, const void **b) 1153 1193 { 1154 1194 pmSource *A = *(pmSource **)a; 1155 1195 pmSource *B = *(pmSource **)b; 1156 1196 1157 psF32 fA = (A->peak == NULL) ? 0 : A->peak-> SN;1158 psF32 fB = (B->peak == NULL) ? 0 : B->peak-> SN;1197 psF32 fA = (A->peak == NULL) ? 0 : A->peak->rawFlux; 1198 psF32 fB = (B->peak == NULL) ? 0 : B->peak->rawFlux; 1159 1199 if (isnan (fA)) fA = 0; 1160 1200 if (isnan (fB)) fB = 0; … … 1166 1206 } 1167 1207 1208 // sort by SN (descending) 1209 int pmSourceSortByParentFlux (const void **a, const void **b) 1210 { 1211 pmSource *Ao = *(pmSource **)a; 1212 pmSource *Bo = *(pmSource **)b; 1213 pmSource *A = Ao->parent; 1214 pmSource *B = Bo->parent; 1215 1216 psF32 fA = (A->peak == NULL) ? 0 : A->peak->rawFlux; 1217 psF32 fB = (B->peak == NULL) ? 0 : B->peak->rawFlux; 1218 if (isnan (fA)) fA = 0; 1219 if (isnan (fB)) fB = 0; 1220 1221 psF32 diff = fA - fB; 1222 if (diff > FLT_EPSILON) return (-1); 1223 if (diff < FLT_EPSILON) return (+1); 1224 return (0); 1225 } 1226 1168 1227 // sort by Y (ascending) 1169 1228 int pmSourceSortByY (const void **a, const void **b) … … 1201 1260 pmSource *A = *(pmSource **)a; 1202 1261 pmSource *B = *(pmSource **)b; 1262 1263 int iA = A->seq; 1264 int iB = B->seq; 1265 1266 int diff = iA - iB; 1267 if (diff > 0) return (+1); 1268 if (diff < 0) return (-1); 1269 return (0); 1270 } 1271 1272 // sort by Seq (ascending) 1273 int pmSourceSortByParentSeq (const void **a, const void **b) 1274 { 1275 pmSource *Ao = *(pmSource **)a; 1276 pmSource *Bo = *(pmSource **)b; 1277 pmSource *A = Ao->parent; 1278 pmSource *B = Bo->parent; 1203 1279 1204 1280 int iA = A->seq;
Note:
See TracChangeset
for help on using the changeset viewer.
