Changeset 25027 for branches/pap/psModules/src/objects/pmSourceMatch.c
- Timestamp:
- Aug 7, 2009, 4:08:25 PM (17 years ago)
- Location:
- branches/pap
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/pap
- Property svn:mergeinfo changed
-
branches/pap/psModules
- Property svn:mergeinfo deleted
-
branches/pap/psModules/src/objects/pmSourceMatch.c
r23241 r25027 45 45 psVector **x, psVector **y, // Coordinate vectors to return 46 46 psVector **mag, psVector **magErr, // Magnitude and error vectors to return 47 psVector **indices, // Indices for sources 47 48 const psArray *sources // Input sources 48 49 ) … … 58 59 *mag = psVectorRecycle(*mag, numSources, PS_TYPE_F32); 59 60 *magErr = psVectorRecycle(*magErr, numSources, PS_TYPE_F32); 61 *indices = psVectorRecycle(*indices, numSources, PS_TYPE_S32); 60 62 float xMin = INFINITY, xMax = -INFINITY, yMin = INFINITY, yMax = -INFINITY; // Bounds of sources 61 63 long num = 0; // Number of valid sources 62 64 for (long i = 0; i < numSources; i++) { 63 65 pmSource *source = sources->data[i]; // Source of interest 64 if (!source) continue; 65 if (source->mode & SOURCE_MASK) continue; 66 if (!isfinite(source->psfMag)) continue; 67 if (!isfinite(source->errMag)) continue; 68 if (source->psfMag > SOURCE_FAINTEST) continue; 66 if (!source || (source->mode & SOURCE_MASK) || !isfinite(source->psfMag) || 67 !isfinite(source->errMag) || source->psfMag > SOURCE_FAINTEST) { 68 continue; 69 } 69 70 70 71 float xSrc, ySrc; // Coordinates of source … … 78 79 (*y)->data.F32[num] = ySrc; 79 80 (*mag)->data.F32[num] = source->psfMag; 80 (*magErr)->data.F32[num] = source->errMag ; 81 (*magErr)->data.F32[num] = source->errMag; 82 (*indices)->data.S32[num] = i; 81 83 num++; 82 84 } … … 85 87 (*mag)->n = num; 86 88 (*magErr)->n = num; 89 (*indices)->n = num; 87 90 88 91 if (*bounds) { … … 175 178 psVector *xImage = NULL, *yImage = NULL; // Coordinates of sources 176 179 psVector *magImage = NULL, *magErrImage = NULL; // Magnitude and mag 177 178 int numSources = sourcesParse(&boundsImage, &xImage, &yImage, &magImage, &magErrImage, 180 psVector *indices = NULL; // Indices for sources 181 182 int numSources = sourcesParse(&boundsImage, &xImage, &yImage, &magImage, &magErrImage, &indices, 179 183 sources); // Number of sources 180 184 … … 187 191 for (int j = 0; j < numSources; j++) { 188 192 pmSourceMatch *match = pmSourceMatchAlloc(); // Match data 189 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j); 193 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], 194 i, indices->data.S32[j]); 190 195 matches->data[j] = match; 191 196 } … … 206 211 for (int j = 0, k = numMaster; j < numSources; j++, k++) { 207 212 pmSourceMatch *match = pmSourceMatchAlloc(); // Match data 208 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j); 213 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], 214 i, indices->data.S32[j]); 209 215 matches->data[k] = match; 210 216 } … … 231 237 // Record the match 232 238 pmSourceMatch *match = matches->data[index]; // Match data 233 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j); 239 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], 240 i, indices->data.S32[j]); 234 241 numMatch++; 235 242 } else { 236 243 // Add to the master list 237 244 pmSourceMatch *match = pmSourceMatchAlloc(); // Match data 238 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], i, j); 245 pmSourceMatchAdd(match, magImage->data.F32[j], magErrImage->data.F32[j], 246 i, indices->data.S32[j]); 239 247 xMaster->data.F32[numMaster] = xImage->data.F32[j]; 240 248 yMaster->data.F32[numMaster] = yImage->data.F32[j]; … … 469 477 470 478 if (!psVectorStats(stats, trans, NULL, badImage, 0xFF)) { 479 psError(PS_ERR_UNKNOWN, false, "Unable to perform statistics on transparencies."); 480 psFree(stats); 481 return -1; 482 } 483 // XXX handle this case better: 484 if (isnan(stats->clippedMean)) { 471 485 psError(PS_ERR_UNKNOWN, false, "Unable to perform statistics on transparencies."); 472 486 psFree(stats);
Note:
See TracChangeset
for help on using the changeset viewer.
