Index: /branches/eam_branches/ipp-20120905/psModules/src/objects/pmModel.c
===================================================================
--- /branches/eam_branches/ipp-20120905/psModules/src/objects/pmModel.c	(revision 34567)
+++ /branches/eam_branches/ipp-20120905/psModules/src/objects/pmModel.c	(revision 34568)
@@ -64,4 +64,5 @@
     tmp->type = type;
     tmp->mag = NAN;
+    tmp->magErr = NAN;
     tmp->chisq = NAN;
     tmp->chisqNorm = NAN;
Index: /branches/eam_branches/ipp-20120905/psModules/src/objects/pmMoments.c
===================================================================
--- /branches/eam_branches/ipp-20120905/psModules/src/objects/pmMoments.c	(revision 34567)
+++ /branches/eam_branches/ipp-20120905/psModules/src/objects/pmMoments.c	(revision 34568)
@@ -30,41 +30,41 @@
     pmMoments *tmp = (pmMoments *) psAlloc(sizeof(pmMoments));
 
-    tmp->Mrf = 0.0;
-    tmp->Mrh = 0.0;
+    tmp->Mrf = NAN;
+    tmp->Mrh = NAN;
 
-    tmp->KronCore = 0.0;
-    tmp->KronCoreErr = 0.0;
+    tmp->KronCore = NAN;
+    tmp->KronCoreErr = NAN;
 
-    tmp->KronFlux = 0.0;
-    tmp->KronFluxErr = 0.0;
+    tmp->KronFlux = NAN;
+    tmp->KronFluxErr = NAN;
 
-    tmp->KronFinner = 0.0;
-    tmp->KronFouter = 0.0;
+    tmp->KronFinner = NAN;
+    tmp->KronFouter = NAN;
 
-    tmp->KronFluxPSF = 0.0;
-    tmp->KronFluxPSFErr = 0.0;
-    tmp->KronRadiusPSF = 0.0;
+    tmp->KronFluxPSF = NAN;
+    tmp->KronFluxPSFErr = NAN;
+    tmp->KronRadiusPSF = NAN;
 
-    tmp->Mx = 0.0;
-    tmp->My = 0.0;
+    tmp->Mx = NAN;
+    tmp->My = NAN;
 
-    tmp->Mxx = 0.0;
-    tmp->Mxy = 0.0;
-    tmp->Myy = 0.0;
+    tmp->Mxx = NAN;
+    tmp->Mxy = NAN;
+    tmp->Myy = NAN;
 
-    tmp->Mxxx = 0.0;
-    tmp->Mxxy = 0.0;
-    tmp->Mxyy = 0.0;
-    tmp->Myyy = 0.0;
+    tmp->Mxxx = NAN;
+    tmp->Mxxy = NAN;
+    tmp->Mxyy = NAN;
+    tmp->Myyy = NAN;
 
-    tmp->Mxxxx = 0.0;
-    tmp->Mxxxy = 0.0;
-    tmp->Mxxyy = 0.0;
-    tmp->Mxyyy = 0.0;
-    tmp->Myyyy = 0.0;
+    tmp->Mxxxx = NAN;
+    tmp->Mxxxy = NAN;
+    tmp->Mxxyy = NAN;
+    tmp->Mxyyy = NAN;
+    tmp->Myyyy = NAN;
 
-    tmp->Sum = 0.0;
-    tmp->Peak = 0.0;
-    tmp->Sky = 0.0;
+    tmp->Sum = NAN;
+    tmp->Peak = NAN;
+    tmp->Sky = NAN;
     tmp->nPixels = 0;
     tmp->SN = 0;
