Index: trunk/psvideophot/src/dumpvideo.c
===================================================================
--- trunk/psvideophot/src/dumpvideo.c	(revision 32553)
+++ trunk/psvideophot/src/dumpvideo.c	(revision 32556)
@@ -2,4 +2,5 @@
 #include <assert.h>
 #include <pslib.h>
+#include <psmodules.h>
 
 int main (int argc, char **argv) {
@@ -9,4 +10,12 @@
 	exit (2);
     }
+
+    pmConfig *config = pmConfigRead(&argc, argv, NULL);
+    if (config == NULL) {
+        psErrorStackPrint(stderr, "Can't find site configuration!\n");
+        exit(EXIT_FAILURE);
+    }
+
+
 
     char *input   = argv[1];      // Input file name
@@ -19,5 +28,6 @@
     }
 
-    psFits *infile = psFitsOpen (input, "r"); // Input file
+    psString inputResolved = pmConfigConvertFilename(input, config, false, false);
+    psFits *infile = psFitsOpen (inputResolved, "r"); // Input file
     if (!infile) {
         fprintf (stderr, "Unable to open input file %s", input);
@@ -25,5 +35,6 @@
     }
 
-    psFits *outfile = psFitsOpen (output, "w"); // Output file
+    psString outputResolved = pmConfigConvertFilename(output, config, true, true);
+    psFits *outfile = psFitsOpen (outputResolved, "w"); // Output file
     if (!outfile) {
         fprintf (stderr, "Unable to open output file %s", output);
Index: trunk/psvideophot/src/psvideoLoop.c
===================================================================
--- trunk/psvideophot/src/psvideoLoop.c	(revision 32553)
+++ trunk/psvideophot/src/psvideoLoop.c	(revision 32556)
@@ -58,4 +58,6 @@
         ESCAPE("load failure for FPA");
     }
+
+    psArray *output = NULL;
 
     pmChip *chip;                       // Chip from FPA
@@ -136,5 +138,7 @@
             }
             psFree(video_extension_name);
