Index: /trunk/psModules/src/objects/pmPSF.c
===================================================================
--- /trunk/psModules/src/objects/pmPSF.c	(revision 9881)
+++ /trunk/psModules/src/objects/pmPSF.c	(revision 9882)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-31 19:38:04 $
+ *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-11-07 09:08:59 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -154,112 +154,4 @@
 }
 
-
-
-/*****************************************************************************
-pmPSFFromModels (*psf, *models, *mask): build a PSF from a collection of
-free-fitted models.  The PSF ignores the first 4 (independent) model
-parameters and constructs a polynomial fit to the remaining as a function of
-image coordinate.
-    input: an array of pmModels, pre-allocated psf
-Note: some of the array entries may be NULL (failed fits); ignore them.
- *****************************************************************************/
-bool pmPSFFromModels (pmPSF *psf, psArray *models, psVector *mask)
-{
-
-    // construct the fit vectors from the collection of objects
-    // use the mask to ignore missing fits
-    psVector *x  = psVectorAlloc (models->n, PS_TYPE_F64);
-    psVector *y  = psVectorAlloc (models->n, PS_TYPE_F64);
-    psVector *z  = psVectorAlloc (models->n, PS_TYPE_F64);
-    psVector *dz = psVectorAlloc (models->n, PS_TYPE_F64);
-
-    // construct the x,y terms
-    for (int i = 0; i < models->n; i++) {
-        pmModel *model = models->data[i];
-        if (model == NULL)
-            continue;
-
-        // use F64 for polynomial fitting
-        x->data.F64[i] = model->params->data.F32[PM_PAR_XPOS];
-        y->data.F64[i] = model->params->data.F32[PM_PAR_YPOS];
-    }
-
-    // we are doing a robust fit.  after each pass, we drop points which are
-    // more deviant than three sigma.
-    // mask is currently updated for each pass. this is inconsistent?
-
-    psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV);
-
-    // skip the unfitted parameters (X, Y, Io, Sky)
-    for (int i = 0; i < psf->params_NEW->n; i++) {
-        if (i == PM_PAR_SKY)
-            continue;
-        if (i == PM_PAR_I0)
-            continue;
-        if (i == PM_PAR_XPOS)
-            continue;
-        if (i == PM_PAR_YPOS)
-            continue;
-
-        // select the per-object fitted data for this parameter
-        for (int j = 0; j < models->n; j++) {
-            pmModel *model = models->data[j];
-            if (model == NULL)
-                continue;
-            z->data.F64[j] = model->params->data.F32[i];
-            dz->data.F64[j] = 1; // use the model-fitted error? or S/N?
-
-            // for SXY, we actually fit SXY / (SXX^-2  + SYY^-2)
-            if (i == PM_PAR_SXY) {
-                z->data.F64[j] = pmPSF_SXYfromModel (model->params->data.F32);
-            }
-        }
-        psf->params_NEW->data[i] = psVectorClipFitPolynomial2D(psf->params_NEW->data[i], stats, mask, 0xff, z, dz, x, y);
-        // psTrace ("psphot.psftest", 3, "keeping %d of %d PSF candidates (PSF param %d)\n", Nkeep, mask->n, i);
-
-        // XXX Test output
-        # if (0)
-
-            psPolynomial2D *poly = psf->params_NEW->data[i];
-        fprintf (stderr, "stats: %f +/- %f\n", stats->robustMedian, stats->robustStdev);
-        fprintf (stderr, "PO: %g %g %g\n", poly->coeff[0][0], poly->coeff[1][0], poly->coeff[0][1]);
-        fprintf (stderr, "PO: %g %g %g\n", poly->coeff[0][2], poly->coeff[1][1], poly->coeff[2][0]);
-        fprintf (stderr, "PO: %g %g %g\n", poly->coeff[0][0], poly->coeff[1][0], poly->coeff[0][1]);
-        fprintf (stderr, "PO: %g %g %g\n", poly->coeff[0][2], poly->coeff[1][1], poly->coeff[2][0]);
-        # endif
-
-    }
-
-    // XXX test dump of star parameters vs position (compare with fitted values)
-    if (0) {
-        FILE *f = fopen ("params.dat", "w");
-
-        for (int j = 0; j < models->n; j++) {
-            pmModel *model = models->data[j];
-            if (model == NULL)
-                continue;
-
-            pmModel *modelPSF = pmModelFromPSF (model, psf);
-
-            fprintf (f, "%f %f : ", model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS]);
-
-            for (int i = 0; i < psf->params_NEW->n; i++) {
-                if (psf->params_NEW->data[i] == NULL)
-                    continue;
-                fprintf (f, "%f %f : ", model->params->data.F32[i], modelPSF->params->data.F32[i]);
-            }
-            fprintf (f, "%f %d\n", model->chisq, model->nIter);
-        }
-        fclose (f);
-    }
-
-    psFree (stats);
-    psFree (x);
-    psFree (y);
-    psFree (z);
-    psFree (dz);
-    return (true);
-}
-
 /*****************************************************************************
 pmModelFromPSF (*modelEXT, *psf):  use the model position parameters to
@@ -331,4 +223,34 @@
     double SXY = fit * PS_SQR(1.0 / PS_SQR(SXX) + 1.0 / PS_SQR(SYY));
     return SXY;
+}
+
+// generate a psf model of the requested type, with fixed shape
+pmPSF *pmPSFBuildSimple (char *typeName, float sxx, float syy, float sxy, ...)
+{
+
+    va_list ap;
+    va_start(ap, sxy);
+
+    pmModelType type = pmModelSetType (typeName);
+    psPolynomial2D *psfTrend = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, 0, 0);
+    pmPSF *psf = pmPSFAlloc (type, true, psfTrend);
+
+    // set the psf shape parameters
+    psPolynomial2D *poly = psf->params_NEW->data[PM_PAR_SXX];
+    poly->coeff[0][0] = M_SQRT2*sxx;
+
+    poly = psf->params_NEW->data[PM_PAR_SYY];
+    poly->coeff[0][0] = M_SQRT2*syy;
+
+    poly = psf->params_NEW->data[PM_PAR_SXY];
+    poly->coeff[0][0] = sxy;
+
+    for (int i = PM_PAR_SXY + 1; i < psf->params_NEW->n; i++) {
+        poly = psf->params_NEW->data[i];
+        poly->coeff[0][0] = (psF32)va_arg(ap, psF64);
+    }
+    va_end(ap);
+
+    return psf;
 }
 
Index: /trunk/psModules/src/objects/pmPSF.h
===================================================================
--- /trunk/psModules/src/objects/pmPSF.h	(revision 9881)
+++ /trunk/psModules/src/objects/pmPSF.h	(revision 9882)
@@ -72,24 +72,4 @@
 );
 
-
-/**
- * 
- * This function takes a collection of pmModel fitted models from across a
- * single image and builds a pmPSF representation of the PSF. The input array of
- * model fits may consist of entries to be ignored (noted by a non-zero mask
- * entry). The analysis of the models fits a 2D polynomial for each parameter to
- * the collection of model parameters as a function of position (and
- * normalization?). In this process, some of the input models may be marked as
- * outliers and excluded from the fit. These elements will be marked with a
- * specific mask value (1 == PSFTRY_MASK_OUTLIER).
- * 
- */
-bool pmPSFFromModels(
-    pmPSF *psf,                         ///< Add comment
-    psArray *models,                    ///< Add comment
-    psVector *mask                      ///< Add comment
-);
-
-
 /**
  * 
