IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 5, 2012, 3:54:44 PM (14 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20120805/psModules
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20120805/psModules

  • branches/eam_branches/ipp-20120805/psModules/src/objects/pmSource.c

    r34375 r34396  
    263263    PS_ASSERT_INT_POSITIVE(Radius, false);
    264264
    265     psRegion srcRegion;
     265    psRegion sourceRegion;
    266266
    267267    // Grab a subimage of the original image of size (2 * outerRadius).
    268     srcRegion = psRegionForSquare (x, y, Radius);
    269     srcRegion = psRegionForImage (readout->image, srcRegion);
     268    sourceRegion = psRegionForSquare (x, y, Radius);
     269    sourceRegion = psRegionForImage (readout->image, sourceRegion);
    270270
    271271    // these images are subset images of the equivalent parents
    272     mySource->pixels = psImageSubset(readout->image, srcRegion);
     272    mySource->pixels = psImageSubset(readout->image, sourceRegion);
    273273    if (readout->variance) {
    274         mySource->variance = psImageSubset(readout->variance, srcRegion);
     274        mySource->variance = psImageSubset(readout->variance, sourceRegion);
    275275    }
    276276    if (readout->mask) {
    277         mySource->maskView = psImageSubset(readout->mask,  srcRegion);
     277        mySource->maskView = psImageSubset(readout->mask,  sourceRegion);
    278278        // the object mask is a copy, and used to define the source pixels
    279279        mySource->maskObj = psImageCopy(NULL, mySource->maskView, PS_TYPE_IMAGE_MASK);
    280280    }
    281     mySource->region   = srcRegion;
     281    mySource->region   = sourceRegion;
    282282    mySource->windowRadius = Radius;
    283283
     
    417417        int nValid = 0;                 // Number of valid sources
    418418        for (int i = 0; i < sources->n; i++) {
    419             pmSource *src = sources->data[i]; // Source of interest
    420             if (!src || !src->moments) {
     419            pmSource *source = sources->data[i]; // Source of interest
     420            if (!source || !source->moments) {
    421421                continue;
    422422            }
    423423
    424424            if (region) {
    425                 int x = src->peak->x, y = src->peak->y; // Coordinates of peak
     425                int x = source->peak->x, y = source->peak->y; // Coordinates of peak
    426426                if (x < region->x0 || x > region->x1 || y < region->y0 || y > region->y1) {
    427427                    continue;
     
    429429            }
    430430
    431             if (src->mode & PM_SOURCE_MODE_BLEND) {
    432                 continue;
    433             }
    434 
    435             if (!src->moments->nPixels) continue;
    436 
    437             if (src->moments->SN < PSF_SN_LIM) {
     431            if (source->mode & PM_SOURCE_MODE_BLEND) {
     432                continue;
     433            }
     434
     435            if (!source->moments->nPixels) continue;
     436
     437            if (source->moments->SN < PSF_SN_LIM) {
    438438                psTrace("psModules.objects", 10, "Rejecting source from clump because of low S/N (%f)\n",
    439                         src->moments->SN);
    440                 continue;
    441             }
    442 
    443             float Mxx = src->moments->Mxx, Myy = src->moments->Myy; // Second moments
     439                        source->moments->SN);
     440                continue;
     441            }
     442
     443            float Mxx = source->moments->Mxx, Myy = source->moments->Myy; // Second moments
    444444            float ar = Mxx / Myy;       // Radius
    445445
     
    15081508  return NULL;
    15091509}
     1510
     1511// Function to estimate the memory consumed by a source.
     1512#define IMAGE_BYTES(_im, _pix_size) (_im ? (sizeof(psImage) + (_im->numRows * sizeof(void*)) + (_im->numRows * _im->numCols * _pix_size * (_im->parent ? 0 : 1))) : 0)
     1513
     1514#define VECTOR_BYTES(_v, _elem_size) (_v ? (sizeof(psVector) + (_v->n * _elem_size)) : 0)
     1515
     1516// estimate the memory consumed by this source.
     1517// It doesn't count everything (a couple of psArrays), the big stuff is counted
     1518psU64 pmSourceMemoryUse (pmSource *source) {
     1519    psU64 bytes = sizeof(pmSource) + sizeof(pmPeak) + sizeof(pmMoments);
     1520
     1521    bytes += IMAGE_BYTES(source->pixels, 4);
     1522    bytes += IMAGE_BYTES(source->variance, 4);
     1523    bytes += IMAGE_BYTES(source->modelVar, 4);
     1524    bytes += IMAGE_BYTES(source->maskObj, 2);
     1525    bytes += IMAGE_BYTES(source->maskView, 2);
     1526    bytes += IMAGE_BYTES(source->modelFlux, 4);
     1527    bytes += IMAGE_BYTES(source->psfImage, 4);
     1528
     1529    if (source->modelFits) {
     1530        for (int i = 0; i < source->modelFits->n; i++) {
     1531            pmModel *model = source->modelFits->data[i];
     1532            if (!model) continue;
     1533            bytes += sizeof(pmModel);
     1534            bytes += IMAGE_BYTES(model->covar, 4);
     1535            bytes += VECTOR_BYTES(model->params, 4);
     1536            bytes += VECTOR_BYTES(model->dparams, 4);
     1537            if (model->residuals) {
     1538                bytes += sizeof(pmResiduals);
     1539                bytes += IMAGE_BYTES(model->residuals->Ro, 4);
     1540                bytes += IMAGE_BYTES(model->residuals->Rx, 4);
     1541                bytes += IMAGE_BYTES(model->residuals->Ry, 4);
     1542                bytes += IMAGE_BYTES(model->residuals->variance, 4);
     1543                bytes += IMAGE_BYTES(model->residuals->mask, 2);
     1544            }
     1545        }
     1546    }
     1547    if (source->radialAper) {
     1548        for (int i = 0; i < source->radialAper->n; i++) {
     1549            pmSourceRadialApertures *radialAper = source->radialAper->data[i];
     1550            if (radialAper) {
     1551                bytes += sizeof(pmSourceRadialApertures);
     1552                bytes += VECTOR_BYTES(radialAper->flux, 4);
     1553                bytes += VECTOR_BYTES(radialAper->fluxStdev, 4);
     1554                bytes += VECTOR_BYTES(radialAper->fluxErr, 4);
     1555                bytes += VECTOR_BYTES(radialAper->fill, 4);
     1556            }
     1557        }
     1558    }
     1559
     1560    return bytes;
     1561}
  • branches/eam_branches/ipp-20120805/psModules/src/objects/pmSource.h

    r34375 r34396  
    324324char *pmSourceModeToString (const pmSourceMode mode);
    325325
     326psU64 pmSourceMemoryUse(pmSource *source);
     327
    326328/// @}
    327329# endif /* PM_SOURCE_H */
  • branches/eam_branches/ipp-20120805/psModules/src/objects/pmSourceIO_CMF.c.in

    r34383 r34396  
    399399        @PS1_DV?@  }
    400400
    401         @ALL@                     source->mode  = psMetadataLookupU32 (&status, row, "FLAGS");
    402         @>PS1_V2,PS1_SV?,>PS1_DV1@ source->mode2 = psMetadataLookupU32 (&status, row, "FLAGS2");
     401        @ALL@                      source->mode       = psMetadataLookupU32 (&status, row, "FLAGS");
     402        @>PS1_V2,PS1_SV?,>PS1_DV1@ source->mode2      = psMetadataLookupU32 (&status, row, "FLAGS2");
     403        @ALL@                      source->nFrames    = psMetadataLookupU16 (&status, row, "N_FRAMES");
    403404        assert (status);
    404405
Note: See TracChangeset for help on using the changeset viewer.