Changeset 25178
- Timestamp:
- Aug 24, 2009, 8:40:34 AM (17 years ago)
- Location:
- branches/eam_branches/20090715/psphot/src
- Files:
-
- 11 edited
-
Makefile.am (modified) (1 diff)
-
pmPetrosian.c (modified) (4 diffs)
-
pmPetrosian.h (modified) (2 diffs)
-
psphotEllipticalContour.c (modified) (1 diff)
-
psphotPetrosianProfile.c (modified) (1 diff)
-
psphotPetrosianRadialBins.c (modified) (7 diffs)
-
psphotPetrosianStats.c (modified) (1 diff)
-
psphotPetrosianStudy.c (modified) (1 diff)
-
psphotPetrosianVisual.c (modified) (5 diffs)
-
psphotRadialProfileByAngle.c (modified) (4 diffs)
-
psphotRadiiFromProfiles.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090715/psphot/src/Makefile.am
r25105 r25178 17 17 # Force recompilation of psphotVersion.c, since it gets the version information 18 18 psphotVersion.c: psphotVersionDefinitions.h 19 psphotVersionDefinitions.h: psphotVersionDefinitions.h.in FORCE20 -$(RM) psphotVersionDefinitions.h21 $(SED) -e "s|@PSPHOT_VERSION@|\"$(PSPHOT_VERSION)\"|" -e "s|@PSPHOT_BRANCH@|\"$(PSPHOT_BRANCH)\"|" -e "s|@PSPHOT_SOURCE@|\"$(PSPHOT_SOURCE)\"|" psphotVersionDefinitions.h.in > psphotVersionDefinitions.h22 FORCE: ;19 # psphotVersionDefinitions.h: psphotVersionDefinitions.h.in FORCE 20 # -$(RM) psphotVersionDefinitions.h 21 # $(SED) -e "s|@PSPHOT_VERSION@|\"$(PSPHOT_VERSION)\"|" -e "s|@PSPHOT_BRANCH@|\"$(PSPHOT_BRANCH)\"|" -e "s|@PSPHOT_SOURCE@|\"$(PSPHOT_SOURCE)\"|" psphotVersionDefinitions.h.in > psphotVersionDefinitions.h 22 # FORCE: ; 23 23 24 24 libpsphot_la_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) 25 25 libpsphot_la_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 26 26 27 bin_PROGRAMS = psphot psphotTest psphotMomentsStudy psphotPetrosianStudy 27 # bin_PROGRAMS = psphot psphotTest psphotMomentsStudy psphotPetrosianStudy 28 bin_PROGRAMS = psphotPetrosianStudy 28 29 29 30 psphot_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -
branches/eam_branches/20090715/psphot/src/pmPetrosian.c
r25105 r25178 24 24 psFree(petrosian->fluxElliptical); 25 25 26 psFree(petrosian->binnedFlux); 26 psFree(petrosian->binSB); 27 psFree(petrosian->binSBstdev); 27 28 psFree(petrosian->radialBins); 28 29 psFree(petrosian->area); … … 44 45 petrosian->radialBins = NULL; 45 46 petrosian->area = NULL; 46 petrosian->binnedFlux = NULL; 47 petrosian->binSB = NULL; 48 petrosian->binSBstdev = NULL; 47 49 48 50 petrosian->petrosianRadius = NAN; … … 64 66 psFree(petrosian->fluxElliptical); 65 67 66 psFree(petrosian->binnedFlux); 68 psFree(petrosian->binSB); 69 psFree(petrosian->binSBstdev); 67 70 psFree(petrosian->radialBins); 68 71 psFree(petrosian->area); … … 78 81 petrosian->radialBins = NULL; 79 82 petrosian->area = NULL; 80 petrosian->binnedFlux = NULL; 83 petrosian->binSB = NULL; 84 petrosian->binSBstdev = NULL; 81 85 82 86 return true; -
branches/eam_branches/20090715/psphot/src/pmPetrosian.h
r25105 r25178 20 20 psVector *fluxElliptical; // flux for the above radial coordinates 21 21 22 psVector *binnedFlux; // mean surface brightness within radial bins 22 psVector *binSB; // mean surface brightness within radial bins 23 psVector *binSBstdev; // scatter of mean surface brightness within radial bins 23 24 psVector *radialBins; // radii corresponding to above binnedBlux 24 25 psVector *area; // differential area of the non-overlapping radial bins … … 52 53 bool psphotPetrosianVisualStats (psVector *radBin, psVector *fluxBin, 53 54 psVector *refRadius, psVector *meanSB, 54 psVector *petRatio, psVector *fluxSum, 55 float petRadius, float petFlux); 55 psVector *petRatio, psVector *petRatioErr, psVector *fluxSum, 56 float petRadius, float ratioForRadius, 57 float petFlux, float radiusForFlux); 56 58 57 59 bool pmVisualLimitsFromVectors (Graphdata *graphdata, psVector *xVec, psVector *yVec); -
branches/eam_branches/20090715/psphot/src/psphotEllipticalContour.c
r25105 r25178 73 73 psMinimizeLMChi2(myMin, covar, params, constraint, x, y, yErr, psphotEllipticalContourFunc); 74 74 75 /// XXX rationalize? if epsilon > 1, flip major and minor axes (rotate by 90 degrees) 76 if (params->data.F32[PAR_EPSILON] < 1.0) { 77 petrosian->axes.major = params->data.F32[PAR_RMIN] / params->data.F32[PAR_EPSILON]; 78 petrosian->axes.minor = params->data.F32[PAR_RMIN]; 79 petrosian->axes.theta = params->data.F32[PAR_PHI]; 80 } else { 81 petrosian->axes.major = params->data.F32[PAR_RMIN]; 82 petrosian->axes.minor = params->data.F32[PAR_RMIN] / params->data.F32[PAR_EPSILON]; 83 petrosian->axes.theta = params->data.F32[PAR_PHI] + 0.5*M_PI; 84 } 85 75 86 fprintf (stderr, "# fitted values:\n"); 76 87 fprintf (stderr, "Po: %f\n", params->data.F32[PAR_PHI]*PS_DEG_RAD); 77 88 fprintf (stderr, "Ep: %f\n", params->data.F32[PAR_EPSILON]); 78 89 fprintf (stderr, "Rm: %f\n", params->data.F32[PAR_RMIN]); 79 80 /// XXX rationalize? if epsilon > 1, flip major and minor axes (rotate by 90 degrees)81 petrosian->axes.major = params->data.F32[PAR_RMIN] / params->data.F32[PAR_EPSILON];82 petrosian->axes.minor = params->data.F32[PAR_RMIN];83 petrosian->axes.theta = params->data.F32[PAR_PHI];84 90 85 91 // show the results -
branches/eam_branches/20090715/psphot/src/psphotPetrosianProfile.c
r25128 r25178 61 61 psphotPetrosianFreeVectors(petrosian); 62 62 63 fprintf (std err, "petrosian radius: %f, flux: %f, axis ratio: %f,angle: %f\n",63 fprintf (stdout, "\n petrosian radius: %f\n flux: %f\n axis ratio: %f\n angle: %f\n", 64 64 petrosian->petrosianRadius, petrosian->petrosianFlux, petrosian->axes.minor/petrosian->axes.major, PS_DEG_RAD*petrosian->axes.theta); 65 65 -
branches/eam_branches/20090715/psphot/src/psphotPetrosianRadialBins.c
r25105 r25178 12 12 // finely spaced than r_{i+1} = r_i * \beta / \alpha. for the integration, we need to 13 13 // track the non-overlapping radius values. 14 15 # define PETROSIAN_ALPHA 0.816 # define PETROSIAN_BETA 1.2517 14 18 15 bool psphotPetrosianRadialBins (pmSource *source, pmPetrosian *petrosian, float radiusMax) { … … 33 30 psVector *radBet = psVectorAllocEmpty(nMax, PS_TYPE_F32); 34 31 35 psVector *fluxBin = psVectorAllocEmpty(nMax, PS_TYPE_F32); 36 psVector *radBin = psVectorAllocEmpty(nMax, PS_TYPE_F32); 37 psVector *area = psVectorAllocEmpty(nMax, PS_TYPE_F32); 32 psVector *binSB = psVectorAllocEmpty(nMax, PS_TYPE_F32); // surface brightness of radial bin 33 psVector *binSBstdev = psVectorAllocEmpty(nMax, PS_TYPE_F32); // surface brightness of radial bin 34 psVector *binRad = psVectorAllocEmpty(nMax, PS_TYPE_F32); // mean radius of radial bin 35 psVector *binArea = psVectorAllocEmpty(nMax, PS_TYPE_F32); // area of radial bin (contiguous, non-overlapping) 38 36 39 psVectorInit (fluxBin, 0.0); 40 psVectorInit (radBin, 0.0); 37 psVectorInit (binSB, 0.0); 38 psVectorInit (binSBstdev, 0.0); 39 psVectorInit (binRad, 0.0); 41 40 42 41 // generate radial bin bounds … … 56 55 radBet->data.F32[2] = 2.0; 57 56 58 int nPts = 3; 59 for (int i = 3; i < radiusMax; i++) { 60 radMin->data.F32[nPts] = (i - 1); 61 radMax->data.F32[nPts] = i; 62 nPts++; 57 # define PETROSIAN_ALPHA 0.8 58 # define PETROSIAN_BETA 1.25 59 # define POWER_LAW_SPACING true 60 61 // power-law spacing with overlapping boundaries at the geometric mid-points 62 float rBeta = sqrt(PETROSIAN_BETA); 63 for (int i = 3; radBet->data.F32[i-1] < radiusMax; i++) { 64 if (POWER_LAW_SPACING) { 65 radMin->data.F32[i] = radMax->data.F32[i-1]; 66 radMax->data.F32[i] = radMin->data.F32[i] * PETROSIAN_BETA; 67 radAlp->data.F32[i] = radMin->data.F32[i] / rBeta; 68 radBet->data.F32[i] = radMax->data.F32[i] * rBeta; 69 } else { 70 radMin->data.F32[i] = radMax->data.F32[i-1]; 71 radMax->data.F32[i] = radMin->data.F32[i] + 1; 72 float rMid = 0.5*(radMin->data.F32[i] + radMax->data.F32[i]); 73 radAlp->data.F32[i] = rMid * PETROSIAN_ALPHA; 74 radBet->data.F32[i] = rMid * PETROSIAN_BETA; 75 } 76 radMin->n = radMax->n = radAlp->n = radBet->n = i + 1; 63 77 } 64 radMin->n = radMax->n = radAlp->n = radBet->n = nPts;65 78 66 79 // generate radial area-weighted mean radius & non-overlapping areas … … 78 91 79 92 // XXX calculate area-weighted radius rather than asserting? 80 radBin->data.F32[i] = rBin;81 area->data.F32[i] = M_PI * (rMax2 - rMin2);93 binRad->data.F32[i] = rBin; 94 binArea->data.F32[i] = M_PI * (rMax2 - rMin2); 82 95 83 if (i > 2) { 84 radAlp->data.F32[i] = rBin*PETROSIAN_ALPHA; 85 radBet->data.F32[i] = rBin*PETROSIAN_BETA; 96 if (0) { 97 fprintf (stderr, "%3d %5.1f %5.1f : %5.1f : %5.1f %5.1f\n", 98 i, radAlp->data.F32[i], radMin->data.F32[i], binRad->data.F32[i], 99 radMax->data.F32[i], radBet->data.F32[i]); 86 100 } 87 101 } … … 89 103 // storage vector for stats 90 104 psVector *values = psVectorAllocEmpty (flux->n, PS_TYPE_F32); 91 psStats *stats = psStatsAlloc(PS_STAT_ SAMPLE_MEDIAN);105 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); 92 106 93 107 // integrate flux, radius for each of these bins. since flux is sorted by radius, … … 107 121 // calculate the value for the nOut bin 108 122 psVectorStats (stats, values, NULL, NULL, 0); 109 fluxBin->data.F32[nOut] = stats->sampleMedian; 123 // binSB->data.F32[nOut] = stats->sampleMedian; 124 binSB->data.F32[nOut] = stats->robustMedian; 125 binSBstdev->data.F32[nOut] = stats->robustStdev / sqrt(values->n); 126 127 if (1) { 128 fprintf (stderr, "%3d %5.1f %5.1f : %5.1f %5.2f\n", 129 nOut, radAlp->data.F32[nOut], radBet->data.F32[nOut], binSB->data.F32[nOut], binSBstdev->data.F32[nOut]); 130 } 131 110 132 nOut ++; 111 if (nOut >= nMax) break;133 if (nOut >= radAlp->n) break; 112 134 Rmin = radAlp->data.F32[nOut]; 113 135 Rmax = radBet->data.F32[nOut]; … … 122 144 psVectorAppend (values, flux->data.F32[i]); 123 145 } 124 fluxBin->n = radBin->n = area->n = nOut;146 binSB->n = binSBstdev->n = binRad->n = binArea->n = nOut; 125 147 // XXX I think this misses the last radial bin -- do we care? 126 148 127 149 // save the vectors 128 petrosian->radialBins = radBin; 129 petrosian->area = area; 130 petrosian->binnedFlux = fluxBin; 150 petrosian->radialBins = binRad; 151 petrosian->area = binArea; 152 petrosian->binSB = binSB; 153 petrosian->binSBstdev = binSBstdev; 131 154 132 psphotPetrosianVisualProfileRadii (radius, flux, radBin, fluxBin, 0.0);155 psphotPetrosianVisualProfileRadii (radius, flux, binRad, binSB, 0.0); 133 156 134 157 psFree(radMin); -
branches/eam_branches/20090715/psphot/src/psphotPetrosianStats.c
r25105 r25178 1 1 # include "psphotInternal.h" 2 2 3 # define PETROSIAN_RATIO 0.05 3 # define PETROSIAN_RATIO 0.2 4 # define PETROSIAN_RADII 2.0 4 5 5 6 // generate the Petrosian radius and flux from the mean surface brightness (r_i) 6 7 8 float InterpolateValues (float X0, float Y0, float X1, float Y1, float X); 9 7 10 bool psphotPetrosianStats (pmPetrosian *petrosian) { 8 11 9 float petRadius, petFlux;12 float petRadius, petFlux; 10 13 11 psVector *fluxBin = petrosian->binnedFlux; 12 psVector *radBin = petrosian->radialBins; 13 psVector *area = petrosian->area; 14 psVector *binSB = petrosian->binSB; 15 psVector *binSBstdev = petrosian->binSBstdev; 16 psVector *binRad = petrosian->radialBins; 17 psVector *area = petrosian->area; 14 18 15 psVector *fluxSum = psVectorAllocEmpty(fluxBin->n, PS_TYPE_F32); 16 psVector *refRadius= psVectorAllocEmpty(fluxBin->n, PS_TYPE_F32); 17 psVector *petRatio = psVectorAllocEmpty(fluxBin->n, PS_TYPE_F32); 18 psVector *meanSB = psVectorAllocEmpty(fluxBin->n, PS_TYPE_F32); 19 psVector *areaSum = psVectorAllocEmpty(fluxBin->n, PS_TYPE_F32); 19 psVector *fluxSum = psVectorAllocEmpty(binSB->n, PS_TYPE_F32); 20 psVector *refRadius = psVectorAllocEmpty(binSB->n, PS_TYPE_F32); 21 psVector *petRatio = psVectorAllocEmpty(binSB->n, PS_TYPE_F32); 22 psVector *petRatioErr = psVectorAllocEmpty(binSB->n, PS_TYPE_F32); 23 psVector *meanSB = psVectorAllocEmpty(binSB->n, PS_TYPE_F32); 24 psVector *areaSum = psVectorAllocEmpty(binSB->n, PS_TYPE_F32); 20 25 21 bool above = true; 22 float Fsum = 0.0; 23 float Asum = 0.0; 24 float Area = area->data.F32[0]; 26 bool anyPetro = false; 27 bool manyPetro = false; 28 bool above = true; 29 float Fsum = 0.0; 30 float Asum = 0.0; 25 31 26 int nOut = 0; 27 for (int i = 0; i < fluxBin->n; i++) { 28 // for nan bins, we keep the area for use with the next valid bin 29 if (!isfinite(fluxBin->data.F32[i])) { 30 Area += area->data.F32[i]; 31 continue; 32 } 33 Fsum += fluxBin->data.F32[i] * Area; 34 Asum += Area; 35 if (i+1 < fluxBin->n) { 36 Area = area->data.F32[i+1]; 32 int nOut = 0; 33 for (int i = 0; i < binSB->n; i++) { 34 // skip nan bins (do not contribute to flux or area) 35 if (!isfinite(binSB->data.F32[i])) continue; 36 37 float Area = area->data.F32[i]; 38 Fsum += binSB->data.F32[i] * Area; 39 Asum += Area; 40 41 float fluxInner = 0.5 * Area * binSB->data.F32[i]; 42 float areaInner = 0.5 * Area; 43 if (nOut > 0) { 44 fluxInner += fluxSum->data.F32[nOut-1]; 45 areaInner += areaSum->data.F32[nOut-1]; 46 } 47 48 psVectorAppend(meanSB, (fluxInner / areaInner)); 49 psVectorAppend(petRatio, binSB->data.F32[i] / meanSB->data.F32[nOut]); 50 psVectorAppend(petRatioErr, binSBstdev->data.F32[i] / meanSB->data.F32[nOut]); 51 psVectorAppend(fluxSum, Fsum); 52 psVectorAppend(areaSum, Asum); 53 psVectorAppend(refRadius, binRad->data.F32[i]); 54 55 if (1) { 56 fprintf (stderr, "%3d : %5.2f : %5.3f %5.3f : %5.3f %5.3f : %5.1f %5.1f\n", 57 i, refRadius->data.F32[nOut], binSB->data.F32[i], meanSB->data.F32[nOut], petRatio->data.F32[nOut], petRatioErr->data.F32[nOut], fluxSum->data.F32[nOut], areaSum->data.F32[nOut]); 58 } 59 60 // anytime we transition below the PETROSIAN_RATIO, calculate the radius and flux 61 // we will keep and report the last (largest radius) value 62 if (above && (petRatio->data.F32[nOut] < PETROSIAN_RATIO)) { 63 // interpolate Rvec between i-1 and i to PETROSIAN_RATIO to get flux (Fvec) and radius (rvec) 64 if (i == 0) { 65 // assume Fmax @ R = 0.0 66 petRadius = InterpolateValues (1.0, 0.0, petRatio->data.F32[nOut], refRadius->data.F32[nOut], PETROSIAN_RATIO); 67 } else { 68 petRadius = InterpolateValues (petRatio->data.F32[nOut-1], refRadius->data.F32[nOut-1], petRatio->data.F32[nOut], refRadius->data.F32[nOut], PETROSIAN_RATIO); 69 } 70 above = false; 71 if (anyPetro) manyPetro = true; 72 anyPetro = true; 73 } 74 75 // reset on transitions up, but do not re-calculate rad_90, flux_90 76 if (!above && (petRatio->data.F32[nOut] >= PETROSIAN_RATIO)) { 77 above = true; 78 } 79 nOut ++; 37 80 } 38 81 39 psVectorAppend(petRatio, Asum * fluxBin->data.F32[i] / Fsum); 40 psVectorAppend(fluxSum, Fsum); 41 psVectorAppend(meanSB, Fsum / Asum); 42 psVectorAppend(areaSum, Asum); 43 psVectorAppend(refRadius, radBin->data.F32[i]); 82 if (!anyPetro) { 83 // set default radius: 84 } 44 85 45 // anytime we transition below the PETROSIAN_RATIO, calculate the radius and flux 46 // we will keep and report the last (largest radius) value 47 if (above && (petRatio->data.F32[nOut] < PETROSIAN_RATIO)) { 48 // interpolate Rvec between i-1 and i to PETROSIAN_RATIO to get flux (Fvec) and radius (rvec) 49 if (i == 0) { 50 // assume Fmax @ R = 0.0 51 petRadius = radBin->data.F32[nOut] * (PETROSIAN_RATIO - 1.0) / (petRatio->data.F32[nOut] - 1.0); 52 petFlux = fluxSum->data.F32[nOut] * (PETROSIAN_RATIO - 1.0) / (petRatio->data.F32[nOut] - 1.0); 53 } else { 54 petRadius = radBin->data.F32[nOut-1] + (radBin->data.F32[nOut] - radBin->data.F32[nOut-1]) * (PETROSIAN_RATIO - petRatio->data.F32[nOut-1]) / (petRatio->data.F32[nOut] - petRatio->data.F32[nOut-1]); 55 petFlux = fluxSum->data.F32[nOut-1] + (fluxSum->data.F32[nOut] - fluxSum->data.F32[nOut-1]) * (PETROSIAN_RATIO - petRatio->data.F32[nOut-1]) / (petRatio->data.F32[nOut] - petRatio->data.F32[nOut-1]); 56 } 57 above = false; 86 // now measure the flux within PETROSIAN_RADII * petRadius 87 float apRadius = PETROSIAN_RADII * petRadius; 88 for (int i = 0; i < refRadius->n; i++) { 89 // XXX use bisection to do this faster: 90 if (refRadius->data.F32[i] > apRadius) { 91 if (i == 0) { 92 psAbort ("does this case make any sense?"); 93 } else { 94 petFlux = InterpolateValues (refRadius->data.F32[i-1], fluxSum->data.F32[i-1], refRadius->data.F32[i], fluxSum->data.F32[i], apRadius); 95 break; 96 } 97 } 58 98 } 59 60 // reset on transitions up, but do not re-calculate rad_90, flux_9061 if (!above && (petRatio->data.F32[nOut] >= PETROSIAN_RATIO)) {62 above = true;63 }64 nOut ++;65 }66 99 67 // save petRadius, petFlux68 petrosian->petrosianRadius = petRadius;69 petrosian->petrosianFlux = petFlux;100 // save petRadius, petFlux 101 petrosian->petrosianRadius = petRadius; 102 petrosian->petrosianFlux = petFlux; 70 103 71 psphotPetrosianVisualStats (radBin, fluxBin, refRadius, meanSB, petRatio, fluxSum, petRadius, petFlux);104 psphotPetrosianVisualStats (binRad, binSB, refRadius, meanSB, petRatio, petRatioErr, fluxSum, petRadius, PETROSIAN_RATIO, petFlux, apRadius); 72 105 73 psFree(fluxSum);74 psFree(petRatio);75 psFree(meanSB);76 psFree(areaSum);106 psFree(fluxSum); 107 psFree(petRatio); 108 psFree(meanSB); 109 psFree(areaSum); 77 110 78 return true;111 return true; 79 112 } 113 114 float InterpolateValues (float X0, float Y0, float X1, float Y1, float X) { 115 float Y = Y0 + (Y1 - Y0) * (X - X0) / (X1 - X0); 116 return Y; 117 } 118 -
branches/eam_branches/20090715/psphot/src/psphotPetrosianStudy.c
r25128 r25178 133 133 source = pmSourceAlloc(); 134 134 source->peak = psphotLocalPeak(readout, Xo, Yo); 135 pmSourceDefinePixels (source, readout, Xo, Yo, 64);135 pmSourceDefinePixels (source, readout, Xo, Yo, 128); 136 136 } 137 137 -
branches/eam_branches/20090715/psphot/src/psphotPetrosianVisual.c
r25128 r25178 161 161 bool psphotPetrosianVisualStats (psVector *radBin, psVector *fluxBin, 162 162 psVector *refRadius, psVector *meanSB, 163 psVector *petRatio, psVector *fluxSum, 164 float petRadius, float petFlux) 163 psVector *petRatio, psVector *petRatioErr, 164 psVector *fluxSum, 165 float petRadius, float ratioForRadius, 166 float petFlux, float radiusForFlux) 165 167 { 166 168 Graphdata graphdata; … … 229 231 230 232 graphdata.color = KapaColorByName ("black"); 231 pmVisualLimitsFromVectors (&graphdata, radBin, petRatio); 233 graphdata.ymax = +1.05; 234 graphdata.ymin = -0.05; 235 pmVisualLimitsFromVectors (&graphdata, radBin, NULL); 232 236 KapaSetLimits (kapa, &graphdata); 233 237 … … 240 244 graphdata.ptype = 0; 241 245 graphdata.size = 1.0; 246 graphdata.etype = 0x01; 242 247 KapaPrepPlot (kapa, refRadius->n, &graphdata); 243 248 KapaPlotVector (kapa, refRadius->n, refRadius->data.F32, "x"); 244 249 KapaPlotVector (kapa, refRadius->n, petRatio->data.F32, "y"); 245 246 float ratio_90 = 0.1; 250 KapaPlotVector (kapa, refRadius->n, petRatioErr->data.F32, "dym"); 251 KapaPlotVector (kapa, refRadius->n, petRatioErr->data.F32, "dyp"); 252 graphdata.etype = 0; 253 247 254 graphdata.color = KapaColorByName ("red"); 248 255 graphdata.style = 2; … … 251 258 KapaPrepPlot (kapa, 1, &graphdata); 252 259 KapaPlotVector (kapa, 1, &petRadius, "x"); 253 KapaPlotVector (kapa, 1, &ratio _90, "y");260 KapaPlotVector (kapa, 1, &ratioForRadius, "y"); 254 261 255 262 // *** section 3: radius vs integrated flux … … 283 290 graphdata.size = 2.0; 284 291 KapaPrepPlot (kapa, 1, &graphdata); 285 KapaPlotVector (kapa, 1, & petRadius, "x");292 KapaPlotVector (kapa, 1, &radiusForFlux, "x"); 286 293 KapaPlotVector (kapa, 1, &petFlux, "y"); 287 294 -
branches/eam_branches/20090715/psphot/src/psphotRadialProfileByAngle.c
r25128 r25178 4 4 // separations 5 5 6 // XXX choices for rMax and Nsec? 6 float psphotMeanSectorValue (psImage *image, int x, int y, float dL, float dW, float theta); 7 psVector *psphotBoxValues (psImage *image, float x0, float y0, float dL, float dW, float theta); 8 psVector *psphotLineValues (psImage *image, double x1, double y1, double x2, double y2, int dW); 9 psVector *psphotLineValuesBresen (psImage *image, int X1, int Y1, int X2, int Y2, int dW, int swapcoords); 7 10 8 11 bool psphotRadialProfilesByAngles (pmPetrosian *petrosian, pmSource *source, int Nsec, float Rmax) { … … 28 31 psVector *flux = psVectorAllocEmpty(Rmax, PS_TYPE_F32); 29 32 30 // start at Xo,Yo and find the x,y locations for r_i, theta where r_i increments by 1 pixel 31 // XXX at large radii ( > 10-15) use stats in a patch rather than sub-pixel interpolation 32 for (float r = 0; r < Rmax; r += 1.0) { 33 // Start at Xo,Yo and find the x,y locations for r_i, theta where r_i initially 34 // increments by 1 pixel. At large radii (r*dtheta > 2) use stats in a box rather than 35 // sub-pixel interpolation 36 37 int dR = 1.0; 38 for (float r = 0; r < Rmax; r += dR) { 33 39 34 40 float Xo = source->peak->xf + 0.5; … … 38 44 float x = r * cos (theta) + Xo; 39 45 float y = r * sin (theta) + Yo; 40 41 if (x < 0) continue; 42 if (y < 0) continue; 43 if (x >= source->pixels->parent->numCols) continue; 44 if (y >= source->pixels->parent->numRows) continue; 45 46 // value is NAN if we run off the image 47 float value = psImageInterpolatePixelBilinear(x, y, source->pixels); 48 49 // keep the nan values so all vectors are matched 50 // if (isnan(value)) continue; 51 46 dR = 2*(int)(0.5*r*sin(dtheta)) + 1; 47 48 if (x < 0) goto badvalue; 49 if (y < 0) goto badvalue; 50 if (x >= source->pixels->parent->numCols) goto badvalue; 51 if (y >= source->pixels->parent->numRows) goto badvalue; 52 53 float value = NAN; 54 if (dR < 2) { 55 // value is NAN if we run off the image 56 value = psImageInterpolatePixelBilinear(x, y, source->pixels); 57 } else { 58 value = psphotMeanSectorValue(source->pixels, x, y, dR, dR, theta); 59 } 60 61 // keep the all values (even NAN) so all vectors are matched in length 52 62 psVectorAppend (radius, r); 53 63 psVectorAppend (flux, value); 64 continue; 65 66 badvalue: 67 psVectorAppend (radius, r); 68 psVectorAppend (flux, NAN); 54 69 } 55 70 … … 103 118 return true; 104 119 } 120 121 float psphotMeanSectorValue (psImage *image, int x, int y, float dL, float dW, float theta) { 122 123 psVector *values = psphotBoxValues (image, x, y, dL, dW, theta); 124 125 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN); 126 psVectorStats (stats, values, NULL, NULL, 0); 127 128 float value = stats->sampleMedian; 129 130 psFree (stats); 131 psFree (values); 132 133 return value; 134 } 135 136 psVector *psphotBoxValues (psImage *image, float x0, float y0, float dL, float dW, float theta) { 137 138 // extract pixels from a series of lines (from -0.5*dW to +0.5*dW) of length dL, 139 // centered on x0, y0 in parent pixel coordinates (not pixel indicies) 140 141 float xs = x0 - image->col0 - 0.5*dL*cos(theta); 142 float ys = y0 - image->row0 - 0.5*dL*sin(theta); 143 144 float xe = xs + 0.5*dL*cos(theta); 145 float ye = ys + 0.5*dL*sin(theta); 146 147 psVector *values = psphotLineValues (image, xs, ys, xe, ye, (int) dW); 148 return values; 149 } 150 151 /** 152 * identify the quadrant and draw the correct line 153 */ 154 psVector *psphotLineValues (psImage *image, double x1, double y1, double x2, double y2, int dW) { 155 156 int FlipDirect, FlipCoords; 157 int X1, Y1, X2, Y2, dX, dY; 158 159 /* rather than draw the line from float positions, we find the closest 160 integer end-points and draw the line between those pixels */ 161 162 X1 = ROUND(x1); 163 Y1 = ROUND(y1); 164 X2 = ROUND(x2); 165 Y2 = ROUND(y2); 166 167 dX = X2 - X1; 168 dY = Y2 - Y1; 169 170 FlipCoords = (abs(dX) < abs(dY)); 171 FlipDirect = FlipCoords ? (y1 > y2) : (x1 > x2); 172 173 psVector *values = NULL; 174 if (!FlipDirect && !FlipCoords) values = psphotLineValuesBresen (image, X1, Y1, X2, Y2, dW, FALSE); 175 if ( FlipDirect && !FlipCoords) values = psphotLineValuesBresen (image, X2, Y2, X1, Y1, dW, FALSE); 176 if (!FlipDirect && FlipCoords) values = psphotLineValuesBresen (image, Y1, X1, Y2, X2, dW, TRUE); 177 if ( FlipDirect && FlipCoords) values = psphotLineValuesBresen (image, Y2, X2, Y1, X1, dW, TRUE); 178 179 return values; 180 } 181 182 /** 183 * use the Bresenham line drawing technique 184 * integer-only Bresenham line-draw version which is fast 185 */ 186 psVector *psphotLineValuesBresen (psImage *image, int X1, int Y1, int X2, int Y2, int dW, int swapcoords) { 187 188 int X, Y, dX, dY; 189 int e, e2; 190 191 psVector *values = psVectorAllocEmpty(100, PS_TYPE_F32); 192 193 dX = X2 - X1; 194 dY = Y2 - Y1; 195 196 Y = Y1; 197 e = 0; 198 for (X = X1; X <= X2; X++) { 199 if (X > 0) { 200 if (swapcoords) { 201 if (X >= image->numRows) continue; 202 for (int y = Y - dW; y <= Y + dW; y++) { 203 if (y < 0) continue; 204 if (y >= image->numCols) continue; 205 psVectorAppend(values, image->data.F32[X][y]); 206 } 207 } else { 208 if (X >= image->numCols) continue; 209 for (int y = Y - dW; y <= Y + dW; y++) { 210 if (y < 0) continue; 211 if (y >= image->numRows) continue; 212 psVectorAppend(values, image->data.F32[y][X]); 213 } 214 } 215 } 216 e += dY; 217 e2 = 2 * e; 218 if (e2 > dX) { 219 Y++; 220 e -= dX; 221 } 222 if (e2 < -dX) { 223 Y--; 224 e += dX; 225 } 226 } 227 return values; 228 } 229 -
branches/eam_branches/20090715/psphot/src/psphotRadiiFromProfiles.c
r25128 r25178 31 31 // examine data in the two ranges Fm - Fo and Fo - Fp to define the bin size 32 32 // XXX reconsider the fractional isophote value 33 float Fm = fluxMin + 0. 25*fluxRange;34 float F p = fluxMin + 0.75*fluxRange;35 float F o= fluxMin + 0.50*fluxRange;33 float Fm = fluxMin + 0.10*fluxRange; 34 float Fo = fluxMin + 0.25*fluxRange; 35 float Fp = fluxMin + 0.50*fluxRange; 36 36 int Rbin = 1; 37 37
Note:
See TracChangeset
for help on using the changeset viewer.
