Changeset 36218
- Timestamp:
- Oct 15, 2013, 11:40:28 AM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130904/psphot/src
- Files:
-
- 3 edited
-
psphot.h (modified) (2 diffs)
-
psphotGalaxyShape.c (modified) (11 diffs)
-
psphotSetThreads.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130904/psphot/src/psphot.h
r36213 r36218 421 421 } psphotStackOptions; 422 422 423 typedef struct { 424 float fRmajorMin; 425 float fRmajorMax; 426 float fRmajorDel; 427 float fRminorMin; 428 float fRminorMax; 429 float fRminorDel; 430 } psphotGalaxyShapeOptions; 431 423 432 /*** psphotStackMatchPSF prototypes ***/ 424 433 bool psphotStackMatchPSFs (pmConfig *config, const pmFPAview *view); … … 517 526 bool psphotGalaxyShapeReadout(pmConfig *config, psMetadata *recipe, const pmFPAview *view, const char * filerule, pmReadout *readout, psArray *sources, pmPSF *psf); 518 527 bool psphotGalaxyShape_Threaded (psThreadJob *job); 519 bool psphotGalaxyShapeGrid (pmSource *source, pmSourceFitOptions *fitOptions, ps ImageMaskType maskVal, int psfSize);528 bool psphotGalaxyShapeGrid (pmSource *source, pmSourceFitOptions *fitOptions, psphotGalaxyShapeOptions *opt, psImageMaskType maskVal, int psfSize); 520 529 bool psphotGalaxyShapeSource (pmPCMdata *pcm, pmSource *source, psImageMaskType maskVal, int psfSize); 530 psphotGalaxyShapeOptions *psphotGalaxyShapeOptionsAlloc(); 521 531 522 532 bool psphotRadialProfileWings (pmConfig *config, const pmFPAview *view, const char *filerule); -
branches/eam_branches/ipp-20130904/psphot/src/psphotGalaxyShape.c
r36216 r36218 83 83 maskVal |= markVal; 84 84 85 // bit-mask to mark pixels not used in analysis 86 psphotGalaxyShapeOptions *opt = psphotGalaxyShapeOptionsAlloc(); 87 opt->fRmajorMin = psMetadataLookupF32(&status, recipe, "GALAXY_SHAPES_FR_MAJOR_MIN"); if (!status) opt->fRmajorMin = 0.5; 88 opt->fRmajorMax = psMetadataLookupF32(&status, recipe, "GALAXY_SHAPES_FR_MAJOR_MAX"); if (!status) opt->fRmajorMax = 2.0; 89 opt->fRmajorDel = psMetadataLookupF32(&status, recipe, "GALAXY_SHAPES_FR_MAJOR_DEL"); if (!status) opt->fRmajorDel = 0.1; 90 opt->fRminorMin = psMetadataLookupF32(&status, recipe, "GALAXY_SHAPES_FR_MINOR_MIN"); if (!status) opt->fRminorMin = 0.5; 91 opt->fRminorMax = psMetadataLookupF32(&status, recipe, "GALAXY_SHAPES_FR_MINOR_MAX"); if (!status) opt->fRminorMax = 2.0; 92 opt->fRminorDel = psMetadataLookupF32(&status, recipe, "GALAXY_SHAPES_FR_MINOR_DEL"); if (!status) opt->fRminorDel = 0.1; 93 85 94 // what fraction of the PSF is used? (radius in pixels : 2 -> 5x5 box) 95 // NOTE: this is only used if we are NOT smoothing with a 1D Gaussian 86 96 int psfSize = psMetadataLookupS32 (&status, recipe, "PCM_BOX_SIZE"); 87 97 assert (status); … … 119 129 psArrayAdd(job->args, 1, cells->data[j]); // sources 120 130 psArrayAdd(job->args, 1, fitOptions); 131 psArrayAdd(job->args, 1, opt); 121 132 PS_ARRAY_ADD_SCALAR(job->args, markVal, PS_TYPE_IMAGE_MASK); 122 133 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); … … 156 167 psFree (cellGroups); 157 168 psFree (fitOptions); 169 psFree (opt); 158 170 159 171 psLogMsg ("psphot.galaxy", PS_LOG_WARN, "measure galaxy shapes : %f sec for %ld objects\n", psTimerMark ("psphot.galaxy"), sources->n); … … 166 178 psArray *sources = job->args->data[1]; 167 179 pmSourceFitOptions *fitOptions = job->args->data[2]; 168 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[3],PS_TYPE_IMAGE_MASK_DATA); 169 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA); 170 int psfSize = PS_SCALAR_VALUE(job->args->data[5],S32); 180 psphotGalaxyShapeOptions *opt = job->args->data[3]; 181 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA); 182 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[5],PS_TYPE_IMAGE_MASK_DATA); 183 int psfSize = PS_SCALAR_VALUE(job->args->data[6],S32); 171 184 172 185 float fitRadius; … … 202 215 // this function populates moments->Mrf,GalaxyShape,GalaxyShapeErr 203 216 // do the following for a set of shapes (Ex,Ey) 204 psphotGalaxyShapeGrid (source, fitOptions, maskVal, psfSize); 217 psphotGalaxyShapeGrid (source, fitOptions, opt, maskVal, psfSize); 218 205 219 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); 206 220 … … 211 225 } 212 226 213 bool psphotGalaxyShapeGrid (pmSource *source, pmSourceFitOptions *fitOptions, ps ImageMaskType maskVal, int psfSize) {227 bool psphotGalaxyShapeGrid (pmSource *source, pmSourceFitOptions *fitOptions, psphotGalaxyShapeOptions *opt, psImageMaskType maskVal, int psfSize) { 214 228 215 229 // we use the 0th model to define the initial guess shape … … 230 244 // I have some source guess (e0, e1, e2) 231 245 psEllipseAxes guessAxes = pmPSF_ModelToAxes (PAR, modelType); 232 psEllipsePol guessPol = psEllipseAxesToPol (guessAxes);233 234 // I am going to retain the value of e0, and grid search around e1,e2235 // I need to study a valid range (and distribution?) for e1,e2)236 246 237 247 if (!source->galaxyFits) { 238 source->galaxyFits = pmSourceGalaxyFitsAlloc();239 } 240 241 for (float de1 = -0.2; de1 <= +0.2; de1 += 0.1) {242 for (float de2 = -0.2; de2 <= +0.2; de2 += 0.1) {248 source->galaxyFits = pmSourceGalaxyFitsAlloc(); 249 } 250 251 for (float fRmajor = opt->fRmajorMin; fRmajor < opt->fRmajorMax + 0.5*opt->fRmajorDel; fRmajor += opt->fRmajorDel) { 252 for (float fRminor = opt->fRminorMin; fRminor < opt->fRminorMax + 0.5*opt->fRminorDel; fRminor += opt->fRminorDel) { 243 253 244 psEllipsePol testPol = guessPol; 245 testPol.e1 += de1; 246 testPol.e2 += de2; 247 248 psEllipseAxes axes = psEllipsePolToAxes (testPol, 0.1); 249 250 pmPSF_AxesToModel (PAR, axes, modelType); 251 254 psEllipseAxes testAxes = guessAxes; 255 testAxes.major = guessAxes.major * fRmajor; 256 testAxes.minor = guessAxes.minor * fRminor; 257 258 pmPSF_AxesToModel (PAR, testAxes, modelType); 259 252 260 // where do the results go?? 253 261 psphotGalaxyShapeSource (pcm, source, maskVal, psfSize); 254 262 } 255 263 } 264 256 265 psFree (pcm); 257 266 return true; … … 267 276 268 277 // generate the modelFlux 278 // need to reset here each time since we assign below to calculate the flux 269 279 pmPCMMakeModel (source, pcm->modelConv, maskVal, psfSize); 280 pcm->modelConv->params->data.F32[PM_PAR_I0] = 1.0; 270 281 271 282 int nPix = 0; … … 273 284 float YM = 0.0; 274 285 float MM = 0.0; 275 bool usePoisson = false;286 bool usePoisson = true; 276 287 277 288 for (int iy = 0; iy < source->pixels->numRows; iy++) { … … 306 317 float Chisq = (YY - 2 * Io * YM + Io * Io * MM) / (float) nPix; 307 318 308 // fprintf (stderr, "Io: %f, Chisq: %f\n", Io, Chisq); 309 310 psVectorAppend (source->galaxyFits->Io, Io); 311 psVectorAppend (source->galaxyFits->dIo, dIo); 319 pcm->modelConv->params->data.F32[PM_PAR_I0] = Io; 320 float flux = pcm->modelConv->modelFlux (pcm->modelConv->params); 321 float dflux = flux * (dIo / Io); 322 323 psVectorAppend (source->galaxyFits->Flux, flux); 324 psVectorAppend (source->galaxyFits->dFlux, dflux); 312 325 psVectorAppend (source->galaxyFits->chisq, Chisq); 313 326 source->galaxyFits->nPix = nPix; … … 315 328 return true; 316 329 } 330 331 /**** support functions ****/ 332 333 void psphotGalaxyShapeOptionsFree (psphotGalaxyShapeOptions *opt) { 334 return; 335 } 336 337 psphotGalaxyShapeOptions *psphotGalaxyShapeOptionsAlloc() 338 { 339 psphotGalaxyShapeOptions *opt = (psphotGalaxyShapeOptions *) psAlloc(sizeof(psphotGalaxyShapeOptions)); 340 psMemSetDeallocator(opt, (psFreeFunc) psphotGalaxyShapeOptionsFree); 341 342 opt->fRmajorMin = 0.5; 343 opt->fRmajorMax = 2.0; 344 opt->fRmajorDel = 0.1; 345 opt->fRminorMin = 0.5; 346 opt->fRminorMax = 2.0; 347 opt->fRminorDel = 0.1; 348 349 return opt; 350 } 351 -
branches/eam_branches/ipp-20130904/psphot/src/psphotSetThreads.c
r36213 r36218 57 57 psFree(task); 58 58 59 task = psThreadTaskAlloc("PSPHOT_GALAXY_SHAPES", 6);59 task = psThreadTaskAlloc("PSPHOT_GALAXY_SHAPES", 7); 60 60 task->function = &psphotGalaxyShape_Threaded; 61 61 psThreadTaskAdd(task);
Note:
See TracChangeset
for help on using the changeset viewer.
