Index: trunk/ippMonitor/Makefile.in
===================================================================
--- trunk/ippMonitor/Makefile.in	(revision 28597)
+++ trunk/ippMonitor/Makefile.in	(revision 28601)
@@ -18,5 +18,6 @@
 $(DESTBIN)/czartool_getServerStatus.pl \
 $(DESTBIN)/build_histogram.dvo \
-
+$(DESTBIN)/helpers.dvo \
+$(DESTBIN)/plot_x_vs_y.dvo
 
 RAWSRC = \
@@ -36,4 +37,6 @@
 $(DESTWWW)/ipp.load.dat \
 $(DESTWWW)/ipp.load.php \
+$(DESTWWW)/ipp.plots.dat \
+$(DESTWWW)/ipp.plots.php \
 $(DESTWWW)/ipp.science.dat \
 $(DESTWWW)/ipp.science.php \
@@ -55,4 +58,7 @@
 $(DESTWWW)/histogram.php \
 $(DESTWWW)/show_and_delete_image.php \
+$(DESTWWW)/scatterPlot.php \
+$(DESTWWW)/select_forms.php \
+$(DESTWWW)/plotHistogram.php \
 
 
@@ -178,5 +184,15 @@
 $(DESTWWW)/flatcorrChip.php \
 $(DESTWWW)/flatcorrCamera.php \
-$(DESTWWW)/maskStats.php
+$(DESTWWW)/maskStats.php \
+$(DESTWWW)/simplePlotRawImage.php \
+$(DESTWWW)/simplePlotChipImage.php \
+$(DESTWWW)/simplePlotCamImage.php \
+$(DESTWWW)/histogramBackgroundImage.php \
+$(DESTWWW)/histogramCamProcessedExpImage.php \
+$(DESTWWW)/histogramChipProcessedImfileFwhmMajorImage.php \
+$(DESTWWW)/scatterPlotAirMassFwhmImage.php \
+$(DESTWWW)/scatterCpiBgReMaImage.php \
+$(DESTWWW)/scatterCpiBgReMpImage.php \
+$(DESTWWW)/scatterCpiBgReSaImage.php
 
 PICTURES = \
@@ -206,4 +222,7 @@
 	ln -s $(DESTWWW)/Login.php $@
 
+$(SRC)/%Image.php: $(DEF)/%Image.d $(DEF)/autocodeImage.php $(GENERATE)
+	@if [ ! -d $(SRC) ]; then mkdir -p $(SRC); fi
+	$(GENERATE) $< $(DEF)/autocodeImage.php $@
 $(SRC)/%.php: $(DEF)/%.d $(DEF)/autocode.php $(GENERATE)
 	@if [ ! -d $(SRC) ]; then mkdir -p $(SRC); fi
@@ -211,4 +230,8 @@
 
 # generated php code is built into SRC first
+$(DESTWWW)/%Image.php: $(SRC)/%Image.php
+	@if [ ! -d $(DESTWWW) ]; then mkdir -p $(DESTWWW) || exit; fi
+	rm -f $(DESTWWW)/$*Image.php || exit
+	cp $(SRC)/$*Image.php $(DESTWWW)/$*Image.php || exit
 $(DESTWWW)/%.php: $(SRC)/%.php
 	@if [ ! -d $(DESTWWW) ]; then mkdir -p $(DESTWWW) || exit; fi
