Index: /trunk/psphot/src/psphot.h
===================================================================
--- /trunk/psphot/src/psphot.h	(revision 11381)
+++ /trunk/psphot/src/psphot.h	(revision 11382)
@@ -67,4 +67,5 @@
 
 // output functions
+bool            psphotAddPhotcode (psMetadata *recipe, pmConfig *config, pmFPAview *view);
 bool            psphotDumpMoments (psMetadata *recipe, psArray *sources);
 psMetadata     *psphotDefineHeader (psMetadata *recipe);
Index: /trunk/psphot/src/psphotOutput.c
===================================================================
--- /trunk/psphot/src/psphotOutput.c	(revision 11381)
+++ /trunk/psphot/src/psphotOutput.c	(revision 11382)
@@ -73,4 +73,23 @@
     }
     fclose (f);
+    return true;
+}
+
+bool psphotAddPhotcode (psMetadata *recipe, pmConfig *config, pmFPAview *view) {
+
+    bool status;
+
+    pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PSPHOT.INPUT");
+    assert (status);
+
+    // determine PHOTCODE from fpa & view, overwrite in recipe
+    // XXX test this:
+    char *photcode = pmConceptsPhotcodeForView (config, input, view);
+    assert (photcode);
+
+    psMetadataAddStr (recipe, PS_LIST_TAIL, "PHOTCODE", PS_META_REPLACE, "photcode from FPA concepts", photcode);
+    psLogMsg ("psphot", 3, "PHOTCODE is %s", photcode);
+
+    psFree (photcode);
     return true;
 }
Index: /trunk/psphot/src/psphotReadout.c
===================================================================
--- /trunk/psphot/src/psphotReadout.c	(revision 11381)
+++ /trunk/psphot/src/psphotReadout.c	(revision 11382)
@@ -21,4 +21,10 @@
     if (!pmReadoutGenerateMaskWeight (readout, true)) {
         psError (PSPHOT_ERR_CONFIG, false, "trouble creating mask and/or weight");
+        return false;
+    }
+
+    // set the photcode for this image
+    if (!psphotAddPhotcode (recipe, config, view)) {
+        psError (PSPHOT_ERR_CONFIG, false, "trouble defining the photcode");
         return false;
     }
