Index: branches/eam_branches/gDiff.20200202/src/gDiffCamera.c
===================================================================
--- branches/eam_branches/gDiff.20200202/src/gDiffCamera.c	(revision 41260)
+++ branches/eam_branches/gDiff.20200202/src/gDiffCamera.c	(revision 41413)
@@ -1,2 +1,10 @@
+/** @file gDiffCamera.c
+ *  @brief: image subtraction based on matched Gaussians profiles
+ *  @author Eugene Magnier @ IfA
+ *  @version $Revision: 1.12 $
+ *  @date $Date: 2020-01-25 $
+ *  Copyright 2020 Institute for Astronomy, University of Hawaii
+ */
+
 #include "gDiff.h"
 
@@ -207,4 +215,19 @@
     }
 
+    /* in ppSub, there is a recipe value 'PHOTOMETRY' which is supposed to enable / disable photometry analysis.
+       This is set to FALSE in the recipes by default.
+
+       In the script diff_skycell.pl, there is a global variable 'do_photom' which is TRUE by default, 
+       but is set to FALSE if a) the reduction class is NOCONVDIFF or b) the run_state is not new (i.e, 'update' mode)
+       (the script changes the call in an inconsistent way, if do_photom is true, it appends -photometry, but
+       if it is false, it appends -Db PHOTOMETRY FALSE.  this could be made consistent.
+       (also note that it is bad practice to have hard-wired reduction classes)
+
+       But both of these situations are ignored because the test in ppSubCamera for data->photometry 
+       (set if PHOTOMETRY is true or -photometry is supplied) is ignored and the photometric analysis 
+       is always performed.
+
+     */ 
+
     // Now that the camera has been determined, we can read the recipe
     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, GDIFF_RECIPE); // Recipe for ppSim
@@ -380,94 +403,108 @@
     }
 
