IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21381


Ignore:
Timestamp:
Feb 6, 2009, 10:54:14 AM (17 years ago)
Author:
eugene
Message:

some comments re threading and malloc hits

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmModel.c

    r21183 r21381  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2009-01-27 06:39:38 $
     8 *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2009-02-06 20:54:14 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    167167}
    168168
     169// XXX this is expensive in terms of malloc calls: the use of image interpolate and the residual images
     170// makes this somewhat painful.
    169171static bool AddOrSubModel(psImage *image,
    170172                          psImage *mask,
  • trunk/psphot/src/psphotGuessModels.c

    r21359 r21381  
    142142    psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[3],PS_TYPE_IMAGE_MASK_DATA);
    143143    psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA);
     144
     145    int nSrc = 0;
     146
     147    for (int i = 0; i < sources->n; i++) {
     148        pmSource *source = sources->data[i];
     149
     150        // XXXX this is just for a test: use this to mark sources for which the model is measured
     151        // check later that all are used.
     152        source->mode |= PM_SOURCE_MODE_EXT_LIMIT;
     153
     154        // skip non-astronomical objects (very likely defects)
     155        if (source->type == PM_SOURCE_TYPE_DEFECT) continue;
     156        if (source->type == PM_SOURCE_TYPE_SATURATED) continue;
     157        if (!source->peak) continue;
     158
     159        nSrc ++;
     160       
     161        // XXX if a source is faint, it will not have moments measured.
     162        // it must be modelled as a PSF.  In this case, we need to use
     163        // the peak centroid to get the coordinates and get the peak flux
     164        // from the image?
     165        pmModel *modelEXT;
     166        if (!source->moments) {
     167            modelEXT = wildGuess(source, psf);
     168        } else {
     169            // use the source moments, etc to guess basic model parameters
     170            modelEXT = pmSourceModelGuess (source, psf->type); // ALLOC X5
     171            if (!modelEXT) {
     172                modelEXT = wildGuess(source, psf);
     173            }
     174            // these valuse are set in pmSourceModelGuess, should this rule be in there as well?
     175            if (source->mode &  PM_SOURCE_MODE_SATSTAR) {
     176                modelEXT->params->data.F32[PM_PAR_XPOS] = source->moments->Mx;
     177                modelEXT->params->data.F32[PM_PAR_YPOS] = source->moments->My;
     178            } else {
     179                modelEXT->params->data.F32[PM_PAR_XPOS] = source->peak->xf;
     180                modelEXT->params->data.F32[PM_PAR_YPOS] = source->peak->yf;
     181            }
     182        }
     183
     184        // set PSF parameters for this model (apply 2D shape model)
     185        pmModel *modelPSF = pmModelFromPSF (modelEXT, psf); // ALLOC X5
     186        if (modelPSF == NULL) {
     187            psError(PSPHOT_ERR_PSF, false,
     188                    "Failed to determine PSF model at r,c = (%d,%d); trying centre of image",
     189                    source->peak->y, source->peak->x);
     190            //
     191            // Try the centre of the image
     192            //
     193            modelEXT->params->data.F32[PM_PAR_XPOS] = 0.5*readout->image->numCols;
     194            modelEXT->params->data.F32[PM_PAR_YPOS] = 0.5*readout->image->numRows;
     195            modelPSF = pmModelFromPSF (modelEXT, psf);
     196            if (modelPSF == NULL) {
     197                psError(PSPHOT_ERR_PSF, false,
     198                        "Failed to determine PSF model at centre of image");
     199                psFree(modelEXT);
     200                return false;
     201            }
     202
     203            source->mode |= PM_SOURCE_MODE_BADPSF;
     204        }
     205        psFree (modelEXT); // FREE (x3)
     206
     207        // XXX need to define the guess flux?
     208        // set the fit radius based on the object flux limit and the model
     209        // this function affects the mask pixels
     210        psphotCheckRadiusPSF (readout, source, modelPSF, markVal);
     211
     212        // set the source PSF model
     213        source->modelPSF = modelPSF;
     214        source->modelPSF->residuals = psf->residuals;
     215
     216        pmSourceCacheModel (source, maskVal);  // ALLOC x14 (!)
     217
     218    }
     219
     220    return true;
     221}
     222
     223// construct models only for sources in the specified region
     224bool psphotGuessModel_Unthreaded (pmReadout *readout, psArray *sources, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal) {
    144225
    145226    int nSrc = 0;
     
    220301    return true;
    221302}
    222 
    223 // construct models only for sources in the specified region
    224 bool psphotGuessModel_Unthreaded (pmReadout *readout, psArray *sources, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal) {
    225 
    226     int nSrc = 0;
    227 
    228     for (int i = 0; i < sources->n; i++) {
    229         pmSource *source = sources->data[i];
    230 
    231         // XXXX this is just for a test: use this to mark sources for which the model is measured
    232         // check later that all are used.
    233         source->mode |= PM_SOURCE_MODE_EXT_LIMIT;
    234 
    235         // skip non-astronomical objects (very likely defects)
    236         if (source->type == PM_SOURCE_TYPE_DEFECT) continue;
    237         if (source->type == PM_SOURCE_TYPE_SATURATED) continue;
    238         if (!source->peak) continue;
    239 
    240         nSrc ++;
    241        
    242         // XXX if a source is faint, it will not have moments measured.
    243         // it must be modelled as a PSF.  In this case, we need to use
    244         // the peak centroid to get the coordinates and get the peak flux
    245         // from the image?
    246         pmModel *modelEXT;
    247         if (!source->moments) {
    248             modelEXT = wildGuess(source, psf);
    249         } else {
    250             // use the source moments, etc to guess basic model parameters
    251             modelEXT = pmSourceModelGuess (source, psf->type); // ALLOC
    252             if (!modelEXT) {
    253                 modelEXT = wildGuess(source, psf);
    254             }
    255             // these valuse are set in pmSourceModelGuess, should this rule be in there as well?
    256             if (source->mode &  PM_SOURCE_MODE_SATSTAR) {
    257                 modelEXT->params->data.F32[PM_PAR_XPOS] = source->moments->Mx;
    258                 modelEXT->params->data.F32[PM_PAR_YPOS] = source->moments->My;
    259             } else {
    260                 modelEXT->params->data.F32[PM_PAR_XPOS] = source->peak->xf;
    261                 modelEXT->params->data.F32[PM_PAR_YPOS] = source->peak->yf;
    262             }
    263         }
    264 
    265         // set PSF parameters for this model (apply 2D shape model)
    266         pmModel *modelPSF = pmModelFromPSF (modelEXT, psf); // ALLOC
    267         if (modelPSF == NULL) {
    268             psError(PSPHOT_ERR_PSF, false,
    269                     "Failed to determine PSF model at r,c = (%d,%d); trying centre of image",
    270                     source->peak->y, source->peak->x);
    271             //
    272             // Try the centre of the image
    273             //
    274             modelEXT->params->data.F32[PM_PAR_XPOS] = 0.5*readout->image->numCols;
    275             modelEXT->params->data.F32[PM_PAR_YPOS] = 0.5*readout->image->numRows;
    276             modelPSF = pmModelFromPSF (modelEXT, psf);
    277             if (modelPSF == NULL) {
    278                 psError(PSPHOT_ERR_PSF, false,
    279                         "Failed to determine PSF model at centre of image");
    280                 psFree(modelEXT);
    281                 return false;
    282             }
    283 
    284             source->mode |= PM_SOURCE_MODE_BADPSF;
    285         }
    286         psFree (modelEXT);
    287 
    288         // XXX need to define the guess flux?
    289         // set the fit radius based on the object flux limit and the model
    290         // this function affects the mask pixels
    291         psphotCheckRadiusPSF (readout, source, modelPSF, markVal);
    292 
    293         // set the source PSF model
    294         source->modelPSF = modelPSF;
    295         source->modelPSF->residuals = psf->residuals;
    296 
    297         pmSourceCacheModel (source, maskVal);
    298 
    299     }
    300 
    301     return true;
    302 }
Note: See TracChangeset for help on using the changeset viewer.