Index: /branches/eam_branches/ipp-20120905/psModules/src/objects/pmSourceIO.c
===================================================================
--- /branches/eam_branches/ipp-20120905/psModules/src/objects/pmSourceIO.c	(revision 34567)
+++ /branches/eam_branches/ipp-20120905/psModules/src/objects/pmSourceIO.c	(revision 34568)
@@ -1232,5 +1232,5 @@
 {
     if (!psFitsMoveExtNameClean (file->fits, xsrcname)) {
-        psWarning ("cannot find xsrc extension %s in %s, skipping", xsrcname, file->filename);
+        psTrace ("pmFPAfile", 1, "cannot find xsrc extension %s in %s, skipping", xsrcname, file->filename);
         return false;
     }
@@ -1270,5 +1270,5 @@
 {
     if (!psFitsMoveExtNameClean (file->fits, extname)) {
-        psWarning ("cannot find xfit extension %s in %s, skipping", extname, file->filename);
+        psTrace ("pmFPAfile", 1, "cannot find xfit extension %s in %s, skipping", extname, file->filename);
         return false;
     }
@@ -1307,5 +1307,5 @@
 {
     if (!psFitsMoveExtNameClean (file->fits, extname)) {
-        psWarning ("cannot find xrad extension %s in %s, skipping", extname, file->filename);
+        psTrace ("pmFPAfile", 1, "cannot find xrad extension %s in %s, skipping", extname, file->filename);
         return false;
     }
Index: /branches/eam_branches/ipp-20120905/psModules/src/objects/pmSourceIO_CMF.c.in
===================================================================
--- /branches/eam_branches/ipp-20120905/psModules/src/objects/pmSourceIO_CMF.c.in	(revision 34567)
+++ /branches/eam_branches/ipp-20120905/psModules/src/objects/pmSourceIO_CMF.c.in	(revision 34568)
@@ -196,8 +196,8 @@
         @PS1_DV?@          	  psMetadataAdd (row, PS_LIST_TAIL, "DIFF_NRATIO_ALL",  PS_DATA_F32, "nPos / (nGood + nMask + nBad)",              diffStats.nRatioAll);
 
-        @PS1_DV2@      		  psMetadataAdd (row, PS_LIST_TAIL, "DIFF_R_P",         PS_DATA_F32, "distance to positive match source",          diffStats.Rp);
-        @PS1_DV2@      		  psMetadataAdd (row, PS_LIST_TAIL, "DIFF_SN_P",        PS_DATA_F32, "signal-to-noise of pos match src",           diffStats.SNp);
-        @PS1_DV2@      		  psMetadataAdd (row, PS_LIST_TAIL, "DIFF_R_M",         PS_DATA_F32, "distance to negative match source",          diffStats.Rm);
-        @PS1_DV2@      		  psMetadataAdd (row, PS_LIST_TAIL, "DIFF_SN_M",        PS_DATA_F32, "signal-to-noise of neg match src",           diffStats.SNm);
+        @>PS1_DV1@      		  psMetadataAdd (row, PS_LIST_TAIL, "DIFF_R_P",         PS_DATA_F32, "distance to positive match source",          diffStats.Rp);
+        @>PS1_DV1@      		  psMetadataAdd (row, PS_LIST_TAIL, "DIFF_SN_P",        PS_DATA_F32, "signal-to-noise of pos match src",           diffStats.SNp);
+        @>PS1_DV1@      		  psMetadataAdd (row, PS_LIST_TAIL, "DIFF_R_M",         PS_DATA_F32, "distance to negative match source",          diffStats.Rm);
+        @>PS1_DV1@      		  psMetadataAdd (row, PS_LIST_TAIL, "DIFF_SN_M",        PS_DATA_F32, "signal-to-noise of neg match src",           diffStats.SNm);
 
         @ALL@     		   psMetadataAdd (row, PS_LIST_TAIL, "FLAGS",            PS_DATA_U32, "psphot analysis flags",                      source->mode);
@@ -309,4 +309,5 @@
         @ALL@     axes.minor        = psMetadataLookupF32 (&status, row, "PSF_MINOR");
         @ALL@     axes.theta        = psMetadataLookupF32 (&status, row, "PSF_THETA");
+        @ALL@     axes.theta        = axes.theta * PS_RAD_DEG;
 
         @ALL@     PAR[PM_PAR_SKY]   = psMetadataLookupF32 (&status, row, "SKY");
@@ -465,5 +466,5 @@
 	sprintf (keyword2, "RMAX_%02d", i);
 	psMetadataAddF32 (outhead, PS_LIST_TAIL, keyword1, PS_META_REPLACE, "min radius for SB profile", radMin->data.F32[i]);
-	psMetadataAddF32 (outhead, PS_LIST_TAIL, keyword2, PS_META_REPLACE, "min radius for SB profile", radMax->data.F32[i]);
+	psMetadataAddF32 (outhead, PS_LIST_TAIL, keyword2, PS_META_REPLACE, "max radius for SB profile", radMax->data.F32[i]);
     }
 
@@ -723,4 +724,10 @@
     sources = psArraySort (sources, pmSourceSortByFlux);
 
+    @>PS1_DV2@ float magOffset; 
+    @>PS1_DV2@ float zeroptErr; 
+    @>PS1_DV2@ float fwhmMajor; 
+    @>PS1_DV2@ float fwhmMinor;
+    @>PS1_DV2@ pmSourceOutputsCommonValues (&magOffset, &zeroptErr, &fwhmMajor, &fwhmMinor, readout, imageHeader);
+
     // we are writing one row per model; we need to write out same number of columns for each row: find the max Nparams
     int nParamMax = 0;
@@ -781,4 +788,6 @@
 	    @>PS1_DV2@ double raPos = ptSky.r*PS_DEG_RAD;
 	    @>PS1_DV2@ double decPos = ptSky.d*PS_DEG_RAD;
+	    @>PS1_DV2@ posAngle *= PS_DEG_RAD;
+	    @>PS1_DV2@ pltScale *= PS_DEG_RAD*3600.0;
 
 	    float kronFlux = source->moments ? source->moments->KronFlux : NAN;
@@ -797,6 +806,14 @@
             @>PS1_DV2@ psMetadataAddF32 (row, PS_LIST_TAIL, "RA_EXT",           0, "EXT model ra coordinate",                    raPos);
             @>PS1_DV2@ psMetadataAddF32 (row, PS_LIST_TAIL, "DEC_EXT",          0, "EXT model dec coordinate",                   decPos);
+	    @>PS1_DV2@ float instFlux = isfinite(model->mag) ? pow(10.0, -0.4*model->mag) : NAN;
+	    @>PS1_DV2@ psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_FLUX",    0, "EXT fit instrumental counts",                instFlux);
+
             psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_MAG",     0, "EXT fit instrumental magnitude",             model->mag);
             psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_INST_MAG_SIG", 0, "Sigma of PSF instrumental magnitude",        model->magErr);
+
+	    @>PS1_DV2@ float calMag = isfinite(magOffset) ? model->mag + magOffset : NAN;
+	    @>PS1_DV2@ psMetadataAdd (row, PS_LIST_TAIL, "EXT_CAL_MAG", PS_DATA_F32, "EXT Magnitude using supplied calibration",   calMag);
+	    @>PS1_DV2@ psMetadataAdd (row, PS_LIST_TAIL, "EXT_CHISQ",   PS_DATA_F32, "EXT Magnitude using supplied calibration",   model->chisq);
+	    @>PS1_DV2@ psMetadataAdd (row, PS_LIST_TAIL, "EXT_NDOF",    PS_DATA_S32, "EXT Magnitude using supplied calibration",   model->nDOF);
 
             @>PS1_DV2@ psMetadataAddF32 (row, PS_LIST_TAIL, "POSANGLE",   0, "position angle at source (degrees)",         posAngle);
@@ -813,6 +830,6 @@
             psMetadataAddF32 (row, PS_LIST_TAIL, "KRON_MAG",         0, "Kron Mag",                                   kronMag);
 
-            @ALL, <PS1_DV3@ psMetadataAddF32 (row, PS_LIST_TAIL, "NPARAMS",          0, "number of model parameters",                 model->params->n);
-            @>PS1_DV2@       psMetadataAddS32 (row, PS_LIST_TAIL, "NPARAMS",          0, "number of model parameters",                 model->params->n);
+            @PS1_DV1,PS1_DV2@ psMetadataAddF32 (row, PS_LIST_TAIL, "NPARAMS",          0, "number of model parameters",                 model->params->n);
+            @ALL,!PS1_DV0,!PS1_DV1@ psMetadataAddS32 (row, PS_LIST_TAIL, "NPARAMS",          0, "number of model parameters",                 model->params->n);
             psMetadataAddStr (row, PS_LIST_TAIL, "MODEL_TYPE",       0, "name of model",                              pmModelClassGetName (model->type));
 
@@ -820,8 +837,8 @@
 	    if (model->type == pmModelClassGetType("PS_MODEL_TRAIL")) {
 		psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MAJ",    0, "EXT width (major axis), length for trail", PAR[PM_PAR_LENGTH]);
-		psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MIN",    0, "EXT width (minor axis), sigma for trail",  PAR[PM_PAR_SIGMA]);
+		psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MIN",    0, "EXT width (minor axis), sigma for trail",  PAR[PM_PAR_SIGMA]); // this is not fitted
 		psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_THETA",        0, "EXT orientation angle",                    PAR[PM_PAR_THETA]);
 		psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MAJ_ERR",0, "EXT width error (major axis)",            dPAR[PM_PAR_LENGTH]);
-		psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MIN_ERR",0, "EXT width error (minor axis)",            dPAR[PM_PAR_SIGMA]);
+		psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_WIDTH_MIN_ERR",0, "EXT width error (minor axis)",            NAN); // this is not fitted, so error is NAN
 		psMetadataAddF32 (row, PS_LIST_TAIL, "EXT_THETA_ERR",    0, "EXT orientation angle (error)",           dPAR[PM_PAR_THETA]);
 	    } else {
Index: /branches/eam_branches/ipp-20120905/psModules/src/objects/pmSourceOutputs.c
===================================================================
--- /branches/eam_branches/ipp-20120905/psModules/src/objects/pmSourceOutputs.c	(revision 34567)
+++ /branches/eam_branches/ipp-20120905/psModules/src/objects/pmSourceOutputs.c	(revision 34568)
@@ -227,11 +227,22 @@
     *pltScale = 0.5*(pltScale_x + pltScale_y);
 
+    float posAngle_x, posAngle_y;
     float crossProduct = dTPx_dCHx * dTPy_dCHy - dTPx_dCHy * dTPy_dCHx;
     if  (crossProduct > 0.) {
       *pltScale *= -1.0;
-    }
-
-    float posAngle_x = atan2 (+dTPy_dCHx, +dTPx_dCHx);
-    float posAngle_y = atan2 (-dTPy_dCHy, +dTPx_dCHy);
+      posAngle_x = atan2 (dTPy_dCHx, dTPx_dCHx);
+      posAngle_y = atan2 (dTPy_dCHy, dTPx_dCHy) - M_PI_2;
+    } else {
+      posAngle_x = atan2 (dTPy_dCHx, -dTPx_dCHx);
+      posAngle_y = atan2 (dTPy_dCHy,  dTPx_dCHy) - M_PI_2;
+    }
+
+    // with errors, these may end up on opposite sides of the M_PI boundary.  
+    if (posAngle_x - posAngle_y > M_PI) {
+      posAngle_y += 2.0 * M_PI;
+    }
+    if (posAngle_y - posAngle_x > M_PI) {
+      posAngle_x += 2.0 * M_PI;
+    }
     *posAngle = 0.5*(posAngle_x + posAngle_y);
 
Index: /branches/eam_branches/ipp-20120905/psModules/src/objects/pmSourcePhotometry.c
===================================================================
--- /branches/eam_branches/ipp-20120905/psModules/src/objects/pmSourcePhotometry.c	(revision 34567)
+++ /branches/eam_branches/ipp-20120905/psModules/src/objects/pmSourcePhotometry.c	(revision 34568)
@@ -165,4 +165,6 @@
             status = pmSourcePhotometryModel (&model->mag, NULL, model);
             if (model == source->modelEXT) foundEXT = true;
+	    float SN = fabs(model->params->data.F32[PM_PAR_I0] / model->dparams->data.F32[PM_PAR_I0]);
+	    model->magErr = 1.0 / SN;
         }
         if (foundEXT) {
