Index: branches/czw_branch/20120906/psModules/src/objects/pmModel.c
===================================================================
--- branches/czw_branch/20120906/psModules/src/objects/pmModel.c	(revision 34667)
+++ branches/czw_branch/20120906/psModules/src/objects/pmModel.c	(revision 34772)
@@ -64,4 +64,5 @@
     tmp->type = type;
     tmp->mag = NAN;
+    tmp->magErr = NAN;
     tmp->chisq = NAN;
     tmp->chisqNorm = NAN;
Index: branches/czw_branch/20120906/psModules/src/objects/pmMoments.c
===================================================================
--- branches/czw_branch/20120906/psModules/src/objects/pmMoments.c	(revision 34667)
+++ branches/czw_branch/20120906/psModules/src/objects/pmMoments.c	(revision 34772)
@@ -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/czw_branch/20120906/psModules/src/objects/pmSourceIO.c
===================================================================
--- branches/czw_branch/20120906/psModules/src/objects/pmSourceIO.c	(revision 34667)
+++ branches/czw_branch/20120906/psModules/src/objects/pmSourceIO.c	(revision 34772)
@@ -1028,4 +1028,5 @@
 	if (strcmp (xtension, "BINTABLE")) {
 	    psWarning ("no binary table in extension %s, skipping\n", dataname);
+            psFree(tableHeader);
 	    return false;
 	}
@@ -1232,5 +1233,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;
     }
@@ -1242,4 +1243,5 @@
     if (!xtension) psAbort("cannot read table type");
     if (strcmp (xtension, "BINTABLE")) {
+        psFree(tableHeader);
         psWarning ("no binary table in extension %s, skipping\n", xsrcname);
         return false;
@@ -1270,5 +1272,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;
     }
@@ -1281,4 +1283,5 @@
     if (strcmp (xtension, "BINTABLE")) {
         psWarning ("no binary table in extension %s, skipping\n", extname);
+        psFree(tableHeader);
         return false;
     }
@@ -1307,5 +1310,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;
     }
@@ -1318,4 +1321,5 @@
     if (strcmp (xtension, "BINTABLE")) {
         psWarning ("no binary table in extension %s, skipping\n", extname);
+        psFree(tableHeader);
         return false;
     }
Index: branches/czw_branch/20120906/psModules/src/objects/pmSourceIO_CMF.c.in
===================================================================
--- branches/czw_branch/20120906/psModules/src/objects/pmSourceIO_CMF.c.in	(revision 34667)
+++ branches/czw_branch/20120906/psModules/src/objects/pmSourceIO_CMF.c.in	(revision 34772)
@@ -118,4 +118,7 @@
 
         row = psMetadataAlloc ();
+
+        // the psMetadataAdd entry and the double quotes are used by grep to select the output fields for automatic documentation
+        // This set of psMetadataAdd Entries marks the "----" "Start of the PSF segment"
         @ALL@      		  psMetadataAdd (row, PS_LIST_TAIL, "IPP_IDET",         PS_DATA_U32, "IPP detection identifier index",             source->seq);
         @ALL@      		  psMetadataAdd (row, PS_LIST_TAIL, "X_PSF",            PS_DATA_F32, "PSF x coordinate",                           outputs.xPos);
@@ -193,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);
@@ -306,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");
@@ -462,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]);
     }
 
@@ -491,4 +495,6 @@
 
         // XXX we are not writing out the mode (flags) or the type (psf, ext, etc)
+        // the psMetadataAdd entry and the double quotes are used by grep to select the output fields for automatic documentation
+        // This set of psMetadataAdd Entries marks the "----" "Start of the XSRC segment"
         psMetadataAdd (row, PS_LIST_TAIL, "IPP_IDET",         PS_DATA_U32, "IPP detection identifier index",             source->seq);
         psMetadataAdd (row, PS_LIST_TAIL, "X_EXT",            PS_DATA_F32, "EXT model x coordinate",                     xPos);
