Index: /trunk/psvideophot/src/Makefile.am
===================================================================
--- /trunk/psvideophot/src/Makefile.am	(revision 32552)
+++ /trunk/psvideophot/src/Makefile.am	(revision 32553)
@@ -1,3 +1,4 @@
-bin_PROGRAMS = psvideophot
+bin_PROGRAMS =  psvideophot \
+		dumpvideo
 
 noinst_HEADERS = \
@@ -40,4 +41,9 @@
 	psvideophotVersion.c
 
+dumpvideo_CFLAGS = $(PSVIDEOPHOT_CFLAGS) $(PPSTATS_CFLAGS) $(PSASTRO_CFLAGS) $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
+dumpvideo_LDFLAGS = $(PSVIDEOPHOT_LIBS) $(PSASTRO_LIBS) $(PPSTATS_LIBS) $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
+dumpvideo_SOURCES = \
+	dumpvideo.c
+
 CLEANFILES = *~
 
Index: /trunk/psvideophot/src/dumpvideo.c
===================================================================
--- /trunk/psvideophot/src/dumpvideo.c	(revision 32553)
+++ /trunk/psvideophot/src/dumpvideo.c	(revision 32553)
@@ -0,0 +1,64 @@
+#include <stdio.h>
+#include <assert.h>
+#include <pslib.h>
+
+int main (int argc, char **argv) {
+
+    if (argc < 4) {
+        fprintf (stderr, "USAGE: dumpvideo (input) (extname) (output) [-includetable]\n");
+	exit (2);
+    }
+
+    char *input   = argv[1];      // Input file name
+    char *extname = argv[2];      // Extension of interest
+    char *output  = argv[3];      // Output file name
+
+    bool includetable = false;
+    if (argc > 4) {
+        includetable = true;
+    }
+
+    psFits *infile = psFitsOpen (input, "r"); // Input file
+    if (!infile) {
+        fprintf (stderr, "Unable to open input file %s", input);
+        exit (PS_EXIT_DATA_ERROR);
+    }
+
+    psFits *outfile = psFitsOpen (output, "w"); // Output file
+    if (!outfile) {
+        fprintf (stderr, "Unable to open output file %s", output);
+        exit(PS_EXIT_DATA_ERROR);
+    }
+
+    if (!psFitsMoveExtName (infile, extname)) {
+        fprintf (stderr, "Unable to find extname %s\n", extname);
+        exit(PS_EXIT_DATA_ERROR);
+    }
+
+    psMetadata *header = psFitsReadHeader (NULL, infile);
+
+    psRegion region = {0, 0, 0, 0};
+    psArray *cube = psFitsReadImageCube (infile, region);
+
+    psFitsWriteImageCube (outfile, header, cube, extname);
+
+    if (includetable) {
+        psString video_extname = NULL;
+        psStringAppend(&video_extname, "video_table_%s", extname);
+        if (!psFitsMoveExtName (infile, video_extname)) {
+            fprintf (stderr, "Unable to find extname %s\n", video_extname);
+            exit(PS_EXIT_DATA_ERROR);
+        }
+        psArray *table = psFitsReadTable(infile);
+        if (!psFitsWriteTable(outfile, NULL, table, video_extname)) {
+            fprintf (stderr, "Unable to write video table video_extname %s\n", video_extname);
+            exit(PS_EXIT_DATA_ERROR);
+        }
+    }
+
+    psFitsClose(infile);
+    psFitsClose(outfile);
+
+    return PS_EXIT_SUCCESS;
+}
+    
Index: /trunk/psvideophot/src/psvideoLoop.c
===================================================================
--- /trunk/psvideophot/src/psvideoLoop.c	(revision 32552)
+++ /trunk/psvideophot/src/psvideoLoop.c	(revision 32553)
@@ -44,4 +44,7 @@
     }
 
+    psString class_id = psMetadataLookupStr(&status, config->arguments, "CLASS_ID");
+    psString cell_id = psMetadataLookupStr(&status, config->arguments, "CELL_ID");
+
 
     pmConfigCamerasCull(config, NULL);
