Index: trunk/ippconfig/recipes/filerules-mef.mdc
===================================================================
--- trunk/ippconfig/recipes/filerules-mef.mdc	(revision 29378)
+++ trunk/ippconfig/recipes/filerules-mef.mdc	(revision 29379)
@@ -295,4 +295,5 @@
                                                                                      
 PPSTAMP.OUTPUT          OUTPUT {OUTPUT}.fits                     IMAGE     COMP_IMG   FPA        TRUE      NONE
+PPSTAMP.OUTPUT.DIFF     OUTPUT {OUTPUT}.fits                     IMAGE     COMP_SUB   FPA        TRUE      NONE
 PPSTAMP.OUTPUT.MASK     OUTPUT {OUTPUT}.mk.fits                  MASK      COMP_MASK  FPA        TRUE      NONE
 PPSTAMP.OUTPUT.VARIANCE OUTPUT {OUTPUT}.wt.fits                  VARIANCE  COMP_WT    FPA        TRUE      NONE
Index: trunk/ippconfig/recipes/filerules-simple.mdc
===================================================================
--- trunk/ippconfig/recipes/filerules-simple.mdc	(revision 29378)
+++ trunk/ippconfig/recipes/filerules-simple.mdc	(revision 29379)
@@ -261,4 +261,5 @@
                                              
 PPSTAMP.OUTPUT               OUTPUT {OUTPUT}.fits                 IMAGE           COMP_IMG   FPA        TRUE      NONE
+PPSTAMP.OUTPUT.DIFF          OUTPUT {OUTPUT}.fits                 IMAGE           COMP_SUB   FPA        TRUE      NONE
 PPSTAMP.OUTPUT.MASK          OUTPUT {OUTPUT}.mk.fits              MASK            COMP_MASK  FPA        TRUE      NONE
 PPSTAMP.OUTPUT.VARIANCE      OUTPUT {OUTPUT}.wt.fits              VARIANCE        COMP_WT    FPA        TRUE      NONE
Index: trunk/ippconfig/recipes/filerules-split.mdc
===================================================================
--- trunk/ippconfig/recipes/filerules-split.mdc	(revision 29378)
+++ trunk/ippconfig/recipes/filerules-split.mdc	(revision 29379)
@@ -280,4 +280,5 @@
 
 PPSTAMP.OUTPUT               OUTPUT {OUTPUT}.fits                     IMAGE           COMP_IMG   FPA        TRUE      NONE
+PPSTAMP.OUTPUT.DIFF          OUTPUT {OUTPUT}.fits                     IMAGE           COMP_SUB   FPA        TRUE      NONE
 PPSTAMP.OUTPUT.MASK          OUTPUT {OUTPUT}.mk.fits                  MASK            COMP_MASK  FPA        TRUE      NONE
 PPSTAMP.OUTPUT.VARIANCE      OUTPUT {OUTPUT}.wt.fits                  VARIANCE        COMP_WT    FPA        TRUE      NONE
Index: trunk/pstamp/src/ppstamp.c
===================================================================
--- trunk/pstamp/src/ppstamp.c	(revision 29378)
+++ trunk/pstamp/src/ppstamp.c	(revision 29379)
@@ -22,5 +22,5 @@
 
     // define the active I/O files
