Index: trunk/ppSim/src/ppSimSequence.c
===================================================================
--- trunk/ppSim/src/ppSimSequence.c	(revision 19244)
+++ trunk/ppSim/src/ppSimSequence.c	(revision 19315)
@@ -43,4 +43,11 @@
         psArgumentRemove(argNum, &argc, argv);
         workdir = psStringCopy (argv[argNum]);
+        psArgumentRemove(argNum, &argc, argv);
+    }
+
+    char *ppsim_recipe = NULL;
+    if ((argNum = psArgumentGet (argc, argv, "-ppsim_recipe"))) {
+        psArgumentRemove(argNum, &argc, argv);
+        ppsim_recipe = psStringCopy (argv[argNum]);
         psArgumentRemove(argNum, &argc, argv);
     }
@@ -83,4 +90,6 @@
         fprintf (stderr, " (inject)   : an output file with commands to inject the images into the pipeline\n");
         fprintf (stderr, "options:\n");
+        fprintf (stderr, " -camera (camera) [otherwise must be set in sequences file]\n");
+        fprintf (stderr, " -ppsim_recipe (recipe)\n");
         fprintf (stderr, " -dbname (dbname)\n");
         fprintf (stderr, " -path (path)\n");
@@ -120,4 +129,8 @@
     if (tess_id) psStringAppend (&injectCommand, " --tess_id %s", tess_id);
 
+    // build the base ppSimCommand string
+    psString ppSimCommand = psStringCopy ("ppSim");
+    if (ppsim_recipe) psStringAppend (&ppSimCommand, " -recipe PPSIM %s", ppsim_recipe);
+
     unsigned long seed = psMetadataLookupS32 (&status, config, "RND_SEED");
     if (!status) seed = 0;
@@ -157,18 +170,29 @@
         }
 
+	// determine the camera for the sequence and define the ppSim command
+	if (camera == NULL) {
+	    camera = psMetadataLookupStr (&status, sequence, "CAMERA");
+	}
+
+	psString injectCommandReal = NULL;
+	psString ppSimCommandReal = NULL;
+
+	psStringAppend (&injectCommandReal, "%s --camera %s", injectCommand, camera);
+	psStringAppend (&ppSimCommandReal, "%s -camera %s", ppSimCommand, camera);
+
         if (!strcasecmp (type, "BIAS")) {
-            ppSimSequenceBias (simfile, inject, sequence, i, rng, path, basename, camera, injectCommand);
+            ppSimSequenceBias (simfile, inject, sequence, i, rng, path, basename, ppSimCommandReal, injectCommandReal);
             continue;
         }
         if (!strcasecmp (type, "DARK")) {
-            ppSimSequenceDark (simfile, inject, sequence, i, rng, path, basename, camera, injectCommand);
+            ppSimSequenceDark (simfile, inject, sequence, i, rng, path, basename, ppSimCommandReal, injectCommandReal);
             continue;
         }
         if (!strcasecmp (type, "FLAT")) {
-            ppSimSequenceFlat (simfile, inject, sequence, i, rng, path, basename, camera, injectCommand);
+            ppSimSequenceFlat (simfile, inject, sequence, i, rng, path, basename, ppSimCommandReal, injectCommandReal);
             continue;
         }
         if (!strcasecmp (type, "OBJECT")) {
-            ppSimSequenceObject (simfile, inject, sequence, i, rng, path, basename, camera, injectCommand);
+            ppSimSequenceObject (simfile, inject, sequence, i, rng, path, basename, ppSimCommandReal, injectCommandReal);
             continue;
         }
Index: trunk/ppSim/src/ppSimSequence.h
===================================================================
--- trunk/ppSim/src/ppSimSequence.h	(revision 19244)
+++ trunk/ppSim/src/ppSimSequence.h	(revision 19315)
@@ -12,8 +12,8 @@
 #include <psastro.h>
 
