- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 4 edited
-
. (modified) (1 prop)
-
psphot (modified) (1 prop)
-
psphot/src (modified) (1 prop)
-
psphot/src/psphotPetrosian.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/psphot
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/psphot merged eligible /branches/eam_branches/stackphot.20100406/psphot 27622-27655 /branches/pap_delete/psphot 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/simtest_nebulous_branches/psphot/src
- Property svn:ignore
-
old new 18 18 psphotVersionDefinitions.h 19 19 psphotMomentsStudy 20 psphotPetrosianStudy 21 psphotForced 22 psphotMakePSF 23 psphotStack
-
- Property svn:ignore
-
branches/simtest_nebulous_branches/psphot/src/psphotPetrosian.c
r21183 r27840 1 1 # include "psphotInternal.h" 2 2 3 bool psphotPetrosian (pmSource *source, psMetadata *recipe, psImageMaskType maskVal) {3 bool psphotPetrosian (pmSource *source, psMetadata *recipe, float skynoise, psImageMaskType maskVal) { 4 4 5 bool status; 5 // XXX these need to go into recipe values 6 float Rmax = 200; 6 7 7 assert (source->extpars); 8 assert (source->extpars->profile); 9 assert (source->extpars->profile->radius); 10 assert (source->extpars->profile->flux); 8 psAssert (source->extpars, "need to run psphotRadialProfile first"); 9 psAssert (source->extpars->ellipticalFlux, "need to run psphotRadialProfile first"); 11 10 12 psVector *radius = source->extpars->profile->radius; 13 psVector *flux = source->extpars->profile->flux; 11 // integrate the radial profile for radial bins defined for the petrosian measurement: 12 // SB_i (r_i) where \alpha r_i < r < \beta r_i 13 if (!psphotPetrosianRadialBins (source, Rmax, skynoise)) { 14 psError (PS_ERR_UNKNOWN, false, "failed to generate elliptical profile"); 15 return false; 16 } 17 18 // use the SB_i from above to calculate the petrosian radius and the flux within that radius 19 if (!psphotPetrosianStats (source)) { 20 psError (PS_ERR_UNKNOWN, false, "failed to generate elliptical profile"); 21 return false; 22 } 23 24 psTrace ("psphot", 3, "source at %f,%f: petrosian radius: %f, flux: %f, axis ratio: %f, angle: %f", 25 source->peak->xf, source->peak->yf, 26 source->extpars->petrosianRadius, 27 source->extpars->petrosianFlux, 28 source->extpars->axes.minor/source->extpars->axes.major, 29 source->extpars->axes.theta*PS_DEG_RAD); 14 30 15 // flux at which to measure isophotal parameters 16 float PETROSIAN_R0 = psMetadataLookupF32 (&status, recipe, "PETROSIAN_R0"); 17 float PETROSIAN_RF = psMetadataLookupF32 (&status, recipe, "PETROSIAN_FLUX_RATIO"); 18 assert (status); 19 20 // first find flux at R0 21 int firstAbove = -1; 22 int lastBelow = -1; 23 for (int i = 0; i < radius->n; i++) { 24 if (radius->data.F32[i] < PETROSIAN_R0) lastBelow = i; 25 if ((firstAbove < 0) && (radius->data.F32[i] > PETROSIAN_R0)) firstAbove = i; 26 } 27 // if we don't go out far enough, we have a problem... 28 if (lastBelow == radius->n - 1) { 29 psTrace ("psphot", 5, "did not go out far enough to reach petrosian reference radius..."); 30 // XXX skip object? raise a flag ? 31 return false; 32 } 33 if (firstAbove < 0) { 34 psTrace ("psphot", 5, "did not go out far enough to bound petrosian reference radius"); 35 // XXX raise a flag ? 36 return false; 37 } 38 39 // average flux in this range 40 float fluxR0 = 0.0; 41 int fluxRn = 0; 42 for (int i = PS_MIN(firstAbove, lastBelow); i <= PS_MAX(firstAbove, lastBelow); i++) { 43 fluxR0 += flux->data.F32[i]; 44 fluxRn ++; 45 } 46 fluxR0 /= (float)(fluxRn); 47 48 // target flux for petrosian radius 49 float fluxRP = fluxR0 * PETROSIAN_RF; 50 51 // find the first bin below the flux level and the last above the level 52 // XXX can this be done faster with bisection? 53 // XXX do I need to worry about crazy outliers? 54 // XXX should i be smoothing or fitting the curve? 55 int firstBelow = -1; 56 int lastAbove = -1; 57 for (int i = 0; i < flux->n; i++) { 58 if (flux->data.F32[i] > fluxRP) lastAbove = i; 59 if ((firstBelow < 0) && (flux->data.F32[i] < fluxRP)) firstBelow = i; 60 } 61 // if we don't go out far enough, we have a problem... 62 if (lastAbove == radius->n - 1) { 63 psTrace ("psphot", 5, "did not go out far enough to reach petrosian radius..."); 64 // XXX skip object? raise a flag ? 65 return false; 66 } 67 if (firstBelow < 0) { 68 psTrace ("psphot", 5, "did not go out far enough to bound petrosian radius"); 69 // XXX raise a flag ? 70 return false; 71 } 72 73 // need to examine pixels in this vicinity 74 float fluxFirst = 0; 75 float fluxLast = 0; 76 for (int i = 0; i <= PS_MAX(firstBelow, lastAbove); i++) { 77 if (i <= firstBelow) { 78 fluxFirst += flux->data.F32[i]; 79 } 80 if (i <= lastAbove) { 81 fluxLast += flux->data.F32[i]; 82 } 83 } 84 float fluxRPSum = 0.5*(fluxLast + fluxFirst); 85 float fluxRPSumErr = 0.5*fabs(fluxLast - fluxFirst); 86 // XXX need to use the weight appropriately here... 87 88 float rad = 0.5*(radius->data.F32[firstBelow] + radius->data.F32[lastAbove]); 89 float radErr = 0.5*fabs(radius->data.F32[firstBelow] - radius->data.F32[lastAbove]); 90 91 if (!source->extpars->petrosian) { 92 source->extpars->petrosian = pmSourcePetrosianValuesAlloc (); 93 } 94 95 // these are uncalibrated: instrumental mags and pixel units 96 source->extpars->petrosian->mag = -2.5*log10(fluxRPSum); 97 source->extpars->petrosian->magErr = fluxRPSumErr / fluxRPSum; 98 99 source->extpars->petrosian->rad = rad; 100 source->extpars->petrosian->radErr = radErr; 101 102 psTrace ("psphot", 5, "Petrosian flux:%f +/- %f @ %f +/- %f for %f, %f\n", 103 source->extpars->petrosian->mag, source->extpars->petrosian->magErr, 104 source->extpars->petrosian->rad, source->extpars->petrosian->radErr, 105 source->peak->xf, source->peak->yf); 106 107 return true; 108 31 return true; 109 32 }
Note:
See TracChangeset
for help on using the changeset viewer.
