Changeset 31153 for trunk/psModules/src/objects/pmPeaks.c
- Timestamp:
- Apr 4, 2011, 1:04:41 PM (15 years ago)
- Location:
- trunk/psModules
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/objects/pmPeaks.c (modified) (7 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/pmPeaks.c
r29004 r31153 115 115 XXX: Macro this. 116 116 *****************************************************************************/ 117 # if (0) 117 118 static bool isItInThisRegion(const psRegion valid, 118 119 psS32 x, … … 130 131 return(false); 131 132 } 133 # endif 132 134 133 135 /****************************************************************************** … … 148 150 tmp->x = x; 149 151 tmp->y = y; 150 tmp->value = value; 151 tmp->flux = value; 152 tmp->SN = 0; 152 tmp->detValue = value; 153 tmp->rawFlux = value; // set this by default: it is up to the user to supply a better value 154 tmp->rawFluxStdev = NAN; 155 tmp->smoothFlux = value; // set this by default: it is up to the user to supply a better value 156 tmp->smoothFluxStdev = NAN; 157 // tmp->SN = 0; 153 158 tmp->xf = x; 154 159 tmp->yf = y; … … 170 175 171 176 172 // psSort comparison function for peaks177 // psSort comparison functions for peaks 173 178 // XXX: Add error-checking for NULL args 174 int pmPeaksCompareAscend (const void **a, const void **b) 175 { 176 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 179 int pmPeaksSortByDetValueAscend (const void **a, const void **b) 180 { 177 181 pmPeak *A = *(pmPeak **)a; 178 182 pmPeak *B = *(pmPeak **)b; … … 180 184 psF32 diff; 181 185 182 diff = A-> value - B->value;186 diff = A->detValue - B->detValue; 183 187 if (diff < FLT_EPSILON) { 184 psTrace("psModules.objects", 10, "---- %s(-1) end ----\n", __func__);185 188 return (-1); 186 189 } else if (diff > FLT_EPSILON) { 187 psTrace("psModules.objects", 10, "---- %s(+1) end ----\n", __func__);188 190 return (+1); 189 191 } 190 psTrace("psModules.objects", 10, "---- %s(0) end ----\n", __func__);191 192 return (0); 192 193 } 193 194 // psSort comparison function for peaks 195 // XXX: Add error-checking for NULL args 196 int pmPeaksCompareDescend (const void **a, const void **b) 197 { 198 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__); 194 int pmPeaksSortByDetValueDescend (const void **a, const void **b) 195 { 199 196 pmPeak *A = *(pmPeak **)a; 200 197 pmPeak *B = *(pmPeak **)b; … … 202 199 psF32 diff; 203 200 204 diff = A-> value - B->value;201 diff = A->detValue - B->detValue; 205 202 if (diff < FLT_EPSILON) { 206 psTrace("psModules.objects", 10, "---- %s(+1) end ----\n", __func__);207 203 return (+1); 208 204 } else if (diff > FLT_EPSILON) { 209 psTrace("psModules.objects", 10, "---- %s(-1) end ----\n", __func__);210 205 return (-1); 211 206 } 212 psTrace("psModules.objects", 10, "---- %s(0) end ----\n", __func__);213 207 return (0); 214 208 } 215 216 // sort by SN (descending) 217 int pmPeakSortBySN (const void **a, const void **b) 209 int pmPeaksSortByRawFluxAscend (const void **a, const void **b) 218 210 { 219 211 pmPeak *A = *(pmPeak **)a; 220 212 pmPeak *B = *(pmPeak **)b; 221 213 222 psF32 fA = A->SN;223 psF32 fB = B->SN; 224 if (isnan (fA)) fA = 0;225 if ( isnan (fB)) fB = 0;226 227 psF32 diff = fA - fB;228 if (diff > FLT_EPSILON) return (-1);229 if (diff < FLT_EPSILON) return (+1);214 psF32 diff; 215 216 diff = A->rawFlux - B->rawFlux; 217 if (diff < FLT_EPSILON) { 218 return (-1); 219 } else if (diff > FLT_EPSILON) { 220 return (+1); 221 } 230 222 return (0); 231 223 } 232 233 // sort by Y (ascending) 234 int pmPeakSortByY (const void **a, const void **b) 224 int pmPeaksSortByRawFluxDescend (const void **a, const void **b) 235 225 { 236 226 pmPeak *A = *(pmPeak **)a; 237 227 pmPeak *B = *(pmPeak **)b; 238 228 239 psF32 fA = A->y; 240 psF32 fB = B->y; 241 242 psF32 diff = fA - fB; 243 if (diff > FLT_EPSILON) return (+1); 244 if (diff < FLT_EPSILON) return (-1); 229 psF32 diff; 230 231 diff = A->rawFlux - B->rawFlux; 232 if (diff < FLT_EPSILON) { 233 return (+1); 234 } else if (diff > FLT_EPSILON) { 235 return (-1); 236 } 245 237 return (0); 246 238 } 239 int pmPeaksSortBySmoothFluxAscend (const void **a, const void **b) 240 { 241 pmPeak *A = *(pmPeak **)a; 242 pmPeak *B = *(pmPeak **)b; 243 244 psF32 diff; 245 246 diff = A->smoothFlux - B->smoothFlux; 247 if (diff < FLT_EPSILON) { 248 return (-1); 249 } else if (diff > FLT_EPSILON) { 250 return (+1); 251 } 252 return (0); 253 } 254 int pmPeaksSortBySmoothFluxDescend (const void **a, const void **b) 255 { 256 pmPeak *A = *(pmPeak **)a; 257 pmPeak *B = *(pmPeak **)b; 258 259 psF32 diff; 260 261 diff = A->smoothFlux - B->smoothFlux; 262 if (diff < FLT_EPSILON) { 263 return (+1); 264 } else if (diff > FLT_EPSILON) { 265 return (-1); 266 } 267 return (0); 268 } 269 270 // // sort by SN (descending) 271 // int pmPeakSortBySN (const void **a, const void **b) 272 // { 273 // pmPeak *A = *(pmPeak **)a; 274 // pmPeak *B = *(pmPeak **)b; 275 // 276 // psF32 fA = A->flux; 277 // psF32 fB = B->flux; 278 // if (isnan (fA)) fA = 0; 279 // if (isnan (fB)) fB = 0; 280 // 281 // psF32 diff = fA - fB; 282 // if (diff > FLT_EPSILON) return (-1); 283 // if (diff < FLT_EPSILON) return (+1); 284 // return (0); 285 // } 286 // 287 // // sort by Y (ascending) 288 // int pmPeakSortByY (const void **a, const void **b) 289 // { 290 // pmPeak *A = *(pmPeak **)a; 291 // pmPeak *B = *(pmPeak **)b; 292 // 293 // psF32 fA = A->y; 294 // psF32 fB = B->y; 295 // 296 // psF32 diff = fA - fB; 297 // if (diff > FLT_EPSILON) return (+1); 298 // if (diff < FLT_EPSILON) return (-1); 299 // return (0); 300 // } 247 301 248 302 /****************************************************************************** … … 554 608 return(list); 555 609 } 556 557 // return a new array of peaks which are in the valid region and below threshold558 // XXX this function is unused and probably could be dropped559 psArray *pmPeaksSubset(560 psArray *peaks,561 psF32 maxValue,562 const psRegion valid)563 {564 psTrace("psModules.objects", 10, "---- %s() begin ----\n", __func__);565 PS_ASSERT_PTR_NON_NULL(peaks, NULL);566 567 psArray *output = psArrayAllocEmpty (200);568 569 psTrace ("psModules.objects", 3, "list size is %ld\n", peaks->n);570 571 for (int i = 0; i < peaks->n; i++) {572 pmPeak *tmpPeak = (pmPeak *) peaks->data[i];573 if (tmpPeak->value > maxValue)574 continue;575 if (isItInThisRegion(valid, tmpPeak->x, tmpPeak->y))576 continue;577 psArrayAdd (output, 200, tmpPeak);578 }579 psTrace("psModules.objects", 10, "---- %s() end ----\n", __func__);580 return(output);581 }
Note:
See TracChangeset
for help on using the changeset viewer.
