Changeset 20948 for trunk/psModules/src/objects/pmSourceMatch.c
- Timestamp:
- Dec 9, 2008, 3:37:57 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmSourceMatch.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSourceMatch.c
r20947 r20948 176 176 if (!boundsMaster) { 177 177 // First run through --- can just copy 178 boundsMaster = boundsImage;179 xMaster = xImage;180 yMaster = yImage;178 boundsMaster = psMemIncrRefCounter(boundsImage); 179 xMaster = psMemIncrRefCounter(xImage); 180 yMaster = psMemIncrRefCounter(yImage); 181 181 matches = psArrayAlloc(numSources); 182 182 for (int j = 0; j < numSources; j++) { … … 266 266 if (i != numGood) { 267 267 psFree(matches->data[numGood]); 268 matches->data[numGood] = match;269 psFree(match);268 matches->data[numGood] = psMemIncrRefCounter(match); 269 // psFree(match); 270 270 } 271 271 numGood++; … … 273 273 } 274 274 matches->n = numGood; 275 for (int i = numGood; i < numMaster; i++) { 276 psFree(matches->data[i]); 277 matches->data[i] = NULL; 278 } 275 279 276 280 return matches; … … 281 285 282 286 283 psVector *pmSource Relphot(const psArray *matches, // Array of matches284 const psVector *zp, // Zero points for each image (including airmass term)285 float cloudClip // Clipping for clouds286 )287 psVector *pmSourceMatchRelphot(const psArray *matches, // Array of matches 288 const psVector *zp, // Zero points for each image (including airmass term) 289 float cloudClip // Clipping for clouds 290 ) 287 291 { 288 292 PS_ASSERT_ARRAY_NON_NULL(matches, NULL); … … 291 295 PS_ASSERT_FLOAT_LARGER_THAN(cloudClip, 0.0, NULL); 292 296 293 return NULL; 294 } 297 int numImages = zp->n; // Number of images 298 int numStars = matches->n; // Number of stars 299 psVector *trans = psVectorAlloc(numImages, PS_TYPE_F32); // Transparencies for each image, magnitudes 300 psVector *transErr = psVectorAlloc(numImages, PS_TYPE_F32); // Errors in the transparency 301 psVector *stars = psVectorAlloc(numStars, PS_TYPE_F32); // Magnitudes for each star 302 psVector *starsErr = psVectorAlloc(numStars, PS_TYPE_F32); // Errors in the star magnitudes 303 304 305 // XXX Need to apply provided ZPs 306 307 psVectorInit(trans, 0.0); 308 psVectorInit(transErr, 0.0); 309 310 // Solve the star magnitudes 311 psVectorInit(stars, 0.0); 312 psVectorInit(starsErr, 0.0); 313 for (int i = 0; i < numStars; i++) { 314 pmSourceMatch *match = matches->data[i]; // Matched stars 315 for (int j = 0; j < match->num; j++) { 316 int index = match->image->data.U32[j]; // Image index 317 float mag = match->mag->data.F32[j]; // Measured magnitude 318 float magErr = match->magErr->data.F32[j]; // Error in measured magnitude 319 float invErr2 = 1.0 / PS_SQR(magErr); // Inverse square error 320 stars->data.F32[i] += (mag - trans->data.F32[index]) * invErr2; 321 starsErr->data.F32[i] += invErr2; 322 } 323 } 324 for (int i = 0; i < numStars; i++) { 325 float inverse = 1.0 / starsErr->data.F32[i]; // Inverse error 326 stars->data.F32[i] *= inverse; 327 starsErr->data.F32[i] = sqrtf(inverse); 328 } 329 330 // Solve for the transparencies 331 psVectorInit(trans, 0.0); 332 psVectorInit(transErr, 0.0); 333 for (int i = 0; i < numStars; i++) { 334 pmSourceMatch *match = matches->data[i]; // Matched stars 335 for (int j = 0; j < match->num; j++) { 336 int index = match->image->data.U32[j]; // Image index 337 float mag = match->mag->data.F32[j]; // Measured magnitude 338 float magErr = match->magErr->data.F32[j]; // Error in measured magnitude 339 float invErr2 = 1.0 / PS_SQR(magErr); // Inverse square error 340 trans->data.F32[index] += (mag - stars->data.F32[i]) * invErr2; 341 transErr->data.F32[index] += invErr2; 342 } 343 } 344 for (int i = 0; i < numImages; i++) { 345 float inverse = 1.0 / transErr->data.F32[i]; // Inverse error 346 trans->data.F32[i] *= inverse; 347 transErr->data.F32[i] = sqrtf(inverse); 348 349 psTrace("psModules.objects", 1, "Transparency for image %d: %f +/- %f\n", 350 i, trans->data.F32[i], transErr->data.F32[i]); 351 } 352 353 psFree(transErr); 354 psFree(stars); 355 psFree(starsErr); 356 357 return trans; 358 }
Note:
See TracChangeset
for help on using the changeset viewer.