-    if (!ppstampParseCamera(config)) {
+    if (!ppstampParseCamera(config, options)) {
         psErrorStackPrint(stderr, "Unable to parse camera.");
         ppstampCleanup(config, options);
Index: trunk/pstamp/src/ppstamp.h
===================================================================
--- trunk/pstamp/src/ppstamp.h	(revision 29378)
+++ trunk/pstamp/src/ppstamp.h	(revision 29379)
@@ -18,5 +18,5 @@
 
 // Determine what type of camera, and initialise
-bool ppstampParseCamera(pmConfig *config);
+bool ppstampParseCamera(pmConfig *config, ppstampOptions *options);
 
 int ppstampMakeStamp(pmConfig *config, ppstampOptions *);
Index: trunk/pstamp/src/ppstampArguments.c
===================================================================
--- trunk/pstamp/src/ppstampArguments.c	(revision 29378)
+++ trunk/pstamp/src/ppstampArguments.c	(revision 29379)
@@ -78,4 +78,9 @@
         psArgumentRemove(argnum, &argc, argv);
     }
+    if ((argnum = psArgumentGet(argc, argv, "-stage"))) {
+        psArgumentRemove(argnum, &argc, argv);
+        options->stage = psStringCopy(argv[argnum]);
+        psArgumentRemove(argnum, &argc, argv);
+    }
 
     pmConfigFileSetsMD(config->arguments, &argc, argv, "ASTROM", "-astrom", "-astromlist");
Index: trunk/pstamp/src/ppstampMakeStamp.c
===================================================================
--- trunk/pstamp/src/ppstampMakeStamp.c	(revision 29378)
+++ trunk/pstamp/src/ppstampMakeStamp.c	(revision 29379)
@@ -233,5 +233,10 @@
     int status = false;
 
-    pmFPAfile *output = psMetadataLookupPtr(NULL, config->files, "PPSTAMP.OUTPUT");
+    pmFPAfile *output;
+    if (!options->stage || (strcmp(options->stage, "diff") != 0)) {
+        output = psMetadataLookupPtr(NULL, config->files, "PPSTAMP.OUTPUT");
+    } else {
+        output = psMetadataLookupPtr(NULL, config->files, "PPSTAMP.OUTPUT.DIFF");
+    }
     if (!output) {
         psError(PS_ERR_UNKNOWN, false, "Can't find output data\n");
Index: trunk/pstamp/src/ppstampOptions.h
===================================================================
--- trunk/pstamp/src/ppstampOptions.h	(revision 29378)
+++ trunk/pstamp/src/ppstampOptions.h	(revision 29379)
@@ -10,4 +10,5 @@
     psString    chipName;
     psString    cellName;
+    psString    stage;
     //
     // Calculated Values
Index: trunk/pstamp/src/ppstampParseCamera.c
===================================================================
--- trunk/pstamp/src/ppstampParseCamera.c	(revision 29378)
+++ trunk/pstamp/src/ppstampParseCamera.c	(revision 29379)
@@ -8,7 +8,19 @@
 
 // Set up the ppstamp output Image file
-bool setupOutput(pmConfig *config, pmFPAfile *input, bool doMask, bool doWeight)
+bool setupOutput(pmConfig *config, pmFPAfile *input, psString stage, bool doMask, bool doWeight)
 {
-    pmFPAfile *output = pmFPAfileDefineSkycell(config, NULL, "PPSTAMP.OUTPUT");
+    pmFPAfile *output;
+    
+    if (!stage || (strcmp(stage, "diff") != 0)) {
+        output = pmFPAfileDefineSkycell(config, NULL, "PPSTAMP.OUTPUT");
+    } else {
+        // need special filerule for diff stage image to allow for negative values
+        output = pmFPAfileDefineSkycell(config, NULL, "PPSTAMP.OUTPUT.DIFF");
+    }
+    if (!output) {
+        psError(PS_ERR_UNKNOWN, false, "Unable to setup output.");
+        return false;
+    }
+
     output->save = true;
 
@@ -29,5 +41,5 @@
 // something else that I'm missing?
 
-bool ppstampParseCamera(pmConfig *config)
+bool ppstampParseCamera(pmConfig *config, ppstampOptions *options)
 {
     bool status = false;
@@ -83,5 +95,5 @@
 
     // Set up the output target
-    if (!setupOutput(config, input, doMask, doWeight)) {
+    if (!setupOutput(config, input, options->stage, doMask, doWeight)) {
         psError(PS_ERR_UNKNOWN, false, "Unable to setup output.");
         return false;
