Index: /branches/eam_branches/ipp-20120405/psModules/src/camera/pmFPAfile.c
===================================================================
--- /branches/eam_branches/ipp-20120405/psModules/src/camera/pmFPAfile.c	(revision 33950)
+++ /branches/eam_branches/ipp-20120405/psModules/src/camera/pmFPAfile.c	(revision 33951)
@@ -382,5 +382,5 @@
         // Number of the file in list
         psString num = NULL;            // Number to use
-        psStringAppend(&num, "%03d", file->fileID);
+        psStringAppend(&num, "%" PRId64, file->fileID);
         psStringSubstitute(&newRule, num, "{FILE.ID}");
         psFree(num);
Index: /branches/eam_branches/ipp-20120405/psModules/src/camera/pmFPAfile.h
===================================================================
--- /branches/eam_branches/ipp-20120405/psModules/src/camera/pmFPAfile.h	(revision 33950)
+++ /branches/eam_branches/ipp-20120405/psModules/src/camera/pmFPAfile.h	(revision 33951)
@@ -114,5 +114,5 @@
 
     int fileIndex;			// Index of file
-    int fileID;				// internal sequence number
+    psS64 fileID;		        // internal sequence number
 
     psS64 imageId, sourceId;            // Image and source identifiers
Index: /branches/eam_branches/ipp-20120405/psModules/src/detrend/pmDetrendDB.c
===================================================================
--- /branches/eam_branches/ipp-20120405/psModules/src/detrend/pmDetrendDB.c	(revision 33950)
+++ /branches/eam_branches/ipp-20120405/psModules/src/detrend/pmDetrendDB.c	(revision 33951)
@@ -107,4 +107,6 @@
         DETREND_STRING_CASE(ASTROM);
         DETREND_STRING_CASE(NOISEMAP);
+	DETREND_STRING_CASE(VIDEOMASK);
+	DETREND_STRING_CASE(VIDEODARK);
 	DETREND_STRING_CASE(LINEARITY);
     default:
Index: /branches/eam_branches/ipp-20120405/psModules/src/detrend/pmDetrendDB.h
===================================================================
--- /branches/eam_branches/ipp-20120405/psModules/src/detrend/pmDetrendDB.h	(revision 33950)
+++ /branches/eam_branches/ipp-20120405/psModules/src/detrend/pmDetrendDB.h	(revision 33951)
@@ -36,4 +36,6 @@
     PM_DETREND_TYPE_ASTROM,
     PM_DETREND_TYPE_NOISEMAP,
+    PM_DETREND_TYPE_VIDEOMASK,
+    PM_DETREND_TYPE_VIDEODARK,
     PM_DETREND_TYPE_LINEARITY,
 } pmDetrendType;
Index: /branches/eam_branches/ipp-20120405/psModules/src/objects/pmSource.c
===================================================================
--- /branches/eam_branches/ipp-20120405/psModules/src/objects/pmSource.c	(revision 33950)
+++ /branches/eam_branches/ipp-20120405/psModules/src/objects/pmSource.c	(revision 33951)
@@ -39,4 +39,5 @@
 #include "pmSourceExtendedPars.h"
 #include "pmSourceDiffStats.h"
+#include "pmSourcePhotometry.h"
 #include "pmSource.h"
 
@@ -163,4 +164,5 @@
     source->radialAper = NULL;
     source->parent = NULL;
+    source->tmpPtr = NULL;
     source->imageID = -1;
     source->nFrames = 0;
@@ -1170,4 +1172,92 @@
     PAR[PM_PAR_SYY] = oldshape.sy;
     PAR[PM_PAR_SXY] = oldshape.sxy;