Index: trunk/ippMonitor/def/autocodeImage.php
===================================================================
--- trunk/ippMonitor/def/autocodeImage.php	(revision 28601)
+++ trunk/ippMonitor/def/autocodeImage.php	(revision 28601)
@@ -0,0 +1,169 @@
+<?php 
+
+include 'ipp.php';
+
+$ID = checkID ();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+$db = dbconnect($ID['proj']);
+
+if ($ID['menu']) {
+  $myMenu = $ID['menu'];
+} else {
+  $myMenu = "$MENU";
+}
+
+menu($myMenu, '$TITLE', '$STYLE', $ID['link'], $ID['proj']);
+
+echo "<p> $TITLE </p>";
+
+// set up the form
+echo "<form action=\"$FILE\" method=\"POST\">\n";
+
+$restricted = 0;
+
+// define restrictiosn to the queries
+// ** TABLE RESTRICTIONS **
+
+if ($restricted == 0) {//Don't select anything
+  if ($WHERE == "") {
+    $WHERE = "WHERE (0 > 1)";
+  } else {
+    $WHERE = "WHERE (0 > 1)";
+  }
+}
+
+// get the result table count
+$sql = "SELECT count(*) FROM $TABLE $WHERE";
+
+$qry = $db->query($sql);
+if (dberror($qry)) {
+  echo "<b>error reading $TABLE table count</b><br>\n";
+  echo "<br><small><b> count query : $sql </b></small><br>\n";
+  menu_end();
+}
+if (!$qry->fetchInto($row)) {
+  echo "<b>error reading $TABLE table count</b><br>\n";
+  echo "<br><small><b> count query : $sql </b></small><br>\n";
+  menu_end();
+}
+$nValues = $row[0];
+echo "<b>$nValues match selection</b><br>\n";
+
+$sql = "SELECT $TOPLOT FROM $TABLE $WHERE";
+$qry = $db->query($sql);
+
+if (dberror($qry)) {
+  echo "<b>error reading $TABLE table</b><br>\n";
+  echo "<br><small><b> table query : $sql </b></small><br>\n";
+  menu_end();
+}
+
+// ** HEAD CODE **
+
+// ** BUTTON RESTRICTIONS **
+navigate_buttons ($rowStart, $rowLast, $dTABLE, $rowTotal, $buttonLink, $ID, '$FILE');
+
+echo "&nbsp; : &nbsp; or enter start row: <input type=\"text\" name=\"from\" size=\"5\" value=\"$rowStart\">\n";
+
+// set up the table
+echo "<table class=list>\n";
+
+// echo "<tr><td></td>\n"; // first field is a label set below for the query rows only
+// ** TABLE HEADER **
+// echo "</tr>\n";
+
+// query restriction form
+// echo "<tr>\n";
+// echo "<td class=list> <input type=\"text\" name=\"expID\"></td>\n";
+// ** TABLE QUERY **
+// echo "</tr>\n";
+
+// query restriction form
+// echo "<tr>\n";
+// echo "<td class=list> <input type=\"text\" name=\"expID\"></td>\n";
+// TABLE QUERY 
+// echo "</tr>\n";
+
+// close the table and form
+echo "</table>\n";
+echo "<input type=\"submit\" name=\"constraints\" value=\"refine search\">\n";
+$pass = $ID['pass'];
+$proj = $ID['proj'];
+$menu = $ID['menu'];
+echo "<input type=\"hidden\" name=\"pass\" value=\"$pass\">\n";
+echo "<input type=\"hidden\" name=\"proj\" value=\"$proj\">\n";
+echo "<input type=\"hidden\" name=\"menu\" value=\"$menu\">\n";
+echo "</form>\n";
+
+if ($row[0] == 0) {
+  menu_end();
+}
+
+$datFilename = tempnam("/tmp", "dvodat.");
+$pngFilename = $datFilename.".png";
+
+$datfile = fopen($datFilename, "w");
+chmod($datFilename, 0777);
+
+// output the results to tmpfile
+while ($qry->fetchInto($row)) {
+  $line = "";
+  foreach ($row as $i => $value) {
+    switch ($value) {
+    case 'g.00000':
+      $filter = 1;
+      break;
+    case 'r.00000':
+      $filter = 2;
+      break;
+    case 'i.00000':
+      $filter = 3;
+      break;
+    case 'z.00000':
+      $filter = 4;
+      break;
+    case 'y.00000':
+      $filter = 5;
+      break;
+    case 'w.00000':
+      $filter = 6;
+      break;
+    case 'OPEN':
+      $filter = 0;
+      break;
+    default:
+      $filter = $value;
+      break;
+    }
+    $line .= "$filter ";
+  }
+  if (preg_match('/^[ \t]*$/', $line) == 0) {//Don't write empty lines
+    $line = preg_replace('/[ \t]*$/', '', $line);
+    fwrite ($datfile, $line."\n");
+  }
+}
+fclose($datfile);
+
+echo "<img src=\"$PLOTTER?input=$datFilename&output=$pngFilename&title='$PLOTTITLE'\"><br>\n";
+
+$wait = shell_exec("sleep 2");
+
+// ** TAIL CODE **
+
+echo "<small> WHERE: $WHERE<br><br></small>\n";
+echo "<small> SQL: $sql<br><br></small>\n";
+
+//menu_end();
+echo "</td></tr></table>\n";
+
+echo "Temporary files are [$datFilename] and [$pngFilename]\n";
+
+echo "</body></html>\n\n";
+
+/* $deleteFile = shell_exec("rm -f $datFilename"); */
+/* $deleteFile = shell_exec("rm -f $pngFilename"); */
+
+?>
Index: trunk/ippMonitor/def/histogramBackgroundImage.d
===================================================================
--- trunk/ippMonitor/def/histogramBackgroundImage.d	(revision 28601)
+++ trunk/ippMonitor/def/histogramBackgroundImage.d	(revision 28601)
@@ -0,0 +1,31 @@
+TABLE camRun, chipRun, rawExp, camProcessedExp
+TITLE New histogram background
+FILE  histogramBackgroundImage.php
+MENU  ipp.imfiles.dat
+
+WHERE camRun.state = 'full'
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE camProcessedExp.cam_id = camRun.cam_id
+WHERE camProcessedExp.fault = 0
+
+#    field                size  format  name           show     link to         extras
+FIELD rawExp.exp_name,            5, %s,     Exp Name, 	      restrict
+FIELD rawExp.exp_id,             5, %d,      Exp ID, 	      restrict
+FIELD rawExp.telescope,          10, %s,     Telescope,       restrict
+FIELD rawExp.camera,             10, %s,     Camera, 	      restrict
+FIELD rawExp.dateobs,            19, %T,     Date/Time,       restrict
+FIELD rawExp.ra,                  8, %C,     RA, 	      restrict
+FIELD rawExp.decl,                8, %C,     DEC, 	      restrict
+FIELD rawExp.comment,            65, %s,     Comment, 	      restrict
+FIELD rawExp.object,              8, %s,     Object, 	      restrict
+FIELD rawExp.filter,             10, %s,     FILTER, 	      restrict
+FIELD rawExp.exp_time,            5, %.2f,   exp_time, 	      restrict
+FIELD rawExp.airmass,             5, %.4f,   airmass, 	      restrict
+FIELD rawExp.bg,                  5, %.2f,   backgnd, 	      restrict
+FIELD rawExp.bg_stdev,            5, %.2f,   stdev, 	      restrict
+
+# What to plot
+TOPLOT rawExp.bg
+PLOTTER plotHistogram.php
+PLOTTITLE Background values
Index: trunk/ippMonitor/def/histogramBackgroundImage.php
===================================================================
--- trunk/ippMonitor/def/histogramBackgroundImage.php	(revision 28601)
+++ trunk/ippMonitor/def/histogramBackgroundImage.php	(revision 28601)
@@ -0,0 +1,30 @@
+TABLE camRun, chipRun, rawExp, camProcessedExp
+TITLE New histogram background
+FILE  hsitogramBackgroundImage.php
+MENU  ipp.imfiles.dat
+
+WHERE camRun.state = 'full'
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE camProcessedExp.cam_id = camRun.cam_id
+WHERE camProcessedExp.fault = 0
+
+#    field                size  format  name           show     link to         extras
+FIELD rawExp.exp_name,            5, %s,     Exp Name, 	      restrict
+FIELD rawExp.exp_id,             5, %d,      Exp ID, 	      restrict
+FIELD rawExp.telescope,          10, %s,     Telescope,       restrict
+FIELD rawExp.camera,             10, %s,     Camera, 	      restrict
+FIELD rawExp.dateobs,            19, %T,     Date/Time,       restrict
+FIELD rawExp.ra,                  8, %C,     RA, 	      restrict
+FIELD rawExp.decl,                8, %C,     DEC, 	      restrict
+FIELD rawExp.comment,            65, %s,     Comment, 	      restrict
+FIELD rawExp.object,              8, %s,     Object, 	      restrict
+FIELD rawExp.filter,             10, %s,     FILTER, 	      restrict
+FIELD rawExp.exp_time,            5, %.2f,   exp_time, 	      restrict
+FIELD rawExp.airmass,             5, %.4f,   airmass, 	      restrict
+FIELD rawExp.bg,                  5, %.2f,   backgnd, 	      restrict
+FIELD rawExp.bg_stdev,            5, %.2f,   stdev, 	      restrict
+
+# What to plot
+TOPLOT rawExp.bg
+PLOTTER plotHistogram.php
Index: trunk/ippMonitor/def/histogramCamProcessedExpImage.d
===================================================================
--- trunk/ippMonitor/def/histogramCamProcessedExpImage.d	(revision 28601)
+++ trunk/ippMonitor/def/histogramCamProcessedExpImage.d	(revision 28601)
@@ -0,0 +1,31 @@
+TABLE camRun, chipRun, rawExp, camProcessedExp
+TITLE Histogram fwhm major (camProcessedExp)
+FILE  histogramCamProcessedExpImage.php
+MENU  ipp.plots.dat
+
+WHERE camRun.state = 'full'
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE camProcessedExp.cam_id = camRun.cam_id
+WHERE camProcessedExp.fault = 0
+
+#    field                size  format  name           show     link to         extras
+FIELD rawExp.exp_name,            5, %s,     Exp Name, 	      restrict
+FIELD rawExp.exp_id,             5, %d,      Exp ID, 	      restrict
+FIELD rawExp.telescope,          10, %s,     Telescope,       restrict
+FIELD rawExp.camera,             10, %s,     Camera, 	      restrict
+FIELD rawExp.dateobs,            19, %T,     Date/Time,       restrict
+FIELD rawExp.ra,                  8, %C,     RA, 	      restrict
+FIELD rawExp.decl,                8, %C,     DEC, 	      restrict
+FIELD rawExp.comment,            65, %s,     Comment, 	      restrict
+FIELD rawExp.object,              8, %s,     Object, 	      restrict
+FIELD rawExp.filter,             10, %s,     FILTER, 	      restrict
+FIELD rawExp.exp_time,            5, %.2f,   exp_time, 	      restrict
+FIELD rawExp.airmass,             5, %.4f,   airmass, 	      restrict
+FIELD rawExp.bg,                  5, %.2f,   backgnd, 	      restrict
+FIELD rawExp.bg_stdev,            5, %.2f,   stdev, 	      restrict
+
+# What to plot
+TOPLOT camProcessedExp.fwhm_major
+PLOTTER plotHistogram.php
+PLOTTITLE Fwhm_major from camProcessedExp
Index: trunk/ippMonitor/def/histogramChipProcessedImfileFwhmMajorImage.d
===================================================================
--- trunk/ippMonitor/def/histogramChipProcessedImfileFwhmMajorImage.d	(revision 28601)
+++ trunk/ippMonitor/def/histogramChipProcessedImfileFwhmMajorImage.d	(revision 28601)
@@ -0,0 +1,32 @@
+TABLE camRun, chipRun, rawExp, camProcessedExp, chipProcessedImfile
+TITLE Histogram fwhm major (chipProcessedImfile)
+FILE  histogramChipProcessedImfileFwhmMajorImage.php
+MENU  ipp.plots.dat
+
+WHERE camRun.state = 'full'
+WHERE chipProcessedImfile.exp_id = rawExp.exp_id
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE camProcessedExp.cam_id = camRun.cam_id
+WHERE camProcessedExp.fault = 0
+
+#    field                size  format  name           show     link to         extras
+FIELD rawExp.exp_name,            5, %s,     Exp Name, 	      restrict
+FIELD rawExp.exp_id,             5, %d,      Exp ID, 	      restrict
+FIELD rawExp.telescope,          10, %s,     Telescope,       restrict
+FIELD rawExp.camera,             10, %s,     Camera, 	      restrict
+FIELD rawExp.dateobs,            19, %T,     Date/Time,       restrict
+FIELD rawExp.ra,                  8, %C,     RA, 	      restrict
+FIELD rawExp.decl,                8, %C,     DEC, 	      restrict
+FIELD rawExp.comment,            65, %s,     Comment, 	      restrict
+FIELD rawExp.object,              8, %s,     Object, 	      restrict
+FIELD rawExp.filter,             10, %s,     FILTER, 	      restrict
+FIELD rawExp.exp_time,            5, %.2f,   exp_time, 	      restrict
+FIELD rawExp.airmass,             5, %.4f,   airmass, 	      restrict
+FIELD rawExp.bg,                  5, %.2f,   backgnd, 	      restrict
+FIELD rawExp.bg_stdev,            5, %.2f,   stdev, 	      restrict
+
+# What to plot
+TOPLOT chipProcessedImfile.fwhm_major
+PLOTTER plotHistogram.php
+PLOTTITLE Fwhm_major from ChipProcessedImfile
Index: trunk/ippMonitor/def/histogramChipRunFwhmMajorImage.d
===================================================================
--- trunk/ippMonitor/def/histogramChipRunFwhmMajorImage.d	(revision 28601)
+++ trunk/ippMonitor/def/histogramChipRunFwhmMajorImage.d	(revision 28601)
@@ -0,0 +1,31 @@
+TABLE camRun, chipRun, rawExp, camProcessedExp
+TITLE Histogram fwhm major (camProcessedExp)
+FILE  histogramCamProcessedExpImage.php
+MENU  ipp.imfiles.dat
+
+WHERE camRun.state = 'full'
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE camProcessedExp.cam_id = camRun.cam_id
+WHERE camProcessedExp.fault = 0
+
+#    field                size  format  name           show     link to         extras
+FIELD rawExp.exp_name,            5, %s,     Exp Name, 	      restrict
+FIELD rawExp.exp_id,             5, %d,      Exp ID, 	      restrict
+FIELD rawExp.telescope,          10, %s,     Telescope,       restrict
+FIELD rawExp.camera,             10, %s,     Camera, 	      restrict
+FIELD rawExp.dateobs,            19, %T,     Date/Time,       restrict
+FIELD rawExp.ra,                  8, %C,     RA, 	      restrict
+FIELD rawExp.decl,                8, %C,     DEC, 	      restrict
+FIELD rawExp.comment,            65, %s,     Comment, 	      restrict
+FIELD rawExp.object,              8, %s,     Object, 	      restrict
+FIELD rawExp.filter,             10, %s,     FILTER, 	      restrict
+FIELD rawExp.exp_time,            5, %.2f,   exp_time, 	      restrict
+FIELD rawExp.airmass,             5, %.4f,   airmass, 	      restrict
+FIELD rawExp.bg,                  5, %.2f,   backgnd, 	      restrict
+FIELD rawExp.bg_stdev,            5, %.2f,   stdev, 	      restrict
+
+# What to plot
+TOPLOT camProcessedExp.fwhm_major
+PLOTTER plotHistogram.php
+PLOTTITLE Fwhm_major values
Index: trunk/ippMonitor/def/histogramFwhmMajorImage.d
===================================================================
--- trunk/ippMonitor/def/histogramFwhmMajorImage.d	(revision 28601)
+++ trunk/ippMonitor/def/histogramFwhmMajorImage.d	(revision 28601)
@@ -0,0 +1,31 @@
+TABLE camRun, chipRun, rawExp, camProcessedExp
+TITLE New histogram fwhm major
+FILE  histogramFwhmMajorImage.php
+MENU  ipp.imfiles.dat
+
+WHERE camRun.state = 'full'
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE camProcessedExp.cam_id = camRun.cam_id
+WHERE camProcessedExp.fault = 0
+
+#    field                size  format  name           show     link to         extras
+FIELD rawExp.exp_name,            5, %s,     Exp Name, 	      restrict
+FIELD rawExp.exp_id,             5, %d,      Exp ID, 	      restrict
+FIELD rawExp.telescope,          10, %s,     Telescope,       restrict
+FIELD rawExp.camera,             10, %s,     Camera, 	      restrict
+FIELD rawExp.dateobs,            19, %T,     Date/Time,       restrict
+FIELD rawExp.ra,                  8, %C,     RA, 	      restrict
+FIELD rawExp.decl,                8, %C,     DEC, 	      restrict
+FIELD rawExp.comment,            65, %s,     Comment, 	      restrict
+FIELD rawExp.object,              8, %s,     Object, 	      restrict
+FIELD rawExp.filter,             10, %s,     FILTER, 	      restrict
+FIELD rawExp.exp_time,            5, %.2f,   exp_time, 	      restrict
+FIELD rawExp.airmass,             5, %.4f,   airmass, 	      restrict
+FIELD rawExp.bg,                  5, %.2f,   backgnd, 	      restrict
+FIELD rawExp.bg_stdev,            5, %.2f,   stdev, 	      restrict
+
+# What to plot
+TOPLOT camProcessedExp.fwhm_major
+PLOTTER plotHistogram.php
+PLOTTITLE Fwhm_major values
Index: trunk/ippMonitor/def/histogramFwhmMinorImage.d
===================================================================
--- trunk/ippMonitor/def/histogramFwhmMinorImage.d	(revision 28601)
+++ trunk/ippMonitor/def/histogramFwhmMinorImage.d	(revision 28601)
@@ -0,0 +1,31 @@
+TABLE camRun, chipRun, rawExp, camProcessedExp
+TITLE New histogram fwhm minor
+FILE  histogramFwhmMinorImage.php
+MENU  ipp.imfiles.dat
+
+WHERE camRun.state = 'full'
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE camProcessedExp.cam_id = camRun.cam_id
+WHERE camProcessedExp.fault = 0
+
+#    field                size  format  name           show     link to         extras
+FIELD rawExp.exp_name,            5, %s,     Exp Name, 	      restrict
+FIELD rawExp.exp_id,             5, %d,      Exp ID, 	      restrict
+FIELD rawExp.telescope,          10, %s,     Telescope,       restrict
+FIELD rawExp.camera,             10, %s,     Camera, 	      restrict
+FIELD rawExp.dateobs,            19, %T,     Date/Time,       restrict
+FIELD rawExp.ra,                  8, %C,     RA, 	      restrict
+FIELD rawExp.decl,                8, %C,     DEC, 	      restrict
+FIELD rawExp.comment,            65, %s,     Comment, 	      restrict
+FIELD rawExp.object,              8, %s,     Object, 	      restrict
+FIELD rawExp.filter,             10, %s,     FILTER, 	      restrict
+FIELD rawExp.exp_time,            5, %.2f,   exp_time, 	      restrict
+FIELD rawExp.airmass,             5, %.4f,   airmass, 	      restrict
+FIELD rawExp.bg,                  5, %.2f,   backgnd, 	      restrict
+FIELD rawExp.bg_stdev,            5, %.2f,   stdev, 	      restrict
+
+# What to plot
+TOPLOT camProcessedExp.fwhm_minor
+PLOTTER plotHistogram.php
+PLOTTITLE Fwhm_minor values
Index: trunk/ippMonitor/def/image_autocode.php
===================================================================
--- trunk/ippMonitor/def/image_autocode.php	(revision 28601)
+++ trunk/ippMonitor/def/image_autocode.php	(revision 28601)
@@ -0,0 +1,124 @@
+<?php 
+
+include 'ipp.php';
+
+$ID = checkID ();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+$db = dbconnect($ID['proj']);
+
+if ($ID['menu']) {
+  $myMenu = $ID['menu'];
+} else {
+  $myMenu = "$MENU";
+}
+
+menu($myMenu, '$TITLE', '$STYLE', $ID['link'], $ID['proj']);
+
+echo "<p> $TITLE </p>";
+
+// set up the form
+echo "<form action=\"$FILE\" method=\"POST\">\n";
+
+$restricted = 0;
+
+// define restrictiosn to the queries
+// ** TABLE RESTRICTIONS **
+
+if ($restricted == 0) {//Don't display anything
+  if ($WHERE == "") {
+    $WHERE = "WHERE (0 > 1)";
+  } else {
+    $WHERE = "WHERE (0 > 1)";
+  }
+}
+
+// get the result table count
+$sql = "SELECT count(*) FROM $TABLE $WHERE";
+
+$qry = $db->query($sql);
+if (dberror($qry)) {
+  echo "<b>error reading $TABLE table count</b><br>\n";
+  echo "<br><small><b> count query : $sql </b></small><br>\n";
+  menu_end();
+}
+if (!$qry->fetchInto($row)) {
+  echo "<b>error reading $TABLE table count</b><br>\n";
+  echo "<br><small><b> count query : $sql </b></small><br>\n";
+  menu_end();
+}
+$nValues = $row[0];
+echo "<b>$nValues match selection</b><br>\n";
+
+if ($row[0]) {
+  menu_end();
+}
+
+$sql = "SELECT $FIELDS FROM $TABLE $WHERE";
+$qry = $db->query($sql);
+
+if (dberror($qry)) {
+  echo "<b>error reading $TABLE table</b><br>\n";
+  echo "<br><small><b> table query : $sql </b></small><br>\n";
+  menu_end();
+}
+
+// ** HEAD CODE **
+
+// ** BUTTON RESTRICTIONS **
+navigate_buttons ($rowStart, $rowLast, $dTABLE, $rowTotal, $buttonLink, $ID, '$FILE');
+
+echo "&nbsp; : &nbsp; or enter start row: <input type=\"text\" name=\"from\" size=\"5\" value=\"$rowStart\">\n";
+
+// set up the table
+echo "<table class=list>\n";
+
+// echo "<tr><td></td>\n"; // first field is a label set below for the query rows only
+// ** TABLE HEADER **
+// echo "</tr>\n";
+
+// query restriction form
+// echo "<tr>\n";
+// echo "<td class=list> <input type=\"text\" name=\"expID\"></td>\n";
+// ** TABLE QUERY **
+// echo "</tr>\n";
+
+// list the results
+while ($qry->fetchInto($row)) {
+  // $link = "$FILE" . "?expID=" . $row[0] . "&" . $ID['link'];
+
+  $class = "list";
+  // ** TD CLASS **
+
+  echo "<tr><td></td>\n";
+  // ** TABLE DATA **
+  echo "</tr>\n";
+}
+
+// query restriction form
+// echo "<tr>\n";
+// echo "<td class=list> <input type=\"text\" name=\"expID\"></td>\n";
+// TABLE QUERY 
+// echo "</tr>\n";
+
+// close the table and form
+echo "</table>\n";
+echo "<input type=\"submit\" name=\"constraints\" value=\"refine search\">\n";
+$pass = $ID['pass'];
+$proj = $ID['proj'];
+$menu = $ID['menu'];
+echo "<input type=\"hidden\" name=\"pass\" value=\"$pass\">\n";
+echo "<input type=\"hidden\" name=\"proj\" value=\"$proj\">\n";
+echo "<input type=\"hidden\" name=\"menu\" value=\"$menu\">\n";
+echo "</form>\n";
+
+// ** TAIL CODE **
+
+echo "<small> WHERE: $WHERE<br><br></small>\n";
+echo "<small> SQL: $sql<br><br></small>\n";
+
+menu_end();
+
+?>
Index: trunk/ippMonitor/def/scatterCpiBgReMaImage.d
===================================================================
--- trunk/ippMonitor/def/scatterCpiBgReMaImage.d	(revision 28601)
+++ trunk/ippMonitor/def/scatterCpiBgReMaImage.d	(revision 28601)
@@ -0,0 +1,33 @@
+TABLE camRun, chipRun, rawExp, camProcessedExp, chipProcessedImfile
+TITLE Scatter plot Background (chipProcessedImfile) vs Moon angle (rawExp)
+FILE  scatterCpiBgReMaImage.php
+MENU  ipp.plots.dat
+
+WHERE camRun.state = 'full'
+WHERE chipProcessedImfile.exp_id = rawExp.exp_id
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE camProcessedExp.cam_id = camRun.cam_id
+WHERE camProcessedExp.fault = 0
+
+#    field                size  format  name           show     link to         extras
+FIELD rawExp.exp_name,            5, %s,     Exp Name, 	      restrict
+FIELD rawExp.exp_id,             5, %d,      Exp ID, 	      restrict
+FIELD rawExp.telescope,          10, %s,     Telescope,       restrict
+FIELD rawExp.camera,             10, %s,     Camera, 	      restrict
+FIELD rawExp.dateobs,            19, %T,     Date/Time,       restrict
+FIELD rawExp.moon_phase,          5, %.2f,   Moon Phase,      restrict
+FIELD rawExp.ra,                  8, %C,     RA, 	      restrict
+FIELD rawExp.decl,                8, %C,     DEC, 	      restrict
+FIELD rawExp.comment,            65, %s,     Comment, 	      restrict
+FIELD rawExp.object,              8, %s,     Object, 	      restrict
+FIELD rawExp.filter,             10, %s,     FILTER, 	      restrict
+FIELD rawExp.exp_time,            5, %.2f,   exp_time, 	      restrict
+FIELD rawExp.airmass,             5, %.4f,   airmass, 	      restrict
+FIELD rawExp.bg,                  5, %.2f,   backgnd, 	      restrict
+FIELD rawExp.bg_stdev,            5, %.2f,   stdev, 	      restrict
+
+# What to plot
+TOPLOT chipProcessedImfile.bg, rawExp.moon_angle
+PLOTTER scatterPlot.php
+PLOTTITLE Airmass vs Fwhm_major (ChipProcessedImfile)
Index: trunk/ippMonitor/def/scatterCpiBgReMpImage.d
===================================================================
--- trunk/ippMonitor/def/scatterCpiBgReMpImage.d	(revision 28601)
+++ trunk/ippMonitor/def/scatterCpiBgReMpImage.d	(revision 28601)
@@ -0,0 +1,33 @@
+TABLE camRun, chipRun, rawExp, camProcessedExp, chipProcessedImfile
+TITLE Scatter plot Background (chipProcessedImfile) vs Moon phase (rawExp)
+FILE  scatterCpiBgReMpImage.php
+MENU  ipp.plots.dat
+
+WHERE camRun.state = 'full'
+WHERE chipProcessedImfile.exp_id = rawExp.exp_id
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE camProcessedExp.cam_id = camRun.cam_id
+WHERE camProcessedExp.fault = 0
+
+#    field                size  format  name           show     link to         extras
+FIELD rawExp.exp_name,            5, %s,     Exp Name, 	      restrict
+FIELD rawExp.exp_id,             5, %d,      Exp ID, 	      restrict
+FIELD rawExp.telescope,          10, %s,     Telescope,       restrict
+FIELD rawExp.camera,             10, %s,     Camera, 	      restrict
+FIELD rawExp.dateobs,            19, %T,     Date/Time,       restrict
+FIELD rawExp.moon_angle,          5, %.2f,   Moon Angle,      restrict
+FIELD rawExp.ra,                  8, %C,     RA, 	      restrict
+FIELD rawExp.decl,                8, %C,     DEC, 	      restrict
+FIELD rawExp.comment,            65, %s,     Comment, 	      restrict
+FIELD rawExp.object,              8, %s,     Object, 	      restrict
+FIELD rawExp.filter,             10, %s,     FILTER, 	      restrict
+FIELD rawExp.exp_time,            5, %.2f,   exp_time, 	      restrict
+FIELD rawExp.airmass,             5, %.4f,   airmass, 	      restrict
+FIELD rawExp.bg,                  5, %.2f,   backgnd, 	      restrict
+FIELD rawExp.bg_stdev,            5, %.2f,   stdev, 	      restrict
+
+# What to plot
+TOPLOT chipProcessedImfile.bg, rawExp.moon_phase
+PLOTTER scatterPlot.php
+PLOTTITLE Background (chipProcessedImfile) vs Moon Phase (rawExp)
Index: trunk/ippMonitor/def/scatterCpiBgReSaImage.d
===================================================================
--- trunk/ippMonitor/def/scatterCpiBgReSaImage.d	(revision 28601)
+++ trunk/ippMonitor/def/scatterCpiBgReSaImage.d	(revision 28601)
@@ -0,0 +1,33 @@
+TABLE camRun, chipRun, rawExp, camProcessedExp, chipProcessedImfile
+TITLE Scatter plot Background (chipProcessedImfile) vs Sun Angle (rawExp)
+FILE  scatterCpiBgReSaImage.php
+MENU  ipp.plots.dat
+
+WHERE camRun.state = 'full'
+WHERE chipProcessedImfile.exp_id = rawExp.exp_id
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE camProcessedExp.cam_id = camRun.cam_id
+WHERE camProcessedExp.fault = 0
+
+#    field                size  format  name           show     link to         extras
+FIELD rawExp.exp_name,            5, %s,     Exp Name, 	      restrict
+FIELD rawExp.exp_id,             5, %d,      Exp ID, 	      restrict
+FIELD rawExp.telescope,          10, %s,     Telescope,       restrict
+FIELD rawExp.camera,             10, %s,     Camera, 	      restrict
+FIELD rawExp.dateobs,            19, %T,     Date/Time,       restrict
+FIELD rawExp.moon_angle,          5, %.2f,   Moon Angle,      restrict
+FIELD rawExp.ra,                  8, %C,     RA, 	      restrict
+FIELD rawExp.decl,                8, %C,     DEC, 	      restrict
+FIELD rawExp.comment,            65, %s,     Comment, 	      restrict
+FIELD rawExp.object,              8, %s,     Object, 	      restrict
+FIELD rawExp.filter,             10, %s,     FILTER, 	      restrict
+FIELD rawExp.exp_time,            5, %.2f,   exp_time, 	      restrict
+FIELD rawExp.airmass,             5, %.4f,   airmass, 	      restrict
+FIELD rawExp.bg,                  5, %.2f,   backgnd, 	      restrict
+FIELD rawExp.bg_stdev,            5, %.2f,   stdev, 	      restrict
+
+# What to plot
+TOPLOT chipProcessedImfile.bg, rawExp.sun_angle
+PLOTTER scatterPlot.php
+PLOTTITLE Background (chipProcessedImfile) vs Sun Angle (rawExp)
Index: trunk/ippMonitor/def/scatterPlotAirMassFwhmImage.d
===================================================================
--- trunk/ippMonitor/def/scatterPlotAirMassFwhmImage.d	(revision 28601)
+++ trunk/ippMonitor/def/scatterPlotAirMassFwhmImage.d	(revision 28601)
@@ -0,0 +1,32 @@
+TABLE camRun, chipRun, rawExp, camProcessedExp, chipProcessedImfile
+TITLE Scatter plot airmass vs fwhm major (chipProcessedImfile)
+FILE  scatterPlotAirMassFwhmImage.php
+MENU  ipp.plots.dat
+
+WHERE camRun.state = 'full'
+WHERE chipProcessedImfile.exp_id = rawExp.exp_id
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE camProcessedExp.cam_id = camRun.cam_id
+WHERE camProcessedExp.fault = 0
+
+#    field                size  format  name           show     link to         extras
+FIELD rawExp.exp_name,            5, %s,     Exp Name, 	      restrict
+FIELD rawExp.exp_id,             5, %d,      Exp ID, 	      restrict
+FIELD rawExp.telescope,          10, %s,     Telescope,       restrict
+FIELD rawExp.camera,             10, %s,     Camera, 	      restrict
+FIELD rawExp.dateobs,            19, %T,     Date/Time,       restrict
+FIELD rawExp.ra,                  8, %C,     RA, 	      restrict
+FIELD rawExp.decl,                8, %C,     DEC, 	      restrict
+FIELD rawExp.comment,            65, %s,     Comment, 	      restrict
+FIELD rawExp.object,              8, %s,     Object, 	      restrict
+FIELD rawExp.filter,             10, %s,     FILTER, 	      restrict
+FIELD rawExp.exp_time,            5, %.2f,   exp_time, 	      restrict
+FIELD rawExp.airmass,             5, %.4f,   airmass, 	      restrict
+FIELD rawExp.bg,                  5, %.2f,   backgnd, 	      restrict
+FIELD rawExp.bg_stdev,            5, %.2f,   stdev, 	      restrict
+
+# What to plot
+TOPLOT rawExp.airmass, chipProcessedImfile.fwhm_major
+PLOTTER scatterPlot.php
+PLOTTITLE Airmass vs Fwhm_major (ChipProcessedImfile)
Index: trunk/ippMonitor/def/simplePlotChipImage.d
===================================================================
--- trunk/ippMonitor/def/simplePlotChipImage.d	(revision 28601)
+++ trunk/ippMonitor/def/simplePlotChipImage.d	(revision 28601)
@@ -0,0 +1,28 @@
+TABLE chipRun, rawExp
+TITLE New sky plot - chip
+FILE  simplePlotChipImage.php
+MENU  ipp.plots.dat
+
+WHERE chipRun.state != 'new' 
+WHERE chipRun.exp_id = rawExp.exp_id
+
+#    field                size  format  name           show     link to         extras
+FIELD rawExp.exp_name,            5, %s,     Exp Name, 	      restrict
+FIELD rawExp.exp_id,             5, %d,      Exp ID, 	      restrict
+FIELD rawExp.telescope,          10, %s,     Telescope,       restrict
+FIELD rawExp.camera,             10, %s,     Camera, 	      restrict
+FIELD rawExp.dateobs,            19, %T,     Date/Time,       restrict
+FIELD rawExp.ra,                  8, %C,     RA, 	      restrict
+FIELD rawExp.decl,                8, %C,     DEC, 	      restrict
+FIELD rawExp.comment,            65, %s,     Comment, 	      restrict
+FIELD rawExp.object,              8, %s,     Object, 	      restrict
+FIELD rawExp.filter,             10, %s,     FILTER, 	      restrict
+FIELD rawExp.exp_time,            5, %.2f,   exp_time, 	      restrict
+FIELD rawExp.airmass,             5, %.4f,   airmass, 	      restrict
+FIELD rawExp.bg,                  5, %.2f,   backgnd, 	      restrict
+FIELD rawExp.bg_stdev,            5, %.2f,   stdev, 	      restrict
+
+# What to plot
+TOPLOT rawExp.ra,rawExp.decl,rawExp.filter
+PLOTTER skyplot.php
+PLOTTITLE Sky Plot Chip
Index: trunk/ippMonitor/def/simplePlotRawImage.d
===================================================================
--- trunk/ippMonitor/def/simplePlotRawImage.d	(revision 28601)
+++ trunk/ippMonitor/def/simplePlotRawImage.d	(revision 28601)
@@ -0,0 +1,25 @@
+TABLE rawExp
+TITLE New sky plot - raw
+FILE  simplePlotRawImage.php
+MENU  ipp.plots.dat
+
+#    field                size  format  name           show     link to         extras
+FIELD rawExp.exp_name,            5, %s,     Exp Name, 	      restrict
+FIELD rawExp.exp_id,             5, %d,      Exp ID, 	      restrict
+FIELD rawExp.telescope,          10, %s,     Telescope,       restrict
+FIELD rawExp.camera,             10, %s,     Camera, 	      restrict
+FIELD rawExp.dateobs,            19, %T,     Date/Time,       restrict
+FIELD rawExp.ra,                  8, %C,     RA, 	      restrict
+FIELD rawExp.decl,                8, %C,     DEC, 	      restrict
+FIELD rawExp.comment,            65, %s,     Comment, 	      restrict
+FIELD rawExp.object,              8, %s,     Object, 	      restrict
+FIELD rawExp.filter,             10, %s,     FILTER, 	      restrict
+FIELD rawExp.exp_time,            5, %.2f,   exp_time, 	      restrict
+FIELD rawExp.airmass,             5, %.4f,   airmass, 	      restrict
+FIELD rawExp.bg,                  5, %.2f,   backgnd, 	      restrict
+FIELD rawExp.bg_stdev,            5, %.2f,   stdev, 	      restrict
+
+# What to plot
+TOPLOT rawExp.ra,rawExp.decl,rawExp.filter
+PLOTTER skyplot.php
+PLOTTITLE Sky Plot Raw
Index: trunk/ippMonitor/raw/ipp.imfiles.dat
===================================================================
--- trunk/ippMonitor/raw/ipp.imfiles.dat	(revision 28597)
+++ trunk/ippMonitor/raw/ipp.imfiles.dat	(revision 28601)
@@ -24,2 +24,10 @@
 menutop   | menutop      | link    | mask stats                   | maskStats.php
 menutop   | menutop      | link    | histogram                    | histogram.php
