Changeset 36148 for branches/eam_branches/ipp-20130904/psphot/src
- Timestamp:
- Sep 24, 2013, 12:09:27 PM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130904/psphot/src
- Files:
-
- 9 edited
-
. (modified) (1 prop)
-
Makefile.am (modified) (5 diffs)
-
psphot.h (modified) (2 diffs)
-
psphotBlendFit.c (modified) (1 diff)
-
psphotFullForceReadout.c (modified) (2 diffs)
-
psphotGalaxyShape.c (modified) (13 diffs)
-
psphotKronFlux.c (modified) (11 diffs)
-
psphotPetroFlux.c (modified) (13 diffs)
-
psphotSetThreads.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130904/psphot/src
- Property svn:ignore
-
old new 24 24 psphotModelTest 25 25 psphotMinimal 26 psphotFullForce
-
- Property svn:ignore
-
branches/eam_branches/ipp-20130904/psphot/src/Makefile.am
r34317 r36148 25 25 libpsphot_la_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 26 26 27 bin_PROGRAMS = psphot psphotForced psphot Minimal psphotMakePSF psphotStack psphotModelTest27 bin_PROGRAMS = psphot psphotForced psphotFullForce psphotMinimal psphotMakePSF psphotStack psphotModelTest 28 28 # bin_PROGRAMS = psphotPetrosianStudy psphotTest psphotMomentsStudy 29 29 … … 35 35 psphotForced_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 36 36 psphotForced_LDADD = libpsphot.la 37 38 psphotFullForce_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 39 psphotFullForce_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 40 psphotFullForce_LDADD = libpsphot.la 37 41 38 42 psphotMinimal_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) … … 77 81 psphotForced.c \ 78 82 psphotForcedArguments.c \ 83 psphotParseCamera.c \ 84 psphotImageLoop.c \ 85 psphotMosaicChip.c \ 86 psphotCleanup.c 87 88 # generalized forced photometry (including Kron, Petro, and Models) of specified positions given a specified psf 89 psphotFullForce_SOURCES = \ 90 psphotFullForce.c \ 91 psphotFullForceArguments.c \ 79 92 psphotParseCamera.c \ 80 93 psphotImageLoop.c \ … … 155 168 psphotReadoutMinimal.c \ 156 169 psphotForcedReadout.c \ 170 psphotFullForceReadout.c \ 157 171 psphotMakePSFReadout.c \ 158 172 psphotModelBackground.c \ … … 198 212 psphotRadialPlot.c \ 199 213 psphotKronIterate.c \ 214 psphotKronFlux.c \ 215 psphotPetroFlux.c \ 216 psphotGalaxyShape.c \ 200 217 psphotRadialProfileWings.c \ 201 218 psphotDeblendSatstars.c \ -
branches/eam_branches/ipp-20130904/psphot/src/psphot.h
r36146 r36148 342 342 bool psphotForcedReadout(pmConfig *config, const pmFPAview *view, const char *filerule); 343 343 344 pmConfig *psphotFullForceArguments(int argc, char **argv); 345 bool psphotFullForceReadout(pmConfig *config, const pmFPAview *view, const char *filerule); 346 344 347 pmConfig *psphotMinimalArguments(int argc, char **argv); 345 348 bool psphotReadoutMinimal(pmConfig *config, const pmFPAview *view, const char *filerule); … … 498 501 bool psphotKronIterate_Threaded (psThreadJob *job); 499 502 503 bool psphotKronFlux (pmConfig *config, const pmFPAview *view, const char *filerule); 504 bool psphotKronFluxReadout(pmConfig *config, psMetadata *recipe, const pmFPAview *view, const char *filerule, pmReadout *readout, psArray *sources); 505 bool psphotKronFlux_Threaded (psThreadJob *job); 506 bool psphotKronFluxSource (pmSource *source, psImageMaskType maskVal); 507 508 bool psphotPetroFlux (pmConfig *config, const pmFPAview *view, const char *filerule); 509 bool psphotPetroFluxReadout(pmConfig *config, psMetadata *recipe, const pmFPAview *view, const char * filerule, pmReadout *readout, psArray *sources); 510 bool psphotPetroFlux_Threaded (psThreadJob *job); 511 bool psphotPetroFluxSource (pmSource *source, psImageMaskType maskVal); 512 513 bool psphotGalaxyShape (pmConfig *config, const pmFPAview *view, const char *filerule); 514 bool psphotGalaxyShapeReadout(pmConfig *config, psMetadata *recipe, const pmFPAview *view, const char * filerule, pmReadout *readout, psArray *sources, pmPSF *psf); 515 bool psphotGalaxyShape_Threaded (psThreadJob *job); 516 bool psphotGalaxyShapeGrid (pmSource *source, pmSourceFitOptions *fitOptions, psImageMaskType maskVal, int psfSize); 517 bool psphotGalaxyShapeSource (pmPCMdata *pcm, pmSource *source, psImageMaskType maskVal, int psfSize); 518 500 519 bool psphotRadialProfileWings (pmConfig *config, const pmFPAview *view, const char *filerule); 501 520 bool psphotRadialProfileWingsReadout(pmConfig *config, psMetadata *recipe, const pmFPAview *view, pmReadout *readout, psArray *sources); -
branches/eam_branches/ipp-20130904/psphot/src/psphotBlendFit.c
r36086 r36148 273 273 pmSource *source = sources->data[i]; 274 274 275 # if (0) 276 int TEST_ON = false; 275 # if (PS_TRACE_ON) 277 276 # define TEST_X 653 278 277 # define TEST_Y 466 279 if ((fabs(source->peak->xf - TEST_X) < 5) && (fabs(source->peak->yf - TEST_Y) < 5)) { 278 # define TESTING 1 279 int TEST_ON = false; 280 if (TESTING && (fabs(source->peak->xf - TEST_X) < 5) && (fabs(source->peak->yf - TEST_Y) < 5)) { 280 281 fprintf (stderr, "test object\n"); 281 282 psTraceSetLevel("psLib.math.psMinimizeLMChi2", 5); -
branches/eam_branches/ipp-20130904/psphot/src/psphotFullForceReadout.c
r36146 r36148 57 57 58 58 // generate a psf model for any readouts which need one 59 psphotFullForcePSF (config, view, filerule); 59 // psphotFullForcePSF (config, view, filerule); 60 // XXX I'm not sure we need a different algorithm here or not : we are supplying the 61 // sources; we should mark with a flag bit the ones we actually want to use as PSF 62 // stars (this means we need to supply this info in the load). 63 psphotChoosePSF (config, view, filerule, true); 60 64 61 65 // Construct an initial model for each object, set the radius to fitRadius, set circular … … 73 77 74 78 // measure kron fluxes 75 psphotKronFlux (config, view, filerule , false);79 psphotKronFlux (config, view, filerule); 76 80 77 81 // measure petro fluxes -
branches/eam_branches/ipp-20130904/psphot/src/psphotGalaxyShape.c
r36146 r36148 1 1 # include "psphotInternal.h" 2 2 3 bool psphotGalaxyShape (pmConfig *config, const pmFPAview *view, const char *filerule , int pass)3 bool psphotGalaxyShape (pmConfig *config, const pmFPAview *view, const char *filerule) 4 4 { 5 5 bool status = true; … … 38 38 // psAssert (psf, "missing psf?"); 39 39 40 if (!psphotGalaxyShapeReadout (config, recipe, view, filerule, readout, sources, psf , i, pass)) {40 if (!psphotGalaxyShapeReadout (config, recipe, view, filerule, readout, sources, psf)) { 41 41 psError (PSPHOT_ERR_CONFIG, false, "failed to measure magnitudes for %s entry %d", filerule, i); 42 42 return false; … … 46 46 } 47 47 48 bool psphotGalaxyShapeReadout(pmConfig *config, psMetadata *recipe, const pmFPAview *view, const char * filerule, pmReadout *readout, psArray *sources, pmPSF *psf , int index, int pass) {48 bool psphotGalaxyShapeReadout(pmConfig *config, psMetadata *recipe, const pmFPAview *view, const char * filerule, pmReadout *readout, psArray *sources, pmPSF *psf) { 49 49 50 50 bool status = false; … … 55 55 } 56 56 57 psTimerStart ("psphot. kron");57 psTimerStart ("psphot.galaxy"); 58 58 59 59 // determine the number of allowed threads … … 63 63 } 64 64 65 bool KRON_APPLY_WEIGHT = psMetadataLookupBool (&status, recipe, "KRON_APPLY_WEIGHT");66 if (!status) {67 KRON_APPLY_WEIGHT = true;68 }69 70 bool KRON_APPLY_WINDOW = psMetadataLookupBool (&status, recipe, "KRON_APPLY_WINDOW");71 if (!status) {72 KRON_APPLY_WINDOW = false;73 }74 75 65 // bit-masks to test for good/bad pixels 76 66 psImageMaskType maskVal = psMetadataLookupImageMask(&status, recipe, "MASK.PSPHOT"); … … 83 73 // maskVal is used to test for rejected pixels, and must include markVal 84 74 maskVal |= markVal; 75 76 // what fraction of the PSF is used? (radius in pixels : 2 -> 5x5 box) 77 int psfSize = psMetadataLookupS32 (&status, recipe, "PCM_BOX_SIZE"); 78 assert (status); 79 80 // source fitting parameters for extended source fits 81 int fitIter = psMetadataLookupS32(&status, recipe, "EXT_FIT_ITER"); // Max number of fit iterations 82 assert (status && fitIter > 0); 83 84 float fitMinTol = psMetadataLookupF32 (&status, recipe, "EXT_FIT_MIN_TOL"); // Fit tolerance 85 if (!status || !isfinite(fitMinTol) || fitMinTol <= 0) { 86 fitMinTol = psMetadataLookupF32 (&status, recipe, "PSF_FIT_TOL"); // Fit tolerance 87 if (!status || !isfinite(fitMinTol) || fitMinTol <= 0) { 88 psAbort("PSF_FIT_MIN_TOL (and PSF_FIT_TOL) not defined or positive"); 89 } 90 } 91 92 float fitMaxTol = psMetadataLookupF32 (&status, recipe, "EXT_FIT_MAX_TOL"); // Fit tolerance 93 if (!status || !isfinite(fitMaxTol) || fitMaxTol <= 0) { 94 fitMaxTol = 1.0; 95 } 96 97 bool chisqConvergence = psMetadataLookupBool (&status, recipe, "LMM_FIT_CHISQ_CONVERGENCE"); // Fit tolerance 98 if (!status) { 99 // default to the old method (chisqConvergence) 100 chisqConvergence = true; 101 } 102 103 int gainFactorMode = psMetadataLookupS32 (&status, recipe, "LMM_FIT_GAIN_FACTOR_MODE"); // Fit tolerance 104 if (!status) { 105 // default to the old method (chisqConvergence) 106 gainFactorMode = 0; 107 } 108 109 // perform full extended source non-linear fits? 110 bool isInteractive = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_FITS_INTERACTIVE"); 111 if (!status) isInteractive = false; 112 113 // Define source fitting parameters for extended source fits 114 pmSourceFitOptions *fitOptions = pmSourceFitOptionsAlloc(); 115 fitOptions->mode = PM_SOURCE_FIT_EXT_AND_SKY; 116 fitOptions->saveCovariance = true; // XXX make this a user option? 117 fitOptions->covarFactor = psImageCovarianceFactorForAperture(readout->covariance, 10.0); // Covariance matrix 118 fitOptions->nIter = fitIter; 119 fitOptions->minTol = fitMinTol; 120 fitOptions->maxTol = fitMaxTol; 121 122 fitOptions->gainFactorMode = gainFactorMode; 123 fitOptions->chisqConvergence = chisqConvergence; 124 fitOptions->isInteractive = isInteractive; 85 125 86 126 // source analysis is done in S/N order (brightest first) … … 105 145 106 146 // allocate a job -- if threads are not defined, this just runs the job 107 psThreadJob *job = psThreadJobAlloc ("PSPHOT_ KRON_ITERATE");147 psThreadJob *job = psThreadJobAlloc ("PSPHOT_GALAXY_SHAPES"); 108 148 109 149 psArrayAdd(job->args, 1, readout); 110 150 psArrayAdd(job->args, 1, cells->data[j]); // sources 111 PS_ARRAY_ADD_SCALAR(job->args, markVal, PS_TYPE_IMAGE_MASK); 112 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 113 PS_ARRAY_ADD_SCALAR(job->args, pass, PS_TYPE_S32); 151 psArrayAdd(job->args, 1, fitOptions); 152 PS_ARRAY_ADD_SCALAR(job->args, markVal, PS_TYPE_IMAGE_MASK); 153 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 154 PS_ARRAY_ADD_SCALAR(job->args, psfSize, PS_TYPE_S32); 114 155 115 156 // set this to 0 to run without threading … … 146 187 psFree (cellGroups); 147 188 148 psLogMsg ("psphot. kron", PS_LOG_WARN, "measure kron fluxes : %f sec for %ld objects\n", psTimerMark ("psphot.kron"), sources->n);189 psLogMsg ("psphot.galaxy", PS_LOG_WARN, "measure galaxy shapes : %f sec for %ld objects\n", psTimerMark ("psphot.galaxy"), sources->n); 149 190 return true; 150 191 } … … 152 193 bool psphotGalaxyShape_Threaded (psThreadJob *job) { 153 194 154 pmReadout *readout = job->args->data[0]; 155 psArray *sources = job->args->data[2]; 156 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA); 157 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[5],PS_TYPE_IMAGE_MASK_DATA); 195 pmReadout *readout = job->args->data[0]; 196 psArray *sources = job->args->data[1]; 197 pmSourceFitOptions *fitOptions = job->args->data[2]; 198 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[3],PS_TYPE_IMAGE_MASK_DATA); 199 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA); 200 int psfSize = PS_SCALAR_VALUE(job->args->data[5],S32); 158 201 159 202 for (int i = 0; i < sources->n; i++) { 160 161 // XXX what do i need for the kron flux (given a supplied kron radius?)162 203 163 204 pmSource *source = sources->data[i]; … … 184 225 185 226 // re-allocate image, weight, mask arrays for each peak with box big enough to fit BIG_RADIUS 186 bool extend =pmSourceRedefinePixels (source, readout, source->peak->x, source->peak->y, windowRadius + 2);227 pmSourceRedefinePixels (source, readout, source->peak->x, source->peak->y, windowRadius + 2); 187 228 psAssert (source->pixels, "WTF?"); 188 229 189 230 // this function populates moments->Mrf,GalaxyShape,GalaxyShapeErr 190 231 // do the following for a set of shapes (Ex,Ey) 191 psphotGalaxyShape Source (source, maskVal);232 psphotGalaxyShapeGrid (source, fitOptions, maskVal, psfSize); 192 233 psImageMaskPixels (source->maskObj, "AND", PS_NOT_IMAGE_MASK(markVal)); 193 234 … … 198 239 } 199 240 200 bool psphotGalaxyShapeGrid (pmSource *source, psImageMaskType maskVal, float psfSize) { 201 202 pmPCMdata *pcm = pmPCMinit (source, &options, model, maskVal, psfSize); 203 204 // I have some source guess (e0, e1, e2) 205 psEllipsePol guessPol; 206 207 // I am going to retain the value of e0, and grid search around e1,e2 208 // I need to study a valid range (and distribution?) for e1,e2) 209 210 for (float de1 = -0.2; de1 <= +0.2; de1 += 0.1) { 211 for (float de2 = -0.2; de2 <= +0.2; de2 += 0.1) { 241 bool psphotGalaxyShapeGrid (pmSource *source, pmSourceFitOptions *fitOptions, psImageMaskType maskVal, int psfSize) { 242 243 // allocate the model 244 // XXX need to figure out how to get the model into the program 245 pmModelType modelType = pmModelClassGetType ("PS_MODEL_EXP"); 246 247 pmModel *model = pmModelAlloc(modelType); 248 if (!model) { 249 return NULL; 250 } 251 252 pmPCMdata *pcm = pmPCMinit (source, fitOptions, model, maskVal, psfSize); 253 254 psF32 *PAR = pcm->modelConv->params->data.F32; 255 256 // I have some source guess (e0, e1, e2) 257 psEllipsePol guessPol; 258 259 // I am going to retain the value of e0, and grid search around e1,e2 260 // I need to study a valid range (and distribution?) for e1,e2) 261 262 for (float de1 = -0.2; de1 <= +0.2; de1 += 0.1) { 263 for (float de2 = -0.2; de2 <= +0.2; de2 += 0.1) { 212 264 213 psEllipsePol testPol = guessPol; 214 testPol.e1 += de1; 215 testPol.e2 += de2; 216 217 psEllipseShape shape; 218 psEllipsePolToShape (&shape, testPol); 219 220 PAR[PM_PAR_SXX] = shape.sxx; 221 PAR[PM_PAR_SXY] = shape.sxy; 222 PAR[PM_PAR_SYY] = shape.syy; 223 224 // where do the results go?? 225 psphotGalaxyShapeSource (pcm, source, maskVal); 226 } 227 } 228 229 return true; 265 psEllipsePol testPol = guessPol; 266 testPol.e1 += de1; 267 testPol.e2 += de2; 268 269 psEllipseAxes axes = psEllipsePolToAxes (testPol, 0.1); 270 271 pmPSF_AxesToModel (PAR, axes, modelType); 272 273 // where do the results go?? 274 psphotGalaxyShapeSource (pcm, source, maskVal, psfSize); 275 } 276 } 277 278 return true; 230 279 } 231 280 232 281 // fit the given model to the source and find chisq & normalization 233 282 // XXX is this a single-component model? sersic with a supplied index, Reff, axis ratio, and theta? 234 bool psphotGalaxyShapeSource (pmPCMdata *pcm, pmSource *source, psImageMaskType maskVal ) {283 bool psphotGalaxyShapeSource (pmPCMdata *pcm, pmSource *source, psImageMaskType maskVal, int psfSize) { 235 284 236 285 PS_ASSERT_PTR_NON_NULL(source, false); 237 286 PS_ASSERT_PTR_NON_NULL(source->peak, false); 238 287 PS_ASSERT_PTR_NON_NULL(source->pixels, false); 239 240 psF32 *PAR = pcm->modelConv->params->data.F32;241 288 242 289 // generate the modelFlux … … 249 296 250 297 for (int iy = 0; iy < source->pixels->numRows; iy++) { 251 for (int ix = 0; ix < source->pixels->numCols; ix++) { 252 // skip masked points 253 if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix]) { 254 continue; 298 for (int ix = 0; ix < source->pixels->numCols; ix++) { 299 // skip masked points 300 if (source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix]) { 301 continue; 302 } 303 // skip zero-variance points 304 if (source->variance->data.F32[iy][ix] == 0) { 305 continue; 306 } 307 // skip nan value points 308 if (!isfinite(source->pixels->data.F32[iy][ix])) { 309 continue; 310 } 311 312 float fy = source->pixels->data.F32[iy][ix]; 313 float fm = source->modelFlux->data.F32[iy][ix]; 314 float wt = (usePoisson) ? 1.0 / source->variance->data.F32[iy][ix] : 1.0; 315 316 YY += PS_SQR(fy) * wt; 317 YM += fm * fy * wt; 318 MM += PS_SQR(fm) * wt; 255 319 } 256 // skip zero-variance points257 if (source->variance->data.F32[iy][ix] == 0) {258 continue;259 }260 // skip nan value points261 if (!isfinite(source->pixels->data.F32[iy][ix])) {262 continue;263 }264 265 float fy = source->pixels->data.F32[iy][ix];266 float fm = source->modelFlux->data.F32[iy][ix];267 float wt = (usePoisson) ? 1.0 / source->variance->data.F32[iy][ix] : 1.0;268 269 YY += PS_SQR(fy) * wt;270 YM += fm * fy * wt;271 MM += PS_SQR(fm) * wt;272 }273 320 } 274 321 … … 276 323 float Chisq = YY - 2 * Io * YM + Io * Io * MM; 277 324 278 return true; 279 } 325 fprintf (stderr, "Io: %f, Chisq: %f\n", Io, Chisq); 326 327 return true; 328 } -
branches/eam_branches/ipp-20130904/psphot/src/psphotKronFlux.c
r36146 r36148 1 1 # include "psphotInternal.h" 2 2 3 bool psphotKronFlux (pmConfig *config, const pmFPAview *view, const char *filerule , int pass)3 bool psphotKronFlux (pmConfig *config, const pmFPAview *view, const char *filerule) 4 4 { 5 5 bool status = true; … … 35 35 psAssert (sources, "missing sources?"); 36 36 37 pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF"); 38 // psAssert (psf, "missing psf?"); 39 40 if (!psphotKronFluxReadout (config, recipe, view, filerule, readout, sources, psf, i, pass)) { 37 if (!psphotKronFluxReadout (config, recipe, view, filerule, readout, sources)) { 41 38 psError (PSPHOT_ERR_CONFIG, false, "failed to measure magnitudes for %s entry %d", filerule, i); 42 39 return false; … … 46 43 } 47 44 48 bool psphotKronFluxReadout(pmConfig *config, psMetadata *recipe, const pmFPAview *view, const char * filerule, pmReadout *readout, psArray *sources, pmPSF *psf, int index, int pass) {45 bool psphotKronFluxReadout(pmConfig *config, psMetadata *recipe, const pmFPAview *view, const char *filerule, pmReadout *readout, psArray *sources) { 49 46 50 47 bool status = false; … … 61 58 if (!status) { 62 59 nThreads = 0; 63 }64 65 bool KRON_APPLY_WEIGHT = psMetadataLookupBool (&status, recipe, "KRON_APPLY_WEIGHT");66 if (!status) {67 KRON_APPLY_WEIGHT = true;68 }69 70 bool KRON_APPLY_WINDOW = psMetadataLookupBool (&status, recipe, "KRON_APPLY_WINDOW");71 if (!status) {72 KRON_APPLY_WINDOW = false;73 60 } 74 61 … … 105 92 106 93 // allocate a job -- if threads are not defined, this just runs the job 107 psThreadJob *job = psThreadJobAlloc ("PSPHOT_KRON_ ITERATE");94 psThreadJob *job = psThreadJobAlloc ("PSPHOT_KRON_FLUX"); 108 95 109 96 psArrayAdd(job->args, 1, readout); … … 111 98 PS_ARRAY_ADD_SCALAR(job->args, markVal, PS_TYPE_IMAGE_MASK); 112 99 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 113 PS_ARRAY_ADD_SCALAR(job->args, pass, PS_TYPE_S32);114 100 115 101 // set this to 0 to run without threading … … 153 139 154 140 pmReadout *readout = job->args->data[0]; 155 psArray *sources = job->args->data[ 2];156 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[ 4],PS_TYPE_IMAGE_MASK_DATA);157 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[ 5],PS_TYPE_IMAGE_MASK_DATA);141 psArray *sources = job->args->data[1]; 142 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[2],PS_TYPE_IMAGE_MASK_DATA); 143 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[3],PS_TYPE_IMAGE_MASK_DATA); 158 144 159 145 for (int i = 0; i < sources->n; i++) { 160 161 // XXX what do i need for the kron flux (given a supplied kron radius?)162 146 163 147 pmSource *source = sources->data[i]; … … 180 164 } 181 165 182 // is th eright??183 float windowRadius = 6.0*source->moments->Mrf ;166 // is this right?? 167 float windowRadius = 2.5*source->moments->Mrf ; 184 168 185 169 // re-allocate image, weight, mask arrays for each peak with box big enough to fit BIG_RADIUS 186 bool extend =pmSourceRedefinePixels (source, readout, source->peak->x, source->peak->y, windowRadius + 2);170 pmSourceRedefinePixels (source, readout, source->peak->x, source->peak->y, windowRadius + 2); 187 171 psAssert (source->pixels, "WTF?"); 188 172 … … 205 189 206 190 // the peak position is less accurate but less subject to extreme deviations 191 // XXX do this or just use the peak position? 207 192 float dX = source->moments->Mx - source->peak->xf; 208 193 float dY = source->moments->My - source->peak->yf; … … 211 196 float Yo = (dR < 2.0) ? source->moments->My : source->peak->yf; 212 197 198 // center of mass in subimage. Note: the calculation below uses pixel index, so we correct 199 // xCM, yCM from pixel coords to pixel index here. 200 psF32 xCM = Xo - 0.5 - source->pixels->col0; // coord of peak in subimage 201 psF32 yCM = Yo - 0.5 - source->pixels->row0; // coord of peak in subimage 202 213 203 // Calculate the Kron magnitude (make this block optional?) 214 204 // XXX set the aperture here 215 float radKron = 2.5* Mrf;205 float radKron = 2.5*source->moments->Mrf; 216 206 float radKron2 = radKron*radKron; 217 207 … … 222 212 // set vPix to the source pixels (it may have been set to the 223 213 // smoothed image above) 224 vPix = source->pixels->data.F32;225 vWgt = source->variance->data.F32;226 vMsk = source->mask->data.F32;214 psF32 **vPix = source->pixels->data.F32; 215 psF32 **vWgt = source->variance->data.F32; 216 psImageMaskType **vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA; 227 217 228 218 for (psS32 row = 0; row < source->pixels->numRows ; row++) { -
branches/eam_branches/ipp-20130904/psphot/src/psphotPetroFlux.c
r36146 r36148 1 1 # include "psphotInternal.h" 2 2 3 bool psphotPetroFlux (pmConfig *config, const pmFPAview *view, const char *filerule , int pass)3 bool psphotPetroFlux (pmConfig *config, const pmFPAview *view, const char *filerule) 4 4 { 5 5 bool status = true; … … 35 35 psAssert (sources, "missing sources?"); 36 36 37 pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF"); 38 // psAssert (psf, "missing psf?"); 39 40 if (!psphotPetroFluxReadout (config, recipe, view, filerule, readout, sources, psf, i, pass)) { 37 if (!psphotPetroFluxReadout (config, recipe, view, filerule, readout, sources)) { 41 38 psError (PSPHOT_ERR_CONFIG, false, "failed to measure magnitudes for %s entry %d", filerule, i); 42 39 return false; … … 46 43 } 47 44 48 bool psphotPetroFluxReadout(pmConfig *config, psMetadata *recipe, const pmFPAview *view, const char * filerule, pmReadout *readout, psArray *sources , pmPSF *psf, int index, int pass) {45 bool psphotPetroFluxReadout(pmConfig *config, psMetadata *recipe, const pmFPAview *view, const char * filerule, pmReadout *readout, psArray *sources) { 49 46 50 47 bool status = false; 51 48 52 49 if (!sources->n) { 53 psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping kron fluxes");50 psLogMsg ("psphot", PS_LOG_INFO, "no sources, skipping petrosian fluxes"); 54 51 return true; 55 52 } 56 53 57 psTimerStart ("psphot. kron");54 psTimerStart ("psphot.petro"); 58 55 59 56 // determine the number of allowed threads … … 61 58 if (!status) { 62 59 nThreads = 0; 63 }64 65 bool KRON_APPLY_WEIGHT = psMetadataLookupBool (&status, recipe, "KRON_APPLY_WEIGHT");66 if (!status) {67 KRON_APPLY_WEIGHT = true;68 }69 70 bool KRON_APPLY_WINDOW = psMetadataLookupBool (&status, recipe, "KRON_APPLY_WINDOW");71 if (!status) {72 KRON_APPLY_WINDOW = false;73 60 } 74 61 … … 105 92 106 93 // allocate a job -- if threads are not defined, this just runs the job 107 psThreadJob *job = psThreadJobAlloc ("PSPHOT_ KRON_ITERATE");94 psThreadJob *job = psThreadJobAlloc ("PSPHOT_PETRO_FLUX"); 108 95 109 96 psArrayAdd(job->args, 1, readout); … … 111 98 PS_ARRAY_ADD_SCALAR(job->args, markVal, PS_TYPE_IMAGE_MASK); 112 99 PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK); 113 PS_ARRAY_ADD_SCALAR(job->args, pass, PS_TYPE_S32);114 100 115 101 // set this to 0 to run without threading … … 146 132 psFree (cellGroups); 147 133 148 psLogMsg ("psphot. kron", PS_LOG_WARN, "measure kron fluxes : %f sec for %ld objects\n", psTimerMark ("psphot.kron"), sources->n);134 psLogMsg ("psphot.petro", PS_LOG_WARN, "measure petro fluxes : %f sec for %ld objects\n", psTimerMark ("psphot.petro"), sources->n); 149 135 return true; 150 136 } … … 153 139 154 140 pmReadout *readout = job->args->data[0]; 155 psArray *sources = job->args->data[ 2];156 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[ 4],PS_TYPE_IMAGE_MASK_DATA);157 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[ 5],PS_TYPE_IMAGE_MASK_DATA);141 psArray *sources = job->args->data[1]; 142 psImageMaskType markVal = PS_SCALAR_VALUE(job->args->data[2],PS_TYPE_IMAGE_MASK_DATA); 143 psImageMaskType maskVal = PS_SCALAR_VALUE(job->args->data[3],PS_TYPE_IMAGE_MASK_DATA); 158 144 159 145 for (int i = 0; i < sources->n; i++) { 160 161 // XXX what do i need for the kron flux (given a supplied kron radius?)162 146 163 147 pmSource *source = sources->data[i]; … … 169 153 if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) continue; 170 154 171 // XXX where are we storing the supplied kronradius?155 // XXX where are we storing the supplied petro radius? 172 156 if (!isfinite(source->moments->Mrf)) continue; 173 157 … … 180 164 } 181 165 182 // is the right?? 183 float windowRadius = 6.0*source->moments->Mrf ;166 // is the right?? XXX need the correct location for Rpet 167 float windowRadius = 2.0*source->moments->Mrf ; 184 168 185 169 // re-allocate image, weight, mask arrays for each peak with box big enough to fit BIG_RADIUS 186 bool extend =pmSourceRedefinePixels (source, readout, source->peak->x, source->peak->y, windowRadius + 2);170 pmSourceRedefinePixels (source, readout, source->peak->x, source->peak->y, windowRadius + 2); 187 171 psAssert (source->pixels, "WTF?"); 188 172 … … 211 195 float Yo = (dR < 2.0) ? source->moments->My : source->peak->yf; 212 196 197 // center of mass in subimage. Note: the calculation below uses pixel index, so we correct 198 // xCM, yCM from pixel coords to pixel index here. 199 psF32 xCM = Xo - 0.5 - source->pixels->col0; // coord of peak in subimage 200 psF32 yCM = Yo - 0.5 - source->pixels->row0; // coord of peak in subimage 201 213 202 // Calculate the Petro magnitude (make this block optional?) 214 203 // XXX set the aperture here 215 float radPetro = 2. 5*Mrf;204 float radPetro = 2.0*source->moments->Mrf; 216 205 float radPetro2 = radPetro*radPetro; 217 206 … … 222 211 // set vPix to the source pixels (it may have been set to the 223 212 // smoothed image above) 224 vPix = source->pixels->data.F32;225 vWgt = source->variance->data.F32;226 vMsk = source->mask->data.F32;213 psF32 **vPix = source->pixels->data.F32; 214 psF32 **vWgt = source->variance->data.F32; 215 psImageMaskType **vMsk = (source->maskObj == NULL) ? NULL : source->maskObj->data.PS_TYPE_IMAGE_MASK_DATA; 227 216 228 217 for (psS32 row = 0; row < source->pixels->numRows ; row++) { … … 253 242 254 243 // return the flux and error to parameters? 255 source->moments->PetroFlux = Sum; 256 source->moments->PetroFluxErr = sqrt(Var); 257 258 return true; 259 } 244 // source->moments->PetroFlux = Sum; 245 // source->moments->PetroFluxErr = sqrt(Var); 246 247 fprintf (stderr, "petro flux: %f +/- %f\n", Sum, sqrt(Var)); 248 249 return true; 250 } -
branches/eam_branches/ipp-20130904/psphot/src/psphotSetThreads.c
r35769 r36148 47 47 psFree(task); 48 48 49 task = psThreadTaskAlloc("PSPHOT_KRON_FLUX", 4); 50 task->function = &psphotKronFlux_Threaded; 51 psThreadTaskAdd(task); 52 psFree(task); 53 54 task = psThreadTaskAlloc("PSPHOT_PETRO_FLUX", 4); 55 task->function = &psphotPetroFlux_Threaded; 56 psThreadTaskAdd(task); 57 psFree(task); 58 59 task = psThreadTaskAlloc("PSPHOT_GALAXY_SHAPE", 6); 60 task->function = &psphotGalaxyShape_Threaded; 61 psThreadTaskAdd(task); 62 psFree(task); 63 49 64 task = psThreadTaskAlloc("PSPHOT_BLEND_FIT", 10); 50 65 task->function = &psphotBlendFit_Threaded;
Note:
See TracChangeset
for help on using the changeset viewer.