+
+    return true;
+}
+
+bool pmSourceSmoothOp (pmSource *source, pmModelOpMode mode, psImage *target, float sigma, bool add, psImageMaskType maskVal, int dx, int dy)
+{
+//    assert (mode & PM_MODEL_OP_NOISE);
+    PS_ASSERT_PTR_NON_NULL(source, false);
+    PS_ASSERT_PTR_NON_NULL(source->peak, false);
+    PS_ASSERT_PTR_NON_NULL(target, false);
+
+    if (add) {
+        psTrace ("psphot", 3, "adding smoothed object at %f,%f\n", source->peak->xf, source->peak->yf);
+    } else {
+        psTrace ("psphot", 3, "removing smooted object at %f,%f\n", source->peak->xf, source->peak->yf);
+    }
+
+    pmModel *model = pmSourceGetModel(NULL, source);
+    if (!model) {
+        return false;
+    }
+    pmSourceSmoothOpModel (model, source, mode, target, sigma, add, maskVal, dx, dy);
+
+    return true;
+}
+
+bool pmSourceSmoothOpModel (pmModel *model, pmSource *source, pmModelOpMode mode, psImage *target, float sigma, bool add, psImageMaskType maskVal, int dx, int dy) 
+{
+    bool status;
+    psEllipseShape oldshape;
+    psEllipseShape newshape;
+    psEllipseAxes axes;
+
+    if (add) {
+	psTrace ("psphot", 4, "adding smoothed object at %f,%f\n", model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS]);
+    } else {
+	psTrace ("psphot", 4, "removing smoothed object at %f,%f\n", model->params->data.F32[PM_PAR_XPOS], model->params->data.F32[PM_PAR_YPOS]);
+    }
+
+    psF32 *PAR = model->params->data.F32;
+
+    // Isn't this hanging around somewhere?
+    float oldFlux = NAN;
+    if (!pmSourcePhotometryModel (NULL, &oldFlux, model)) return false;
+
+    // save original values
+    float oldI0  = PAR[PM_PAR_I0];
+    float oldsxx = PAR[PM_PAR_SXX];
+    float oldsyy = PAR[PM_PAR_SYY];
+    float oldsxy = PAR[PM_PAR_SXY];
+
+    // Since we are going to scale the flux correctly we need to get our
+    // factors of sqrt(2) right
+    oldshape.sx  = oldsxx / M_SQRT2;
+    oldshape.sy  = oldsyy / M_SQRT2;
+    oldshape.sxy = oldsxy;
+
+    // XXX can this be done more intelligently?
+    if (oldI0 == 0.0) return false;
+    if (!isfinite(oldI0)) return false;
+
+    // increase size and height of source
+    axes = psEllipseShapeToAxes (oldshape, 20.0);
+    axes.major = sqrt(PS_SQR(axes.major) + PS_SQR(sigma));
+    axes.minor = sqrt(PS_SQR(axes.minor) + PS_SQR(sigma));
+    newshape = psEllipseAxesToShape (axes);
+    PAR[PM_PAR_SXX] = newshape.sx * M_SQRT2;
+    PAR[PM_PAR_SYY] = newshape.sy * M_SQRT2;
+    PAR[PM_PAR_SXY] = newshape.sxy;
+
+    PAR[PM_PAR_I0]  = 1.0;
+
+    float newFlux;
+    if (!pmSourcePhotometryModel (NULL, &newFlux, model)) return false;
+
+    PAR[PM_PAR_I0]  = oldFlux / newFlux;
+
+    if (add) {
+	status = pmModelAddWithOffset (target, source->maskObj, model, mode, maskVal, dx, dy);
+    } else {
+	status = pmModelSubWithOffset (target, source->maskObj, model, mode, maskVal, dx, dy);
+    }
+
+    // restore original values
+    PAR[PM_PAR_I0]  = oldI0;
+    PAR[PM_PAR_SXX] = oldsxx;
+    PAR[PM_PAR_SYY] = oldsyy;
+    PAR[PM_PAR_SXY] = oldsxy;
 
     return true;
Index: /branches/eam_branches/ipp-20120405/psModules/src/objects/pmSource.h
===================================================================
--- /branches/eam_branches/ipp-20120405/psModules/src/objects/pmSource.h	(revision 33950)
+++ /branches/eam_branches/ipp-20120405/psModules/src/objects/pmSource.h	(revision 33951)
@@ -118,4 +118,5 @@
     psArray *radialAper;		///< radial flux in circular apertures
     pmSource *parent;			///< reference to the master source from which this is derived
+    psPtr *tmpPtr;                      ///< pointer that may be used to store data in a particular module. e.g. psphotKronIterate.
     int imageID;
     psU16 nFrames;
@@ -303,4 +304,7 @@
 bool pmSourceNoiseOp (pmSource *source, pmModelOpMode mode, float FACTOR, float SIZE, bool add, psImageMaskType maskVal, int dx, int dy);
 
+bool pmSourceSmoothOp (pmSource *source, pmModelOpMode mode, psImage *target, float sigma, bool add, psImageMaskType maskVal, int dx, int dy);
+bool pmSourceSmoothOpModel (pmModel *model, pmSource *source, pmModelOpMode mode, psImage *target, float sigma, bool add, psImageMaskType maskVal, int dx, int dy);
+
 bool pmSourceOp (pmSource *source, pmModelOpMode mode, bool add, psImageMaskType maskVal, int dx, int dy);
 bool pmSourceCacheModel (pmSource *source, psImageMaskType maskVal);
Index: /branches/eam_branches/ipp-20120405/psModules/src/objects/pmSourceMoments.c
===================================================================
--- /branches/eam_branches/ipp-20120405/psModules/src/objects/pmSourceMoments.c	(revision 33950)
+++ /branches/eam_branches/ipp-20120405/psModules/src/objects/pmSourceMoments.c	(revision 33951)
@@ -319,14 +319,14 @@
     }
 
-    source->moments->Mrf = RF/RS;
     source->moments->Mrh = RH/RS;
 
-    // if Mrf (first radial moment) is very small, we are getting into low-significance
+    // if Mrf = RF/RS (first radial moment) is very small, we are getting into low-significance
     // territory.  saturate at minKronRadius.  conversely, if Mrf is >> radius for faint
     // sources, we are clearly making an error.  saturate at radius.
-    float kronRefRadius = MAX(minKronRadius, source->moments->Mrf);
+    float kronRefRadius = MAX(minKronRadius, RF/RS);
     if (source->moments->SN < 10) {
 	kronRefRadius = MIN(radius, kronRefRadius);
     }
+    source->moments->Mrf = kronRefRadius;
 
     // *** now calculate the kron flux values using the 1st radial moment