+menutop   | menutop      | link    | Scatter plot                 | plot_x_vs_y.php
+
+menutop   | menutop      | link    | Simple plot - raw            | simplePlotRawImage.php
+menutop   | menutop      | link    | Simple plot - chip            | simplePlotChipImage.php
+menutop   | menutop      | link    | Simple plot - cam            | simplePlotCamImage.php
+menutop   | menutop      | link    | Histogram background     | histogramBackgroundImage.php
+menutop   | menutop      | link    | Histogram Fwhm Major (camProcessedExp)     | histogramCamProcessedExpImage.php
+menutop   | menutop      | link    | Histogram Fwhm Minor (chip processed)     | histogramChipProcessedImfileFwhmMajorImage.php
Index: trunk/ippMonitor/raw/ipp.menu.dat
===================================================================
--- trunk/ippMonitor/raw/ipp.menu.dat	(revision 28597)
+++ trunk/ippMonitor/raw/ipp.menu.dat	(revision 28601)
@@ -24,4 +24,5 @@
 menutop   | menutop      | link    | Distribution                 | ipp.dist.php
 menutop   | menutop      | link    | Calibration                  | ipp.cal.php
+menutop   | menutop      | link    | Plots              	  | ipp.plots.php
 menutop   | menutop      | link    | Admin and Debug              | ipp.imfiles.php
 