-    // psPhot input
-    if (data->photometry || 1) {
-        psphotModelClassInit();        // load implementation-specific models
-
-        pmFPAfile *psphot = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.INPUT");
-        if (!psphot) {
-            psError(psErrorCodeLast(), false, "Failed to build FPA from PSPHOT.INPUT");
-            return false;
-        }
-        if (psphot->type != PM_FPA_FILE_IMAGE) {
-            psError(psErrorCodeLast(), true, "PSPHOT.INPUT is not of type IMAGE");
-            return false;
-        }
-        pmFPAfileActivate(config->files, false, "PSPHOT.INPUT");
-
-        // Internal file for getting the PSF from the minuend
-        pmFPAfile *psf = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.PSF.LOAD");
-        if (!psf) {
-            psError(psErrorCodeLast(), false, "Failed to build FPA from PSPHOT.PSF.LOAD");
-            return false;
-        }
-        if (psf->type != PM_FPA_FILE_PSF) {
-            psError(psErrorCodeLast(), true, "PSPHOT.PSF.LOAD is not of type PSF");
-            return false;
-        }
-        pmFPAfileActivate(config->files, false, "PSPHOT.PSF.LOAD");
-
-        if (!psphotDefineFiles(config, psphot)) {
-            psError(psErrorCodeLast(), false, "Unable to set up psphot files.");
-            return false;
-        }
-
-        // Deactivate psphot output sources --- we want to define output source files of our own
-        pmFPAfile *psphotOutput = pmFPAfileSelectSingle(config->files, "PSPHOT.OUTPUT", 0);
-        psphotOutput->save = false;  // this one should NOT be set
-
-        pmFPAfile *outSources = defineOutputFile(config, output, false, "GDIFF.OUTPUT.SOURCES",
-                                                 PM_FPA_FILE_CMF);
-        if (!outSources) {
-            psError(psErrorCodeLast(), false, "Unable to set up output source file.");
-            return false;
-        }
-        checkFileruleFileSave(outSources, config);
-
-        if (data->inverse) {
-            pmFPAfile *invSources = defineOutputFile(config, inverse, false, "GDIFF.INVERSE.SOURCES",
-                                                     PM_FPA_FILE_CMF);
-            if (!invSources) {
-                psError(psErrorCodeLast(), false, "Unable to set up inverse source file.");
-                return false;
-            }
-            checkFileruleFileSave(invSources, config);
-        }
-
-	// files need to do the forced photometry on the positions of sources in the positive images
-        if (data->forcedPhot1) {
-	    // this pmFPAfile is used to carry sources detected in the positive image #1
-            pmFPAfile *posSources1 = defineOutputFile(config, input, true, "GDIFF.POS1.SOURCES", PM_FPA_FILE_CMF);
-            if (!posSources1) {
-                psError(psErrorCodeLast(), false, "Unable to set up forced source file.");
-                return false;
-            }
-            checkFileruleFileSave(posSources1, config);
-
-	    // this pmFPAfile is used to carry sources detected in the diff image @ the positions from positive image #1
-            pmFPAfile *frcSources1 = defineOutputFile(config, input, true, "GDIFF.FORCED1.SOURCES", PM_FPA_FILE_CMF);
-            if (!frcSources1) {
-                psError(psErrorCodeLast(), false, "Unable to set up forced source file.");
-                return false;
-            }
-            checkFileruleFileSave(frcSources1, config);
+    /* in ppSub, there is a recipe value 'PHOTOMETRY' which is supposed to enable / disable photometry analysis.
+       This is set to FALSE in the recipes by default.
+
+       In the script diff_skycell.pl, there is a global variable 'do_photom' which is TRUE by default, 
+       but is set to FALSE if a) the reduction class is NOCONVDIFF or b) the run_state is not new (i.e, 'update' mode)
+       (the script changes the call in an inconsistent way, if do_photom is true, it appends -photometry, but
+       if it is false, it appends -Db PHOTOMETRY FALSE.  this could be made consistent.
+       (also note that it is bad practice to have hard-wired reduction classes)
+
+       But both of these situations are ignored because the test in ppSubCamera for data->photometry 
+       (set if PHOTOMETRY is true or -photometry is supplied) is ignored and the photometric analysis 
+       is always performed.
+
+       Should we rationalize this?
+     */ 
+
+    // define the psphot I/O files
+    psphotModelClassInit();        // load implementation-specific models
+
+    pmFPAfile *psphot = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.INPUT");
+    if (!psphot) {
+	psError(psErrorCodeLast(), false, "Failed to build FPA from PSPHOT.INPUT");
+	return false;
+    }
+    if (psphot->type != PM_FPA_FILE_IMAGE) {
+	psError(psErrorCodeLast(), true, "PSPHOT.INPUT is not of type IMAGE");
+	return false;
+    }
+    pmFPAfileActivate(config->files, false, "PSPHOT.INPUT");
+
+    // Internal file for getting the PSF from the minuend
+    pmFPAfile *psf = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.PSF.LOAD");
+    if (!psf) {
+	psError(psErrorCodeLast(), false, "Failed to build FPA from PSPHOT.PSF.LOAD");
+	return false;
+    }
+    if (psf->type != PM_FPA_FILE_PSF) {
+	psError(psErrorCodeLast(), true, "PSPHOT.PSF.LOAD is not of type PSF");
+	return false;
+    }
+    pmFPAfileActivate(config->files, false, "PSPHOT.PSF.LOAD");
+
+    if (!psphotDefineFiles(config, psphot)) {
+	psError(psErrorCodeLast(), false, "Unable to set up psphot files.");
+	return false;
+    }
+
+    // Deactivate psphot output sources --- we want to define output source files of our own
+    pmFPAfile *psphotOutput = pmFPAfileSelectSingle(config->files, "PSPHOT.OUTPUT", 0);
+    psphotOutput->save = false;  // this one should NOT be set
+
+    pmFPAfile *outSources = defineOutputFile(config, output, false, "GDIFF.OUTPUT.SOURCES",
+					     PM_FPA_FILE_CMF);
+    if (!outSources) {
+	psError(psErrorCodeLast(), false, "Unable to set up output source file.");
+	return false;
+    }
+    checkFileruleFileSave(outSources, config);
+
+    if (data->inverse) {
+	pmFPAfile *invSources = defineOutputFile(config, inverse, false, "GDIFF.INVERSE.SOURCES",
+						 PM_FPA_FILE_CMF);
+	if (!invSources) {
+	    psError(psErrorCodeLast(), false, "Unable to set up inverse source file.");
+	    return false;
 	}
-
-        if (data->forcedPhot2) {
-	    // this pmFPAfile is used to carry sources detected in the positive image #2
-            pmFPAfile *posSources2 = defineOutputFile(config, ref, true, "GDIFF.POS2.SOURCES", PM_FPA_FILE_CMF);
-            if (!posSources2) {
-                psError(psErrorCodeLast(), false, "Unable to set up forced source file.");
-                return false;
-            }
-            checkFileruleFileSave(posSources2, config);
-
-	    // this pmFPAfile is used to carry sources detected in the diff image @ the positions from positive image #2
-            pmFPAfile *frcSources2 = defineOutputFile(config, ref, true, "GDIFF.FORCED2.SOURCES", PM_FPA_FILE_CMF);
-            if (!frcSources2) {
-                psError(psErrorCodeLast(), false, "Unable to set up forced source file.");
-                return false;
-            }
-	    checkFileruleFileSave(frcSources2, config);
-        }
+	checkFileruleFileSave(invSources, config);
+    }
+
+    // files need to do the forced photometry on the positions of sources in the positive images
+    if (data->forcedPhot1) {
+	// this pmFPAfile is used to carry sources detected in the positive image #1
+	pmFPAfile *posSources1 = defineOutputFile(config, input, true, "GDIFF.POS1.SOURCES", PM_FPA_FILE_CMF);
+	if (!posSources1) {
+	    psError(psErrorCodeLast(), false, "Unable to set up forced source file.");
+	    return false;
+	}
+	checkFileruleFileSave(posSources1, config);
+
+	// this pmFPAfile is used to carry sources detected in the diff image @ the positions from positive image #1
+	pmFPAfile *frcSources1 = defineOutputFile(config, input, true, "GDIFF.FORCED1.SOURCES", PM_FPA_FILE_CMF);
+	if (!frcSources1) {
+	    psError(psErrorCodeLast(), false, "Unable to set up forced source file.");
+	    return false;
+	}
+	checkFileruleFileSave(frcSources1, config);
+    }
+
+    if (data->forcedPhot2) {
+	// this pmFPAfile is used to carry sources detected in the positive image #2
+	pmFPAfile *posSources2 = defineOutputFile(config, ref, true, "GDIFF.POS2.SOURCES", PM_FPA_FILE_CMF);
+	if (!posSources2) {
+	    psError(psErrorCodeLast(), false, "Unable to set up forced source file.");
+	    return false;
+	}
+	checkFileruleFileSave(posSources2, config);
+
+	// this pmFPAfile is used to carry sources detected in the diff image @ the positions from positive image #2
+	pmFPAfile *frcSources2 = defineOutputFile(config, ref, true, "GDIFF.FORCED2.SOURCES", PM_FPA_FILE_CMF);
+	if (!frcSources2) {
+	    psError(psErrorCodeLast(), false, "Unable to set up forced source file.");
+	    return false;
+	}
+	checkFileruleFileSave(frcSources2, config);
     }
 