@@ -59,10 +62,15 @@
     while ((chip = pmFPAviewNextChip(view, input->fpa, 1)) != NULL) {
         psLogMsg ("psvideophotLoop", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
+        psString chipName = psMetadataLookupStr(&status, chip->concepts, "CHIP.NAME");
+        if (strcmp(chipName, class_id)) {
+            continue;
+        }
         if (!chip->process || !chip->file_exists) {
-            continue;
+            ESCAPE("target chip has no data");
         }
         if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
             ESCAPE("load failure for Chip");
         }
+        (void) class_id;
 
         double threshold = THRESHOLD;
@@ -72,10 +80,16 @@
         while ((cell = pmFPAviewNextCell(view, input->fpa, 1)) != NULL) {
             psLogMsg ("psvideophotLoop", 5, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
+            psString cellName = psMetadataLookupStr(&status, cell->concepts, "CELL.NAME");
+            if (strcmp(cellName, cell_id)) {
+                continue;
+            }
             if (!cell->process || !cell->file_exists) {
-                continue;
+                ESCAPE("target cell has no data");
             }
             if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
                 ESCAPE("load failure for Cell");
             }
+
+	    psLogMsg("psvideophotLoop", 1, "Found target cell %s %d. %ld readouts\n", cellName, view->cell, cell->readouts->n);
 
             // Put version information into the header
@@ -87,9 +101,7 @@
 
             if (cell->readouts->n <2) {
-	      continue; 
+              psLogMsg("psvideophotLoop", 1, "cell %s has only %ld readouts\n", cellName, cell->readouts->n);
+              ESCAPE("invalid video Cell");
 	    }
-
-            psString cellName = psMetadataLookupStr(&status, cell->concepts, "CELL.NAME");
-	    psLogMsg("psvideophotLoop", 1, "Found video cell %s %d\n", cellName, view->cell);
 
             // get the position of this cell on the chip 
@@ -114,6 +126,8 @@
 
             // go find the video extension data
-            psString video_extension_name = NULL;
-            psStringAppend(&video_extension_name, "video_table_%s", cellName);
+            psString video_extension_name = psMetadataLookupStr(&status, config->arguments, "VIDEOEXTNAME");
+            if (!video_extension_name) {
+                psStringAppend(&video_extension_name, "video_table_%s", cellName);
+            }
             psArray *video_table = readVideoTable(input, video_extension_name);
             if (!video_table) {
@@ -121,4 +135,5 @@
                 ESCAPE("invalid image file");
             }
+            psFree(video_extension_name);
             psMetadataAddArray(cell->analysis, PS_LIST_TAIL, "VIDEO_DATA", 0, "", video_table);
 
Index: /trunk/psvideophot/src/psvideophotArguments.c
===================================================================
--- /trunk/psvideophot/src/psvideophotArguments.c	(revision 32552)
+++ /trunk/psvideophot/src/psvideophotArguments.c	(revision 32553)
@@ -6,24 +6,10 @@
 
 static void usage (void) {
-    fprintf(stderr, "USAGE: psvideophot [-file INPUT.fits] [-list INPUT.txt] OUTPUT\n\n");
+    fprintf(stderr, "USAGE: psvideophot [-file INPUT.fits] [-list INPUT.txt] OUTPUT -class_id CLASS_ID -cell_id CELL_ID\n\n");
     fprintf(stderr, "Optional arguments:\n");
     fprintf(stderr, "\t-stats STATS.mdc: Output statistics into STATS.mdc\n");
-    fprintf(stderr, "\t-isfringe: The input image contains fringe data.\n");
-    fprintf(stderr, "\t-isdark: The input image contains dark data.\n");
-    fprintf(stderr, "\t-usemask MASKVAL: Use this mask value (override recipe).\n");
-    fprintf(stderr, "\t-chip CHIPNUM: Only process this chip number.\n");
-    fprintf(stderr, "\t-norm VALUE: Divide through by this value when done.\n");
-    fprintf(stderr, "\t-normlist file.mdc: normalizations by class_id.\n");
-    fprintf(stderr, "\t-video: process video cells\n");
+    fprintf(stderr, "\t-video_extname VIDEOEXTNAME: EXTNAME for video table\n");
     fprintf(stderr, "\n");
     fprintf(stderr, "Input options (single file / file list):\n");
-    fprintf(stderr, "\t-noisemap/-noisemaplist: Noise Map image.\n");
-    fprintf(stderr, "\t-bias/-biaslist: Bias image.\n");
-    fprintf(stderr, "\t-dark/-darklist: Dark image.\n");
-    fprintf(stderr, "\t-shutter/-shutterlist: Shutter image.\n");
-    fprintf(stderr, "\t-flat/-flatlist: Flat image.\n");
-    fprintf(stderr, "\t-mask/-masklist: Mask image.\n");
-    fprintf(stderr, "\t-fringe/-fringelist: Fringe image and data.\n");
-    fprintf(stderr, "\t-linearity/-linearlist: linearity correction file.\n");
     fprintf(stderr, "\n");
     exit (2);
@@ -63,4 +49,29 @@
     // psMetadata *options = psMetadataAlloc ();
     // psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "PSVIDEOPHOT.OPTIONS",  PS_DATA_METADATA, "", options);
+
+    if ((argnum = psArgumentGet(argc, argv, "-class_id"))) {
+        psArgumentRemove(argnum, &argc, argv);
+        psMetadataAddStr(config->arguments, PS_LIST_TAIL, "CLASS_ID", PS_META_REPLACE,
+                         "Chip to process", argv[argnum]);
+        psArgumentRemove(argnum, &argc, argv);
+    } else {
+        fprintf(stderr, "-class_id is required\n");
+        usage();
+    }
+    if ((argnum = psArgumentGet(argc, argv, "-cell_id"))) {
+        psArgumentRemove(argnum, &argc, argv);
+        psMetadataAddStr(config->arguments, PS_LIST_TAIL, "CELL_ID", PS_META_REPLACE,
+                         "Cell to process", argv[argnum]);
+        psArgumentRemove(argnum, &argc, argv);
+    } else {
+        fprintf(stderr, "-cell_id is required\n");
+        usage();
+    }
+    if ((argnum = psArgumentGet(argc, argv, "-video_extname"))) {
+        psArgumentRemove(argnum, &argc, argv);
+        psMetadataAddStr(config->arguments, PS_LIST_TAIL, "VIDEOEXTNAME", PS_META_REPLACE,
+                         "EXTNAME of video table", argv[argnum]);
+        psArgumentRemove(argnum, &argc, argv);
+    }
 
     if ((argnum = psArgumentGet(argc, argv, "-stats"))) {
@@ -117,4 +128,5 @@
     // the input file is a required argument; if not found, we will exit
     pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list");
+    pmConfigFileSetsMD (config->arguments, &argc, argv, "ASTROM", "-astrom", "-astromlist");
 
     // if these command-line options are supplied, load the file name lists into config->arguments
