- Timestamp:
- Sep 17, 2009, 2:26:32 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090715/psphot/src/psphotRadiiFromProfiles.c
r25275 r25433 3 3 // Given the Petrosian data (radii, fluxes) determine the radius for each profile at the desisred isophote 4 4 5 bool psphotRadiiFromProfiles (pm Petrosian *petrosian, float fluxMin, float fluxMax) {5 bool psphotRadiiFromProfiles (pmSource *source, pmPetrosian *petrosian, float fluxMin, float fluxMax) { 6 6 7 7 petrosian->isophotalRadii = psVectorAlloc(petrosian->theta->n, PS_TYPE_F32); … … 10 10 psVector *radii = petrosian->radii->data[i]; 11 11 psVector *fluxes = petrosian->fluxes->data[i]; 12 float radius = psphotRadiusFromProfile ( radii, fluxes, fluxMin, fluxMax);12 float radius = psphotRadiusFromProfile (source, radii, fluxes, fluxMin, fluxMax); 13 13 14 14 // psphotPetrosianVisualProfileByAngle (radii, fluxes, radius); … … 20 20 } 21 21 22 float psphotRadiusFromProfile (p sVector *radius, psVector *flux, float fluxMin, float fluxMax) {22 float psphotRadiusFromProfile (pmSource *source, psVector *radius, psVector *flux, float fluxMin, float fluxMax) { 23 23 24 24 // 'flux' is a noisy sample of the galaxy radial profile at points 'radius' … … 49 49 psVectorAppend (values, radius->data.F32[i]); 50 50 } 51 psVectorStats (stats, values, NULL, NULL, 0); 51 if (values->n > 1) { 52 psVectorStats (stats, values, NULL, NULL, 0); 52 53 53 // if we have a valid range, rebin with bin size 1/2 of median radius 54 if (isfinite(stats->sampleMedian)) { 55 Rbin = MAX(1, 0.5*stats->sampleMedian); 54 // if we have a valid range, rebin with bin size 1/2 of median radius 55 if (isfinite(stats->sampleMedian)) { 56 Rbin = MAX(1, 0.5*stats->sampleMedian); 57 } 56 58 } 59 psFree (values); 60 psFree (stats); 57 61 } 58 62 Rbin = 3; … … 90 94 // calculate the value for the nOut bin 91 95 // XXX need to fix this as well psStats (stats, values); 92 psVectorStats (stats, values, NULL, NULL, 0); 93 fluxBinned->data.F32[nOut] = stats->sampleMedian; 96 float value; 97 if (values->n > 0) { 98 psVectorStats (stats, values, NULL, NULL, 0); 99 value = stats->sampleMedian; 100 } else { 101 value = NAN; 102 } 103 fluxBinned->data.F32[nOut] = value; 94 104 nOut ++; 95 105 radiusBinned->data.F32[nOut] = (nOut + 0.5)*Rbin; … … 118 128 // XXX is there a macro in psLib that does this interpolation? 119 129 if (i == 0) { 120 psWarning ("impossible condition f[0] < Fo"); 121 continue; 122 } else { 123 Ro = radiusBinned->data.F32[i-1] + (radiusBinned->data.F32[i] - radiusBinned->data.F32[i-1]) * (Fo - fluxBinned->data.F32[i-1]) / (fluxBinned->data.F32[i] - fluxBinned->data.F32[i-1]); 124 } 130 psLogMsg ("psphot", 3, "bogus radial profile for ..., skipping"); 131 psFree (fluxBinned); 132 psFree (radiusBinned); 133 return NAN; 134 } 135 Ro = radiusBinned->data.F32[i-1] + (radiusBinned->data.F32[i] - radiusBinned->data.F32[i-1]) * (Fo - fluxBinned->data.F32[i-1]) / (fluxBinned->data.F32[i] - fluxBinned->data.F32[i-1]); 125 136 above = FALSE; 126 137 }
Note:
See TracChangeset
for help on using the changeset viewer.
