Changeset 34315
- Timestamp:
- Aug 15, 2012, 9:12:28 AM (14 years ago)
- Location:
- trunk/psModules/src/objects
- Files:
-
- 2 edited
-
pmSource.c (modified) (4 diffs)
-
pmSource.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSource.c
r34085 r34315 261 261 PS_ASSERT_INT_POSITIVE(Radius, false); 262 262 263 psRegion s rcRegion;263 psRegion sourceRegion; 264 264 265 265 // Grab a subimage of the original image of size (2 * outerRadius). 266 s rcRegion = psRegionForSquare (x, y, Radius);267 s rcRegion = psRegionForImage (readout->image, srcRegion);266 sourceRegion = psRegionForSquare (x, y, Radius); 267 sourceRegion = psRegionForImage (readout->image, sourceRegion); 268 268 269 269 // these images are subset images of the equivalent parents 270 mySource->pixels = psImageSubset(readout->image, s rcRegion);270 mySource->pixels = psImageSubset(readout->image, sourceRegion); 271 271 if (readout->variance) { 272 mySource->variance = psImageSubset(readout->variance, s rcRegion);272 mySource->variance = psImageSubset(readout->variance, sourceRegion); 273 273 } 274 274 if (readout->mask) { 275 mySource->maskView = psImageSubset(readout->mask, s rcRegion);275 mySource->maskView = psImageSubset(readout->mask, sourceRegion); 276 276 // the object mask is a copy, and used to define the source pixels 277 277 mySource->maskObj = psImageCopy(NULL, mySource->maskView, PS_TYPE_IMAGE_MASK); 278 278 } 279 mySource->region = s rcRegion;279 mySource->region = sourceRegion; 280 280 mySource->windowRadius = Radius; 281 281 … … 415 415 int nValid = 0; // Number of valid sources 416 416 for (int i = 0; i < sources->n; i++) { 417 pmSource *s rc= sources->data[i]; // Source of interest418 if (!s rc || !src->moments) {417 pmSource *source = sources->data[i]; // Source of interest 418 if (!source || !source->moments) { 419 419 continue; 420 420 } 421 421 422 422 if (region) { 423 int x = s rc->peak->x, y = src->peak->y; // Coordinates of peak423 int x = source->peak->x, y = source->peak->y; // Coordinates of peak 424 424 if (x < region->x0 || x > region->x1 || y < region->y0 || y > region->y1) { 425 425 continue; … … 427 427 } 428 428 429 if (s rc->mode & PM_SOURCE_MODE_BLEND) {430 continue; 431 } 432 433 if (!s rc->moments->nPixels) continue;434 435 if (s rc->moments->SN < PSF_SN_LIM) {429 if (source->mode & PM_SOURCE_MODE_BLEND) { 430 continue; 431 } 432 433 if (!source->moments->nPixels) continue; 434 435 if (source->moments->SN < PSF_SN_LIM) { 436 436 psTrace("psModules.objects", 10, "Rejecting source from clump because of low S/N (%f)\n", 437 s rc->moments->SN);438 continue; 439 } 440 441 float Mxx = s rc->moments->Mxx, Myy = src->moments->Myy; // Second moments437 source->moments->SN); 438 continue; 439 } 440 441 float Mxx = source->moments->Mxx, Myy = source->moments->Myy; // Second moments 442 442 float ar = Mxx / Myy; // Radius 443 443 … … 1496 1496 return NULL; 1497 1497 } 1498 1499 // Function to estimate the memory consumed by a source. 1500 // Not yet complete but it counts the biggest stuff. 1501 // XXX: handle child images. For big ones the array of data pointers is significant 1502 #define IMAGE_BYTES(_im, _pix_size) (_im ? (sizeof(psImage) + (_im->numRows * _im->numCols * _pix_size)) : 0) 1503 #define VECTOR_BYTES(_v, _elem_size) (_v ? (sizeof(psVector) + (_v->n * _elem_size)) : 0) 1504 1505 // estimate the memory consumed by this source 1506 psU64 pmSourceMemoryUse (pmSource *source) { 1507 psU64 bytes = sizeof(pmSource) + sizeof(pmPeak) + sizeof(pmMoments); 1508 1509 bytes += IMAGE_BYTES(source->modelVar, 4); 1510 bytes += IMAGE_BYTES(source->maskObj, 2); 1511 bytes += IMAGE_BYTES(source->modelFlux, 4); 1512 bytes += IMAGE_BYTES(source->psfImage, 4); 1513 1514 if (source->modelFits) { 1515 for (int i = 0; i < source->modelFits->n; i++) { 1516 pmModel *model = source->modelFits->data[i]; 1517 if (!model) continue; 1518 bytes += sizeof(pmModel); 1519 bytes += IMAGE_BYTES(model->covar, 4); 1520 bytes += VECTOR_BYTES(model->params, 4); 1521 bytes += VECTOR_BYTES(model->dparams, 4); 1522 if (model->residuals) { 1523 bytes += sizeof(pmResiduals); 1524 bytes += IMAGE_BYTES(model->residuals->Ro, 4); 1525 bytes += IMAGE_BYTES(model->residuals->Rx, 4); 1526 bytes += IMAGE_BYTES(model->residuals->Ry, 4); 1527 bytes += IMAGE_BYTES(model->residuals->variance, 4); 1528 bytes += IMAGE_BYTES(model->residuals->mask, 2); 1529 } 1530 } 1531 } 1532 if (source->radialAper) { 1533 for (int i = 0; i < source->radialAper->n; i++) { 1534 pmSourceRadialApertures *radialAper = source->radialAper->data[i]; 1535 if (radialAper) { 1536 bytes += sizeof(pmSourceRadialApertures); 1537 bytes += VECTOR_BYTES(radialAper->flux, 4); 1538 bytes += VECTOR_BYTES(radialAper->fluxStdev, 4); 1539 bytes += VECTOR_BYTES(radialAper->fluxErr, 4); 1540 bytes += VECTOR_BYTES(radialAper->fill, 4); 1541 } 1542 } 1543 } 1544 1545 return bytes; 1546 } -
trunk/psModules/src/objects/pmSource.h
r34085 r34315 323 323 char *pmSourceModeToString (const pmSourceMode mode); 324 324 325 psU64 pmSourceMemoryUse(pmSource *source); 326 325 327 /// @} 326 328 # endif /* PM_SOURCE_H */
Note:
See TracChangeset
for help on using the changeset viewer.