Index: trunk/ippMonitor/raw/ipp.php
===================================================================
--- trunk/ippMonitor/raw/ipp.php	(revision 28597)
+++ trunk/ippMonitor/raw/ipp.php	(revision 28601)
@@ -871,3 +871,7 @@
 }
 
+//////////////////////////////////////////////////////////////////////////
+// Extra filtering parameters array
+$filteringParameters = array();
+
 ?>
Index: trunk/ippMonitor/raw/ipp.plots.dat
===================================================================
--- trunk/ippMonitor/raw/ipp.plots.dat	(revision 28601)
+++ trunk/ippMonitor/raw/ipp.plots.dat	(revision 28601)
@@ -0,0 +1,17 @@
+input     | ipp.menu.dat 
+
+menutop   | menutop      | plain   | &nbsp;                                 | 
+menutop   | menutop      | link    | Simple plot - raw            	    | simplePlotRawImage.php
+menutop   | menutop      | link    | Simple plot - chip           	    | simplePlotChipImage.php
+menutop   | menutop      | link    | Simple plot - cam            	    | simplePlotCamImage.php
+
+menutop   | menutop      | plain   | &nbsp;                                 | 
+menutop   | menutop      | link    | Histogram background                   | histogramBackgroundImage.php
+menutop   | menutop      | link    | Histogram Fwhm Major (camProcessedExp) | histogramCamProcessedExpImage.php
+menutop   | menutop      | link    | Histogram Fwhm Minor (chip processed)  | histogramChipProcessedImfileFwhmMajorImage.php
+
+menutop   | menutop      | plain   | &nbsp;                                 | 
+menutop   | menutop      | link    | Plot airmass vs fwhm_major (chipProcessedImfile) | scatterPlotAirMassFwhmImage.php
+menutop   | menutop      | link    | Plot Background (chipProcessedImfile) vs Moon Angle (rawExp) | scatterCpiBgReMaImage.php
+menutop   | menutop      | link    | Plot Background (chipProcessedImfile) vs Moon Phase (rawExp) | scatterCpiBgReMpImage.php
+menutop   | menutop      | link    | Plot Background (chipProcessedImfile) vs Sun Angle (rawExp) | scatterCpiBgReSaImage.php
Index: trunk/ippMonitor/raw/ipp.plots.php
===================================================================
--- trunk/ippMonitor/raw/ipp.plots.php	(revision 28601)
+++ trunk/ippMonitor/raw/ipp.plots.php	(revision 28601)
@@ -0,0 +1,17 @@
+<?php 
+
+include 'ipp.php';
+
+$ID = checkID ();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+menu('ipp.plots.dat', 'Plots', 'ipp.css', $ID['link'], $ID['proj']);
+
+// document body
+echo "Plots scripts<br>\n";
+
+menu_end();
+
+?>
Index: trunk/ippMonitor/raw/plotHistogram.php
===================================================================
--- trunk/ippMonitor/raw/plotHistogram.php	(revision 28601)
+++ trunk/ippMonitor/raw/plotHistogram.php	(revision 28601)
@@ -0,0 +1,72 @@
+<?php
+
+# this program takes two arguments: 
+# an input filename of a file containing floating point values
+# an output png filename
+
+$debug = 0;
+include 'site.php';
+
+### these need to be set to the correct locations!!
+$MISSING = "missing.png";
+
+### we must have been past arguments with GET:
+if ($_SERVER[REQUEST_METHOD] != 'GET') { 
+  exit ();
+}
+
+$PATH = getenv("PATH");
+putenv("PATH=$BINDIR:$PATH");
+
+$LD_LIBRARY_PATH = getenv("LD_LIBRARY_PATH");
+putenv("LD_LIBRARY_PATH=$LIBDIR:$LD_LIBRARY_PATH");
+
+if ($debug) {
+  echo "path: $PATH<br>";
+
+  $newpath = getenv("PATH");
+  echo "new path: $newpath<br>";
+
+  $newpath = getenv("LD_LIBRARY_PATH");
+  echo "new path: $newpath<br>";
+
+  echo "bindir: $BINDIR<br>";
+}
+
+if ($debug) {
+  exec ("which build_histogram.dvo", $output, $status);
+  echo "which output:<br>";
+  for ($i = 0; $i < count($output); $i++) {
+    echo "output $i: $output[$i]<br>";
+  }
+  echo "status:   $status<br>";
+}
+
+$infile  = $_GET[input];
+$outfile = $_GET[output];
+$title = $_GET[title];
+
+if ($debug) {
+  echo "Calling: build_histogram.dvo $infile $outfile 0.1 100 $title\n";
+}
+exec ("build_histogram.dvo $infile $outfile 0.1 100 $title", $output, $status);
+
+if ($debug) {
+  for ($i = 0; $i < count($output); $i++) {
+    echo "output $i: $output[$i]<br>";
+  }
+  echo "status:   $status<br>";
+  exit ();
+}
+
+# use these to check the environment
+# passthru ("env");
+
+$file = fopen ($outfile, "r");
+if ($file && !$debug) {
+  header ('Content-Type: image/png');
+  fpassthru ($file);
+}
+exit ();
+?>
+
Index: trunk/ippMonitor/raw/scatterPlot.php
===================================================================
--- trunk/ippMonitor/raw/scatterPlot.php	(revision 28601)
+++ trunk/ippMonitor/raw/scatterPlot.php	(revision 28601)
@@ -0,0 +1,80 @@
+<?php
+
+# this program takes two arguments: 
+# an input filename of a file containing floating point values
+# an output png filename
+
+$debug = 0;
+include 'site.php';
+
+### these need to be set to the correct locations!!
+$MISSING = "missing.png";
+
+### we must have been past arguments with GET:
+if ($_SERVER[REQUEST_METHOD] != 'GET') { 
+  exit ();
+}
+
+$PATH = getenv("PATH");
+putenv("PATH=$BINDIR:$PATH");
+
+$LD_LIBRARY_PATH = getenv("LD_LIBRARY_PATH");
+putenv("LD_LIBRARY_PATH=$LIBDIR:$LD_LIBRARY_PATH");
+
+if ($debug) {
+  echo "path: $PATH<br>";
+
+  $newpath = getenv("PATH");
+  echo "new path: $newpath<br>";
+
+  $newpath = getenv("LD_LIBRARY_PATH");
+  echo "new path: $newpath<br>";
+
+  echo "bindir: $BINDIR<br>";
+}
+
+if ($debug) {
+  exec ("which plot_x_vs_y.dvo", $output, $status);
+  echo "which output:<br>";
+  for ($i = 0; $i < count($output); $i++) {
+    echo "output $i: $output[$i]<br>";
+  }
+  echo "status:   $status<br>";
+}
+
+$infile  = $_GET[input];
+$outfile = $_GET[output];
+$title = $_GET[title];
+
+$title = preg_replace("/'/", "", $title);
+$title = preg_replace("/'/", "", $title);
+$title = preg_replace("/\\\\/", "", $title);
+$title = preg_replace("/\\\\/", "", $title);
+$xtitle = preg_replace("/_vs_.*$/", "", $title);
+$ytitle = preg_replace("/^.*_vs_/", "", $title);
+
+$debug = 0;
+if ($debug) {
+  echo "Calling: plot_x_vs_y.dvo $infile $outfile [$xtitle] [$ytitle]\n";
+}
+$debug = 0;
+exec ("plot_x_vs_y.dvo $infile $outfile '$xtitle' '$ytitle'", $output, $status);
+
+if ($debug) {
+  for ($i = 0; $i < count($output); $i++) {
+    echo "output $i: $output[$i]<br>";
+  }
+  echo "status:   $status<br>";
+  exit ();
+}
+
+# use these to check the environment
+# passthru ("env");
+
+$file = fopen ($outfile, "r");
+if ($file && !$debug) {
+  header ('Content-Type: image/png');
+  fpassthru ($file);
+}
+exit ();
+?>
Index: trunk/ippMonitor/raw/skyplot.php
===================================================================
--- trunk/ippMonitor/raw/skyplot.php	(revision 28597)
+++ trunk/ippMonitor/raw/skyplot.php	(revision 28601)
@@ -47,5 +47,5 @@
 $outfile = $_GET[output];
 
