Changeset 15359 for branches/eam_branch_20071023/psphot/src/psphotAnnuli.c
- Timestamp:
- Oct 23, 2007, 10:54:53 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20071023/psphot/src/psphotAnnuli.c
r13983 r15359 3 3 bool psphotAnnuli (pmSource *source, psMetadata *recipe, psMaskType maskVal) { 4 4 5 psLogMsg ("psphot", PS_LOG_INFO, "not implemented\n"); 5 assert (source->extpars); 6 assert (source->extpars->profile); 7 assert (source->extpars->profile->radius); 8 assert (source->extpars->profile->flux); 9 10 psVector *radius = source->extpars->profile->radius; 11 psVector *weight = source->extpars->profile->weight; 12 psVector *flux = source->extpars->profile->flux; 13 14 // XXX how do I define the radii? we can put a vector in the recipe... 15 // radialBins defines the bounds or start and stop (we can skip some that way... 16 psVector *radialBinsLower = psMetadataLookupVector (&status, recipe, RADIAL_ANNULAR_BINS_LOWER); 17 psVector *radialBinsUpper = psMetadataLookupVector (&status, recipe, RADIAL_ANNULAR_BINS_UPPER); 18 assert (radialBinsLower->n == radialBinsUpper->n); 19 20 psVector *fluxValues = psVectorAlloc (radialBinsLower->n, PS_TYPE_F32); 21 psVector *fluxSquare = psVectorAlloc (radialBinsLower->n, PS_TYPE_F32); 22 psVector *fluxWeight = psVectorAlloc (radialBinsLower->n, PS_TYPE_F32); 23 psVector *pixelCount = psVectorAlloc (radialBinsLower->n, PS_TYPE_F32); 24 psVectorInit (fluxValues, 0.0); 25 psVectorInit (fluxSquare, 0.0); 26 psVectorInit (fluxWeight, 0.0); 27 psVectorInit (pixelCount, 0.0); 28 29 // XXX this code assumes the radii are in pixels. convert from arcsec with plate scale 30 // XXX assume the annulii above are not overlapping? much faster... 31 // XXX this might be must faster in the reverse order: loop over annulii and use disection to 32 // skip to the start of the annulus. 33 for (int i = 0; i < flux->n; i++) { 34 for (int j = 0; j < radialBinsLower->n; j++) { 35 if (radius->data.F32[i] < radialBinsLower->data.F32[j]) continue; 36 if (radius->data.F32[i] > radialBinsUpper->data.F32[j]) continue; 37 fluxValues->data.F32[j] += flux->data.F32[i]; 38 fluxSquare->data.F32[j] += PS_SQR(flux->data.F32[i]); 39 fluxWeight->data.F32[j] += weight->data.F32[i]; 40 pixelCount->data.F32[j] += 1.0; 41 } 42 } 43 44 for (int j = 0; j < radialBinsLower->n; j++) { 45 fluxValues->data.F32[j] /= pixelCount->data.F32[j]; 46 fluxSquare->data.F32[j] /= pixelCount->data.F32[j]; 47 fluxSquare->data.F32[j] -= PS_SQR(fluxValues->data.F32[j]); 48 } 49 50 source->extpars->annuli = pmSourceAnnuliAlloc (); 51 source->extpars->annuli->flux = fluxValues; 52 source->extpars->annuli->fluxErr = fluxWeight; 53 source->extpars->annuli->fluxVar = fluxSquare; 54 6 55 return true; 56 } 7 57 8 }
Note:
See TracChangeset
for help on using the changeset viewer.
