Index: trunk/psphot/src/psphotRadialProfile.c
===================================================================
--- trunk/psphot/src/psphotRadialProfile.c	(revision 15357)
+++ trunk/psphot/src/psphotRadialProfile.c	(revision 15357)
@@ -0,0 +1,45 @@
+# include "psphotInternal.h"
+
+bool psphotRadialProfile (pmSource *source, psMetadata *recipe, psMaskType maskVal) {
+
+    // allocate pmSourceExtendedParameters, if not already defined
+    if (!source->extpars) {
+	source->extpars = pmSourceExtendedParametersAlloc ();
+    }
+
+    if (!source->extpars->profile) {
+	source->extpars->profile = pmSourceRadialProfile (); 
+    }    
+    
+    int nPts = source->pixels->numRows * source->pixels->numCols;
+    source->extpars->profile->radius = psVectorAllocEmpty (nPts, PS_TYPE_F32);
+    source->extpars->profile->flux   = psVectorAllocEmpty (nPts, PS_TYPE_F32);
+    source->extpars->profile->weight = psVectorAllocEmpty (nPts, PS_TYPE_F32);
+
+    psVector *radius = source->extpars->profile->radius;
+    psVector *flux   = source->extpars->profile->flux;
+    psVector *weight = source->extpars->profile->radius;
+
+    // XXX use the extended source model here for Xo, Yo?
+    // XXX define a radius scaled to the elliptical contour?
+
+    int n = 0;
+    float Xo = source->modelEXT->params->data.F32[PM_PAR_XPOS] - source->pixels->col0;
+    float Yo = source->modelEXT->params->data.F32[PM_PAR_YPOS] - source->pixels->row0;
+    for (int iy = 0; iy < source->pixels->numRows; iy++) {
+	for (int ix = 0; ix < source->pixels->numCols; ix++) {
+	    if (source->maskObj->data.U8[iy][ix]) continue;
+	    radius->data.F32[n] = hypot (ix - Xo, iy - Yo) ;
+	    flux->data.F32[n]   = source->pixels->data.F32[iy][ix];
+	    weight->data.F32[n] = source->weight->data.F32[iy][ix];
+	    n++;
+	}
+    }
+    radius->n = n;
+    weight->n = n;
+    flux->n = n;
+
+    SortVectorsByRadius (radius, flux, weight);
+
+    return true;
+}