-            psMetadataAddArray(cell->analysis, PS_LIST_TAIL, "VIDEO_DATA", 0, "", video_table);
+            // psMetadataAddArray(cell->analysis, PS_LIST_TAIL, "VIDEO_DATA", 0, "", video_table);
+
+            output = (psArray *) psMemIncrRefCounter(video_table);
 
             if (cell->readouts->n != video_table->n) {
@@ -195,4 +199,5 @@
                 double cnpix2 = psMetadataLookupS32(&status, row, "cnpix2");
 
+                // avoid errors from unused variables
                 (void) frame_start; (void) frame_complete;
                 (void) rowpre; (void) cnpix1; (void) cnpix2; (void) fwhm_x; (void) fwhm_y; (void) fwhm;
@@ -206,8 +211,9 @@
                 double star_readout_y = (centroid_y - cnpix2) / yBin;
 
+#ifdef notdef
                 printf("%4d %9.2f %9.2f %9.2f %.1f %.1f %9.6f %6.3f %6.3f %6.3f\n",
                         frame, flux, snr, sky, star_readout_x, star_readout_y, frame_complete - frame_start,
                             fwhm, fwhm_x, fwhm_y);
-
+#endif
                 psStatsInit(stats);
 
@@ -221,19 +227,32 @@
                 double stddev = stats->sampleStdev;
                 double median = stats->sampleMedian;
+                double vpFlux = 0;
+                double vpSum = 0;
+                double xy[2] = {0, 0};
                 if (stddev > threshold) {
 
-                    double sum = 0;
-                    // XXX: use a point data type
-                    double xy[2];
-                    Centering(readout->image, EDGE, &sum, xy, median);
-                    double ourFlux;
-                    ourFlux = SubSum(readout->image, xy, median);
-
-                    printf("%4d %9.2f %9.2f %9.2f %.1f %.1f %9.2f\n",
-                             frame, ourFlux, ourFlux/stddev, median, xy[0], xy[1], stddev);
+                    Centering(readout->image, EDGE, &vpSum, xy, median);
+
+                    vpFlux = SubSum(readout->image, xy, median);
+
+//                    printf("%4d %9.2f %9.2f %9.2f %.1f %.1f %9.2f\n",
+//                             frame, vpFlux, vpFlux/median, median, xy[0], xy[1], stddev);
                 } else {
-                    printf("%4d %9.2f %9.2f %8.2f\n",
-                            frame, 0.0,   stddev, median);
-                }
+//                    printf("%4d %9.2f %9.2f %8.2f\n",
+//                            frame, 0.0,   stddev, median);
+                }
+                if (frame % 60 == 0) {
+                    printf("frame  flux        sky       snr     X    Y     dt        fwhm   fwhm_x fwhm_y  vp_flux   vp_median vp_sum    vp_stddev vp_x vp_y\n");
+                }
+                printf("%4d   %9.2f %9.2f %9.2f %.1f %.1f %9.6f %6.3f %6.3f %6.3f   %9.2f %9.2f %9.2f %9.2f %.1f %.1f\n",
+                        frame, flux, sky, snr, star_readout_x, star_readout_y, frame_complete - frame_start,
+                            fwhm, fwhm_x, fwhm_y,
+                            vpFlux, median, vpSum, stddev, xy[0], xy[1]);
+                psMetadataAddF32(row, PS_LIST_TAIL, "vp_flux", 0, "vp flux", vpFlux);
+                psMetadataAddF32(row, PS_LIST_TAIL, "vp_median", 0, "vp meidan", median);
+                psMetadataAddF32(row, PS_LIST_TAIL, "vp_stddev", 0, "vp meidan", stddev);
+                psMetadataAddF32(row, PS_LIST_TAIL, "vp_sum", 0, "vp sum of source", vpSum);
+                psMetadataAddF32(row, PS_LIST_TAIL, "vp_x", 0, "centroid x from vp", xy[0]);
+                psMetadataAddF32(row, PS_LIST_TAIL, "vp_y", 0, "centroid y from vp", xy[1]);
             }
             psLogMsg ("psvideophotLoop", 5, "Done processing video cell");
@@ -262,11 +281,22 @@
     psFree(view);
 
-    // Dump configuration
-    psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG");
-    if (dump_file) {
-        if (!pmConfigDump(config, dump_file)) {
-            ESCAPE("Unable to dump configuration.");
-        }
-    }
+    psString outputName = psMetadataLookupStr(&status, config->arguments, "OUTPUT");
+    psString realName = pmConfigConvertFilename(outputName, config, true, true);
+    if (!realName) {
+        psError(PS_ERR_UNKNOWN, false, "failed to convert filename for %s", outputName);
+        ESCAPE("cannot save output");
+    }
+    psFits *outFits = psFitsOpen(realName, "w");
+    if (!outFits) {
+        psError(PS_ERR_UNKNOWN, false, "failed to open output filename for %s", outputName);
+        ESCAPE(" ");
+    }
+
+    psMetadata *outputHeader = lastHDU ? lastHDU->header : NULL;
+    if (!psFitsWriteTable(outFits, outputHeader, output, "videophotemetry")) {
+        psError(PS_ERR_UNKNOWN, false, "failed to write videophotometry table");
+        ESCAPE("cannot write output");
+    }
+    psFitsClose(outFits);
 
     return true;
Index: trunk/psvideophot/src/psvideophotArguments.c
===================================================================
--- trunk/psvideophot/src/psvideophotArguments.c	(revision 32553)
+++ trunk/psvideophot/src/psvideophotArguments.c	(revision 32556)
@@ -180,5 +180,5 @@
 
     // Add the input and output images (which remain on the command-line) to the arguments list
