Changeset 15562 for trunk/psphot/src
- Timestamp:
- Nov 9, 2007, 3:09:20 PM (19 years ago)
- Location:
- trunk/psphot/src
- Files:
-
- 8 edited
-
Makefile.am (modified) (1 diff)
-
psphot.h (modified) (1 diff)
-
psphotAnnuli.c (modified) (1 diff)
-
psphotExtendedSources.c (modified) (1 diff)
-
psphotIsophotal.c (modified) (1 diff)
-
psphotMakeResiduals.c (modified) (3 diffs)
-
psphotPetrosian.c (modified) (1 diff)
-
psphotRadialProfile.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/Makefile.am
r15040 r15562 47 47 psphotModelWithPSF.c \ 48 48 psphotExtendedSources.c \ 49 psphotRadialProfile.c \ 49 50 psphotPetrosian.c \ 50 51 psphotIsophotal.c \ -
trunk/psphot/src/psphot.h
r15040 r15562 116 116 psKernel *psphotKernelFromPSF (pmSource *source, int nPix); 117 117 118 bool psphotRadialProfile (pmSource *source, psMetadata *recipe, psMaskType maskVal); 118 119 bool psphotPetrosian (pmSource *source, psMetadata *recipe, psMaskType maskVal); 119 120 bool psphotIsophotal (pmSource *source, psMetadata *recipe, psMaskType maskVal); -
trunk/psphot/src/psphotAnnuli.c
r13983 r15562 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 bool status; 11 12 psVector *radius = source->extpars->profile->radius; 13 psVector *weight = source->extpars->profile->weight; 14 psVector *flux = source->extpars->profile->flux; 15 16 // XXX how do I define the radii? we can put a vector in the recipe... 17 // radialBins defines the bounds or start and stop (we can skip some that way... 18 psVector *radialBinsLower = psMetadataLookupPtr (&status, recipe, "RADIAL.ANNULAR.BINS.LOWER"); 19 psVector *radialBinsUpper = psMetadataLookupPtr (&status, recipe, "RADIAL.ANNULAR.BINS.UPPER"); 20 assert (radialBinsLower->n == radialBinsUpper->n); 21 22 psVector *fluxValues = psVectorAlloc (radialBinsLower->n, PS_TYPE_F32); 23 psVector *fluxSquare = psVectorAlloc (radialBinsLower->n, PS_TYPE_F32); 24 psVector *fluxWeight = psVectorAlloc (radialBinsLower->n, PS_TYPE_F32); 25 psVector *pixelCount = psVectorAlloc (radialBinsLower->n, PS_TYPE_F32); 26 psVectorInit (fluxValues, 0.0); 27 psVectorInit (fluxSquare, 0.0); 28 psVectorInit (fluxWeight, 0.0); 29 psVectorInit (pixelCount, 0.0); 30 31 // XXX this code assumes the radii are in pixels. convert from arcsec with plate scale 32 // XXX assume the annulii above are not overlapping? much faster... 33 // XXX this might be must faster in the reverse order: loop over annulii and use disection to 34 // skip to the start of the annulus. 35 for (int i = 0; i < flux->n; i++) { 36 for (int j = 0; j < radialBinsLower->n; j++) { 37 if (radius->data.F32[i] < radialBinsLower->data.F32[j]) continue; 38 if (radius->data.F32[i] > radialBinsUpper->data.F32[j]) continue; 39 fluxValues->data.F32[j] += flux->data.F32[i]; 40 fluxSquare->data.F32[j] += PS_SQR(flux->data.F32[i]); 41 fluxWeight->data.F32[j] += weight->data.F32[i]; 42 pixelCount->data.F32[j] += 1.0; 43 } 44 } 45 46 for (int j = 0; j < radialBinsLower->n; j++) { 47 fluxValues->data.F32[j] /= pixelCount->data.F32[j]; 48 fluxSquare->data.F32[j] /= pixelCount->data.F32[j]; 49 fluxSquare->data.F32[j] -= PS_SQR(fluxValues->data.F32[j]); 50 } 51 52 source->extpars->annuli = pmSourceAnnuliAlloc (); 53 source->extpars->annuli->flux = fluxValues; 54 source->extpars->annuli->fluxErr = fluxWeight; 55 source->extpars->annuli->fluxVar = fluxSquare; 56 6 57 return true; 58 } 7 59 8 } -
trunk/psphot/src/psphotExtendedSources.c
r13983 r15562 66 66 return false; 67 67 } else { 68 // XXX why am I caching the model? 68 69 pmSourceCacheModel (source, maskVal); // XXX put this in the source model function? 69 70 psTrace ("psphot", 5, "psf-convolved model for source at %7.1f, %7.1f", source->moments->x, source->moments->y); 70 71 Npsf ++; 72 } 73 74 // all of these below require the radial profile 75 // XXX push this as a test and call in each of the functions below? 76 // XXX this constructs a pmSourceExtendedParameters element 77 if (doPetrosian || doIsophotal || doAnnuli || doKron) { 78 if (!psphotRadialProfile (source, recipe, maskVal)) { 79 psError(PSPHOT_ERR_UNKNOWN, false, "failure to generate radial profile"); 80 return false; 81 } 71 82 } 72 83 -
trunk/psphot/src/psphotIsophotal.c
r13983 r15562 3 3 bool psphotIsophotal (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 bool status; 11 12 psVector *radius = source->extpars->profile->radius; 13 psVector *flux = source->extpars->profile->flux; 14 15 // flux at which to measure isophotal parameters 16 // XXX cache this? 17 float ISOPHOT_FLUX = psMetadataLookupF32 (&status, recipe, "ISOPHOTAL_FLUX"); 18 19 // find the first bin below the flux level and the last above the level 20 // XXX can this be done faster with disection? 21 // XXX do I need to worry about crazy outliers? 22 // XXX should i be smoothing or fitting the curve? 23 int firstBelow = -1; 24 int lastAbove = -1; 25 for (int i = 0; i < flux->n; i++) { 26 if (flux->data.F32[i] > ISOPHOT_FLUX) lastAbove = i; 27 if ((firstBelow < 0) && (flux->data.F32[i] < ISOPHOT_FLUX)) firstBelow = i; 28 } 29 30 // need to examine pixels in this vicinity 31 float isophotalFluxFirst = 0; 32 float isophotalFluxLast = 0; 33 for (int i = 0; i <= PS_MAX(firstBelow, lastAbove); i++) { 34 if (i <= firstBelow) { 35 isophotalFluxFirst += flux->data.F32[i]; 36 } 37 if (i <= lastAbove) { 38 isophotalFluxLast += flux->data.F32[i]; 39 } 40 } 41 float isophotalFlux = 0.5*(isophotalFluxLast + isophotalFluxFirst); 42 float isophotalFluxErr = 0.5*fabs(isophotalFluxLast - isophotalFluxFirst); 43 44 float isophotalRad = 0.5*(radius->data.F32[firstBelow] + radius->data.F32[lastAbove]); 45 float isophotalRadErr = 0.5*fabs(radius->data.F32[firstBelow] - radius->data.F32[lastAbove]); 46 47 if (!source->extpars->isophot) { 48 source->extpars->isophot = pmSourceIsophotalValuesAlloc (); 49 } 50 51 // these are uncalibrated: instrumental mags and pixel units 52 source->extpars->isophot->mag = -2.5*log10(isophotalFlux); 53 source->extpars->isophot->magErr = isophotalFluxErr / isophotalFlux; 54 55 source->extpars->isophot->rad = isophotalRad; 56 source->extpars->isophot->radErr = isophotalRadErr; 57 6 58 return true; 7 59 -
trunk/psphot/src/psphotMakeResiduals.c
r14967 r15562 28 28 29 29 float nSigma = psMetadataLookupF32(&status, recipe, "PSF.RESIDUALS.NSIGMA"); 30 PS_ASSERT (status, false); 31 32 float pixelSN = psMetadataLookupF32(&status, recipe, "PSF.RESIDUALS.PIX.SN"); 30 33 PS_ASSERT (status, false); 31 34 … … 194 197 resid->Rx->data.F32[oy][ox] = resid->Ry->data.F32[oy][ox] = 0.0; 195 198 //resid->weight->data.F32[oy][ox] = fluxStats->sampleStdev; 199 200 if (resid->Ro->data.F32[oy][ox] < pixelSN*fluxStats->sampleStdev) { 201 resid->mask->data.U8[oy][ox] = 1; 202 } 203 196 204 } else { 197 205 assert (SPATIAL_ORDER == 1); … … 227 235 resid->Rx->data.F32[oy][ox] = B->data.F64[1]; 228 236 resid->Ry->data.F32[oy][ox] = B->data.F64[2]; 237 238 float dRo = sqrt(A->data.F32[0][0]); 239 if (resid->Ro->data.F32[oy][ox] < pixelSN*dRo) { 240 resid->mask->data.U8[oy][ox] = 1; 241 } 229 242 //resid->weight->data.F32[oy][ox] = XXX; 230 243 } -
trunk/psphot/src/psphotPetrosian.c
r13983 r15562 3 3 bool psphotPetrosian (pmSource *source, psMetadata *recipe, psMaskType maskVal) { 4 4 5 psLogMsg ("psphot", PS_LOG_INFO, "not implemented\n"); 5 bool status; 6 7 assert (source->extpars); 8 assert (source->extpars->profile); 9 assert (source->extpars->profile->radius); 10 assert (source->extpars->profile->flux); 11 12 psVector *radius = source->extpars->profile->radius; 13 psVector *flux = source->extpars->profile->flux; 14 15 // flux at which to measure isophotal parameters 16 // XXX cache this? 17 float PETROSIAN_R0 = psMetadataLookupF32 (&status, recipe, "PETROSIAN_R0"); 18 float PETROSIAN_RF = psMetadataLookupF32 (&status, recipe, "PETROSIAN_FLUX_RATIO"); 19 20 // first find flux at R0 21 int firstBelow = -1; 22 int lastAbove = -1; 23 for (int i = 0; i < radius->n; i++) { 24 if (radius->data.F32[i] > PETROSIAN_R0) lastAbove = i; 25 if ((firstBelow < 0) && (flux->data.F32[i] < PETROSIAN_R0)) firstBelow = i; 26 } 27 28 // average flux in this range 29 float fluxR0 = 0.0; 30 int fluxRn = 0; 31 for (int i = PS_MIN(firstBelow, lastAbove); i <= PS_MAX(firstBelow, lastAbove); i++) { 32 fluxR0 += flux->data.F32[i]; 33 fluxRn ++; 34 } 35 fluxR0 /= (float)(fluxRn); 36 37 // target flux for petrosian radius 38 float fluxRP = fluxR0 * PETROSIAN_RF; 39 40 // find the first bin below the flux level and the last above the level 41 // XXX can this be done faster with disection? 42 // XXX do I need to worry about crazy outliers? 43 // XXX should i be smoothing or fitting the curve? 44 firstBelow = -1; 45 lastAbove = -1; 46 for (int i = 0; i < flux->n; i++) { 47 if (flux->data.F32[i] > fluxRP) lastAbove = i; 48 if ((firstBelow < 0) && (flux->data.F32[i] < fluxRP)) firstBelow = i; 49 } 50 51 // need to examine pixels in this vicinity 52 float fluxFirst = 0; 53 float fluxLast = 0; 54 for (int i = 0; i <= PS_MAX(firstBelow, lastAbove); i++) { 55 if (i <= firstBelow) { 56 fluxFirst += flux->data.F32[i]; 57 } 58 if (i <= lastAbove) { 59 fluxLast += flux->data.F32[i]; 60 } 61 } 62 float fluxRPSum = 0.5*(fluxLast + fluxFirst); 63 float fluxRPSumErr = 0.5*fabs(fluxLast - fluxFirst); 64 // XXX need to use the weight appropriately here... 65 66 float rad = 0.5*(radius->data.F32[firstBelow] + radius->data.F32[lastAbove]); 67 float radErr = 0.5*fabs(radius->data.F32[firstBelow] - radius->data.F32[lastAbove]); 68 69 if (!source->extpars->petrosian) { 70 source->extpars->petrosian = pmSourcePetrosianValuesAlloc (); 71 } 72 73 // these are uncalibrated: instrumental mags and pixel units 74 source->extpars->petrosian->mag = -2.5*log10(fluxRPSum); 75 source->extpars->petrosian->magErr = fluxRPSumErr / fluxRPSum; 76 77 source->extpars->petrosian->rad = rad; 78 source->extpars->petrosian->radErr = radErr; 79 6 80 return true; 7 81 -
trunk/psphot/src/psphotRadialProfile.c
r15357 r15562 5 5 // allocate pmSourceExtendedParameters, if not already defined 6 6 if (!source->extpars) { 7 source->extpars = pmSourceExtendedPar ametersAlloc ();7 source->extpars = pmSourceExtendedParsAlloc (); 8 8 } 9 9 10 10 if (!source->extpars->profile) { 11 source->extpars->profile = pmSourceRadialProfile ();11 source->extpars->profile = pmSourceRadialProfileAlloc (); 12 12 } 13 13 … … 19 19 psVector *radius = source->extpars->profile->radius; 20 20 psVector *flux = source->extpars->profile->flux; 21 psVector *weight = source->extpars->profile-> radius;21 psVector *weight = source->extpars->profile->weight; 22 22 23 23 // XXX use the extended source model here for Xo, Yo? … … 40 40 flux->n = n; 41 41 42 SortVectorsByRadius (radius, flux, weight); 42 // XXX need to sort here 43 // SortVectorsByRadius (radius, flux, weight); 43 44 44 45 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