-bool ppSimSequenceBias 	 (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, char *camera, const char *injectCommand);
-bool ppSimSequenceDark 	 (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, char *camera, const char *injectCommand);
-bool ppSimSequenceFlat 	 (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, char *camera, const char *injectCommand);
-bool ppSimSequenceObject (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, char *camera, const char *injectCommand);
+bool ppSimSequenceBias 	 (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, const char *ppSimCommand, const char *injectCommand);
+bool ppSimSequenceDark 	 (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, const char *ppSimCommand, const char *injectCommand);
+bool ppSimSequenceFlat 	 (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, const char *ppSimCommand, const char *injectCommand);
+bool ppSimSequenceObject (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, const char *ppSimCommand, const char *injectCommand);
 
 #endif
Index: trunk/ppSim/src/ppSimSequenceBias.c
===================================================================
--- trunk/ppSim/src/ppSimSequenceBias.c	(revision 19244)
+++ trunk/ppSim/src/ppSimSequenceBias.c	(revision 19315)
@@ -1,11 +1,7 @@
 # include "ppSimSequence.h"
 
-bool ppSimSequenceBias (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, char *camera, const char *injectCommand) {
+bool ppSimSequenceBias (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, const char *ppSimCommand, const char *injectCommand) {
 
     bool status, setLevel, setRange;
-
-    if (camera == NULL) {
-	camera = psMetadataLookupStr (&status, sequence, "CAMERA");
-    }
 
     // optional details
@@ -19,33 +15,34 @@
     for (int i = 0; i < nImages; i++) {
 	    
-      psString command = NULL;
+	// define the output filename
+	psString filename = NULL;
+	if (path) {
+	    psStringAppend (&filename, "%s/%s.%03d.%03d", path, basename, nSeq, nImage);
+	} else {
+	    psStringAppend (&filename, "%s.%03d.%03d", basename, nSeq, nImage);
+	}
 
-      psStringAppend (&command, "ppSim -type BIAS");
-      psStringAppend (&command, " -camera %s", camera);
+	// define the ppSim command
+	psString command = NULL;
 
-      if (setLevel) psStringAppend (&command, " -biaslevel %f", level);
-      if (setRange) psStringAppend (&command, " -biasrange %f", range);
+	psStringAppend (&command, "%s -type BIAS", ppSimCommand);
 
-      // XXX need to add output filename
-      psString filename = NULL;
-      if (path) {
-	psStringAppend (&filename, "%s/%s.%03d.%03d", path, basename, nSeq, nImage);
-      } else {
-	psStringAppend (&filename, "%s.%03d.%03d", basename, nSeq, nImage);
-      }
-      psStringAppend (&command, " %s", filename);
+	if (setLevel) psStringAppend (&command, " -biaslevel %f", level);
+	if (setRange) psStringAppend (&command, " -biasrange %f", range);
+      
+	psStringAppend (&command, " %s", filename);
 
-      fprintf (simfile, "%s\n", command);
-      psFree (command);
+	fprintf (simfile, "%s\n", command);
+	psFree (command);
 			    
-      // path should be dirname/filename
-      command = psStringCopy (injectCommand);
-      psStringAppend (&command, " --camera %s", camera);
-      psStringAppend (&command, " %s*.fits",    filename);
-      fprintf (inject, "%s\n", command);
-      psFree (command);
-      psFree (filename);
+	// define the inject command
+	// path should be dirname/filename
+	command = psStringCopy (injectCommand);
+	psStringAppend (&command, " %s*.fits",    filename);
+	fprintf (inject, "%s\n", command);
+	psFree (command);
+	psFree (filename);
 
-      nImage ++;
+	nImage ++;
     }
     return true;
Index: trunk/ppSim/src/ppSimSequenceDark.c
===================================================================
--- trunk/ppSim/src/ppSimSequenceDark.c	(revision 19244)
+++ trunk/ppSim/src/ppSimSequenceDark.c	(revision 19315)
@@ -1,12 +1,8 @@
 # include "ppSimSequence.h"
 
-bool ppSimSequenceDark (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, char *camera, const char *injectCommand) {
+bool ppSimSequenceDark (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, const char *ppSimCommand, const char *injectCommand) {
 
     bool status, setRate;
     float min, max = 0;
-
-    if (camera == NULL) {
-	camera = psMetadataLookupStr (&status, sequence, "CAMERA");
-    }
 
     setRate = false;
@@ -30,9 +26,18 @@
 
 	for (int j = 0; j < n; j++) {
+
+	    // XXX need to add output filename
+	    psString filename = NULL;
+	    if (path) {
+		psStringAppend (&filename, "%s/%s.%03d.%03d", path, basename, nSeq, nImage);
+	    } else {
+		psStringAppend (&filename, "%s.%03d.%03d", basename, nSeq, nImage);
+	    }
+
+	    // define the ppSim command
 	    psString command = NULL;
 
-	    psStringAppend (&command, "ppSim -type DARK");
-	    psStringAppend (&command, " -camera %s", camera);
-
+	    psStringAppend (&command, "%s -type DARK", ppSimCommand);
+      
 	    if (setRate) {
 		double frnd = psRandomUniform(rng);
@@ -43,11 +48,4 @@
 	    psStringAppend (&command, " -exptime %f", exptime);
 
-	    // XXX need to add output filename
-	    psString filename = NULL;
-	    if (path) {
-		psStringAppend (&filename, "%s/%s.%03d.%03d", path, basename, nSeq, nImage);
-	    } else {
-		psStringAppend (&filename, "%s.%03d.%03d", basename, nSeq, nImage);
-	    }
 	    psStringAppend (&command, " %s", filename);
 
@@ -55,7 +53,7 @@
 	    psFree (command);
 			    
+	    // define the inject command
 	    // path should be dirname/filename
 	    command = psStringCopy (injectCommand);
-	    psStringAppend (&command, " --camera %s", camera);
 	    psStringAppend (&command, " %s*.fits",    filename);
 	    fprintf (inject, "%s\n", command);
Index: trunk/ppSim/src/ppSimSequenceFlat.c
===================================================================
--- trunk/ppSim/src/ppSimSequenceFlat.c	(revision 19244)
+++ trunk/ppSim/src/ppSimSequenceFlat.c	(revision 19315)
@@ -1,11 +1,7 @@
 # include "ppSimSequence.h"
 
-bool ppSimSequenceFlat (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, char *camera, const char *injectCommand) {
+bool ppSimSequenceFlat (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, const char *ppSimCommand, const char *injectCommand) {
 
     bool status;
-
-    if (camera == NULL) {
-	camera = psMetadataLookupStr (&status, sequence, "CAMERA");
-    }
 
     // determine the filters & exposure times
@@ -28,38 +24,38 @@
     for (int i = 0; i < filters->n; i++) {
 	    
-      // loop over the filters & exposure times
-      for (int j = 0; j < nSetup; j++) {
+	// loop over the filters & exposure times
+	for (int j = 0; j < nSetup; j++) {
 	    
-	psString command = NULL;
+	    // define the output filename
+	    psString filename = NULL;
+	    if (path) {
+		psStringAppend (&filename, "%s/%s.%03d.%03d", path, basename, nSeq, nImage);
+	    } else {
+		psStringAppend (&filename, "%s.%03d.%03d", basename, nSeq, nImage);
+	    }
 
-	psStringAppend (&command, "ppSim -type FLAT");
-	psStringAppend (&command, " -camera %s", camera);
+	    // define the ppSim comand
+	    psString command = NULL;
 
-	psStringAppend (&command, " -filter %s", (char *) filters->data[i]);
-	psStringAppend (&command, " -exptime %f", exptimes->data.F32[i]);
+	    psStringAppend (&command, "%s -type FLAT", ppSimCommand);
 
-	// XXX need to add output filename
-	psString filename = NULL;
-	if (path) {
-	  psStringAppend (&filename, "%s/%s.%03d.%03d", path, basename, nSeq, nImage);
-	} else {
-	  psStringAppend (&filename, "%s.%03d.%03d", basename, nSeq, nImage);
+	    psStringAppend (&command, " -filter %s", (char *) filters->data[i]);
+	    psStringAppend (&command, " -exptime %f", exptimes->data.F32[i]);
+
+	    psStringAppend (&command, " %s", filename);
+
+	    fprintf (simfile, "%s\n", command);
+	    psFree (command);
+
+	    // define the inject command
+	    // path should be dirname/filename
+	    command = psStringCopy (injectCommand);
+	    psStringAppend (&command, " %s*.fits",    filename);
+	    fprintf (inject, "%s\n", command);
+	    psFree (command);
+	    psFree (filename);
+
+	    nImage ++;
 	}
-	psStringAppend (&command, " %s", filename);
-
-
-	fprintf (simfile, "%s\n", command);
-	psFree (command);
-
-	// path should be dirname/filename
-	command = psStringCopy (injectCommand);
-	psStringAppend (&command, " --camera %s", camera);
-	psStringAppend (&command, " %s*.fits",    filename);
-	fprintf (inject, "%s\n", command);
-	psFree (command);
-	psFree (filename);
-
-	nImage ++;
-      }
     }
     return true;
Index: trunk/ppSim/src/ppSimSequenceObject.c
===================================================================
--- trunk/ppSim/src/ppSimSequenceObject.c	(revision 19244)
+++ trunk/ppSim/src/ppSimSequenceObject.c	(revision 19315)
@@ -1,5 +1,5 @@
 # include "ppSimSequence.h"
 
-bool ppSimSequenceObject (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, char *camera, const char *injectCommand) {
+bool ppSimSequenceObject (FILE *simfile, FILE *inject, psMetadata *sequence, int nSeq, psRandom *rng, const char *path, const char *basename, const char *ppSimCommand, const char *injectCommand) {
 
     bool status;
@@ -8,8 +8,4 @@
     // ppSim -camera $camera -type OBJECT -filter $filter -exptime $exptime
     //       -skyrate $sky -ra $ra -dec $dec -pa $pa -scale $scale -zp $zp -seeing $seeing $filename",
-
-    if (camera == NULL) {
-	camera = psMetadataLookupStr (&status, sequence, "CAMERA");
-    }
 
     // sequence reference coordinate
@@ -80,8 +76,16 @@
 			for (float pos = pos_min; pos <= pos_max; pos += pos_delta) {
 	      
+			    // define the output filename
+			    psString filename = NULL;
+			    if (path) {
+				psStringAppend (&filename, "%s/%s.%03d.%03d", path, basename, nSeq, nImage);
+			    } else {
+				psStringAppend (&filename, "%s.%03d.%03d", basename, nSeq, nImage);
+			    }
+
+			    // define the ppSim command
 			    psString command = NULL;
 
-			    psStringAppend (&command, "ppSim -type OBJECT");
-			    psStringAppend (&command, " -camera %s", camera);
+			    psStringAppend (&command, "%s -type OBJECT", ppSimCommand);
 			    psStringAppend (&command, " -filter %s", (char *) filters->data[i]);
 			    psStringAppend (&command, " -exptime %f", exptimes->data.F32[i]);
@@ -97,11 +101,4 @@
 			    psStringAppend (&command, " -seeing %f", seeing);
 
-			    // XXX need to add output filename
-			    psString filename = NULL;
-			    if (path) {
-				psStringAppend (&filename, "%s/%s.%03d.%03d", path, basename, nSeq, nImage);
-			    } else {
-				psStringAppend (&filename, "%s.%03d.%03d", basename, nSeq, nImage);
-			    }
 			    psStringAppend (&command, " %s", filename);
 
@@ -109,7 +106,7 @@
 			    psFree (command);
 			    
+			    // define the inject command
 			    // path should be dirname/filename
 			    command = psStringCopy (injectCommand);
-			    psStringAppend (&command, " --camera %s", camera);
 			    psStringAppend (&command, " %s*.fits",    filename);
 			    fprintf (inject, "%s\n", command);