@@ -718,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;
@@ -776,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;
@@ -783,4 +797,6 @@
 
             // XXX we are not writing out the mode (flags) or the type (psf, ext, etc)
+	    // the psMetadataAdd entry and the double quotes are used by grep to select the output fields for automatic documentation
+	    // This set of psMetadataAdd Entries marks the "----" "Start of the XFIT segment"
             psMetadataAddU32 (row, PS_LIST_TAIL, "IPP_IDET",         0, "IPP detection identifier index",             source->seq);
             psMetadataAddF32 (row, PS_LIST_TAIL, "X_EXT",            0, "EXT model x coordinate",                     xPos);
@@ -790,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);
@@ -806,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));
 
@@ -813,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 {
@@ -1072,4 +1096,6 @@
 
 	    // XXX we are not writing out the mode (flags) or the type (psf, ext, etc)
+	    // the psMetadataAdd entry and the double quotes are used by grep to select the output fields for automatic documentation
+	    // This set of psMetadataAdd Entries marks the "----" "Start of the XRAD segment"
 	    psMetadataAddU32 (row, PS_LIST_TAIL, "IPP_IDET",         0, "IPP detection identifier index",             source->seq);
 	    psMetadataAddF32 (row, PS_LIST_TAIL, "X_APER",           0, "Center of aperture measurements",            xPos);
Index: branches/czw_branch/20120906/psModules/src/objects/pmSourceIO_CMF.txt
===================================================================
--- branches/czw_branch/20120906/psModules/src/objects/pmSourceIO_CMF.txt	(revision 34772)
+++ branches/czw_branch/20120906/psModules/src/objects/pmSourceIO_CMF.txt	(revision 34772)
@@ -0,0 +1,155 @@
+                                
+                          ----  Start of the PSF segment
+                      IPP_IDET  IPP detection identifier index
+                         X_PSF  PSF x coordinate
+                         Y_PSF  PSF y coordinate
+                     X_PSF_SIG  Sigma in PSF x coordinate
+                     Y_PSF_SIG  Sigma in PSF y coordinate
+                        RA_PSF  PSF RA coordinate (degrees)
+                       DEC_PSF  PSF DEC coordinate (degrees)
+                      POSANGLE  position angle at source (degrees)
+                      PLTSCALE  plate scale at source (arcsec/pixel)
+                  PSF_INST_MAG  PSF fit instrumental magnitude
+              PSF_INST_MAG_SIG  Sigma of PSF instrumental magnitude
+                 PSF_INST_FLUX  PSF fit instrumental flux (counts)
+             PSF_INST_FLUX_SIG  Sigma of PSF instrumental flux
+                        AP_MAG  magnitude in standard aperture
+                    AP_MAG_RAW  magnitude in reported aperture
+                 AP_MAG_RADIUS  radius used for aperture mags
+                       AP_FLUX  instrumental flux in standard aperture
+                   AP_FLUX_SIG  aperture flux error
+              PEAK_FLUX_AS_MAG  Peak flux expressed as magnitude
+                   CAL_PSF_MAG  PSF Magnitude using supplied calibration
+               CAL_PSF_MAG_SIG  measured scatter of zero point calibration
+                        RA_PSF  PSF RA coordinate (degrees)
+                       DEC_PSF  PSF DEC coordinate (degrees)
+              PEAK_FLUX_AS_MAG  Peak flux expressed as magnitude
+                           SKY  Sky level
+                     SKY_SIGMA  Sigma of sky level
+                     PSF_CHISQ  Chisq of PSF-fit
+                     CR_NSIGMA  Nsigma deviations from PSF to CF
+                    EXT_NSIGMA  Nsigma deviations from PSF to EXT
+                     PSF_MAJOR  PSF width (major axis)
+                     PSF_MINOR  PSF width (minor axis)
+                     PSF_THETA  PSF orientation angle
+                        PSF_QF  PSF coverage/quality factor (bad)
+                PSF_QF_PERFECT  PSF coverage/quality factor (poor)
+                      PSF_NDOF  degrees of freedom
+                      PSF_NPIX  number of pixels in fit
+                    MOMENTS_XX  second moments (X^2)
+                    MOMENTS_XY  second moments (X*Y)
+                    MOMENTS_YY  second moments (Y*Y)
+                   MOMENTS_M3C  third momemt cos theta
+                   MOMENTS_M3S  third momemt sin theta
+                   MOMENTS_M4C  fourth momemt cos theta
+                   MOMENTS_M4S  fourth momemt sin theta
+                    MOMENTS_R1  first radial moment
+                    MOMENTS_RH  half radial moment
+                     KRON_FLUX  Kron Flux (in 2.5 R1)
+                 KRON_FLUX_ERR  Kron Flux Error
+               KRON_FLUX_INNER  Kron Flux (in 1.0 R1)
+               KRON_FLUX_OUTER  Kron Flux (in 4.0 R1)
+                 SKY_LIMIT_RAD  Radius where object hits sky
+                SKY_LIMIT_FLUX  Flux / pix where object hits sky
+               SKY_LIMIT_SLOPE  d(Flux/pix)/dRadius where object hits sky
+                     DIFF_NPOS  nPos (n pix > 3 sigma)
+                   DIFF_FRATIO  fPos / (fPos + fNeg)
+               DIFF_NRATIO_BAD  nPos / (nPos + nNeg)
+              DIFF_NRATIO_MASK  nPos / (nPos + nMask)
+               DIFF_NRATIO_ALL  nPos / (nGood + nMask + nBad)
+                      DIFF_R_P  distance to positive match source
+                     DIFF_SN_P  signal-to-noise of pos match src
+                      DIFF_R_M  distance to negative match source
+                     DIFF_SN_M  signal-to-noise of neg match src
+                         FLAGS  psphot analysis flags
+                        FLAGS2  psphot analysis flags
+                      PADDING2  more padding
+                      N_FRAMES  Number of frames overlapping source center
+                       PADDING  padding
+                                
+                          ----  Start of the XSRC segment
+                      IPP_IDET  IPP detection identifier index
+                         X_EXT  EXT model x coordinate
+                         Y_EXT  EXT model y coordinate
+                     X_EXT_SIG  Sigma in EXT x coordinate
+                     Y_EXT_SIG  Sigma in EXT y coordinate
+                    F25_ARATIO  Axial Ratio of radial profile
+                     F25_THETA  Angle of radial profile ellipse
+                     PETRO_MAG  Petrosian Magnitude
+                 PETRO_MAG_ERR  Petrosian Magnitude Error
+                  PETRO_RADIUS  Petrosian Radius (pix)
+              PETRO_RADIUS_ERR  Petrosian Radius Error (pix)
+               PETRO_RADIUS_50  Petrosian R50 (pix)
+           PETRO_RADIUS_50_ERR  Petrosian R50 Error (pix)
+               PETRO_RADIUS_90  Petrosian R90 (pix)
+           PETRO_RADIUS_90_ERR  Petrosian R90 Error (pix)
+                    PETRO_FILL  Petrosian Fill Factor
+                     PETRO_MAG  Petrosian Magnitude
+                 PETRO_MAG_ERR  Petrosian Magnitude Error
+                  PETRO_RADIUS  Petrosian Radius
+              PETRO_RADIUS_ERR  Petrosian Radius Error
+               PETRO_RADIUS_50  Petrosian R50 (pix)
+           PETRO_RADIUS_50_ERR  Petrosian R50 Error (pix)
+               PETRO_RADIUS_90  Petrosian R90 (pix)
+           PETRO_RADIUS_90_ERR  Petrosian R90 Error (pix)
+                    PETRO_FILL  Petrosian Fill Factor
+                       PROF_SB  mean surface brightness annuli
+                     PROF_FLUX  flux within annuli
+                     PROF_FILL  fill factor of annuli
+                                
+                          ----  Start of the XFIT segment
+                      IPP_IDET  IPP detection identifier index
+                         X_EXT  EXT model x coordinate
+                         Y_EXT  EXT model y coordinate
+                     X_EXT_SIG  Sigma in EXT x coordinate
+                     Y_EXT_SIG  Sigma in EXT y coordinate
+                        RA_EXT  EXT model ra coordinate
+                       DEC_EXT  EXT model dec coordinate
+                  EXT_INST_MAG  EXT fit instrumental magnitude
+              EXT_INST_MAG_SIG  Sigma of PSF instrumental magnitude
+                      POSANGLE  position angle at source (degrees)
+                      PLTSCALE  plate scale at source (arcsec/pixel)
+                    MOMENTS_XX  second moment in x
+                    MOMENTS_XY  second moment in x,y
+                    MOMENTS_YY  second moment in y
+                    MOMENTS_R1  first radial moment
+                    MOMENTS_RH  half radial moment
+                  PSF_INST_MAG  PSF fit instrumental magnitude
+                        AP_MAG  PSF-sized aperture magnitude
+                      KRON_MAG  Kron Mag
+                       NPARAMS  number of model parameters
+                       NPARAMS  number of model parameters
+                    MODEL_TYPE  name of model
+                 EXT_WIDTH_MAJ  EXT width (major axis), length for trail
+                 EXT_WIDTH_MIN  EXT width (minor axis), sigma for trail
+                     EXT_THETA  EXT orientation angle
+             EXT_WIDTH_MAJ_ERR  EXT width error (major axis)
+             EXT_WIDTH_MIN_ERR  EXT width error (minor axis)
+                 EXT_THETA_ERR  EXT orientation angle (error)
+                 EXT_WIDTH_MAJ  EXT width (SXX, isnan)
+                 EXT_WIDTH_MIN  EXT width (SYY, isnan)
+                     EXT_THETA  EXT angle (SXY, isnan)
+             EXT_WIDTH_MAJ_ERR  EXT width err (SXX, isnan)
+             EXT_WIDTH_MIN_ERR  EXT width err (SYY, isnan)
+                 EXT_THETA_ERR  EXT angle err (SXY, isnan)
+                 EXT_WIDTH_MAJ  EXT width (major axis), length for trail
+                 EXT_WIDTH_MIN  EXT width (minor axis), sigma for trail
+                     EXT_THETA  EXT orientation angle
+             EXT_WIDTH_MAJ_ERR  EXT width error (major axis)
+             EXT_WIDTH_MIN_ERR  EXT width error (minor axis)
+                 EXT_THETA_ERR  EXT orientation angle (error)
+                                
+                                
+                                
+                                
+                          ----  Start of the XRAD segment
+                      IPP_IDET  IPP detection identifier index
+                        X_APER  Center of aperture measurements
+                        Y_APER  Center of aperture measurements
+                      PSF_FWHM  FWHM of matched PSF
+                      PSF_FWHM  image is not FWHM-matched
+                     APER_FLUX  flux within annuli
+                 APER_FLUX_ERR  flux error in annuli
+               APER_FLUX_STDEV  flux standard deviation
+                     APER_FILL  fill factor of annuli
+         STACK.PSF.FWHM.VALUES  PSF sizes
Index: branches/czw_branch/20120906/psModules/src/objects/pmSourceOutputs.c
===================================================================
--- branches/czw_branch/20120906/psModules/src/objects/pmSourceOutputs.c	(revision 34667)
+++ branches/czw_branch/20120906/psModules/src/objects/pmSourceOutputs.c	(revision 34772)
@@ -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/czw_branch/20120906/psModules/src/objects/pmSourcePhotometry.c
===================================================================
--- branches/czw_branch/20120906/psModules/src/objects/pmSourcePhotometry.c	(revision 34667)
+++ branches/czw_branch/20120906/psModules/src/objects/pmSourcePhotometry.c	(revision 34772)
@@ -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) {