-exec ("skyplot.dvo $infile $outfile", $output, $status);
+$output = shell_exec("skyplot.dvo $infile $outfile");//, $output, $status);
 
 if ($debug) {
@@ -65,4 +65,6 @@
   fpassthru ($file);
 }
-exit ();
+
+exit();
+
 ?>
Index: trunk/ippMonitor/scripts/build_histogram.dvo
===================================================================
--- trunk/ippMonitor/scripts/build_histogram.dvo	(revision 28597)
+++ trunk/ippMonitor/scripts/build_histogram.dvo	(revision 28601)
@@ -37,14 +37,15 @@
   plot dx vhist -x 1 -c blue
   $binsCount = dx[]
-  myecho "  Labeling"
-  myecho "    -x $3"
+  strsub $3 "_" "\\\\_" -var xLabel
+  myecho "  Labelling"
+  myecho "    -x $xLabel"
   myecho "    -y Occurrences "
-  myecho "    +x 'Histogram of $3 "
+  myecho "    +x 'Histogram of $xLabel "
   myecho "           interval = $minvalue : $maxvalue "
   myecho "	     / $binsCount bins"
   myecho "           / bin width: $delta)'"
-  labels -x $3
+  labels -x $xLabel
   labels -y Occurrences
-  labels +x "Histogram of $3 / interval = $minvalue : $maxvalue / $binsCount bins / bin width: $delta"
+  labels +x "Histogram of $xLabel / interval = $minvalue : $maxvalue / $binsCount bins / bin width: $delta"
 
   myecho "Saving graphics to [$2]"
