Changeset 21381
- Timestamp:
- Feb 6, 2009, 10:54:14 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
psModules/src/objects/pmModel.c (modified) (2 diffs)
-
psphot/src/psphotGuessModels.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmModel.c
r21183 r21381 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.2 6$ $Name: not supported by cvs2svn $9 * @date $Date: 2009-0 1-27 06:39:38$8 * @version $Revision: 1.27 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-06 20:54:14 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 167 167 } 168 168 169 // XXX this is expensive in terms of malloc calls: the use of image interpolate and the residual images 170 // makes this somewhat painful. 169 171 static bool AddOrSubModel(psImage *image, 170 172 psImage *mask, -
trunk/psphot/src/psphotGuessModels.c
r21359 r21381 142 142 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[3],PS_TYPE_IMAGE_MASK_DATA); 143 143 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 224 bool psphotGuessModel_Unthreaded (pmReadout *readout, psArray *sources, pmPSF *psf, psImageMaskType maskVal, psImageMaskType markVal) { 144 225 145 226 int nSrc = 0; … … 220 301 return true; 221 302 } 222 223 // construct models only for sources in the specified region224 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 measured232 // 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 use244 // the peak centroid to get the coordinates and get the peak flux245 // 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 parameters251 modelEXT = pmSourceModelGuess (source, psf->type); // ALLOC252 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); // ALLOC267 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 image273 //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 model290 // this function affects the mask pixels291 psphotCheckRadiusPSF (readout, source, modelPSF, markVal);292 293 // set the source PSF model294 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.