-    psMetadataAddStr(config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Name of the output image", argv[1]);
+    psMetadataAddStr(config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Name of the output table", argv[1]);
 
     return config;
Index: trunk/psvideophot/src/psvideophotParseCamera.c
===================================================================
--- trunk/psvideophot/src/psvideophotParseCamera.c	(revision 32553)
+++ trunk/psvideophot/src/psvideophotParseCamera.c	(revision 32556)
@@ -7,6 +7,4 @@
 psvideophotOptions *psvideophotParseCamera(pmConfig *config)
 {
-    bool status = false;
-
     if (!psvideophotDefineFile(config, NULL, "PSVIDEOPHOT.INPUT", "INPUT", PM_FPA_FILE_IMAGE, PM_DETREND_TYPE_NONE)) {
         psError(PS_ERR_IO, false, "Can't find an input image source");
@@ -16,155 +14,13 @@
     psAssert(input, "We just put it there!");
 
+#ifdef notyet
     // add recipe options supplied on command line
+    bool status = false;
     psMetadata *recipe  = psMetadataLookupPtr(&status, config->recipes, RECIPE_NAME);
+#endif
 
     // parse the options from the metadata format to the psvideophotOptions structure
     psvideophotOptions *options = psvideophotOptionsParse(config);
 
-    // the following are defined from the argument list, if given,
-    // otherwise they revert to the config information
-    // not all input or output images are used in a given recipe
-    
-    int nThreads = psMetadataLookupS32(&status, config->arguments, "NTHREADS");
-    if (nThreads > 0) {
-        int nScanRows = psMetadataLookupS32(&status, recipe, "SCAN.ROWS");
-        pmDetrendSetThreadTasks(nScanRows);
-    }
-
-    // the following files are output targets
-    pmFPAfile *outImage = pmFPAfileDefineOutput(config, input->fpa, "PSVIDEOPHOT.OUTPUT");
-    if (!outImage) {
-        psError(PS_ERR_IO, false, _("Unable to generate output file from PSVIDEOPHOT.OUTPUT"));
-        psFree(options);
-        return NULL;
-    }
-    if (outImage->type != PM_FPA_FILE_OBJ) {
-        psError(PS_ERR_IO, true, "PSVIDEOPHOT.OUTPUT is not of type OBJ");
-        psFree(options);
-        return NULL;
-    }
-    
-    // XXX should these be bound explicitly to the outImage->fpa rather than the input->fpa?
-    pmFPAfile *chipImage = pmFPAfileDefineChipMosaic(config, input->fpa, "PSVIDEOPHOT.CHIP");
-    if (!chipImage) {
-        psError(PS_ERR_IO, false, _("Unable to generate new file from PSVIDEOPHOT.CHIP"));
-        psFree(options);
-        return NULL;
-    }
-    if (chipImage->type != PM_FPA_FILE_OBJ) {
-        psError(PS_ERR_IO, true, "PSVIDEOPHOT.CHIP is not of type OBJ");
-        psFree(options);
-        return NULL;
-    }
-    
-
-    // chipImage    -> psphotInput  (pmFPAfileDefineFromFile)       : fpa is constructed
-    // psphotInput  -> psphotOutput (pmFPAfileDefineOutputFromFile) : fpa is equated
-    // psphotOutput -> psastroInput (pmFPAfileDefineInput)          : fpa is ref-copied
-    // psastroInput -> psastroModel (pmFPAfileDefineFromArgs        : fpa is ref-copied
-    // psastroInput -> psastroModel (pmFPAfileDefineFromConf        : fpa is constructed
-    // psastroInput -> psastroModel (pmFPAfileDefineFromDetDB       : fpa is constructed (pmDetrendSelect uses input concepts )
-
-    // For photometry, we operate on the chip-mosaicked image
-    // we create a copy of the mosaicked image for psphot so we can write out a clean image
-    
-
-        // this file is just used as a carrier; output files (eg, PSPHOT.RESID) are defined by
-        // psphotDefineFiles
-        pmFPAfile *psphotInput = pmFPAfileDefineFromFile (config, chipImage, 1, 1, "PSPHOT.INPUT");
-        PS_ASSERT (psphotInput, false);
-
-        // specify the number of psphot input images
-        psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", 1);
-
-        // define associated psphot input/output files
-        if (!psphotDefineFiles (config, psphotInput)) {
-            psError(PSPHOT_ERR_CONFIG, false,
-                    "Trouble defining the additional input/output files for psphot");
-            return false;
-        }
-    
-
-    // For photometry, we operate on the chip-mosaicked image
-    
-
-    // save any of these files?
-    outImage->save   = options->BaseFITS;
-    
-
-    chipImage->save  = options->ChipFITS;
-    
-
-    
-    // outImage is used as a carrier: input to chipImage -> require the data to remain at the CHIP level
-    outImage->freeLevel = PS_MIN(outImage->freeLevel, PM_FPA_LEVEL_CHIP);
-    outImage->dataLevel = outImage->freeLevel;
-    outImage->fileLevel = PS_MIN(outImage->fileLevel, outImage->dataLevel);
-
-    // outMask and outVariance must be freed at the same level as outImage (all freed by pmFPAFreeData)
-    
-
-    // the input data is the same as the outImage data : force the free levels to match
-    input->freeLevel = PS_MIN(outImage->freeLevel, input->freeLevel);
-
-    // define the binned target files (which may just be carriers for some camera configurations)
-    
-    // Chip selection: turn on only the chips specified (pass status to suppress missing-key log msg)
-    char *chipLine = psMetadataLookupStr(&status, config->arguments, "CHIP_SELECTIONS");
-    psArray *chips = psStringSplitArray(chipLine, ",", false);
-    if (chips->n > 0) {
-        pmFPASelectChip (input->fpa, -1, true); // deselect all chips
-        for (int i = 0; i < chips->n; i++) {
-            int chipNum = atoi(chips->data[i]);
-            if (! pmFPASelectChip(input->fpa, chipNum, false)) {
-                psError(PS_ERR_IO, false, "Chip number %d doesn't exist in camera.\n", chipNum);
-                psFree(options);
-                return false;
-            }
-        }
-    }
-    psFree (chips);
-
-    if (psMetadataLookupBool(NULL, config->arguments, "INPUT_IS_FRINGE")) {
-        // It's a fringe file, so change the file type
-        input->type = PM_FPA_FILE_FRINGE;
-        outImage->type = PM_FPA_FILE_FRINGE;
-    }
-    if (psMetadataLookupBool(NULL, config->arguments, "INPUT_IS_DARK")) {
-        // It's a dark file, so change the file type
-        input->type = PM_FPA_FILE_DARK;
-        outImage->type = PM_FPA_FILE_DARK;
-        // Turn off compression --- there are just too many nasties that can happen
-        psFree(outImage->compression);
-        outImage->compression = NULL;
-        psFree(outImage->options);
-        outImage->options = NULL;
-    }
-
-    // Turn off mask and variance output if we're not doing anything interesting
-    
-    if (psTraceGetLevel("psvideophot.config") > 0) {
-        // Get a look inside all the files.
-        psMetadataIterator *filesIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, NULL);
-        psMetadataItem *item;               // Item from iteration
-        fprintf(stderr, "Files:\n");
-        while ((item = psMetadataGetAndIncrement(filesIter))) {
-            pmFPAfile *file = item->data.V; // File of interest
-            fprintf(stderr, "%s: %p %p %p (%p) %p\n", file->name,
-                    file->src, file->fpa,
-                    file->camera, file->fpa->camera, file->format);
-        }
-        psFree(filesIter);
-    }
-
-    // Change the input dark type between the old (IMAGE) and new (multi-DARK).
-    // Hopefully this is a temporary change until we all move over to using the new dark types
-    bool mdok;                          // Status of MD lookup
-    if (options->doDark && psMetadataLookupBool(&mdok, recipe, "OLDDARK")) {
-        pmFPAfile *dark = psMetadataLookupPtr(NULL, config->files, "PSVIDEOPHOT.DARK");
-        assert(dark);
-        dark->type = PM_FPA_FILE_IMAGE;
-    }
-
     return (options);
 }