Index: trunk/ippMonitor/scripts/generate
===================================================================
--- trunk/ippMonitor/scripts/generate	(revision 28597)
+++ trunk/ippMonitor/scripts/generate	(revision 28601)
@@ -35,4 +35,7 @@
     &init_key ("FIELDS");
     &init_key ("GROUPS");
+    &init_key ("TOPLOT");
+    &init_key ("PLOTTER");
+    &init_key ("PLOTTITLE");
 
     foreach $line (@list) {
@@ -43,4 +46,10 @@
         if ($key eq "TABLE") { ($value) = $value =~ m|^\s*(.+)\s*$|; }
         if ($key eq "TYPE")  { ($value) = $value =~ m|^\s*(.+)\s*$|; }
+	if ($key eq "TOPLOT") { ($value) = $value =~ m|^\s*(.+)\s*$|; }
+	if ($key eq "PLOTTER") { ($value) = $value =~ m|^\s*(.+)\s*$|; }
+	if ($key eq "PLOTTITLE") { 
+	    ($value) = $value =~ m|^\s*(.+)\s*$|;
+	    $value =~ s/\s/_/g;
+	}
 
         &set_keypair ($key, $value);
@@ -253,5 +262,4 @@
 # generate a table header cell (<th> </th>) for each field (show != none)
 sub write_table_header {
-
     # print the table header (field labels)
     print FILE "echo \"<tr><td></td>\\n\";\n";
@@ -682,5 +690,5 @@
         if ($key eq $key[$i]) {
             if ($VERBOSE) { print "found $key: $key[$i]  -- $value[$i] (def: $default)\n"; }
-            if (($default eq "") && ($value[$i] eq "")) { die "missing value for required key $key[$i]\n"; }
+            if (($default eq "") && ($value[$i] eq "")) { die "check_key: missing value for required key $key[$i]\n"; }
             if ($value[$i] eq "") { $value[$i] = $default; }
             return;
@@ -695,5 +703,5 @@
         if ($VERBOSE) { print "$key[$i]  -- $value[$i]\n"; }
         if ($line =~ m|\$$key[$i]|) {
-            if ($value[$i] eq "") { die "missing value for required key $key[$i]\n"; }
+            if ($value[$i] eq "") { die "check_keypairs: missing value for required key $key[$i]\n"; }
             $line =~ s|\$$key[$i]|$value[$i]|g;
         }
@@ -708,3 +716,2 @@
 # against the expectation at runtime.  for the moment,
 # calculate by hand and add to def.d file
-
Index: trunk/ippMonitor/scripts/helpers.dvo
===================================================================
--- trunk/ippMonitor/scripts/helpers.dvo	(revision 28601)
+++ trunk/ippMonitor/scripts/helpers.dvo	(revision 28601)
@@ -0,0 +1,29 @@
+#!/usr/bin/env dvo
+
+macro minimum
+  set values = $1
+  set minvalue = values[0]
+  for i 0 values[]
+    if ($minvalue>values[$i])
+      $minvalue = values[$i]
+    end
+  end
+  return $minvalue
+end
+
+macro maximum
+  set values = $1
+  set maxvalue = values[0]
+  for i 0 values[]
+    if ($maxvalue<values[$i])
+      $maxvalue = values[$i]
+    end
+  end
+  return $minvalue
+end
+
+macro myecho
+  if ($debug == 1)
+     echo $1
+  end
+end
Index: trunk/ippMonitor/scripts/plot_x_vs_y.dvo
===================================================================
--- trunk/ippMonitor/scripts/plot_x_vs_y.dvo	(revision 28601)
+++ trunk/ippMonitor/scripts/plot_x_vs_y.dvo	(revision 28601)
@@ -0,0 +1,60 @@
+#!/usr/bin/env dvo
+
+$debug=0
+
+macro build_x_vs_y
+  myecho "Loading data from = $1<br>"
+  data $1
+  read v 1 w 2
+  sort v w
+  limits v w
+  box
+  plot v w -x 0 -c blue
+  strsub $3 "_" "\\\\_" -var xlabel
+  strsub $4 "_" "\\\\_" -var ylabel
+  labels -x $xlabel -y $ylabel +x "$xlabel vs $ylabel"
+
+  fit v w 1
+  $y0 = $C0 + $C1 * $XMIN
+  $y1 = $C0 + $C1 * $XMAX
+  create xfit 0 2
+  xfit[0] = $XMIN
+  xfit[1] = $XMAX
+  create yfit 0 2
+  yfit[0] = $y0
+  yfit[1] = $y1
+  plot xfit yfit -c red -x 0
+
+  vstat v
+  set vUnbiased = v - $MEAN
+  $vsigma = $SIGMA
+  vstat w
+  set wUnbiased = w - $MEAN
+  $wsigma = $SIGMA
+  set vwUnbiased = vUnbiased * wUnbiased
+  vstat vwUnbiased
+  $correlation = $MEAN / ($vsigma * $wsigma)
+  label -ul "Correlation = $correlation"
+
+  myecho "Saving graphics to [$2]"
+  png -name $2
+end
+
+if ($SCRIPT)
+  $KAPA = kapa -noX
+  resize 1000 1000
+  if ($argv:n != 4)
+    echo "USAGE: build_x_vs_y (input) (output) (x-label) (y-label)"
+    echo "  TODO"
+    exit 1
+  end
+
+  echo "Loading dependencies"
+  $helpersFilename = `which helpers.dvo`
+  input $helpersFilename
+  echo "Dependencies loaded"
+
+  echo $argv:3
+  build_x_vs_y $argv:0 $argv:1 $argv:2 $argv:3
+  exit 0
+end
