Index: /branches/sc_branches/ippMonitorLap/INSTALL
===================================================================
--- /branches/sc_branches/ippMonitorLap/INSTALL	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/INSTALL	(revision 31685)
@@ -0,0 +1,24 @@
+
+after setting up psconfig:
+
+alala example:
+ psconfigure --dbhost alala --dbuser ipp --dbpass ipp --htdocs /var/www/localhost/htdocs
+
+ipp001 example:
+
+psconfigure --dbhost ipp001 --dbuser ipp --dbpass ipp --htdocs /var/www/localhost/htdocs
+
+
+kiawe / alala example:
+ psconfigure --dbhost alala --dbuser ipp --dbpass ipp --htdocs /var/www/kiawe
+
+ipp004 / ipp017 example:
+ psconfigure --dbhost ipp017 --dbuser ipp --dbpass ipp --htdocs ~ipp/htdocs
+
+ipp004 / ipp004 example:
+ psconfigure --dbhost ipp004 --dbuser ipp --dbpass ipp --htdocs ~ipp/htdocs
+
+# note that we have a special version for ippmonitor without $PSCONFIG/$PSCONFDIR values:
+ipp@ipp004 / ippdb01 example:
+ psconfigure --dbhost ippdb01 --dbuser ipp --dbpass ipp --htdocs ~/htdocs --site ~/ippconfig/ippmonitor.config
+
Index: /branches/sc_branches/ippMonitorLap/Makefile.in
===================================================================
--- /branches/sc_branches/ippMonitorLap/Makefile.in	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/Makefile.in	(revision 31685)
@@ -0,0 +1,327 @@
+default: updateVersion php
+help:
+	@echo "USAGE: make php"
+
+SRC     =       src
+DEF	=	def
+RAW	=	raw
+SCRIPTS =       scripts
+DESTBIN	=       @BINDIR@
+DESTWWW =       @HTDOCS@/ippMonitor
+
+GENERATE = $(SCRIPTS)/generate
+
+PROGRAMS = \
+$(DESTBIN)/skyplot.dvo \
+$(DESTBIN)/czartool_getServerStatus.pl \
+$(DESTBIN)/czartool_revert.pl \
+$(DESTBIN)/czartool_serverstoprun.pl \
+$(DESTBIN)/build_histogram.dvo \
+$(DESTBIN)/helpers.dvo \
+$(DESTBIN)/plot_x_vs_y.dvo
+
+RAWSRC = \
+$(DESTWWW)/Login.php \
+$(DESTWWW)/SelectProject.php \
+$(DESTWWW)/ipp.css \
+$(DESTWWW)/ipp.php \
+$(DESTWWW)/ipp.menu.dat \
+$(DESTWWW)/ipp.cal.dat \
+$(DESTWWW)/ipp.cal.php \
+$(DESTWWW)/ipp.detrend.dat \
+$(DESTWWW)/ipp.detrend.php \
+$(DESTWWW)/ipp.dist.dat \
+$(DESTWWW)/ipp.dist.php \
+$(DESTWWW)/ipp.imfiles.dat \
+$(DESTWWW)/ipp.imfiles.php \
+$(DESTWWW)/ipp.load.dat \
+$(DESTWWW)/ipp.load.php \
+$(DESTWWW)/ipp.plots.dat \
+$(DESTWWW)/ipp.plots.php \
+$(DESTWWW)/ipp.science.dat \
+$(DESTWWW)/ipp.science.php \
+$(DESTWWW)/ipp.stack.dat \
+$(DESTWWW)/ipp.stack.php \
+$(DESTWWW)/ipp.dvodb.dat \
+$(DESTWWW)/ipp.dvodb.php \
+$(DESTWWW)/phptest.php \
+$(DESTWWW)/site.php \
+$(DESTWWW)/showimage.php \
+$(DESTWWW)/nightSummary.php \
+$(DESTWWW)/simplePlot.php \
+$(DESTWWW)/simplePlotcam.php \
+$(DESTWWW)/simplePlotraw.php \
+$(DESTWWW)/skyplot.php \
+$(DESTWWW)/getimage.php \
+$(DESTWWW)/ipp.czartool.dat \
+$(DESTWWW)/czartool_labels.php \
+$(DESTWWW)/czartool_getplot.php \
+$(DESTWWW)/czartool_exposures.php \
+$(DESTWWW)/histogram.php \
+$(DESTWWW)/show_and_delete_image.php \
+$(DESTWWW)/scatterPlot.php \
+$(DESTWWW)/rawBurntoolState.php \
+$(DESTWWW)/plotHistogram.php \
+$(DESTWWW)/columns_in_db.php \
+$(DESTWWW)/cleanTmpDirectory.php \
+$(DESTWWW)/warpProcessedExp_Images.php \
+$(DESTWWW)/warpProcessedExp.php \
+$(DESTWWW)/diskUsage.php \
+$(DESTWWW)/version.php 
+
+
+
+
+DEFSRC = \
+$(DESTWWW)/keptDetrendFrames.php \
+$(DESTWWW)/masterDetrendFrames.php \
+$(DESTWWW)/masterDetrendImfiles.php \
+$(DESTWWW)/detInputExp.php \
+$(DESTWWW)/detMasterFrame.php \
+$(DESTWWW)/detMasterImfile.php \
+$(DESTWWW)/detNormalizedExp.php \
+$(DESTWWW)/detNormalizedImfile.php \
+$(DESTWWW)/detNormalizedStatImfile.php \
+$(DESTWWW)/detRegisteredImfile.php \
+$(DESTWWW)/detProcessedImfile.php \
+$(DESTWWW)/detProcessedExp.php \
+$(DESTWWW)/detProcessedExp_noimage.php \
+$(DESTWWW)/detResidExp.php \
+$(DESTWWW)/detResidExp_noimage.php \
+$(DESTWWW)/detResidImfile.php \
+$(DESTWWW)/detStackedImfile.php \
+$(DESTWWW)/detNormalizedExp_failure.php \
+$(DESTWWW)/detNormalizedImfile_failure.php \
+$(DESTWWW)/detNormalizedStatImfile_failure.php \
+$(DESTWWW)/detProcessedImfile_failure.php \
+$(DESTWWW)/detProcessedExp_failure.php \
+$(DESTWWW)/detResidExp_failure.php \
+$(DESTWWW)/detResidImfile_failure.php \
+$(DESTWWW)/detStackedImfile_failure.php \
+$(DESTWWW)/detRun.php \
+$(DESTWWW)/detRunActive.php \
+$(DESTWWW)/detRunSummary.php \
+$(DESTWWW)/newExp.php \
+$(DESTWWW)/newImfile.php \
+$(DESTWWW)/guidePendingExp.php \
+$(DESTWWW)/chipSummary.php \
+$(DESTWWW)/chipStageExp.php \
+$(DESTWWW)/chipPendingExp.php \
+$(DESTWWW)/chipPendingImfile.php \
+$(DESTWWW)/chipProcessedExp.php \
+$(DESTWWW)/chipIQstats.php \
+$(DESTWWW)/chipProcessedImfile.php \
+$(DESTWWW)/chipProcessedImfile_failure.php \
+$(DESTWWW)/failedChipProcessedImfile.php \
+$(DESTWWW)/camSummary.php \
+$(DESTWWW)/camStageExp.php \
+$(DESTWWW)/camPendingExp.php \
+$(DESTWWW)/camProcessedExp.php \
+$(DESTWWW)/camProcessedExp_Images.php \
+$(DESTWWW)/camProcessedExp_failure.php \
+$(DESTWWW)/failedCamProcessedExp.php \
+$(DESTWWW)/camIQstats.php \
+$(DESTWWW)/camProcessedImfile.php \
+$(DESTWWW)/fakeSummary.php \
+$(DESTWWW)/fakeStageExp.php \
+$(DESTWWW)/fakePendingExp.php \
+$(DESTWWW)/fakeProcessedExp.php \
+$(DESTWWW)/fakePendingImfile.php \
+$(DESTWWW)/fakeProcessedImfile.php \
+$(DESTWWW)/fakeProcessedImfile_failure.php \
+$(DESTWWW)/failedFakeProcessedImfile.php \
+$(DESTWWW)/pzPendingExp.php \
+$(DESTWWW)/pzPendingImfile.php \
+$(DESTWWW)/pzDoneExp.php \
+$(DESTWWW)/pzDoneImfile.php \
+$(DESTWWW)/pzDoneExp_failed.php \
+$(DESTWWW)/pzDoneImfile_failed.php \
+$(DESTWWW)/rawUnknownExp.php \
+$(DESTWWW)/rawDetrendExp.php \
+$(DESTWWW)/rawDetrendExp_detrend.php \
+$(DESTWWW)/rawImfile.php \
+$(DESTWWW)/rawImfile_failed.php \
+$(DESTWWW)/rawExp_failed.php \
+$(DESTWWW)/rawScienceExp.php \
+$(DESTWWW)/rawExp.php \
+$(DESTWWW)/rawSummary.php \
+$(DESTWWW)/rawExpStats.php \
+$(DESTWWW)/summitExp.php \
+$(DESTWWW)/summitImfile.php \
+$(DESTWWW)/warpSummary.php \
+$(DESTWWW)/warpStageExp.php \
+$(DESTWWW)/warpStageSkyfiles.php \
+$(DESTWWW)/warpStageSkyfileInputs.php \
+$(DESTWWW)/warpProcessedSkyfiles.php \
+$(DESTWWW)/warpFailedSkyfiles.php \
+$(DESTWWW)/failedWarpSkyfiles.php \
+$(DESTWWW)/diffSummary.php \
+$(DESTWWW)/diffSummary_Images.php \
+$(DESTWWW)/diffRun.php \
+$(DESTWWW)/diffInputSkyfile.php \
+$(DESTWWW)/diffProcessedSkyfile.php \
+$(DESTWWW)/diffProcessedSkyfile_Images.php \
+$(DESTWWW)/failedDiffSkyfile.php \
+$(DESTWWW)/stackRun.php \
+$(DESTWWW)/stackSummary.php \
+$(DESTWWW)/stackSummary_Images.php \
+$(DESTWWW)/stackInputSkyfile.php \
+$(DESTWWW)/stackProcessedSkyfile.php \
+$(DESTWWW)/stackProcessedSkyfile_Images.php \
+$(DESTWWW)/stackFailedSkyfile.php \
+$(DESTWWW)/failedStackSkyfile.php \
+$(DESTWWW)/staticskyRun.php \
+$(DESTWWW)/staticskySummary.php \
+$(DESTWWW)/staticskyInputSkyfile.php \
+$(DESTWWW)/staticskyProcessedSkyfile.php \
+$(DESTWWW)/staticskyFailedSkyfile.php \
+$(DESTWWW)/magicRun.php \
+$(DESTWWW)/magicSummary.php \
+$(DESTWWW)/magicTrees.php \
+$(DESTWWW)/magicProcessedNodes.php \
+$(DESTWWW)/magicProcessedMasks.php \
+$(DESTWWW)/magicProcessedMasks_Images.php \
+$(DESTWWW)/magicFailedTrees.php \
+$(DESTWWW)/failedMagicTrees.php \
+$(DESTWWW)/magicFailedNodes.php \
+$(DESTWWW)/failedMagicNodes.php \
+$(DESTWWW)/magicFailedMasks.php \
+$(DESTWWW)/failedMagicMasks.php \
+$(DESTWWW)/distSummary.php \
+$(DESTWWW)/distTarget.php \
+$(DESTWWW)/distRun.php \
+$(DESTWWW)/publishSummary.php \
+$(DESTWWW)/publishClient.php \
+$(DESTWWW)/publishRun.php \
+$(DESTWWW)/publishDone.php \
+$(DESTWWW)/distComponent.php \
+$(DESTWWW)/destreakSummary.php \
+$(DESTWWW)/destreakRun.php \
+$(DESTWWW)/destreakFile.php \
+$(DESTWWW)/calDB.php \
+$(DESTWWW)/calRun.php \
+$(DESTWWW)/flatcorrRun.php \
+$(DESTWWW)/flatcorrChip.php \
+$(DESTWWW)/flatcorrCamera.php \
+$(DESTWWW)/maskStats.php \
+$(DESTWWW)/simplePlotRawImage.php \
+$(DESTWWW)/simplePlotChipImage.php \
+$(DESTWWW)/simplePlotCamImage.php \
+$(DESTWWW)/histogramBackgroundImage.php \
+$(DESTWWW)/histogramCamProcessedExpImage.php \
+$(DESTWWW)/histogramZptObsImage.php \
+$(DESTWWW)/scatterPlotAirMassFwhmImage.php \
+$(DESTWWW)/scatterCpiBgReMaImage.php \
+$(DESTWWW)/scatterCpiBgReMpImage.php \
+$(DESTWWW)/scatterCpiBgReSaImage.php \
+$(DESTWWW)/exposureStatus.php \
+$(DESTWWW)/mopsStatus.php \
+$(DESTWWW)/gpc1MysqlProcessList.php \
+$(DESTWWW)/minidvodbRun.php \
+$(DESTWWW)/minidvodbCopy.php \
+$(DESTWWW)/minidvodbProcessed.php \
+$(DESTWWW)/addRunRun.php \
+$(DESTWWW)/addRunProcessed.php
+
+
+
+PICTURES = \
+$(DESTWWW)/PScolorlogo2.jpg \
+$(DESTWWW)/broken.png \
+$(DESTWWW)/down.png \
+$(DESTWWW)/down_sel.png \
+$(DESTWWW)/left.png \
+$(DESTWWW)/left_sel.png \
+$(DESTWWW)/missing.png \
+$(DESTWWW)/right.png \
+$(DESTWWW)/right_sel.png \
+$(DESTWWW)/up.png \
+$(DESTWWW)/up_sel.png \
+$(DESTWWW)/missing.png \
+$(DESTWWW)/noimage.png
+
+DESTLINK = $(DESTWWW)/index.php
+
+php: $(RAWSRC) $(DEFSRC) $(PICTURES) $(DESTLINK) $(PROGRAMS)
+
+# dependancy rules for binary code #########################
+# .PRECIOUS: %.$(ARCH).o
+# .PRECIOUS: $(BIN)/%.$(ARCH)
+
+$(DESTLINK): $(DESTWWW)/Login.php
+	rm -f $@
+	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
+	$(GENERATE) $< $(DEF)/autocode.php $@
+
+# 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
+	rm -f $(DESTWWW)/$*.php || exit
+	cp $(SRC)/$*.php $(DESTWWW)/$*.php || exit
+
+updateVersion:
+	rm -f $(DESTWWW)/version.php
+
+$(DESTWWW)/version.php:
+	svnversion > $@
+
+# non-generated php code is copied directly
+$(DESTWWW)/%.php: $(RAW)/%.php
+	@if [ ! -d $(DESTWWW) ]; then mkdir -p $(DESTWWW) || exit; fi
+	rm -f $(DESTWWW)/$*.php || exit
+	cp $(RAW)/$*.php $(DESTWWW)/$*.php || exit
+
+# all other files are copied directly
+$(DESTWWW)/%.css: $(RAW)/%.css
+	@if [ ! -d $(DESTWWW) ]; then mkdir -p $(DESTWWW) || exit; fi
+	rm -f $(DESTWWW)/$*.css || exit
+	cp $(RAW)/$*.css $(DESTWWW)/$*.css || exit
+
+$(DESTWWW)/%.dat: $(RAW)/%.dat
+	@if [ ! -d $(DESTWWW) ]; then mkdir -p $(DESTWWW) || exit; fi
+	rm -f $(DESTWWW)/$*.dat || exit
+	cp $(RAW)/$*.dat $(DESTWWW)/$*.dat || exit
+
+$(DESTWWW)/%.jpg: $(RAW)/%.jpg
+	@if [ ! -d $(DESTWWW) ]; then mkdir -p $(DESTWWW) || exit; fi
+	rm -f $(DESTWWW)/$*.jpg || exit
+	cp $(RAW)/$*.jpg $(DESTWWW)/$*.jpg || exit
+
+$(DESTWWW)/%.jpeg: $(RAW)/%.jpeg
+	@if [ ! -d $(DESTWWW) ]; then mkdir -p $(DESTWWW) || exit; fi
+	rm -f $(DESTWWW)/$*.jpeg || exit
+	cp $(RAW)/$*.jpeg $(DESTWWW)/$*.jpeg || exit
+
+$(DESTWWW)/%.png: $(RAW)/%.png
+	@if [ ! -d $(DESTWWW) ]; then mkdir -p $(DESTWWW) || exit; fi
+	rm -f $(DESTWWW)/$*.png || exit
+	cp $(RAW)/$*.png $(DESTWWW)/$*.png || exit
+
+$(DESTBIN)/%: $(SCRIPTS)/%
+	@if [ ! -d $(DESTBIN) ]; then mkdir -p $(DESTBIN) || exit; fi
+	cp $(SCRIPTS)/$* $(DESTBIN)/$* || exit
+	chmod +x $(DESTBIN)/$* || exit
+
+# utilities #################################################
+
+clean:	
+	rm -f `find . -name "*.o"`
+	rm -f `find . -name "*~"`
+	rm -f `find . -name "#*"`
+
+.PRECIOUS: $(SRC)/%.php
+.PRECIOUS: $(SRC)/%.css
+.PRECIOUS: $(SRC)/%.dat
+.PRECIOUS: $(SRC)/%.png
+.PRECIOUS: $(SRC)/%.jpg
+.PRECIOUS: $(SRC)/%.jpeg
Index: /branches/sc_branches/ippMonitorLap/configure
===================================================================
--- /branches/sc_branches/ippMonitorLap/configure	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/configure	(revision 31685)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+./configure.tcsh $*
Index: /branches/sc_branches/ippMonitorLap/configure.tcsh
===================================================================
--- /branches/sc_branches/ippMonitorLap/configure.tcsh	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/configure.tcsh	(revision 31685)
@@ -0,0 +1,234 @@
+#!/bin/csh -f
+
+# this is a very low-tech version of configure, not built by autoconf.
+
+# user needs to supply:
+# --htdocs : top-level of www files
+# --dbhost : machine running database
+# --dbuser : username for database access
+# --dbpass : password for database access
+
+set htdocs  = ""
+set dbhost  = ""
+set dbuser  = ""
+set dbpass  = ""
+
+set prefix  = ""
+set bindir  = ""
+set libdir  = ""
+set datadir = ""
+set site = ""
+
+set DBI     = "DB"
+
+set root    = ""
+set args    = ""
+
+while ("$1" != "") 
+ switch ("$1")
+  # options passed by jhbuild or others which we ignore
+  case --enable-maintainer-mode
+  case --no-create
+  case --no-recursion
+  case --sbindir*
+  case --libexecdir*
+  case --sharedstatedir*
+  case --localstatedir*
+  case --oldincludedir*
+  case --infodir*
+  case --mandir*
+  case --includedir*
+  case --sysconfdir*
+   # we need to strip the --opt word and --opt=word versions
+   set word = `echo $1 | tr = ' '`
+   if ($#word == 1) shift
+   breaksw;
+  case --htdocs*
+   if ("$1" == "--htdocs") then
+     shift
+     set htdocs = $1
+   else
+     set htdocs = `echo $1 | tr = ' ' | awk '{print $2}'`
+   endif
+   breaksw;
+  case --dbhost*
+   if ("$1" == "--dbhost") then
+     shift
+     set dbhost = $1
+   else
+     set dbhost = `echo $1 | tr = ' ' | awk '{print $2}'`
+   endif
+   breaksw;
+  case --dbuser*
+   if ("$1" == "--dbuser") then
+     shift
+     set dbuser = $1
+   else
+     set dbuser = `echo $1 | tr = ' ' | awk '{print $2}'`
+   endif
+   breaksw;
+  case --dbpass*
+   if ("$1" == "--dbpass") then
+     shift
+     set dbpass = $1
+   else
+     set dbpass = `echo $1 | tr = ' ' | awk '{print $2}'`
+   endif
+   breaksw;
+  case --prefix*
+   if ("$1" == "--prefix") then
+     shift
+     set prefix = $1
+   else
+     set prefix = `echo $1 | tr = ' ' | awk '{print $2}'`
+   endif
+   breaksw;
+  case --bindir*
+   if ("$1" == "--bindir") then
+     shift
+     set bindir = $1
+   else
+     set bindir = `echo $1 | tr = ' ' | awk '{print $2}'`
+   endif
+   breaksw;
+  case --libdir*
+   if ("$1" == "--libdir") then
+     shift
+     set libdir = $1
+   else
+     set libdir = `echo $1 | tr = ' ' | awk '{print $2}'`
+   endif
+   breaksw;
+  case --datadir*
+   if ("$1" == "--datadir") then
+     shift
+     set datadir = $1
+   else
+     set datadir = `echo $1 | tr = ' ' | awk '{print $2}'`
+   endif
+   breaksw;
+  case --site*
+   if ("$1" == "--site") then
+     shift
+     set site = $1
+   else
+     set site = `echo $1 | tr = ' ' | awk '{print $2}'`
+   endif
+   breaksw;
+  case --useMDB2
+   set DBI = "MDB2"
+   breaksw;
+  case --help:
+   goto usage
+  case -*: 
+   echo ""
+   echo "Unknown option: $1"
+   goto usage
+  default:
+   set args=($args $1);
+   breaksw;
+ endsw
+ shift
+end
+if ($#args != 1) goto usage
+
+set hostname = `hostname -f`
+
+echo
+echo "prefix: $prefix"
+echo "bindir: $bindir"
+echo "libdir: $libdir"
+echo "datadir:$datadir"
+echo "site:   $site"
+echo "htdocs: $htdocs"
+echo "dbhost: $dbhost"
+echo "dbuser: $dbuser"
+echo "dbpass: $dbpass"
+echo "DBI:    $DBI"
+echo
+
+if ("$htdocs" == "") goto usage
+if ("$dbhost" == "") goto usage
+if ("$dbuser" == "") goto usage
+if ("$dbpass" == "") goto usage
+
+# BINDIR holds the output binary files
+if ("$bindir" == "") then
+  if ("$prefix" == "") goto usage
+  set bindir = $prefix/bin
+endif
+
+# LIBDIR set the install lib directory
+if ("$libdir" == "") then
+  if ("$prefix" == "") goto usage
+  set libdir = $prefix/lib
+endif
+
+# DATADIR holds the general non-binary files
+if ("$datadir" == "") then
+  if ("$prefix" == "") goto usage
+  set datadir = $prefix/share
+endif
+
+# SITE defines the location of the ipprc.config file
+if ("$site" == "") then
+  if ("$datadir" == "") goto usage
+  set site = $datadir/ippconfig/ipprc.config
+endif
+
+rm -f tmp.1 tmp.2
+
+# convert Makefile.in to Makefile:
+if (-e Makefile) mv -f Makefile Makefile~
+cat Makefile.in | sed "s|@HTDOCS@|$htdocs|" > tmp.1
+cat tmp.1       | sed "s|@BINDIR@|$bindir|" > Makefile
+rm -f tmp.1
+
+# convert raw/site.php.in to raw/site.php
+if (-e raw/site.php) mv -f raw/site.php raw/site.php~
+cat raw/site.php.in | sed "s|@DBHOST@|$dbhost|"  > tmp.1
+cat tmp.1           | sed "s|@DBUSER@|$dbuser|"  > tmp.2
+cat tmp.2           | sed "s|@DBPASS@|$dbpass|"  > tmp.1
+cat tmp.1           | sed "s|@BINDIR@|$bindir|"  > tmp.2
+cat tmp.2           | sed "s|@LIBDIR@|$libdir|"  > tmp.1
+cat tmp.1           | sed "s|@PERLLIB@|$libdir|" > tmp.2
+cat tmp.2           | sed "s|@SITE@|$site|"      > tmp.1
+cat tmp.1           | sed "s|@DBI@|$DBI|"        > tmp.2
+cat tmp.2           | sed "s|@HOST@|$hostname|"  > raw/site.php
+rm -f tmp.1 tmp.2
+
+# need to set the PERLLIB and BINDIR variables (use prefix, bindir, libdir)
+
+exit 0
+
+usage:
+if ($#args > 1) then
+  echo unrecognized options: $args
+endif
+
+cat <<EOF
+USAGE: configure [OPTION]
+
+set the WWW installation directory root with --htdocs
+set the IPP installation directory root with --prefix
+
+set the database host, user, password with: --dbhost, --dbuser, -dbpass
+ 
+either --prefix or both --bindir and --libdir and [--datadir or --site] are required
+
+if both --datadir and --site are defined, --site overrides the ipprc.config definition
+
+Configuration:
+  -h, --help              display this help and exit
+
+Installation directories:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+
+Fine tuning of the installation directories:
+  --bindir=DIR           user executables [PREFIX/bin/$ARCH] 
+  --libdir=DIR           object code libraries [PREFIX/lib/$ARCH]
+  --datadir=DIR          read-only architecture-independent data [PREFIX/share]
+  --site=PATH            location of the ipprc.config file [DATADIR/ippconfig/ipprc.config]
+
+EOF
+ exit 2;
Index: /branches/sc_branches/ippMonitorLap/def/README
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/README	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/README	(revision 31685)
@@ -0,0 +1,181 @@
+
+** the current definition files correspond to tasks.md 1.86
+** update this file if you need to update the tables
+
+Each of the *.d files in this directory (except example.d) are used to
+define a page in the ipp web tools which show the contents of a
+database table (or tables).  There are also pages which do not refer
+to a specific database table: these are defined in ../raw and are not
+pre-processed with the 'generate' function.  The contents of the
+description file are confronted with a template file and used to
+generate PHP code.  
+
+The layout of each page is essentially the same: the page is divided
+into a main data area and a left-hand side navigation table.  The
+contents of the navigation table are defined by the menu definition
+file specified for the page.  The data area includes the following
+elements:
+
+- TITLE
+- HEAD (html or php code)
+- TABLE
+- TAIL (html or php code)
+
+The *.d file defines each of these regions with a set of rules.  Each
+rule is specified on a single line, and begins with one of the defined
+keywords.  Several keywords are required to be unique (eg, TABLE and
+TITLE) while others may be repeated (eg, WHERE, FIELD).  For most of
+the keywords, there is no fixed format for the value, but in the case
+of the FIELD keyword, care must be taken to follow the mandatory
+syntax. 
+
+The TITLE is define by a single, fixed keyword (TITLE).
+
+The HEAD and TAIL regions are defined by the HEAD and TAIL lines, and
+are optional.  Each HEAD or TAIL line is followed by a word defining
+the code type (may be HTML or PHP).  The rest of the line defines code
+which is interpreted as either HTML or PHP.  These replace the lines
+"// ** HEAD CODE **" and "// ** TAIL CODE **" in the template file.
+
+By default, the menu definition file for the page is defined by the
+specified MENU key.  If, however, the page is passed a "menu=XXXX"
+directive (either via GET or POST), then the specified file is used
+instead as a menu definition file.  This mechanism is used to allow
+the same table definition page to be linked from different locations
+in the pages and have the same appearence as the referencing page.
+
+The rest of the file defines the displayed contents of the table.  The
+page generates an HTML table based on a query of one (or possibly more
+than one, see below) database tables.  The table used for the query is
+specified by the TABLE key.  An SQL command is generated based on the
+requested fields, defined by the FIELD keys.  If desired, WHERE
+statements may be added to the SQL command with the WHERE key.  Each
+line marked by WHERE is appended (with AND) to the SQL WHERE clause.  
+
+The FIELDS lines define both the queried fields and the rules for
+presenting the fields in the HTML table.  Each FIELD row results in a
+column in the output HTML table, unless otherwise noted (see below).
+Each FIELD row also corresponds to a queried field from the database
+table, again unless otherwise noted.  Each FIELD command is followed
+by a set of comma-separated values.  The first entry defines the name
+of the database table field.  The second entry defines the minimum
+width of the column.  The third entry defines the column header.  The
+rest of the entries are optional.  The fourth entry specifies what is
+placed in the cell, and may consist of:
+
+- the string "value", in which case the corresponding data entry from
+the database for the column and row are used to fill the cell.  This
+is the default behavior.
+
+- the string "value=XXX", in which case the cell is filled with the
+value of XXX instead of the corresponding database cell value.  If XXX
+consists of one of the specified database fields, that column's data
+for this row is substituted instead.  
+
+- the string "image=XXX", in which case the cell is filled with the
+image represented by the URI XXX.  
+
+- the string "none", in which case the cell is column in the output
+HTML table.  Such elements are needed to lookup a value from the
+database (ie, to be passed to links, see below) but not to display the
+value in the table.
+
+The fifth entry defines an optional link for the cell.  If this field
+is set, a link is created for the cell using the given word as the
+target of the link.  The link will also have the mandatory GET data
+attached (including the menu and the pass data needed to validate the
+user).  
+
+The sixth entry is used to specify additional information passed to
+the linked page via GET data elements.  These are typically of the
+form "word=value", and may include multiple comma separated
+entries. If the value elements consist of $field where field is one of
+the valid database field names, this value for the current row is
+passed with the link.
+
+If the first entry of the FIELD row has the value "*", then the row
+is NOT used to define a database field; it is only used to define an
+output column in the HTML table.
+
+Drawing Figures
+===============
+- Definition files (def/*.d) MUST be appended with Image.d to allow specific
+  processing (the template is not def/autocode.php but autocodeImage.php)
+     e.g.:   	  plotMyStuffImage.php
+- No changes to the previous file content except for these 4 items:
+
+     1) The 'restrict' keyword should be used in the 'show' column of
+     	FIELD entry if displaying the column values is wanted.
+	Such FIELDs are used in the WHERE restriction clause, not in
+	the query.
+
+	Note for developpers: actually any word different from the
+	existing keywords '', 'value', 'none', 'image=xxx',
+	'value=xxx' are ok.  No code was developped to support this
+	keyword in the scritps/generate script.
+
+     2) 'TOPLOT <list of db columns>': defines the list of columns to
+     	query.
+	e.g.: 
+	      TOPLOT camProcessedExp.fwhm_major
+	      TOPLOT chipProcessedImfile.bg, rawExp.sun_angle
+	All values (no LIMIT) are written to a temporary (text) file
+	of the /tmp directory.
+	In a row, the different values are separated by a single space
+	(i.e. ' ').
+
+     3) 'PLOTTER <php_script_name>': defines the name of the PHP
+        script that will call an external tool (e.g. a DVO script).
+	
+	It is expected that the PHP script named 'php_script_name'
+	supports the following parameters:
+	- input: the name of an input text filename;
+	- output: the name of an output image filename;
+	- title: a string (see item 4) PLOTTITLE).
+
+	e.g.:
+		PLOTTER scatterPlot.php	
+		PLOTTER plotHistogram.php
+
+	The list of existing plotters are detailed further.
+
+     4) 'PLOTTITLE <A title>': defines the title of a figure. Could be
+     	used in the external program which is effectively used for
+     	rendering the figure.
+
+	e.g.:
+		PLOTTITLE A title
+
+Existing plotting scripts
+=========================
+raw/skyplot.php (calls scripts/skyplot.dvo)
+	Text input file needs to contain 3 columns
+
+raw/plotHistogram.php (calls scripts/build_histogram.dvo)
+	Text input file needs to contain 1 column
+	Computes the histogram of the input file data for 100 bins.
+
+raw/scatterPlot.php (calls scripts/pot_x_vs_y.dvo)
+	Text input file needs to contain 2 columns
+	Scatter plot of the first column values vs the second ones
+	Regression line is also plotted (correlation coefficient is
+	shown in title).
+
+Plotting with PHP and temporary files
+=====================================
+
+Plots in PHP use temporary files (to provide data to dvo scripts and
+to store result images). Unfortunately, if the files are deleted at
+the end of main php script, the browser does not have the time to
+render the image. If the file is not deleted, they remain in the /tmp
+directory leading to disk space exhaustion.
+
+To avoid this problem, the function delete_old_tmp_files() in ipp.php
+was created. It checks the /tmp directory and removes all files
+belonging to the $DELETION_USER user and that are older than
+$DELETION_DELAY minutes. delete_old_tmp_files() is called at the
+beginning of the autocodeImage.php template script (line 4) and is
+therefore present in all generated plotting scripts.
+
+$DELETION_USER and $DELETION_DELAY are defined in site.php.in (values
+are 'apache' and '15').
Index: /branches/sc_branches/ippMonitorLap/def/addRunProcessed.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/addRunProcessed.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/addRunProcessed.d	(revision 31685)
@@ -0,0 +1,32 @@
+TABLE addRun, addProcessedExp
+TITLE Processed addRuns
+FILE  addRunProcessed.php
+MENU  ipp.dvodb.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+
+WHERE addRun.add_id = addProcessedExp.add_id
+
+#     field                   size  format  name         show    link to                  extras
+FIELD distinct(addRun.add_id),        5, %d,     add ID
+
+FIELD addRun.stage,        5, %s,     stage
+FIELD addRun.stage_id,          5, %d,     cam ID
+FIELD addRun.state,        5, %s,     state
+FIELD addProcessedExp.fault,        5, %d,     fault
+FIELD addProcessedExp.dtime_addstar,        5, %d,     addstar time
+
+FIELD addProcessedExp.path_base,        5, %s,     pathbase
+FIELD addRun.reduction,        5, %s,     reduction
+FIELD addRun.label,        5, %s,     label
+FIELD addRun.data_group,        5, %s,     data_group
+FIELD addRun.dvodb,        5, %s,     dvodb
+FIELD addProcessedExp.dvodb_path,        5, %s,     dvodb_path
+
+FIELD addRun.note,        5, %s,     note
+FIELD addRun.image_only,        5, %d,   image_only
+FIELD addRun.minidvodb,        5, %d,     minidvodb
+FIELD addRun.minidvodb_group,        5, %s,     minidvodb_group
+FIELD addRun.minidvodb_name,        5, %s,     minidvodb_name
+
+
Index: /branches/sc_branches/ippMonitorLap/def/addRunRun.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/addRunRun.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/addRunRun.d	(revision 31685)
@@ -0,0 +1,27 @@
+TABLE addRun
+TITLE addRuns
+FILE  addRunRun.php
+MENU  ipp.dvodb.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+
+WHERE add_id >= 0
+
+#     field                   size  format  name         show    link to                  extras
+FIELD distinct(addRun.add_id),        5, %d,     add ID
+FIELD addRun.stage,        5, %s,     stage
+FIELD addRun.stage_id,          5, %d,     stage ID
+FIELD addRun.add_id,        5, %d,     add ID
+FIELD addRun.state,        5, %s,     state
+FIELD addRun.workdir,        5, %s,     workdir
+FIELD addRun.reduction,        5, %s,     reduction
+FIELD addRun.label,        5, %s,     label
+FIELD addRun.data_group,        5, %s,     data_group
+FIELD addRun.dvodb,        5, %s,     dvodb
+FIELD addRun.note,        5, %s,     note
+FIELD addRun.image_only,        5, %d,   image_only
+FIELD addRun.minidvodb,        5, %d,     minidvodb
+FIELD addRun.minidvodb_group,        5, %s,     minidvodb_group
+FIELD addRun.minidvodb_name,        5, %s,     minidvodb_name
+
+
Index: /branches/sc_branches/ippMonitorLap/def/autocode.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/autocode.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/autocode.php	(revision 31685)
@@ -0,0 +1,140 @@
+<?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 restrictions to the queries
+// ** TABLE RESTRICTIONS **
+
+if ($restricted == 0) {
+  if ("$UNRESTRICTED" != "none") {
+    $WHERE = "$WHERE $UNRESTRICTED";
+  }
+}
+
+// Add GROUP BY statements if any
+// ** GROUP RESTRICTIONS **
+
+// get the result table count
+if ($MODE == "basic") {
+  $sql = "SELECT count(*) FROM $TABLE $WHERE";
+}
+if ($MODE == "summary") {
+  $sql = "SELECT count(*) FROM (SELECT $FIELDS FROM $TABLE $WHERE) as TEMP";
+}
+
+$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();
+}
+// set up the row counter variables
+if ($ID['from']) {
+  $rowStart = $ID['from'];
+} else {
+  $rowStart = 0;
+}
+$rowLast = $rowStart + $dTABLE;
+$rowTotal = $row[0];
+if ($rowLast > $rowTotal) { $rowLast = $rowTotal; }
+echo "<b> $rowStart to $rowLast of $rowTotal items</b><br>\n";
+
+// query the database
+if ($MODE == "basic") {
+  $sql = "SELECT $FIELDS FROM $TABLE $WHERE LIMIT $dTABLE OFFSET $rowStart";
+}
+if ($MODE == "summary") {
+  $sql = "SELECT $FIELDS FROM $TABLE $WHERE LIMIT $dTABLE OFFSET $rowStart";
+}
+
+$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: /branches/sc_branches/ippMonitorLap/def/autocodeImage.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/autocodeImage.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/autocodeImage.php	(revision 31685)
@@ -0,0 +1,180 @@
+<?php 
+
+include 'ipp.php';
+delete_old_tmp_files();
+
+$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;
+    case 'g':
+      $filter = 1;
+      break;
+    case 'r':
+      $filter = 2;
+      break;
+    case 'i':
+      $filter = 3;
+      break;
+    case 'z':
+      $filter = 4;
+      break;
+    case 'y':
+      $filter = 5;
+      break;
+    case 'w':
+      $filter = 6;
+      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";
+
+// ** TAIL CODE **
+
+echo "<small> WHERE: $WHERE<br><br></small>\n";
+echo "<small> SQL: $sql<br><br></small>\n";
+
+echo "Temporary files are [$datFilename] and [$pngFilename]\n";
+
+menu_end();
+
+?>
Index: /branches/sc_branches/ippMonitorLap/def/calDB.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/calDB.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/calDB.d	(revision 31685)
@@ -0,0 +1,9 @@
+TABLE calDB
+TITLE calDB
+FILE  calDB.php
+MENU  ipp.cal.dat
+
+#        field        size  format  name           show     link to         extras
+FIELD    cal_id,	20, %s,     calibration ID
+FIELD    dvodb,		20, %s,     DVO database
+FIELD    state,	        20, %s,     state
Index: /branches/sc_branches/ippMonitorLap/def/calRun.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/calRun.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/calRun.d	(revision 31685)
@@ -0,0 +1,10 @@
+TABLE calRun
+TITLE calRun
+FILE  calRun.php
+MENU  ipp.cal.dat
+
+#        field        size  format  name           show     link to         extras
+FIELD    cal_id,	20, %s,     calibration ID
+FIELD    region,	20, %s,     region
+FIELD    last_step,	20, %s,     late calibration
+FIELD    state,	        20, %s,     state
Index: /branches/sc_branches/ippMonitorLap/def/camIQstats.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/camIQstats.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/camIQstats.d	(revision 31685)
@@ -0,0 +1,42 @@
+TABLE camRun, chipRun, rawExp, camProcessedExp
+TITLE Per-Exposure Image Quality Stats
+FILE  camIQstats.php
+MENU  ipp.science.dat
+
+# limit this table to non-OBJECT types of images
+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
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+
+OP   OP1  0.5*($camProcessedExp.fwhm_major_uq + $camProcessedExp.fwhm_minor_uq)
+OP   OP2  0.5*($camProcessedExp.fwhm_major_lq + $camProcessedExp.fwhm_minor_lq)
+
+#     field                   size  format  name         show    link to                  extras
+FIELD rawExp.exp_name,     	 5, %s,     Exp Name
+FIELD chipRun.label,    	 7, %s,     Label
+FIELD chipRun.data_group,    	 7, %s,     data grp
+FIELD chipRun.dist_group,    	 7, %s,     dist grp
+FIELD rawExp.dateobs,        	19, %T,     Date/Time
+FIELD rawExp.filter,         	10, %s,     FILTER
+FIELD rawExp.exp_time,       	 5, %.2f,     exp_time    
+FIELD rawExp.airmass,        	 5, %.4f,     airmass     
+
+FIELD camProcessedExp.fwhm_major, 5, %.2f, fwhm major psf
+FIELD camProcessedExp.fwhm_minor, 5, %.2f, fwhm minor psf
+FIELD camProcessedExp.fwhm_major_uq, 5, %.2f, fwhm UQ, op=OP1
+FIELD camProcessedExp.fwhm_major_lq, 5, %.2f, fwhm LQ, op=OP2
+FIELD camProcessedExp.fwhm_minor_uq, 5, %.2f, fwhm UQ, none
+FIELD camProcessedExp.fwhm_minor_lq, 5, %.2f, fwhm UQ, none
+
+FIELD camProcessedExp.iq_fwhm_major, 5, %.2f, fwhm major moments
+FIELD camProcessedExp.iq_fwhm_minor, 5, %.2f, fwhm minor moments
+
+FIELD camProcessedExp.iq_m2, 5, %.2f, m2 moment
+FIELD camProcessedExp.iq_m3, 5, %.2f, m3 moment
+FIELD camProcessedExp.iq_m4, 5, %.2f, m4 moment
+
Index: /branches/sc_branches/ippMonitorLap/def/camPendingExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/camPendingExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/camPendingExp.d	(revision 31685)
@@ -0,0 +1,39 @@
+TABLE camRun, chipRun, rawExp
+TITLE Camera Pending
+FILE  camPendingExp.php
+MENU  ipp.science.dat
+
+WHERE camRun.state = 'new'
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                     size  format  name          show   link to                  extras
+FIELD rawExp.exp_name,     	10,   %s,     Exp Name
+FIELD rawExp.exp_id,	         5,   %d,     Exp ID,       value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,           5,   %d,     Chip ID,      value,  chipProcessedImfile.php, ARG2
+FIELD camRun.cam_id,             5,   %d,     Cam ID
+FIELD camRun.state,              5,   %s,     State
+FIELD camRun.label,              5,   %s,     Label
+FIELD camRun.data_group,              5,   %s,     data grp
+FIELD camRun.dist_group,              5,   %s,     dist grp
+FIELD rawExp.telescope,      	10,   %s,     Telescope
+FIELD rawExp.camera,         	10,   %s,     Camera
+FIELD rawExp.dateobs,        	19,   %T,     Date/Time
+FIELD rawExp.ra,                 8,   %C, RA,           op=OP1      
+FIELD rawExp.decl,               8,   %C, DEC,          op=OP2
+FIELD rawExp.object,         	10,   %s,     Object
+FIELD rawExp.filter,         	10,   %s,     FILTER
+FIELD rawExp.exp_time,       	 5,   %.2f,   exp_time    
+FIELD rawExp.airmass,        	 5,   %.4f,   airmass     
+FIELD rawExp.bg,             	 5,   %.2f,   backgnd
+FIELD rawExp.bg_stdev,       	 5,   %.2f,   stdev    
+FIELD rawExp.comment,  	        65,   %s,     Comment
+
+# FIELD rawExp.bg_mean_stdev,  	 5,   %.2f,   &lt;backgnd&gt;
Index: /branches/sc_branches/ippMonitorLap/def/camProcessedExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/camProcessedExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/camProcessedExp.d	(revision 31685)
@@ -0,0 +1,56 @@
+TABLE camRun, camProcessedExp, chipRun, rawExp
+TITLE Camera Processed
+FILE  camProcessedExp.php
+MENU  ipp.science.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+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
+
+# define the arguments supplied to the links below (if any)
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+
+ARGS  ARG4 camRun.cam_id=$camRun.cam_id
+ARGS  ARG4 camera=$rawExp.camera
+ARGS  ARG4 basename=$camProcessedExp.path_base
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                     	size  format  name          show   	 link to                  extras
+FIELD rawExp.exp_name,     	 	10,   %s,     Exp Name
+FIELD rawExp.exp_id,	         	 5,   %d,     Exp ID,       value,  	 rawImfile.php,           ARG1
+FIELD chipRun.chip_id,           	 5,   %d,     Chip ID,      value,  	 chipProcessedImfile.php, ARG2
+FIELD camRun.cam_id,             	 5,   %d,     Cam ID,       value,  	 camProcessedExp.php,     ARG3
+FIELD camRun.state,                      5,   %s,     state,        value,  	 camProcessedImfile.php,  ARG4
+FIELD camRun.label,             	 5,   %s,     Label
+FIELD camRun.data_group,             	 5,   %s,     data grp
+FIELD camRun.dist_group,             	 5,   %s,     dist grp
+FIELD rawExp.telescope,      		10,   %s,     Telescope
+FIELD rawExp.camera,         		10,   %s,     Camera
+FIELD rawExp.dateobs,        		19,   %T,     Date/Time
+FIELD rawExp.ra,           		 8,   %C, RA,           op=OP1      
+FIELD rawExp.decl,         		 8,   %C, DEC,          op=OP2
+FIELD rawExp.object,         		10,   %s,     Object
+FIELD rawExp.filter,         		10,   %s,     FILTER
+FIELD rawExp.exp_time,       		 5,   %.2f,     exp_time    
+FIELD rawExp.airmass,        		 5,   %.4f,     airmass     
+FIELD camProcessedExp.bg,             	 5,   %.2f,     backgnd
+FIELD camProcessedExp.bg_stdev,       	 5,   %.2f,     stdev    
+FIELD camProcessedExp.n_stars,  	 5,   %d,     Nstars
+FIELD camProcessedExp.n_astrom, 	 5,   %d,     Nastrom
+FIELD camProcessedExp.sigma_ra, 	 5,   %f,     sigma ra
+FIELD camProcessedExp.fwhm_major,     	 5,   %f,     FHWM (major)
+FIELD rawExp.comment,  	                65, %s,     Comment
+
+FIELD camProcessedExp.path_base,     	 5,   %s,     path_base,    none
+FIELD rawExp.exp_id,     		 5,   %s,     Exp ID,       none
+
+# the last two are used as arguments elsewhere, thus needed in the list, even if not displayed
+# FIELD camRun.reduction,       	         5,   %s,     reduction
+# FIELD camProcessedExp.bg_mean_stdev,  	 5,   %.2f,     &lt;backgnd&gt;
Index: /branches/sc_branches/ippMonitorLap/def/camProcessedExp_Images.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/camProcessedExp_Images.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/camProcessedExp_Images.d	(revision 31685)
@@ -0,0 +1,60 @@
+TABLE camRun, camProcessedExp, chipRun, rawExp
+TITLE Camera Processed
+FILE  camProcessedExp_Images.php
+MENU  ipp.science.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+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
+
+# define image names to be used below
+# IMAGE VAR basename filerule camera class_id
+IMAGE JPEG2 $camProcessedExp.path_base PPIMAGE.JPEG2 $rawExp.camera NONE
+
+# define the arguments supplied to the links below (if any)
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+
+ARGS  ARG4 camRun.cam_id=$camRun.cam_id
+ARGS  ARG4 camera=$rawExp.camera
+ARGS  ARG4 basename=$camProcessedExp.path_base
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                     	size  format  name          show   	 link to                  extras
+FIELD rawExp.exp_name,     	 	10,   %s,     Exp Name
+FIELD rawExp.exp_id,	         	 5,   %d,     Exp ID,       value,  	 rawImfile.php,           ARG1
+FIELD chipRun.chip_id,           	 5,   %d,     Chip ID,      value,  	 chipProcessedImfile.php, ARG2
+FIELD camRun.cam_id,             	 5,   %d,     Cam ID,       value,  	 camProcessedExp_Images.php,     ARG3
+FIELD camRun.label,             	 5,   %s,     Label
+FIELD camRun.data_group,             	 5,   %s,     data grp
+FIELD camRun.dist_group,             	 5,   %s,     dist grp
+FIELD *,    	                	 8,   %s,     image,        image=JPEG2, camProcessedImfile.php,  ARG4
+FIELD rawExp.telescope,      		10,   %s,     Telescope
+FIELD rawExp.camera,         		10,   %s,     Camera
+FIELD rawExp.dateobs,        		19,   %T,     Date/Time
+FIELD rawExp.ra,           		 8,   %C, RA,           op=OP1      
+FIELD rawExp.decl,         		 8,   %C, DEC,          op=OP2
+FIELD rawExp.object,         		10,   %s,     Object
+FIELD rawExp.filter,         		10,   %s,     FILTER
+FIELD rawExp.exp_time,       		 5,   %.2f,     exp_time    
+FIELD rawExp.airmass,        		 5,   %.4f,     airmass     
+FIELD camProcessedExp.bg,             	 5,   %.2f,     backgnd
+FIELD camProcessedExp.bg_stdev,       	 5,   %.2f,     stdev    
+FIELD camProcessedExp.n_stars,  	 5,   %d,     Nstars
+FIELD camProcessedExp.n_astrom, 	 5,   %d,     Nastrom
+FIELD camProcessedExp.sigma_ra, 	 5,   %f,     sigma ra
+FIELD camProcessedExp.fwhm_major,     	 5,   %f,     FHWM (major)
+FIELD rawExp.comment,  	                65, %s,     Comment
+
+FIELD camProcessedExp.path_base,     	 5,   %s,     path_base,    none
+FIELD rawExp.exp_id,     		 5,   %s,     Exp ID,       none
+
+# the last two are used as arguments elsewhere, thus needed in the list, even if not displayed
+# FIELD camRun.reduction,       	         5,   %s,     reduction
+# FIELD camProcessedExp.bg_mean_stdev,  	 5,   %.2f,     &lt;backgnd&gt;
Index: /branches/sc_branches/ippMonitorLap/def/camProcessedExp_NoImages.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/camProcessedExp_NoImages.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/camProcessedExp_NoImages.d	(revision 31685)
@@ -0,0 +1,54 @@
+TABLE camRun, camProcessedExp, chipRun, rawExp
+TITLE Camera Processed (No Images)
+FILE  camProcessedExp_NoImages.php
+MENU  ipp.science.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+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
+
+# define the arguments supplied to the links below (if any)
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+
+ARGS  ARG4 camRun.cam_id=$camRun.cam_id
+ARGS  ARG4 camera=$rawExp.camera
+ARGS  ARG4 basename=$camProcessedExp.path_base
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                     	size  format  name          show   	 link to                  extras
+FIELD rawExp.exp_name,     	 	10,   %s,     Exp Name
+FIELD rawExp.exp_id,	         	 5,   %d,     Exp ID,       value,  	 rawImfile.php,           ARG1
+FIELD chipRun.chip_id,           	 5,   %d,     Chip ID,      value,  	 chipProcessedImfile.php, ARG2
+FIELD camRun.cam_id,             	 5,   %d,     Cam ID,       value,  	 camProcessedExp.php,     ARG3
+FIELD camRun.state,                      5,   %s,     state,        value,  	 camProcessedImfile.php,  ARG4
+FIELD camRun.label,                      5,   %s,     label
+FIELD camRun.data_group,                      5,   %s,     data grp
+FIELD camRun.dist_group,                      5,   %s,     dist grp
+FIELD rawExp.telescope,      		10,   %s,     Telescope
+FIELD rawExp.camera,         		10,   %s,     Camera
+FIELD rawExp.dateobs,        		19,   %T,     Date/Time
+FIELD rawExp.ra,           		 8,   %C, RA,           op=OP1      
+FIELD rawExp.decl,         		 8,   %C, DEC,          op=OP2
+FIELD rawExp.object,         		10,   %s,     Object
+FIELD rawExp.filter,         		10,   %s,     FILTER
+FIELD rawExp.exp_time,       		 5,   %.2f,     exp_time    
+FIELD rawExp.airmass,        		 5,   %.4f,     airmass     
+FIELD camProcessedExp.bg,             	 5,   %.2f,     backgnd
+FIELD camProcessedExp.bg_stdev,       	 5,   %.2f,     stdev    
+FIELD camProcessedExp.n_stars,  	 5,   %d,     Nstars
+FIELD camProcessedExp.n_astrom, 	 5,   %d,     Nastrom
+FIELD camProcessedExp.sigma_ra, 	 5,   %f,     sigma ra
+FIELD camProcessedExp.fwhm_major,     	 5,   %f,     FHWM (major)
+FIELD rawExp.comment,  	                65, %s,     Comment
+
+FIELD camProcessedExp.path_base,     	 5,   %s,     path_base,    none
+FIELD rawExp.exp_id,     		 5,   %s,     Exp ID,       none
+
+# FIELD camProcessedExp.bg_mean_stdev,  	 5,   %.2f,     &lt;backgnd&gt;
Index: /branches/sc_branches/ippMonitorLap/def/camProcessedExp_failure.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/camProcessedExp_failure.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/camProcessedExp_failure.d	(revision 31685)
@@ -0,0 +1,56 @@
+TABLE camRun, camProcessedExp, chipRun, rawExp
+TITLE Camera Failed Exposures
+FILE  camProcessedExp_failure.php
+MENU  ipp.science.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+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
+
+# define the arguments supplied to the links below (if any)
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+
+ARGS  ARG4 camRun.cam_id=$camRun.cam_id
+ARGS  ARG4 camera=$rawExp.camera
+ARGS  ARG4 basename=$camProcessedExp.path_base
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                     	size  format  name          show   	 link to                      extras
+FIELD rawExp.exp_name,     	 	 5,   %s,     Exp Name
+FIELD rawExp.exp_id,	         	 5,   %d,     Exp ID,       value,  	 rawImfile.php,               ARG1
+FIELD chipRun.chip_id,           	 5,   %d,     Chip ID,      value,  	 chipProcessedImfile.php,     ARG2
+FIELD camRun.cam_id,            	 5,   %d,     Cam ID,       value,       camProcessedExp_failure.php, ARG3
+FIELD camRun.state,                      5,   %s,     state,        value,       camProcessedImfile.php,      ARG4
+FIELD camRun.label,                      5,   %s,     label
+FIELD camRun.data_group,                      5,   %s,     data grp
+FIELD camRun.dist_group,                      5,   %s,     dist grp
+FIELD rawExp.telescope,      		10,   %s,     Telescope
+FIELD rawExp.camera,         		10,   %s,     Camera
+FIELD rawExp.dateobs,        		19,   %T,     Date/Time
+FIELD rawExp.ra,           		 8,   %C, RA,           op=OP1      
+FIELD rawExp.decl,         		 8,   %C, DEC,          op=OP2
+FIELD rawExp.object,         		10,   %s,     Object
+FIELD rawExp.filter,         		10,   %s,     FILTER
+FIELD rawExp.exp_time,       		 5,   %.2f,     exp_time    
+FIELD rawExp.airmass,        		 5,   %.4f,     airmass     
+FIELD camProcessedExp.bg,             	 5,   %.2f,     backgnd
+FIELD camProcessedExp.bg_stdev,       	 5,   %.2f,     stdev    
+FIELD camProcessedExp.n_stars,  	 5,   %d,     Nstars
+FIELD camProcessedExp.n_astrom, 	 5,   %d,     Nastrom
+FIELD camProcessedExp.sigma_ra, 	 5,   %f,     sigma ra
+FIELD camProcessedExp.fwhm_major,     	 5,   %f,     FHWM (major)
+FIELD rawExp.comment,  	                65, %s,     Comment
+
+FIELD camProcessedExp.path_base,     	 5,   %s,     path_base,    none
+FIELD rawExp.exp_id,     		 5,   %s,     Exp ID,       none
+
+# FIELD camRun.reduction,       	         5,   %s,     reduction
+# FIELD camProcessedExp.bg_mean_stdev,  	 5,   %.2f,     &lt;backgnd&gt;
+
+TAIL PHP insert_log ('LOG.IMFILE');
Index: /branches/sc_branches/ippMonitorLap/def/camProcessedImfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/camProcessedImfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/camProcessedImfile.d	(revision 31685)
@@ -0,0 +1,49 @@
+TABLE camRun, camProcessedExp, chipRun, rawExp, chipProcessedImfile
+TITLE Camera Processed Imfiles
+FILE  camProcessedImfile.php
+MENU  ipp.science.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+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 chipProcessedImfile.chip_id = camRun.chip_id
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+HEAD PHP insert_image ('PPIMAGE.JPEG1', 'width=1000pix');
+
+#     field                     	size  format  name          show   	 link to                  extras
+FIELD rawExp.exp_name,     		10,   %s,     Exp Name,     value
+FIELD chipProcessedImfile.class_id,  	 8,   %s,     Class ID
+FIELD rawExp.exp_id,	        	 5,   %s,     Exp ID,       value,       rawImfile.php,           ARG1
+FIELD chipRun.chip_id,          	 5,   %s,     Chip ID,      value,       chipProcessedImfile.php, ARG2
+FIELD camRun.cam_id,            	 5,   %s,     Cam ID,       value,       camProcessedExp.php,     ARG3
+FIELD camRun.label,             	 5,   %s,     Label
+FIELD camRun.data_group,             	 5,   %s,     data grp
+FIELD camRun.dist_group,             	 5,   %s,     dist grp
+FIELD rawExp.telescope,      		10,   %s,     Telescope
+FIELD rawExp.camera,         		10,   %s,     Camera
+FIELD rawExp.dateobs,        		19,   %T,     Date/Time
+FIELD rawExp.ra,           		 8,   %C, RA,           op=OP1      
+FIELD rawExp.decl,         		 8,   %C, DEC,          op=OP2
+FIELD rawExp.object,         		10,   %s,     Object
+FIELD rawExp.filter,         		10,   %s,     FILTER
+FIELD rawExp.exp_time,       		 5,   %.2f,     exp_time    
+FIELD rawExp.airmass,        		 5,   %.4f,     airmass     
+FIELD chipProcessedImfile.bg,            5,   %.2f,   backgnd
+FIELD chipProcessedImfile.bg_stdev,      5,   %.2f,   stdev    
+FIELD chipProcessedImfile.bg_mean_stdev, 5,   %.2f,   &lt;backgnd&gt;
+FIELD chipProcessedImfile.n_stars,  	 5,   %d,     Nstars
+FIELD camProcessedExp.n_astrom, 	 5,   %d,     Nastrom
+FIELD camProcessedExp.sigma_ra, 	 5,   %.2f,   sigma ra
+FIELD chipProcessedImfile.fwhm_major,  	 5,   %.2f,   FHWM (major)
+FIELD rawExp.comment,  	                65,   %s,     Comment
+
+TAIL PHP insert_log ('LOG.EXP');
Index: /branches/sc_branches/ippMonitorLap/def/camStageExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/camStageExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/camStageExp.d	(revision 31685)
@@ -0,0 +1,38 @@
+TABLE camRun, chipRun, rawExp
+TITLE Camera Stage Exposures
+FILE  camStageExp.php
+MENU  ipp.science.dat
+
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                     size  format  name          show   link to                  extras
+FIELD rawExp.exp_name,     	10,   %s,     Exp Name
+FIELD rawExp.exp_id,	         5,   %d,     Exp ID,       value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,           5,   %d,     Chip ID,      value,  chipProcessedImfile.php, ARG2
+FIELD camRun.cam_id,             5,   %d,     Cam ID,       value,  camProcessedExp.php,     ARG3
+FIELD camRun.state,              5,   %s,     state
+FIELD camRun.label,              5,   %s,     label
+FIELD camRun.data_group,              5,   %s,     data grp
+FIELD camRun.dist_group,              5,   %s,     dist grp
+FIELD rawExp.telescope,      	10,   %s,     Telescope
+FIELD rawExp.camera,         	10,   %s,     Camera
+FIELD rawExp.dateobs,        	19,   %T,     Date/Time
+FIELD rawExp.ra,                 8,   %C, RA,           op=OP1      
+FIELD rawExp.decl,               8,   %C, DEC,          op=OP2
+FIELD rawExp.object,         	10,   %s,     Object
+FIELD rawExp.filter,         	10,   %s,     FILTER
+FIELD rawExp.exp_time,       	 5,   %.2f,   exp_time    
+FIELD rawExp.airmass,        	 5,   %.4f,   airmass     
+FIELD rawExp.bg,             	 5,   %.2f,   backgnd
+FIELD rawExp.bg_stdev,       	 5,   %.2f,   stdev    
+FIELD rawExp.comment,  	        65,   %s,     Comment
+
+# FIELD rawExp.bg_mean_stdev,  	 5,   %.2f,   &lt;backgnd&gt;
Index: /branches/sc_branches/ippMonitorLap/def/camSummary.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/camSummary.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/camSummary.d	(revision 31685)
@@ -0,0 +1,19 @@
+TABLE camRun
+TITLE Cam Summary
+FILE  camSummary.php
+MENU  ipp.science.dat
+
+#     field           size  format  name         show    link to         extras
+FIELD label,    	 15, %s,     label
+FIELD data_group,        10, %s,    data_group
+FIELD workdir,    	 7, %s,     workdir
+FIELD tess_id,    	 7, %s,     tess_id
+FIELD state,    	 7, %s,     state
+FIELD count(state) as n, 7, %d,     count
+
+MODE  summary
+GROUP state
+GROUP label
+GROUP workdir
+GROUP data_group
+GROUP tess_id
Index: /branches/sc_branches/ippMonitorLap/def/chipIQstats.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/chipIQstats.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/chipIQstats.d	(revision 31685)
@@ -0,0 +1,47 @@
+TABLE chipRun, rawExp, chipProcessedImfile
+TITLE Per-Chip Image Quality Stats
+FILE  chipIQstats.php
+MENU  ipp.science.dat
+
+# limit this table to non-OBJECT types of images
+WHERE chipRun.state = 'full'
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE chipRun.chip_id = chipProcessedImfile.chip_id
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+
+OP   OP1  0.5*($chipProcessedImfile.fwhm_major_uq + $chipProcessedImfile.fwhm_minor_uq)
+OP   OP2  0.5*($chipProcessedImfile.fwhm_major_lq + $chipProcessedImfile.fwhm_minor_lq)
+
+#     field                   size  format  name         show    link to                  extras
+FIELD rawExp.exp_name,     	 5, %s,     Exp Name
+FIELD chipProcessedImfile.class_id, 5, %s,  chip
+FIELD chipRun.chip_id,    	 5, %d,     Ch ID,       value,  chipProcessedImfile.php, ARG2
+FIELD chipRun.label,    	 7, %s,     Label
+FIELD chipRun.data_group,    	 7, %s,     data grp
+FIELD chipRun.dist_group,    	 7, %s,     dist grp
+FIELD rawExp.dateobs,        	19, %T,     Date/Time
+FIELD rawExp.filter,         	10, %s,     FILTER
+FIELD rawExp.exp_time,       	 5, %.2f,     exp_time    
+FIELD rawExp.airmass,        	 5, %.4f,     airmass     
+
+FIELD 0.5*(chipProcessedImfile.fwhm_major + chipProcessedImfile.fwhm_minor) as fwhm, 5, %.2f, fwhm psf
+FIELD chipProcessedImfile.fwhm_major, 5, %.2f, fwhm major psf
+FIELD chipProcessedImfile.fwhm_minor, 5, %.2f, fwhm minor psf
+FIELD 0.5*(chipProcessedImfile.fwhm_major_uq + chipProcessedImfile.fwhm_minor_uq), 5, %.2f, fwhm UQ
+FIELD 0.5*(chipProcessedImfile.fwhm_major_lq + chipProcessedImfile.fwhm_minor_lq), 5, %.2f, fwhm LQ
+
+FIELD 0.5*(chipProcessedImfile.iq_fwhm_major + chipProcessedImfile.iq_fwhm_minor), 5, %.2f, fwhm moments
+FIELD chipProcessedImfile.iq_fwhm_major, 5, %.2f, fwhm major moments
+FIELD chipProcessedImfile.iq_fwhm_minor, 5, %.2f, fwhm minor moments
+
+#FIELD chipProcessedImfile.fwhm_major_uq, 5, %.2f, fwhm UQ, op=OP1
+#FIELD chipProcessedImfile.fwhm_major_lq, 5, %.2f, fwhm LQ, op=OP2
+#FIELD chipProcessedImfile.fwhm_minor_uq, 5, %.2f, fwhm UQ, none
+#FIELD chipProcessedImfile.fwhm_minor_lq, 5, %.2f, fwhm UQ, none
+
+FIELD chipProcessedImfile.iq_m2, 5, %.2f, m2 moment
+FIELD chipProcessedImfile.iq_m3, 5, %.2f, m3 moment
+FIELD chipProcessedImfile.iq_m4, 5, %.2f, m4 moment
+
Index: /branches/sc_branches/ippMonitorLap/def/chipPendingExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/chipPendingExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/chipPendingExp.d	(revision 31685)
@@ -0,0 +1,39 @@
+TABLE chipRun, rawExp
+TITLE chip Pending Exposures
+FILE  chipPendingExp.php
+MENU  ipp.science.dat
+
+# limit this table to non-OBJECT types of images
+WHERE chipRun.state = 'new'
+WHERE chipRun.exp_id = rawExp.exp_id
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                   size  format  name         show    link to         extras
+FIELD rawExp.exp_name,     	10, %s,     Exp Name
+FIELD rawExp.exp_id,     	 5, %d,     Exp ID,      value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,    	 7, %d,     Chip ID,     value,  chipProcessedImfile.php, ARG2
+FIELD chipRun.state,    	 7, %s,     State
+FIELD chipRun.label,    	 7, %s,     Label
+FIELD chipRun.data_group,    	 7, %s,     data grp
+FIELD chipRun.dist_group,    	 7, %s,     dist grp
+FIELD rawExp.telescope,      	10, %s,     Telescope
+FIELD rawExp.camera,         	10, %s,     Camera
+FIELD rawExp.dateobs,        	19, %T,     Date/Time
+FIELD rawExp.ra,       	         8, %C, RA,          op=OP1    
+FIELD rawExp.decl,       	 8, %C, DEC,         op=OP2
+FIELD rawExp.object,         	 8, %s,     Object
+FIELD rawExp.filter,         	10, %s,     FILTER
+FIELD rawExp.exp_time,       	 5, %.2f,   exp_time    
+FIELD rawExp.airmass,        	 5, %.4f,   airmass     
+FIELD rawExp.bg,             	 5, %.2f,   backgnd
+FIELD rawExp.bg_stdev,       	 5, %.2f,   stdev    
+FIELD rawExp.comment,  	        65, %s,     Comment
+
+# FIELD rawExp.bg_mean_stdev,  	 5, %7.2f,  &lt;backgnd&gt;
+# FIELD chipPendingExp.reduction,    20,   reduction
+# FIELD chipPendingExp.guide_id,     20, guide ID
Index: /branches/sc_branches/ippMonitorLap/def/chipPendingImfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/chipPendingImfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/chipPendingImfile.d	(revision 31685)
@@ -0,0 +1,42 @@
+TABLE chipRun, rawExp, rawImfile
+TITLE Chip Pending Imfiles
+FILE  chipPendingImfile.php
+MENU  ipp.science.dat
+
+# XXX this query does not exclude imfiles already processed (unless the exp is done)
+# I need to join against chipProcessedImfile and exclude ones where chipProcessedImfile.class_id is not NULL
+
+# limit this table to OBJECT types of images
+WHERE chipRun.state = 'new'
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE rawImfile.exp_id = rawExp.exp_id
+
+ARGS  ARG1 rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2 chipRun.chip_id=$chipRun.chip_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                   size  format  name         show    link to                  extras
+FIELD rawExp.exp_name,     	10, %s,     Exp Name
+FIELD rawImfile.class_id,     	 8, %s,     Class ID
+FIELD rawExp.exp_id,     	 5, %d,     Exp ID,      value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,    	 7, %d,     Chip ID,     value,  chipProcessedImfile.php, ARG2
+FIELD chipRun.state,    	 7, %s,     State
+FIELD chipRun.label,    	 7, %s,     Label
+FIELD chipRun.data_group,    	 7, %s,     data grp
+FIELD chipRun.dist_group,    	 7, %s,     dist grp
+FIELD rawExp.telescope,      	10, %s,     Telescope
+FIELD rawExp.camera,         	10, %s,     Camera
+FIELD rawExp.dateobs,        	19, %T,     Date/Time
+FIELD rawExp.ra,       	         8, %C, RA,          op=OP1    
+FIELD rawExp.decl,       	 8, %C, DEC,         op=OP2
+FIELD rawExp.object,         	 8, %s,     Object
+FIELD rawExp.filter,         	10, %s,     FILTER
+FIELD rawExp.exp_time,       	 5, %.2f,   exp_time    
+FIELD rawExp.airmass,        	 5, %.4f,   airmass     
+FIELD rawExp.bg,             	 5, %.2f,   backgnd
+FIELD rawExp.bg_stdev,       	 5, %.2f,   stdev    
+FIELD *,                         5, %d,     Nstars,      value=0
+FIELD *, 	                 5, %.2f,   FHWM,        value=0.0
+FIELD rawExp.comment,  	        65, %s,     Comment
Index: /branches/sc_branches/ippMonitorLap/def/chipProcessedExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/chipProcessedExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/chipProcessedExp.d	(revision 31685)
@@ -0,0 +1,40 @@
+TABLE chipRun, rawExp
+TITLE chip Processed Exposures
+FILE  chipProcessedExp.php
+MENU  ipp.science.dat
+
+# limit this table to non-OBJECT types of images
+WHERE chipRun.state != 'new'
+WHERE chipRun.exp_id = rawExp.exp_id
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                   size  format  name         show    link to                  extras
+FIELD rawExp.exp_name,     	 5, %s,     Exp Name
+FIELD rawExp.exp_id,     	 5, %d,     Exp ID,      value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,    	 7, %d,     Chip ID,     value,  chipProcessedImfile.php, ARG2
+FIELD chipRun.state,    	 7, %s,     State
+FIELD chipRun.label,    	 7, %s,     Label
+FIELD chipRun.data_group,    	 7, %s,     data grp
+FIELD chipRun.dist_group,    	 7, %s,     dist grp
+FIELD rawExp.telescope,      	10, %s,     Telescope
+FIELD rawExp.camera,         	10, %s,     Camera
+FIELD rawExp.dateobs,        	19, %T,     Date/Time
+FIELD rawExp.ra,           	 8, %C, RA,           op=OP1      
+FIELD rawExp.decl,         	 8, %C, DEC,          op=OP2
+FIELD rawExp.object,         	 8, %s,     Object
+FIELD rawExp.filter,         	10, %s,     FILTER
+FIELD rawExp.exp_time,       	 5, %.2f,     exp_time    
+FIELD rawExp.airmass,        	 5, %.4f,     airmass     
+FIELD rawExp.bg,             	 5, %.2f,     backgnd
+FIELD rawExp.bg_stdev,       	 5, %.2f,     stdev    
+FIELD rawExp.comment,  	        65, %s,     Comment
+
+# FIELD rawExp.bg_mean_stdev,  	 5, %s,     &lt;backgnd&gt;
+# FIELD rawExp.sat_pixel_frac, 	 5, %s,     f(sat pixels)
+# FIELD chipPendingExp.reduction,    20,   reduction
+# FIELD chipPendingExp.guide_id,     20, guide ID
Index: /branches/sc_branches/ippMonitorLap/def/chipProcessedImfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/chipProcessedImfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/chipProcessedImfile.d	(revision 31685)
@@ -0,0 +1,51 @@
+TABLE chipRun, rawExp, chipProcessedImfile
+TITLE chip Processed Imfile
+FILE  chipProcessedImfile.php
+MENU  ipp.science.dat
+
+# limit this table to non-OBJECT types of images
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE chipProcessedImfile.exp_id = chipRun.exp_id
+WHERE chipProcessedImfile.chip_id = chipRun.chip_id
+WHERE chipProcessedImfile.fault = 0
+
+ARGS  ARG1 rawImfile.exp_id=$rawExp.exp_id
+
+ARGS  ARG2 chipRun.chip_id=$chipRun.chip_id
+
+ARGS  ARG3 chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3 chipProcessedImfile.class_id=$chipProcessedImfile.class_id
+ARGS  ARG3 camera=$rawExp.camera
+ARGS  ARG3 basename=$chipProcessedImfile.path_base
+ARGS  ARG3 class=$chipProcessedImfile.class_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                            size  format  name         show    link to                  extras
+FIELD rawExp.exp_name,     	   	 10, %s,     Exp Name
+FIELD chipProcessedImfile.class_id,  	  8, %s,     Class ID
+FIELD rawExp.exp_id,         	   	  5, %d,     Exp ID,      value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,        	   	  7, %d,     Chip ID,     value,  chipProcessedImfile.php, ARG2
+FIELD chipRun.state,        	   	  7, %s,     State,       value,  chipProcessedImfile.php, ARG3
+FIELD chipRun.label,        	   	  7, %s,     Label
+FIELD chipRun.data_group,        	   	  7, %s,     data grp
+FIELD chipRun.dist_group,        	   	  7, %s,     dist grp
+FIELD rawExp.telescope,      	   	 10, %s,     Telescope
+FIELD rawExp.camera,         	   	 10, %s,     Camera
+FIELD rawExp.dateobs,        	   	 19, %T,     Date/Time
+FIELD rawExp.ra,           	 	  8, %C, RA,           op=OP1      
+FIELD rawExp.decl,         	 	  8, %C, DEC,          op=OP2
+FIELD rawExp.object,       	   	  8, %s,     Object
+FIELD rawExp.filter,         	   	 10, %s,     FILTER
+FIELD rawExp.exp_time,       	   	  5, %.2f,   exp_time    
+FIELD rawExp.airmass,        	   	  5, %.4f,   airmass     
+FIELD chipProcessedImfile.quality,   	  5, %d,     quality     
+FIELD chipProcessedImfile.bg,             5, %.2f,   backgnd
+FIELD chipProcessedImfile.bg_stdev,       5, %.2f,   stdev    
+FIELD chipProcessedImfile.n_stars,  	  5, %d,     Nstars
+FIELD chipProcessedImfile.fwhm_major, 	  5, %.2f,   FHWM
+FIELD chipProcessedImfile.path_base,      5, %s,     path_base, none
+FIELD rawExp.comment,  	                 65, %s,     Comment
+
+TAIL PHP insert_log ('LOG.IMFILE');
Index: /branches/sc_branches/ippMonitorLap/def/chipProcessedImfile_failure.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/chipProcessedImfile_failure.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/chipProcessedImfile_failure.d	(revision 31685)
@@ -0,0 +1,51 @@
+TABLE chipRun, rawExp, chipProcessedImfile
+TITLE Chip Failed Imfiles
+FILE  chipProcessedImfile_failure.php
+MENU  ipp.science.dat
+
+# limit this table to non-OBJECT types of images
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE chipProcessedImfile.exp_id = chipRun.exp_id
+WHERE chipProcessedImfile.chip_id = chipRun.chip_id
+WHERE chipProcessedImfile.fault != 0
+
+ARGS  ARG1 rawImfile.exp_id=$rawExp.exp_id
+
+ARGS  ARG2 chipRun.chip_id=$chipRun.chip_id
+
+ARGS  ARG3 chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3 chipProcessedImfile.class_id=$chipProcessedImfile.class_id
+ARGS  ARG3 camera=$rawExp.camera
+ARGS  ARG3 basename=$chipProcessedImfile.path_base
+ARGS  ARG3 class=$chipProcessedImfile.class_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                            size  format  name         show    link to                          extras
+FIELD rawExp.exp_name,     	   	  5, %s,     Exp Name
+FIELD chipProcessedImfile.class_id,	  8, %s,     Class ID
+FIELD rawExp.exp_id,         	   	  5, %d,     Exp ID,      value,  rawImfile.php,                   ARG1
+FIELD chipRun.chip_id,        	   	  7, %d,     Chip ID,     value,  chipProcessedImfile_failure.php, ARG2
+FIELD chipRun.state,        	   	  7, %s,     State,       value,  chipProcessedImfile_failure.php, ARG3
+FIELD chipRun.label,        	   	  7, %s,     Label
+FIELD chipRun.data_group,        	   	  7, %s,     data grp
+FIELD chipRun.dist_group,        	   	  7, %s,     dist grp
+FIELD chipProcessedImfile.fault,      	  2, %d,     Fault
+FIELD rawExp.telescope,      	   	 10, %s,     Telescope
+FIELD rawExp.camera,         	   	 10, %s,     Camera
+FIELD rawExp.dateobs,        	   	 19, %T,     Date/Time
+FIELD rawExp.ra,           	 	  8, %C, RA,           op=OP1      
+FIELD rawExp.decl,         	 	  8, %C, DEC,          op=OP2
+FIELD rawExp.object,       	   	  8, %s,     Object
+FIELD rawExp.filter,         	   	 10, %s,     FILTER
+FIELD rawExp.exp_time,       	   	  5, %.2f,   exp_time    
+FIELD rawExp.airmass,        	   	  5, %.4f,   airmass     
+FIELD chipProcessedImfile.bg,             5, %.2f,   backgnd
+FIELD chipProcessedImfile.bg_stdev,       5, %.2f,   stdev    
+FIELD chipProcessedImfile.n_stars,  	  5, %d,     Nstars
+FIELD chipProcessedImfile.fwhm_major, 	  5, %.2f,   FHWM
+FIELD chipProcessedImfile.path_base,      5, %s,     path_base, none
+FIELD rawExp.comment,  	                 65, %s,     Comment
+
+TAIL PHP insert_log ('LOG.IMFILE');
Index: /branches/sc_branches/ippMonitorLap/def/chipStageExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/chipStageExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/chipStageExp.d	(revision 31685)
@@ -0,0 +1,37 @@
+TABLE chipRun, rawExp
+TITLE Chip Stage Exposures
+FILE  chipStageExp.php
+MENU  ipp.science.dat
+
+WHERE chipRun.exp_id = rawExp.exp_id
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                   size  format  name         show    link to                  extras
+FIELD rawExp.exp_name,     	 5, %s,     Exp Name
+FIELD rawExp.exp_id,     	 5, %d,     Exp ID,      value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,    	 7, %d,     Chip ID,     value,  chipProcessedImfile.php, ARG2
+FIELD chipRun.state,    	 7, %s,     State
+FIELD chipRun.label,    	 7, %s,     Label
+FIELD chipRun.data_group,    	 7, %s,     data grp
+FIELD chipRun.dist_group,    	 7, %s,     dist grp
+FIELD rawExp.telescope,      	10, %s,     Telescope
+FIELD rawExp.camera,         	10, %s,     Camera
+FIELD rawExp.dateobs,        	19, %T,     Date/Time
+FIELD rawExp.ra,       	         8, %C, RA,          op=OP1    
+FIELD rawExp.decl,       	 8, %C, DEC,         op=OP2
+FIELD rawExp.object,         	 8, %s,     Object
+FIELD rawExp.filter,         	10, %s,     FILTER
+FIELD rawExp.exp_time,       	 5, %.2f,   exp_time    
+FIELD rawExp.airmass,        	 5, %.4f,   airmass     
+FIELD rawExp.bg,             	 5, %.2f,   backgnd
+FIELD rawExp.bg_stdev,       	 5, %.2f,   stdev    
+FIELD rawExp.comment,  	        65, %s,     Comment
+
+# FIELD rawExp.bg_mean_stdev,  	 5, %7.2f,  &lt;backgnd&gt;
+# FIELD chipPendingExp.reduction,    20,   reduction
+# FIELD chipPendingExp.guide_id,     20, guide ID
Index: /branches/sc_branches/ippMonitorLap/def/chipSummary.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/chipSummary.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/chipSummary.d	(revision 31685)
@@ -0,0 +1,19 @@
+TABLE chipRun
+TITLE Chip Summary
+FILE  chipSummary.php
+MENU  ipp.science.dat
+
+#     field           size  format  name         show    link to         extras
+FIELD label,    	 15, %s,     label
+FIELD data_group,    	 10, %s,     data_group
+FIELD workdir,    	 7, %s,     workdir
+FIELD tess_id,    	 7, %s,     tess_id
+FIELD state,    	 7, %s,     state
+FIELD count(state),      7, %d,     count
+
+MODE  summary
+GROUP state
+GROUP label
+GROUP workdir
+GROUP data_group
+GROUP tess_id
Index: /branches/sc_branches/ippMonitorLap/def/destreakFile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/destreakFile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/destreakFile.d	(revision 31685)
@@ -0,0 +1,12 @@
+TABLE magicDSFile
+TITLE Destreak Files
+FILE  destreakFile.php
+MENU  ipp.dist.dat
+
+#     field                    size  format  name         show    link to                  extras
+FIELD magicDSFile.magic_ds_id,        5, %d,     Destreak ID
+FIELD magicDSFile.component,          5, %s,     Component
+FIELD magicDSFile.backup_path_base,   5, %s,     Backup Path
+FIELD magicDSFile.recovery_path_base, 5, %s,     Recovery Path
+FIELD magicDSFile.fault,              5, %d,     Fault
+FIELD magicDSFile.data_state,         5, %s,     Data State
Index: /branches/sc_branches/ippMonitorLap/def/destreakRun.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/destreakRun.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/destreakRun.d	(revision 31685)
@@ -0,0 +1,28 @@
+TABLE magicDSRun, magicDSFile
+TITLE Destreak Runs
+FILE  destreakRun.php
+MENU  ipp.dist.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+
+WHERE magicDSRun.magic_ds_id = magicDSFile.magic_ds_id
+
+#     field                    size  format  name         show    link to                  extras
+FIELD magicDSRun.magic_ds_id,  5, %d,     Destreak ID
+FIELD magicDSRun.magic_id,     5, %d,     Magic ID
+FIELD magicDSRun.inv_magic_id, 5, %d,     Inv Magic ID
+FIELD magicDSRun.state,        5, %s,     State
+FIELD magicDSRun.stage,        5, %s,     Stage
+FIELD magicDSRun.stage_id,     5, %d,     Stage ID
+FIELD magicDSFile.component,   5, %s,     Component
+FIELD magicDSFile.streak_frac, 5, %.3f,   Streak Frac
+FIELD magicDSRun.cam_id,       5, %d,     Camera ID
+FIELD magicDSRun.label,        10, %s,     Label
+FIELD magicDSRun.data_group,        10, %s,     data grp
+FIELD magicDSRun.outroot,      10, %s,     Out Root
+FIELD magicDSRun.recoveryroot, 5, %d,     Recov. Root
+FIELD magicDSRun.re_place,     5, %d,     Replace
+FIELD magicDSRun.remove,       5, %d,     Remove
+FIELD magicDSRun.fault,        5, %d,     Run Fault
+FIELD magicDSFile.fault,       5, %d,     File Fault
+FIELD magicDSRun.note,         5, %s,     Note
Index: /branches/sc_branches/ippMonitorLap/def/destreakSummary.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/destreakSummary.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/destreakSummary.d	(revision 31685)
@@ -0,0 +1,17 @@
+TABLE magicDSRun
+TITLE Destreak Summary
+FILE  destreakSummary.php
+MENU  ipp.dist.dat
+
+#     field                    size  format  name         show    link to                  extras
+FIELD magicDSRun.label,        15, %s,     Label
+FIELD magicDSRun.data_group,   10, %s,     Data Group
+FIELD magicDSRun.stage,        5, %s,     Stage
+FIELD magicDSRun.state,        5, %s,     State
+FIELD count(magicDSRun.state) as n, 7, %d, count
+
+MODE  summary
+GROUP state
+GROUP stage
+GROUP label
+GROUP data_group
Index: /branches/sc_branches/ippMonitorLap/def/detInputExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detInputExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detInputExp.d	(revision 31685)
@@ -0,0 +1,43 @@
+TABLE detInputExp, rawExp
+TITLE detInputExp
+FILE  detInputExp.php
+MENU  ipp.detrend.dat
+
+# limit this table to non-OBJECT types of images
+WHERE detInputExp.exp_id = rawExp.exp_id
+
+ARGS  ARG1  rawImfile.exp_id=$detInputExp.exp_id
+
+ARGS  ARG2  detResidImfile.exp_id=$detInputExp.exp_id
+ARGS  ARG2  detResidImfile.det_id=$detInputExp.det_id
+ARGS  ARG2  detResidImfile.iteration=$detInputExp.iteration
+
+ARGS  ARG2  detProcessedImfile.exp_id=$detInputExp.exp_id
+ARGS  ARG2  detProcessedImfile.det_id=$detInputExp.det_id
+ARGS  ARG2  detProcessedImfile.iteration=$detInputExp.iteration
+
+HEAD PHP if ($_GET['detInputExp_det_id']) { 
+HEAD PHP   echo "<a href=detResidExp.php?" . $ID['link'] . "> resid </a>";
+HEAD PHP   echo "<a href=detProcessedExp.php?" . $ID['link'] . "> proc </a>"; }
+
+#     field                size  format  name        show         link to                 extras
+FIELD detInputExp.det_id,     7, %s,     Det ID
+FIELD detInputExp.iteration,  5, %s,     iteration
+FIELD detInputExp.exp_id,     5, %s,     Exp ID,     value,       rawImfile.php,          ARG1
+FIELD rawExp.exp_name,        5, %s,     Exp Name,   value,       rawImfile.php,          ARG1
+FIELD detInputExp.include,    3, %t,     include
+FIELD rawExp.telescope,      10, %s,     Telescope
+FIELD rawExp.camera,         10, %s,     Camera
+FIELD rawExp.exp_type,       10, %s,     Type    
+FIELD rawExp.filter,         10, %s,     FILTER
+FIELD rawExp.dateobs,        19, %T,     Date/Time
+FIELD rawExp.exp_time,        5, %.2f,   exp_time    
+FIELD rawExp.sat_pixel_frac,  5, %.2f,   f(sat pixels)
+FIELD rawExp.airmass,         5, %.4f,   airmass     
+FIELD rawExp.bg,              5, %.2f,   backgnd
+FIELD rawExp.bg_stdev,        5, %.2f,   stdev    
+FIELD rawExp.bg_mean_stdev,   5, %.2f,   &lt;backgnd&gt;
+FIELD *,                      5, %s,     choose,     value=resid, detResidImfile.php,     ARG2
+FIELD *,                      5, %s,     choose,     value=proc,  detProcessedImfile.php, ARG3
+
+TD_CLASS det_off  $detInputExp.include == 0
Index: /branches/sc_branches/ippMonitorLap/def/detMasterFrame.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detMasterFrame.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detMasterFrame.d	(revision 31685)
@@ -0,0 +1,9 @@
+TABLE detMasterFrame
+TITLE detMasterFrame
+FILE  detMasterFrame.php
+MENU  ipp.detrend.dat
+
+#     field    size  format  name     show  link to     extras
+FIELD det_id,    20, %s,     det_id
+FIELD iteration, 20, %s,     iteration
+FIELD comment,   20, %s,     comment
Index: /branches/sc_branches/ippMonitorLap/def/detMasterImfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detMasterImfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detMasterImfile.d	(revision 31685)
@@ -0,0 +1,10 @@
+TABLE detMasterImfile
+TITLE detMasterImfile
+FILE  detMasterImfile.php
+MENU  ipp.imfiles.dat
+
+#     field    size  format  name     show  link to     extras
+FIELD det_id,    20, %s,     det_id
+FIELD class_id,  20, %s,     class_id
+FIELD uri,       20, %s,     uri
+FIELD recipe,    20, %s,     recipe
Index: /branches/sc_branches/ippMonitorLap/def/detNormalizedExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detNormalizedExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detNormalizedExp.d	(revision 31685)
@@ -0,0 +1,27 @@
+TABLE detNormalizedExp, detRun
+TITLE detNormalizedExp
+FILE  detNormalizedExp.php
+MENU  ipp.detrend.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+WHERE detNormalizedExp.det_id    = detRun.det_id
+# WHERE detNormalizedExp.iteration = detRun.iteration
+
+# define image names to be used below
+# IMAGE VAR basename filerule camera class_id
+IMAGE JPEG2 $detNormalizedExp.path_base PPIMAGE.JPEG2 $detRun.camera NONE
+
+ARGS  ARG2 det_id=$detNormalizedExp.det_id
+ARGS  ARG2 iteration=$detNormalizedExp.iteration
+ARGS  ARG2 basename=$detNormalizedExp.path_base
+ARGS  ARG2 camera=$detRun.camera
+
+#     field        		      size   format  name     show          link to                  extras
+FIELD detNormalizedExp.det_id,        7,     %s,     det_id
+FIELD detNormalizedExp.bg,            8,     %s,     backgnd
+FIELD detNormalizedExp.bg_mean_stdev, 8,     %s,     [stdev]
+FIELD detNormalizedExp.bg_stdev,      8,     %s,     stdev
+FIELD detNormalizedExp.iteration,     5,     %s,     iteration
+FIELD *,             		      8,     %s,     image,     image=JPEG2,  detNormalizedImfile.php, ARG2
+FIELD detNormalizedExp.path_base,     20,    %s,     path_base, none
+FIELD detRun.camera,                  20,    %s,     camera,    none
Index: /branches/sc_branches/ippMonitorLap/def/detNormalizedExp_failure.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detNormalizedExp_failure.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detNormalizedExp_failure.d	(revision 31685)
@@ -0,0 +1,22 @@
+TABLE detNormalizedExp, detRun
+TITLE detNormalizedExp Failures
+FILE  detNormalizedExp_failure.php
+MENU  ipp.detrend.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+WHERE detNormalizedExp.det_id = detRun.det_id
+WHERE detNormalizedExp.fault  > 0
+
+ARGS  ARG2 det_id=$detNormalizedExp.det_id
+ARGS  ARG2 iteration=$detNormalizedExp.iteration
+ARGS  ARG2 basename=$detNormalizedExp.path_base
+ARGS  ARG2 camera=$detRun.camera
+
+#     field        		      size   format  name     show          link to                  extras
+FIELD detNormalizedExp.det_id,        7,     %s,     det_id
+FIELD detNormalizedExp.bg,            8,     %s,     backgnd
+FIELD detNormalizedExp.bg_mean_stdev, 8,     %s,     [stdev]
+FIELD detNormalizedExp.bg_stdev,      8,     %s,     stdev
+FIELD detNormalizedExp.iteration,     5,     %s,     iteration
+FIELD detNormalizedExp.path_base,     20,    %s,     path_base, none
+FIELD detRun.camera,                  20,    %s,     camera,    none
Index: /branches/sc_branches/ippMonitorLap/def/detNormalizedImfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detNormalizedImfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detNormalizedImfile.d	(revision 31685)
@@ -0,0 +1,26 @@
+TABLE detNormalizedImfile, detRun
+TITLE detNormalizedImfile
+FILE  detNormalizedImfile.php
+MENU  ipp.imfiles.dat
+
+WHERE detNormalizedImfile.det_id = detRun.det_id
+
+ARGS  ARG1 detNormalizedImfile.det_id=$detNormalizedImfile.det_id
+ARGS  ARG1 detNormalizedImfile.iteration=$detNormalizedImfile.iteration
+ARGS  ARG1 detNormalizedImfile.class_id=$detNormalizedImfile.class_id
+ARGS  ARG1 camera=$detRun.camera
+ARGS  ARG1 basename=$detNormalizedImfile.path_base
+ARGS  ARG1 class=$detNormalizedImfile.class_id
+
+#     field                             size  format  name      show   link to                  extras
+FIELD detNormalizedImfile.det_id,          7, %s,     det_id
+FIELD detNormalizedImfile.iteration,       5, %s,     iter
+FIELD detNormalizedImfile.class_id,        8, %s,     class_id, value, detNormalizedImfile.php, ARG1
+FIELD detNormalizedImfile.fault,           5, %d,     fault
+FIELD detNormalizedImfile.bg,              8, %f,     backgnd
+FIELD detNormalizedImfile.bg_stdev,        8, %f,     stdev
+FIELD detNormalizedImfile.bg_mean_stdev,   8, %f,     [stdev]
+FIELD detNormalizedImfile.path_base,      10, %s,     path_base
+FIELD detRun.camera,                      10, %s,     camera, none
+
+TAIL PHP insert_log ('LOG.IMFILE');
Index: /branches/sc_branches/ippMonitorLap/def/detNormalizedImfile_failure.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detNormalizedImfile_failure.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detNormalizedImfile_failure.d	(revision 31685)
@@ -0,0 +1,19 @@
+TABLE detNormalizedImfile
+TITLE detNormalizedImfile Failures
+FILE  detNormalizedImfile_failure.php
+MENU  ipp.detrend.dat
+
+WHERE fault > 0
+
+#     field         size  format  name     show   link to     extras
+FIELD det_id,          7, %s,     det_id
+FIELD class_id,        8, %s,     class_id
+FIELD bg,              8, %s,     backgnd
+FIELD bg_stdev,        8, %s,     stdev
+FIELD bg_mean_stdev,   8, %s,     [stdev]
+FIELD iteration,       5, %s,     iteration
+#FIELD uri,           20, %s,     uri
+#FIELD path_base,     20, %s,     path_base
+
+TAIL PHP insert_image ('PPIMAGE.JPEG1', 'width=90%');
+TAIL PHP insert_log ('LOG.EXP');
Index: /branches/sc_branches/ippMonitorLap/def/detNormalizedStatImfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detNormalizedStatImfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detNormalizedStatImfile.d	(revision 31685)
@@ -0,0 +1,10 @@
+TABLE detNormalizedStatImfile
+TITLE detNormalizedStatImfile
+FILE  detNormalizedStatImfile.php
+MENU  ipp.imfiles.dat
+
+#     field    size  format  name   show   link to     extras
+FIELD det_id,     7, %s,     det_id
+FIELD class_id,   8, %s,     class_id
+FIELD iteration,  5, %s,     iteration
+FIELD norm,       5, %s,     norm
Index: /branches/sc_branches/ippMonitorLap/def/detNormalizedStatImfile_failure.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detNormalizedStatImfile_failure.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detNormalizedStatImfile_failure.d	(revision 31685)
@@ -0,0 +1,12 @@
+TABLE detNormalizedStatImfile
+TITLE detNormalizedStatImfile Failures
+FILE  detNormalizedStatImfile_failure.php
+MENU  ipp.detrend.dat
+
+WHERE fault > 0
+
+#     field    size  format  name   show   link to     extras
+FIELD det_id,     7, %s,     det_id
+FIELD class_id,   8, %s,     class_id
+FIELD iteration,  5, %s,     iteration
+FIELD norm,       5, %s,     norm
Index: /branches/sc_branches/ippMonitorLap/def/detProcessedExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detProcessedExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detProcessedExp.d	(revision 31685)
@@ -0,0 +1,42 @@
+TABLE detProcessedExp, rawExp
+TITLE detProcessedExp
+FILE  detProcessedExp.php
+MENU  ipp.detrend.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+WHERE detProcessedExp.exp_id = rawExp.exp_id
+
+# define image names to be used below
+# IMAGE VAR basename filerule camera class_id
+IMAGE JPEG2 $detProcessedExp.path_base PPIMAGE.JPEG2 $rawExp.camera NONE
+
+ARGS  ARG1 detProcessedImfile.det_id=$detProcessedExp.det_id
+ARGS  ARG1 detProcessedImfile.exp_id=$detProcessedExp.exp_id
+ARGS  ARG1 camera=$rawExp.camera
+ARGS  ARG1 basename=$detProcessedExp.path_base
+
+# OP    OP1  $detProcessedExp.bg_stdev > 0.0 ? $detProcessedExp.bg / $detProcessedExp.bg_stdev : NAN
+
+#     field                    size    	format  name       show          link to                 extras
+FIELD detProcessedExp.det_id,     7,   	%d,     Det ID,    value
+FIELD rawExp.camera,             10,    %s,     camera,    value
+FIELD detProcessedExp.exp_id, 	  5,   	%d,     Exp ID,    value
+FIELD rawExp.exp_name, 	          5,   	%s,     Exp Name,  value
+FIELD detProcessedExp.fault,      5,   	%d,     Fault,     value
+FIELD *, 	  		  8,   	%s,     image,     image=JPEG2,  detProcessedImfile.php, ARG1
+FIELD detProcessedExp.bg, 	  8,   	%.3f,   backgnd,   value
+FIELD detProcessedExp.bg_mean_stdev, 8,	%.3f,   [stdev],   value
+FIELD detProcessedExp.bg_stdev,   8,   	%.3f,   stdev,     value
+FIELD (detProcessedExp.bg/detProcessedExp.bg_stdev), 8, %.3f,   S/N,     value
+# FIELD *,                          8,    %.3f,   S/N,       op=OP1
+FIELD rawExp.dateobs,            19,   	%T,     obs date,  value
+FIELD rawExp.filter,             10,   	%s,     filter,    value
+FIELD rawExp.exp_time,            8,   	%.2f,    exptime,   value
+FIELD rawExp.ccd_temp,            8,   	%.2f,    ccd temp,  value
+FIELD rawExp.airmass,             8,   	%.4f,    airmass,   value
+FIELD detProcessedExp.path_base, 20,   	%s,     path_base, none
+
+# TD_CLASS det_off $detProcessedExp.fault > 0
+
+# note: you must include all desired fields, where ever they are used,
+# in FIELD
Index: /branches/sc_branches/ippMonitorLap/def/detProcessedExp_failure.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detProcessedExp_failure.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detProcessedExp_failure.d	(revision 31685)
@@ -0,0 +1,37 @@
+TABLE detProcessedExp, rawExp
+TITLE detProcessedExp Failures
+FILE  detProcessedExp_failure.php
+MENU  ipp.detrend.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+WHERE detProcessedExp.exp_id = rawExp.exp_id
+WHERE detProcessedExp.fault > 0
+
+ARGS  ARG1 detProcessedImfile.det_id=$detProcessedExp.det_id
+ARGS  ARG1 detProcessedImfile.exp_id=$detProcessedExp.exp_id
+ARGS  ARG1 camera=$rawExp.camera
+ARGS  ARG1 basename=$detProcessedExp.path_base
+
+OP    OP1  $detProcessedExp.bg_stdev > 0.0 ? $detProcessedExp.bg / $detProcessedExp.bg_stdev : NAN
+
+#     field                    size    	format  name       show          link to                 extras
+FIELD detProcessedExp.det_id,     7,   	%d,     Det ID,    value
+FIELD rawExp.camera,             10,    %s,     camera,    value
+FIELD detProcessedExp.exp_id, 	  5,   	%d,     Exp ID,    value
+FIELD rawExp.exp_name, 	          5,   	%s,     Exp Name,  value
+FIELD detProcessedExp.fault,      5,   	%d,     Fault,     value
+FIELD detProcessedExp.bg, 	  8,   	%.3f,   backgnd,   value
+FIELD detProcessedExp.bg_mean_stdev, 8,	%.3f,   [stdev],   value
+FIELD detProcessedExp.bg_stdev,   8,   	%.3f,   stdev,     value
+FIELD *,                          8,    %.3f,   S/N,       op=OP1
+FIELD rawExp.dateobs,            19,   	%T,     obs date,  value
+FIELD rawExp.filter,             10,   	%s,     filter,    value
+FIELD rawExp.exp_time,            8,   	%.2f,    exptime,   value
+FIELD rawExp.ccd_temp,            8,   	%.2f,    ccd temp,  value
+FIELD rawExp.airmass,             8,   	%.4f,    airmass,   value
+FIELD detProcessedExp.path_base, 20,   	%s,     path_base, none
+
+# TD_CLASS det_off $detProcessedExp.fault > 0
+
+# note: you must include all desired fields, where ever they are used,
+# in FIELD
Index: /branches/sc_branches/ippMonitorLap/def/detProcessedExp_noimage.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detProcessedExp_noimage.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detProcessedExp_noimage.d	(revision 31685)
@@ -0,0 +1,42 @@
+TABLE detProcessedExp, rawExp
+TITLE detProcessedExp
+FILE  detProcessedExp_noimage.php
+MENU  ipp.detrend.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+WHERE detProcessedExp.exp_id = rawExp.exp_id
+
+# define image names to be used below
+# IMAGE VAR basename filerule camera class_id
+# IMAGE JPEG2 $detProcessedExp.path_base PPIMAGE.JPEG2 $rawExp.camera NONE
+
+ARGS  ARG1 detProcessedImfile.det_id=$detProcessedExp.det_id
+ARGS  ARG1 detProcessedImfile.exp_id=$detProcessedExp.exp_id
+ARGS  ARG1 camera=$rawExp.camera
+ARGS  ARG1 basename=$detProcessedExp.path_base
+
+# OP    OP1  $detProcessedExp.bg_stdev > 0.0 ? $detProcessedExp.bg / $detProcessedExp.bg_stdev : NAN
+
+#     field                    size    	format  name       show          link to                 extras
+FIELD detProcessedExp.det_id,     7,   	%d,     Det ID,    value
+FIELD rawExp.camera,             10,    %s,     camera,    value
+FIELD detProcessedExp.exp_id, 	  5,   	%d,     Exp ID,    value
+FIELD rawExp.exp_name, 	          5,   	%s,     Exp Name,  value
+FIELD detProcessedExp.fault,      5,   	%d,     Fault,     value
+# FIELD *, 	  		  8,   	%s,     image,     image=JPEG2,  detProcessedImfile.php, ARG1
+FIELD detProcessedExp.bg, 	  8,   	%.3f,   backgnd,   value
+FIELD detProcessedExp.bg_mean_stdev, 8,	%.3f,   [stdev],   value
+FIELD detProcessedExp.bg_stdev,   8,   	%.3f,   stdev,     value
+FIELD (detProcessedExp.bg/detProcessedExp.bg_stdev), 8, %.3f,   S/N,     value
+# FIELD *,                          8,    %.3f,   S/N,       op=OP1
+FIELD rawExp.dateobs,            19,   	%T,     obs date,  value
+FIELD rawExp.filter,             10,   	%s,     filter,    value
+FIELD rawExp.exp_time,            8,   	%.2f,    exptime,   value
+FIELD rawExp.ccd_temp,            8,   	%.2f,    ccd temp,  value
+FIELD rawExp.airmass,             8,   	%.4f,    airmass,   value
+FIELD detProcessedExp.path_base, 20,   	%s,     path_base, none
+
+# TD_CLASS det_off $detProcessedExp.fault > 0
+
+# note: you must include all desired fields, where ever they are used,
+# in FIELD
Index: /branches/sc_branches/ippMonitorLap/def/detProcessedImfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detProcessedImfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detProcessedImfile.d	(revision 31685)
@@ -0,0 +1,24 @@
+TABLE detProcessedImfile, rawExp
+TITLE detProcessedImfile
+FILE  detProcessedImfile.php
+MENU  ipp.imfiles.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+WHERE detProcessedImfile.exp_id = rawExp.exp_id
+
+#     field                          size  format  name      show   link to     extras
+FIELD detProcessedImfile.det_id,        7, %s,     Det ID
+FIELD detProcessedImfile.exp_id,        5, %s,     Exp ID
+FIELD rawExp.exp_name,                  5, %s,     Exp Name
+FIELD detProcessedImfile.class_id,      8, %s,     Chip ID
+FIELD detProcessedImfile.fault,         5, %d,     fault
+FIELD detProcessedImfile.bg, 	        8, %f,     backgnd
+FIELD detProcessedImfile.bg_stdev,      8, %s,     stdev
+FIELD detProcessedImfile.bg_mean_stdev, 8, %s,     [stdev]
+FIELD detProcessedImfile.path_base,     10, %s,     path_base
+
+TD_CLASS det_off $detProcessedImfile.fault > 0
+
+TAIL PHP insert_image ('PPIMAGE.JPEG1', 'width=90%');
+TAIL PHP insert_log ('LOG.EXP');
+
Index: /branches/sc_branches/ippMonitorLap/def/detProcessedImfile_failure.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detProcessedImfile_failure.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detProcessedImfile_failure.d	(revision 31685)
@@ -0,0 +1,35 @@
+TABLE detProcessedImfile, rawExp, rawImfile
+TITLE detProcessedImfile Failures
+FILE  detProcessedImfile_failure.php
+MENU  ipp.detrend.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+WHERE detProcessedImfile.exp_id = rawExp.exp_id
+WHERE detProcessedImfile.exp_id = rawImfile.exp_id
+WHERE detProcessedImfile.class_id = rawImfile.class_id
+WHERE detProcessedImfile.fault > 0
+
+ARGS  ARG1 detProcessedImfile.det_id=$detProcessedImfile.det_id
+ARGS  ARG1 detProcessedImfile.exp_id=$detProcessedImfile.exp_id
+ARGS  ARG1 detProcessedImfile.class_id=$detProcessedImfile.class_id
+ARGS  ARG1 camera=$rawExp.camera
+ARGS  ARG1 basename=$detProcessedImfile.path_base
+ARGS  ARG1 class=$detProcessedImfile.class_id
+
+#     field                          size  format  name      show   link to     extras
+FIELD detProcessedImfile.det_id,       12, %d,     Det ID
+FIELD detProcessedImfile.exp_id,        5, %d,     Exp ID
+FIELD rawExp.exp_name,                  5, %s,     Exp Name
+FIELD detProcessedImfile.class_id,      8, %s,     Chip ID,  value,  detProcessedImfile_failure.php, ARG1
+FIELD detProcessedImfile.fault,         5, %d,     fault
+FIELD detProcessedImfile.bg, 	        8, %.2f,   backgnd
+FIELD detProcessedImfile.bg_stdev,      8, %.2f,   stdev
+FIELD detProcessedImfile.bg_mean_stdev, 8, %.2f,   [stdev]
+FIELD rawImfile.ccd_temp,               5, %.2f,   CCD Temp
+FIELD detProcessedImfile.path_base,    20, %s,     path_base
+
+FIELD rawExp.camera,                    5, %s,     Exp Name, none
+
+# TD_CLASS det_off $detProcessedImfile.fault > 0
+
+TAIL PHP insert_log ('LOG.IMFILE');
Index: /branches/sc_branches/ippMonitorLap/def/detRegisteredImfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detRegisteredImfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detRegisteredImfile.d	(revision 31685)
@@ -0,0 +1,26 @@
+TABLE detRegisteredImfile, detRun
+TITLE detRegisteredImfile
+FILE  detRegisteredImfile.php
+MENU  ipp.imfiles.dat
+
+WHERE detRegisteredImfile.det_id = detRun.det_id
+
+ARGS  ARG1 detRegisteredImfile.det_id=$detRegisteredImfile.det_id
+ARGS  ARG1 detRegisteredImfile.iteration=$detRegisteredImfile.iteration
+ARGS  ARG1 detRegisteredImfile.class_id=$detRegisteredImfile.class_id
+ARGS  ARG1 camera=$detRun.camera
+ARGS  ARG1 basename=$detRegisteredImfile.path_base
+ARGS  ARG1 class=$detRegisteredImfile.class_id
+
+#     field                             size  format  name      show   link to                  extras
+FIELD detRegisteredImfile.det_id,          7, %s,     det_id
+FIELD detRegisteredImfile.iteration,       5, %s,     iter
+FIELD detRegisteredImfile.class_id,        8, %s,     class_id, value, detRegisteredImfile.php, ARG1
+FIELD detRegisteredImfile.fault,           5, %d,     fault
+FIELD detRegisteredImfile.bg,              8, %f,     backgnd
+FIELD detRegisteredImfile.bg_stdev,        8, %f,     stdev
+FIELD detRegisteredImfile.bg_mean_stdev,   8, %f,     [stdev]
+FIELD detRegisteredImfile.path_base,      10, %s,     path_base
+FIELD detRun.camera,                      10, %s,     camera, none
+
+TAIL PHP insert_log ('LOG.IMFILE');
Index: /branches/sc_branches/ippMonitorLap/def/detResidExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detResidExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detResidExp.d	(revision 31685)
@@ -0,0 +1,65 @@
+TABLE detResidExp, rawExp, detInputExp
+TITLE detResidExp
+FILE  detResidExp.php
+MENU  ipp.detrend.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+WHERE detResidExp.exp_id = rawExp.exp_id
+WHERE detResidExp.det_id = detInputExp.det_id
+WHERE detResidExp.exp_id = detInputExp.exp_id
+WHERE detResidExp.iteration = detInputExp.iteration
+
+# define image names to be used below
+# IMAGE VAR basename filerule camera class_id
+IMAGE JPEG2 $detResidExp.path_base PPIMAGE.JPEG2 $rawExp.camera NONE
+
+# define the arguments supplied to the links below (if any)
+ARGS  ARG1 exp_id=$detResidExp.exp_id
+
+ARGS  ARG2 detResidImfile.det_id=$detResidExp.det_id
+ARGS  ARG2 detResidImfile.iteration=$detResidExp.iteration
+ARGS  ARG2 detResidImfile.exp_id=$detResidExp.exp_id
+ARGS  ARG2 camera=$rawExp.camera
+ARGS  ARG2 basename=$detResidExp.path_base
+
+# OP    OP1  $detResidExp.bin_stdev > 0.0 ? $detResidExp.bg / $detResidExp.bin_stdev : NAN
+
+#     field                   size  format  name       show         link to              linkargs
+FIELD detResidExp.det_id,        7, %s,     Det ID,    value
+FIELD rawExp.camera,            10, %s,     camera,    none
+FIELD detResidExp.exp_id, 	 5, %s,     Exp ID,    value,       rawImfile.php,       ARG1
+FIELD rawExp.exp_name, 	         5, %s,     Exp Name,  value,       rawImfile.php,       ARG1
+FIELD detResidExp.iteration,     5, %s,     iter,      value
+FIELD detInputExp.include,       3, %t,     used,      value
+FIELD detResidExp.accept,        3, %t,     keep,      value
+FIELD detResidExp.fault,         4, %d,     fault,     value
+FIELD *,    	                 8, %s,     image,     image=JPEG2, detResidImfile.php,  ARG2
+FIELD detResidExp.bg,            8, %.3f,   backgnd,   value
+FIELD detResidExp.bg_mean_stdev, 8, %.3f,   [stdev],   value
+FIELD detResidExp.bg_stdev,      8, %.3f,   stdev,     value
+FIELD detResidExp.bin_stdev,     8, %.3f,   bin stdev, value
+FIELD (detResidExp.bg/detResidExp.bin_stdev), 8, %.3f, S/N, value
+FIELD (detResidExp.bg/rawExp.exp_time), 8, %.3f, flux, value
+FIELD rawExp.exp_time,           8, %.2f,   exptime,   value
+FIELD rawExp.ccd_temp,           8, %.2f,   ccd temp,  value
+# FIELD *,                         8, %s,     S/N,       op=OP1
+# FIELD detResidExp.fringe_0,      8, %.3f,   fringe,    value
+# FIELD detResidExp.fringe_1,      8, %.3f,   fringe err, value
+# FIELD detResidExp.fringe_2,      8, %.3f,   fringe stdev, value
+# FIELD detResidExp.user_1,        8, %.3f,   dfringe,    value
+# FIELD detResidExp.user_2,        8, %.3f,   dfringe err, value
+# FIELD detResidExp.user_3,        8, %.3f,   dfringe stdev, value
+FIELD rawExp.dateobs,           19, %T,     obs date,  value
+FIELD rawExp.filter,            10, %s,     filter,    value
+FIELD rawExp.pon_time,          10, %.1f,   pon_time,    value
+FIELD rawExp.airmass,            8, %.4f,   airmass,   value
+FIELD rawExp.sun_alt,            8, %.4f,   sun_alt,   value
+FIELD rawExp.sun_angle,          8, %.4f,   sun_angle, value
+FIELD rawExp.moon_alt,           8, %.4f,   moon_alt,  value
+FIELD rawExp.moon_angle,         8, %.4f,   moon_angle, value
+FIELD rawExp.moon_phase,         8, %.4f,   moon_phase, value
+FIELD detResidExp.path_base,    20, %s,     path_base, none
+
+TD_CLASS det_drop $detInputExp.include == 1 && $detResidExp.accept == 0
+TD_CLASS det_off  $detInputExp.include == 0 && $detResidExp.accept == 0
+TD_CLASS det_add  $detInputExp.include == 0 && $detResidExp.accept == 1
Index: /branches/sc_branches/ippMonitorLap/def/detResidExp_failure.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detResidExp_failure.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detResidExp_failure.d	(revision 31685)
@@ -0,0 +1,52 @@
+TABLE detResidExp, rawExp, detInputExp
+TITLE detResidExp Failures
+FILE  detResidExp_failure.php
+MENU  ipp.detrend.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+WHERE detResidExp.exp_id = rawExp.exp_id
+WHERE detResidExp.exp_id = detInputExp.exp_id
+WHERE detResidExp.iteration = detInputExp.iteration
+WHERE detResidExp.fault > 0
+
+# define the arguments supplied to the links below (if any)
+ARGS  ARG1 exp_id=$detResidExp.exp_id
+
+ARGS  ARG2 detResidImfile.det_id=$detResidExp.det_id
+ARGS  ARG2 detResidImfile.iteration=$detResidExp.iteration
+ARGS  ARG2 detResidImfile.exp_id=$detResidExp.exp_id
+ARGS  ARG2 camera=$rawExp.camera
+ARGS  ARG2 basename=$detResidExp.path_base
+
+OP    OP1  $detResidExp.bin_stdev > 0.0 ? $detResidExp.bg / $detResidExp.bin_stdev : NAN
+
+#     field                   size  format  name       show         link to              linkargs
+FIELD detResidExp.det_id,        7, %s,     Det ID,    value
+FIELD rawExp.camera,            10, %s,     camera,    value
+FIELD detResidExp.exp_id, 	 5, %s,     Exp ID,    value,       rawImfile.php,       ARG1
+FIELD rawExp.exp_name, 	         5, %s,     Exp Name,  value,       rawImfile.php,       ARG1
+FIELD detResidExp.iteration,     5, %s,     iter,      value
+FIELD detInputExp.include,       3, %t,     used,      value
+FIELD detResidExp.accept,        3, %t,     keep,      value
+FIELD detResidExp.fault,         4, %d,     fault,     value
+FIELD detResidExp.bg,            8, %.3f,   backgnd,   value
+FIELD detResidExp.bg_mean_stdev, 8, %.3f,   [stdev],   value
+FIELD detResidExp.bg_stdev,      8, %.3f,   stdev,     value
+FIELD detResidExp.bin_stdev,     8, %.3f,   bin stdev, value
+FIELD *,                         8, %s,     S/N,       op=OP1
+FIELD detResidExp.fringe_0,      8, %.3f,   fringe,    value
+FIELD detResidExp.fringe_1,      8, %.3f,   fringe err, value
+FIELD detResidExp.fringe_2,      8, %.3f,   fringe stdev, value
+FIELD detResidExp.user_1,        8, %.3f,   dfringe,    value
+FIELD detResidExp.user_2,        8, %.3f,   dfringe err, value
+FIELD detResidExp.user_3,        8, %.3f,   dfringe stdev, value
+FIELD rawExp.dateobs,           19, %T,     obs date,  value
+FIELD rawExp.filter,            10, %s,     filter,    value
+FIELD rawExp.exp_time,           8, %.2f,   exptime,   value
+FIELD rawExp.ccd_temp,           8, %.2f,   ccd temp,  value
+FIELD rawExp.airmass,            8, %.4f,   airmass,   value
+FIELD detResidExp.path_base,    20, %s,     path_base, none
+
+TD_CLASS det_drop $detInputExp.include == 1 && $detResidExp.accept == 0
+TD_CLASS det_off  $detInputExp.include == 0 && $detResidExp.accept == 0
+TD_CLASS det_add  $detInputExp.include == 0 && $detResidExp.accept == 1
Index: /branches/sc_branches/ippMonitorLap/def/detResidExp_noimage.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detResidExp_noimage.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detResidExp_noimage.d	(revision 31685)
@@ -0,0 +1,62 @@
+TABLE detResidExp, rawExp, detInputExp
+TITLE detResidExp
+FILE  detResidExp_noimage.php
+MENU  ipp.detrend.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+WHERE detResidExp.exp_id = rawExp.exp_id
+WHERE detResidExp.exp_id = detInputExp.exp_id
+WHERE detResidExp.iteration = detInputExp.iteration
+
+# define image names to be used below
+# IMAGE VAR basename filerule camera class_id
+# IMAGE JPEG2 $detResidExp.path_base PPIMAGE.JPEG2 $rawExp.camera NONE
+
+# define the arguments supplied to the links below (if any)
+ARGS  ARG1 exp_id=$detResidExp.exp_id
+
+ARGS  ARG2 detResidImfile.det_id=$detResidExp.det_id
+ARGS  ARG2 detResidImfile.iteration=$detResidExp.iteration
+ARGS  ARG2 detResidImfile.exp_id=$detResidExp.exp_id
+ARGS  ARG2 camera=$rawExp.camera
+ARGS  ARG2 basename=$detResidExp.path_base
+
+# OP    OP1  $detResidExp.bin_stdev > 0.0 ? $detResidExp.bg / $detResidExp.bin_stdev : NAN
+
+#     field                   size  format  name       show         link to              linkargs
+FIELD detResidExp.det_id,        7, %s,     Det ID,    value
+FIELD rawExp.camera,            10, %s,     camera,    value
+FIELD detResidExp.exp_id, 	 5, %s,     Exp ID,    value,       rawImfile.php,       ARG1
+FIELD rawExp.exp_name, 	         5, %s,     Exp Name,  value,       rawImfile.php,       ARG1
+FIELD detResidExp.iteration,     5, %s,     iter,      value
+FIELD detInputExp.include,       3, %t,     used,      value
+FIELD detResidExp.accept,        3, %t,     keep,      value
+FIELD detResidExp.fault,         4, %d,     fault,     value
+# FIELD *,    	                 8, %s,     image,     image=JPEG2, detResidImfile.php,  ARG2
+FIELD detResidExp.bg,            8, %.3f,   backgnd,   value
+FIELD detResidExp.bg_mean_stdev, 8, %.3f,   [stdev],   value
+FIELD detResidExp.bg_stdev,      8, %.3f,   stdev,     value
+FIELD detResidExp.bin_stdev,     8, %.3f,   bin stdev, value
+FIELD (detResidExp.bg/detResidExp.bin_stdev), 8, %.3f, S/N, value
+# FIELD *,                         8, %s,     S/N,       op=OP1
+FIELD detResidExp.fringe_0,      8, %.3f,   fringe,    value
+FIELD detResidExp.fringe_1,      8, %.3f,   fringe err, value
+FIELD detResidExp.fringe_2,      8, %.3f,   fringe stdev, value
+FIELD detResidExp.user_1,        8, %.3f,   dfringe,    value
+FIELD detResidExp.user_2,        8, %.3f,   dfringe err, value
+FIELD detResidExp.user_3,        8, %.3f,   dfringe stdev, value
+FIELD rawExp.dateobs,           19, %T,     obs date,  value
+FIELD rawExp.filter,            10, %s,     filter,    value
+FIELD rawExp.exp_time,           8, %.2f,   exptime,   value
+FIELD rawExp.ccd_temp,           8, %.2f,   ccd temp,  value
+FIELD rawExp.airmass,            8, %.4f,   airmass,   value
+FIELD rawExp.sun_alt,            8, %.4f,   sun_alt,   value
+FIELD rawExp.sun_angle,          8, %.4f,   sun_angle, value
+FIELD rawExp.moon_alt,           8, %.4f,   moon_alt,  value
+FIELD rawExp.moon_angle,         8, %.4f,   moon_angle, value
+FIELD rawExp.moon_phase,         8, %.4f,   moon_phase, value
+FIELD detResidExp.path_base,    20, %s,     path_base, none
+
+TD_CLASS det_drop $detInputExp.include == 1 && $detResidExp.accept == 0
+TD_CLASS det_off  $detInputExp.include == 0 && $detResidExp.accept == 0
+TD_CLASS det_add  $detInputExp.include == 0 && $detResidExp.accept == 1
Index: /branches/sc_branches/ippMonitorLap/def/detResidImfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detResidImfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detResidImfile.d	(revision 31685)
@@ -0,0 +1,25 @@
+TABLE detResidImfile, rawImfile
+TITLE detResidImfile
+FILE  detResidImfile.php
+MENU  ipp.imfiles.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+WHERE detResidImfile.exp_id = rawImfile.exp_id
+WHERE detResidImfile.class_id = rawImfile.class_id
+
+#     field                      size  format  name        show  link to     extras
+FIELD detResidImfile.det_id,        7, %s,      Det ID
+FIELD detResidImfile.iteration,     5, %s,      iter
+FIELD detResidImfile.exp_id,        5, %s,      Exp ID
+FIELD rawImfile.exp_name,           5, %s,      Exp Name
+FIELD detResidImfile.class_id,      8, %s,      Chip ID
+FIELD detResidImfile.bg,            8, %s,      backgnd
+FIELD detResidImfile.bg_stdev,      8, %s,      bg stdev
+FIELD detResidImfile.bg_mean_stdev, 8, %s,      [stdev]
+FIELD rawImfile.ccd_temp,           5, %s,      CCD Temp
+FIELD detResidImfile.fault,         5, %s,      fault
+FIELD detResidImfile.path_base,     5, %s,      path_base
+FIELD detResidImfile.uri,           5, %s,      uri, none
+
+TAIL PHP insert_image ('PPIMAGE.JPEG1', 'width=90%');
+TAIL PHP insert_log ('LOG.EXP');
Index: /branches/sc_branches/ippMonitorLap/def/detResidImfile_failure.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detResidImfile_failure.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detResidImfile_failure.d	(revision 31685)
@@ -0,0 +1,35 @@
+TABLE detResidImfile, rawExp, rawImfile
+TITLE detResidImfile Failures
+FILE  detResidImfile_failure.php
+MENU  ipp.detrend.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+WHERE detResidImfile.exp_id = rawExp.exp_id
+WHERE detResidImfile.exp_id = rawImfile.exp_id
+WHERE detResidImfile.class_id = rawImfile.class_id
+WHERE detResidImfile.fault > 0
+
+ARGS  ARG1 detResidImfile.det_id=$detResidImfile.det_id
+ARGS  ARG1 detResidImfile.iteration=$detResidImfile.iteration
+ARGS  ARG1 detResidImfile.exp_id=$detResidImfile.exp_id
+ARGS  ARG1 detResidImfile.class_id=$detResidImfile.class_id
+ARGS  ARG1 camera=$rawExp.camera
+ARGS  ARG1 basename=$detResidImfile.path_base
+ARGS  ARG1 class=$detResidImfile.class_id
+
+#     field                      size  format  name        show  link to     extras
+FIELD detResidImfile.det_id,        5, %d,      Det ID
+FIELD detResidImfile.iteration,     3, %d,      iter
+FIELD detResidImfile.exp_id,        5, %d,      Exp ID
+FIELD rawImfile.exp_name,           5, %s,      Exp Name
+FIELD detResidImfile.class_id,      8, %s,      Chip ID,  value,  detResidImfile_failure.php, ARG1
+FIELD detResidImfile.fault,         5, %d,      fault
+FIELD detResidImfile.bg,            8, %.2f,    backgnd
+FIELD detResidImfile.bg_stdev,      8, %.2f,    bg stdev
+FIELD detResidImfile.bg_mean_stdev, 8, %.2f,    [stdev]
+FIELD rawImfile.ccd_temp,           5, %.2f,    CCD Temp
+FIELD detResidImfile.path_base,    20, %s,      path_base
+
+FIELD rawExp.camera,                    5, %s,     Exp Name, none
+
+TAIL PHP insert_log ('LOG.IMFILE');
Index: /branches/sc_branches/ippMonitorLap/def/detRun.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detRun.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detRun.d	(revision 31685)
@@ -0,0 +1,48 @@
+TABLE detRun
+TITLE detRun
+FILE  detRun.php
+MENU  ipp.detrend.dat
+
+ARGS  ARG1 detRunSummary.det_id=$det_id
+
+ARGS  ARG2 detInputExp.det_id=$det_id
+ARGS  ARG2 detInputExp.iteration=$iteration
+
+ARGS  ARG3 detProcessedExp.det_id=$det_id
+
+ARGS  ARG4 detResidExp.det_id=$det_id
+ARGS  ARG4 detResidExp.iteration=$iteration
+
+ARGS  ARG5 detStackedImfile.det_id=$det_id
+ARGS  ARG6 detNormalizedImfile.det_id=$det_id
+ARGS  ARG7 detRegisteredImfile.det_id=$det_id
+
+#     field       size  format  name         show       link to                   extras
+FIELD det_id,        5, %s,     det ID,      value,     detRunSummary.php,        ARG1
+FIELD iteration,     3, %s,     iter
+FIELD det_type,     12, %s,     type
+FIELD state,         5, %s,     state
+FIELD *,             5, %s,     IN,          value=IN,   detInputExp.php,          ARG2
+FIELD *,             5, %s,     P,           value=P,   detProcessedExp.php,      ARG3
+FIELD *,             5, %s,     D,           value=D,   detResidExp.php,          ARG4
+FIELD *,             5, %s,     S,           value=S,   detStackedImfile.php,     ARG5
+FIELD *,             5, %s,     N,           value=N,   detNormalizedImfile.php,  ARG6
+FIELD *,             5, %s,     R,           value=R,   detRegisteredImfile.php,  ARG7
+FIELD mode,          5, %s,     mode
+FIELD filter,        5, %s,     filter     
+FIELD registered,   19, %s,     registered 
+#FIELD use_begin,    19, %s,     use_begin  
+#FIELD use_end,      19, %s,     use_end    
+FIELD time_begin,    19, %s,     time_begin  
+FIELD time_end,      19, %s,     time_end    
+FIELD airmass_min,   5, %.2f,   min_airmass    
+FIELD airmass_max,   5, %.2f,   max     
+FIELD exp_time_min,  5, %.2f,   min_exp_time   
+FIELD exp_time_max,  5, %.2f,   max 
+FIELD ccd_temp_min,  5, %.2f,   min_ccd_temp   
+FIELD ccd_temp_max,  5, %.2f,   max    
+FIELD posang_min,    5, %.2f,   min_posang     
+FIELD posang_max,    5, %s,     max      
+
+TD_CLASS list_off $state == 'drop'
+TD_CLASS list_run $state == 'run'
Index: /branches/sc_branches/ippMonitorLap/def/detRunActive.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detRunActive.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detRunActive.d	(revision 31685)
@@ -0,0 +1,49 @@
+TABLE detRun
+TITLE Active Detrend Runs
+FILE  detRunActive.php
+MENU  ipp.detrend.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+WHERE detRun.state != 'drop'
+
+ARGS  ARG1 detRunSummary.det_id=$det_id
+
+ARGS  ARG2 detInputExp.det_id=$det_id
+ARGS  ARG2 detInputExp.iteration=$iteration
+
+ARGS  ARG3 detProcessedExp.det_id=$det_id
+
+ARGS  ARG4 detResidExp.det_id=$det_id
+ARGS  ARG4 detResidExp.iteration=$iteration
+
+ARGS  ARG5 detStackedImfile.det_id=$det_id
+ARGS  ARG6 detNormalizedImfile.det_id=$det_id
+ARGS  ARG7 detRegisteredImfile.det_id=$det_id
+
+#     field       size  format  name         show       link to                   extras
+FIELD det_id,        5, %s,     det ID,      value,     detRunSummary.php,        ARG1
+FIELD iteration,     3, %s,     iter
+FIELD det_type,     12, %s,     type
+FIELD state,         5, %s,     state
+FIELD *,             5, %s,     IN,          value=IN,   detInputExp.php,          ARG2
+FIELD *,             5, %s,     P,           value=P,   detProcessedExp.php,      ARG3
+FIELD *,             5, %s,     D,           value=D,   detResidExp.php,          ARG4
+FIELD *,             5, %s,     S,           value=S,   detStackedImfile.php,     ARG5
+FIELD *,             5, %s,     N,           value=N,   detNormalizedImfile.php,  ARG6
+FIELD *,             5, %s,     R,           value=R,   detRegisteredImfile.php,  ARG7
+FIELD mode,          5, %s,     mode
+FIELD filter,        5, %s,     filter     
+FIELD registered,   19, %s,     registered 
+FIELD use_begin,    19, %s,     use_begin  
+FIELD use_end,      19, %s,     use_end    
+FIELD airmass_min,   5, %.2f,   min_airmass    
+FIELD airmass_max,   5, %.2f,   max     
+FIELD exp_time_min,  5, %.2f,   min_exp_time   
+FIELD exp_time_max,  5, %.2f,   max 
+FIELD ccd_temp_min,  5, %.2f,   min_ccd_temp   
+FIELD ccd_temp_max,  5, %.2f,   max    
+FIELD posang_min,    5, %.2f,   min_posang     
+FIELD posang_max,    5, %s,     max      
+
+TD_CLASS list_off $state == 'drop'
+TD_CLASS list_run $state == 'run'
Index: /branches/sc_branches/ippMonitorLap/def/detRunSummary.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detRunSummary.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detRunSummary.d	(revision 31685)
@@ -0,0 +1,26 @@
+TABLE detRunSummary, detRun
+TITLE Detrend Run Iterations (does not list registered frames)
+FILE  detRunSummary.php
+MENU  ipp.detrend.dat
+
+WHERE detRunSummary.det_id = detRun.det_id
+
+ARGS  ARG1  detInputExp.det_id=$detRunSummary.det_id
+ARGS  ARG1  detInputExp.iteration=$detRunSummary.iteration
+
+ARGS  ARG2  detResidExp.det_id=$detRunSummary.det_id
+ARGS  ARG2  detResidExp.iteration=$detRunSummary.iteration
+
+#     field                   size  format  name  show      link to           extras
+FIELD detRunSummary.det_id,     7,  %s,     det_id    
+FIELD detRunSummary.iteration,  5,  %s,     iter
+FIELD detRunSummary.accept,     4,  %s,     keep
+FIELD *,                       20,  %s,     choose,    value=input, detInputExp.php,  ARG1
+FIELD *,                       20,  %s,     choose,    value=proc,  detProcessedExp.php,      ARG3
+FIELD *,                       20,  %s,     choose,    value=resid, detResidExp.php,  ARG2
+FIELD detRunSummary.bg,        20,  %s,     bg
+FIELD detRunSummary.bg_stdev,  20,  %s,     bg_stdev
+FIELD detRun.state,            20,  %s,     state,     none
+
+TD_CLASS list_off $detRun.state == 'drop'
+TD_CLASS list_run $detRun.state == 'run'
Index: /branches/sc_branches/ippMonitorLap/def/detStackedImfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detStackedImfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detStackedImfile.d	(revision 31685)
@@ -0,0 +1,29 @@
+TABLE detStackedImfile, detRun
+TITLE detStackedImfile
+FILE  detStackedImfile.php
+MENU  ipp.imfiles.dat
+
+WHERE detStackedImfile.det_id = detRun.det_id
+
+# XXX change uri to path_base in db
+ARGS  ARG1 detStackedImfile.det_id=$detStackedImfile.det_id
+ARGS  ARG1 detStackedImfile.iteration=$detStackedImfile.iteration
+ARGS  ARG1 detStackedImfile.class_id=$detStackedImfile.class_id
+ARGS  ARG1 camera=$detRun.camera
+ARGS  ARG1 basename=$detStackedImfile.uri
+ARGS  ARG1 class=$detStackedImfile.class_id
+
+#     field                         size  format  name        show  link to     extras
+FIELD detStackedImfile.det_id,         7,  %s,    det_id
+FIELD detStackedImfile.iteration,      5,  %s,    iter
+FIELD detStackedImfile.class_id,       8,  %s,    class_id,   value, detStackedImfile.php, ARG1
+FIELD detStackedImfile.fault,          5,  %d,    fault
+FIELD detStackedImfile.bg,             8,  %f,    backgnd
+FIELD detStackedImfile.bg_stdev,       8,  %f,    stdev
+FIELD detStackedImfile.bg_mean_stdev,  8,  %f,    [stdev]
+FIELD detStackedImfile.uri,           10,  %s,    uri
+FIELD detRun.camera,                  10, %s,     camera, none
+
+TD_CLASS list_off $fault > 0
+
+TAIL PHP insert_log ('LOG.IMFILE');
Index: /branches/sc_branches/ippMonitorLap/def/detStackedImfile_failure.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/detStackedImfile_failure.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/detStackedImfile_failure.d	(revision 31685)
@@ -0,0 +1,32 @@
+TABLE detStackedImfile, detRun
+TITLE detStackedImfile Failures
+FILE  detStackedImfile_failure.php
+MENU  ipp.detrend.dat
+
+WHERE fault > 0
+WHERE detStackedImfile.det_id = detRun.det_id
+
+ARGS  ARG1 detStackedImfile.det_id    =$detStackedImfile.det_id
+ARGS  ARG1 detStackedImfile.iteration =$detStackedImfile.iteration
+ARGS  ARG1 detStackedImfile.class_id  =$detStackedImfile.class_id
+ARGS  ARG1 camera=$detRun.camera
+ARGS  ARG1 basename=$detStackedImfile.path_base
+ARGS  ARG1 class=$detStackedImfile.class_id
+
+# XXX : detStackedImfile has uri only, not path_base : fix!
+
+#     field         size  format  name       show   link to     extras
+FIELD detStackedImfile.det_id,         7,  %s,    det_id
+FIELD detStackedImfile.iteration,      5,  %s,    iteration
+FIELD detStackedImfile.class_id,       8,  %s,    class_id
+FIELD detStackedImfile.class_id,       8,  %s,    Chip ID,    value, detStackedImfile_failure.php, ARG1
+FIELD detStackedImfile.fault,          5,  %d,    fault
+FIELD detStackedImfile.bg,             8,  %f,    backgnd
+FIELD detStackedImfile.bg_stdev,       8,  %f,    stdev
+FIELD detStackedImfile.bg_mean_stdev,  8,  %f,    [stdev]
+FIELD detStackedImfile.uri,           20,  %s,    uri
+# FIELD recipe, 20,   recipe
+
+# TD_CLASS list_off $fault > 0
+
+TAIL PHP insert_log ('LOG.IMFILE');
Index: /branches/sc_branches/ippMonitorLap/def/diffFailedSkyfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/diffFailedSkyfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/diffFailedSkyfile.d	(revision 31685)
@@ -0,0 +1,26 @@
+TABLE diffRun, diffSkyfile
+TITLE Diff Failed Skyfiles
+FILE  diffFailedSkyfile.php
+MENU  ipp.stack.dat
+
+WHERE diffRun.diff_id             = diffSkyfile.diff_id
+WHERE diffSkyfile.fault != 0
+
+ARGS  ARG7 diffSkyfile.diff_id=$diffSkyfile.diff_id
+ARGS  ARG7 diffSkyfile.skycell_id=$diffSkyfile.skycell_id
+ARGS  ARG7 camera=GPC1
+ARGS  ARG7 basename=$diffSkyfile.path_base
+
+#     field                         size  format  name           show     link to         extras
+FIELD diffSkyfile.diff_id,             5, %d,     Diff ID
+FIELD diffSkyfile.skycell_id,          5, %s,     Skycell ID
+FIELD diffRun.label,    	       5, %s,     Label
+FIELD diffRun.data_group,    	       5, %s,     data grp
+FIELD diffRun.dist_group,    	       5, %s,     dist grp
+# FIELD diffRun.filter,    	       5, %s,     Filter
+FIELD diffRun.tess_id,    	       5, %s,     Tess ID
+FIELD diffRun.state,    	       7, %s,     State,         value,   diffProcessedSkyfile.php, ARG7
+FIELD diffSkyfile.fault,               5, %d,     fault
+FIELD diffSkyfile.path_base,           5, %s,     path_base,     none
+
+TAIL PHP insert_log ('LOG.EXP');
Index: /branches/sc_branches/ippMonitorLap/def/diffInputSkyfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/diffInputSkyfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/diffInputSkyfile.d	(revision 31685)
@@ -0,0 +1,21 @@
+TABLE diffInputSkyfile, diffRun
+TITLE diffInputSkyfile
+FILE  diffInputSkyfile.php
+MENU  ipp.stack.dat
+
+WHERE diffInputSkyfile.diff_id = diffRun.diff_id
+
+#        field                            size format  name           show     link to         extras
+FIELD    diffInputSkyfile.diff_id,	    5, %d,     diff ID
+FIELD    diffInputSkyfile.diff_skyfile_id,  5, %d,     skyfile ID
+FIELD    diffInputSkyfile.skycell_id,	    8, %s,     skycell ID
+FIELD    diffRun.state,         	    7, %s,     state
+FIELD    diffRun.label,	    		    7, %s,     label
+FIELD    diffRun.data_group,   		    7, %s,     data grp
+FIELD    diffRun.dist_group,  		    7, %s,     dist grp
+FIELD    diffRun.magicked,	     	    4, %d,     Magicked
+FIELD    diffInputSkyfile.warp1,	    5, %d,     warp 1
+FIELD    diffInputSkyfile.stack1,	    5, %d,     stack 1
+FIELD    diffInputSkyfile.warp2,	    5, %d,     warp 2
+FIELD    diffInputSkyfile.stack2,	    5, %d,     stack 2
+FIELD    diffInputSkyfile.tess_id,	    8, %s,     tessellation ID
Index: /branches/sc_branches/ippMonitorLap/def/diffProcessedSkyfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/diffProcessedSkyfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/diffProcessedSkyfile.d	(revision 31685)
@@ -0,0 +1,36 @@
+TABLE diffRun, diffSkyfile
+TITLE Diff Processed Skyfiles
+FILE  diffProcessedSkyfile.php
+MENU  ipp.stack.dat
+
+WHERE diffRun.diff_id             = diffSkyfile.diff_id
+# WHERE diffRun.state = 'full'
+# WHERE diffSkyfile.fault = 0
+
+ARGS  ARG7 diffSkyfile.diff_id=$diffSkyfile.diff_id
+ARGS  ARG7 diffSkyfile.skycell_id=$diffSkyfile.skycell_id
+ARGS  ARG7 camera=GPC1
+ARGS  ARG7 basename=$diffSkyfile.path_base
+
+#     field                         size  format  name           show     link to         extras
+FIELD diffSkyfile.diff_id,             5, %d,     Diff ID
+FIELD diffSkyfile.skycell_id,          4, %s,     Skycell ID
+FIELD diffRun.label,    	       5, %s,     Label
+FIELD diffRun.data_group,    	       5, %s,     data grp
+FIELD diffRun.dist_group,    	       5, %s,     dist grp
+# FIELD diffRun.filter,    	       5, %s,     Filter
+FIELD diffRun.tess_id,    	       5, %s,     Tess ID
+FIELD diffRun.state,    	       7, %s,     State,         value,   diffProcessedSkyfile.php, ARG7
+FIELD diffSkyfile.bg,                  5, %.2f,   backgnd
+FIELD diffSkyfile.bg_stdev,            5, %.2f,   stdev    
+FIELD diffSkyfile.dtime_diff,          5, %.2f,   t(diff)
+FIELD diffSkyfile.dtime_match,         5, %.2f,   t(match)
+FIELD diffSkyfile.dtime_phot,          5, %.2f,   t(phot)
+FIELD diffSkyfile.dtime_script,        5, %.2f,   t(script)
+FIELD diffSkyfile.stamps_num,          5, %d,     n(stamps)
+FIELD diffSkyfile.stamps_mean,         5, %.2f,   mean(stamps)
+FIELD diffSkyfile.stamps_rms,          5, %.2f,   rms(stamps)
+FIELD diffSkyfile.sources,             5, %d,     n(sources)
+FIELD diffSkyfile.path_base,           5, %s,     path_base,     none
+
+TAIL PHP insert_log ('LOG.EXP');
Index: /branches/sc_branches/ippMonitorLap/def/diffProcessedSkyfile_Images.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/diffProcessedSkyfile_Images.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/diffProcessedSkyfile_Images.d	(revision 31685)
@@ -0,0 +1,46 @@
+TABLE diffRun, diffSkyfile
+TITLE Diff Processed Skyfiles
+FILE  diffProcessedSkyfile_Images.php
+MENU  ipp.stack.dat
+
+WHERE diffRun.diff_id             = diffSkyfile.diff_id
+# WHERE diffRun.state = 'full'
+# WHERE diffSkyfile.fault = 0
+
+# define image names to be used below
+# IMAGE VAR basename filerule camera class_id
+IMAGE JPEG2 $diffSkyfile.path_base PPSUB.OUTPUT.JPEG2 GPC1 NONE
+
+# if no query restrictions are supplied, we want to limit the query or it is extremely long running:
+UNRESTRICTED AND diffRun.diff_id = 0
+
+# XXX need to get camera from lookup
+ARGS  ARG7 diffSkyfile.diff_id=$diffSkyfile.diff_id
+ARGS  ARG7 diffSkyfile.skycell_id=$diffSkyfile.skycell_id
+ARGS  ARG7 camera=GPC1
+ARGS  ARG7 basename=$diffSkyfile.path_base
+
+#     field                         size  format  name           show     link to         extras
+FIELD diffSkyfile.diff_id,             5, %d,     Diff ID
+FIELD diffSkyfile.skycell_id,          5, %s,     Skycell ID
+FIELD diffRun.label,    	       5, %s,     Label
+FIELD diffRun.data_group,    	       5, %s,     data grp
+FIELD diffRun.dist_group,    	       5, %s,     dist grp
+FIELD *,    	                       8, %s,     image,         image=JPEG2, diffProcessedSkyfile_Images.php,  ARG7
+# FIELD diffRun.filter,    	       5, %s,     Filter
+FIELD diffRun.tess_id,    	       5, %s,     Tess ID
+FIELD diffRun.state,    	       7, %s,     State,         value,   diffProcessedSkyfile.php, ARG7
+FIELD diffSkyfile.bg,                  5, %.2f,   backgnd
+FIELD diffSkyfile.bg_stdev,            5, %.2f,   stdev    
+FIELD diffSkyfile.dtime_diff,          5, %.2f,   t(diff)
+FIELD diffSkyfile.dtime_match,         5, %.2f,   t(match)
+FIELD diffSkyfile.dtime_phot,          5, %.2f,   t(phot)
+FIELD diffSkyfile.dtime_script,        5, %.2f,   t(script)
+FIELD diffSkyfile.stamps_num,          5, %d,     n(stamps)
+FIELD diffSkyfile.stamps_mean,         5, %.2f,   mean(stamps)
+FIELD diffSkyfile.stamps_rms,          5, %.2f,   rms(stamps)
+FIELD diffSkyfile.sources,             5, %d,     n(sources)
+FIELD diffSkyfile.path_base,           5, %s,     path_base,     none
+
+TAIL PHP insert_image ('PPSUB.OUTPUT.JPEG1', 'width=90%');
+TAIL PHP insert_log ('LOG.EXP');
Index: /branches/sc_branches/ippMonitorLap/def/diffRun.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/diffRun.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/diffRun.d	(revision 31685)
@@ -0,0 +1,18 @@
+TABLE diffRun
+TITLE diffRun
+FILE  diffRun.php
+MENU  ipp.stack.dat
+
+#        field        size  format  name           show     link to         extras
+FIELD    diff_id,	 5, %d,     diff ID
+FIELD    state,		 7, %s,     state
+FIELD    label,		 7, %s,     label
+FIELD    data_group,	 7, %s,     data grp
+FIELD    dist_group,	 7, %s,     dist grp
+FIELD    magicked,	 4, %d,     Magicked
+FIELD    tess_id,	 8, %s,     tess ID
+FIELD    bothways,	 5, %d,     both ways
+FIELD    registered,	19, %T,     Time registered
+FIELD    reduction,	10, %s,     reduction
+FIELD    workdir,	10, %s,     workdir
+FIELD    dvodb,		10, %s,     DVO database
Index: /branches/sc_branches/ippMonitorLap/def/diffSkyfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/diffSkyfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/diffSkyfile.d	(revision 31685)
@@ -0,0 +1,10 @@
+TABLE diffSkyfile
+TITLE diffSkyfile
+FILE  diffSkyfile.php
+MENU  ipp.stack.dat
+
+#        field        size  format  name           show     link to         extras
+FIELD    diff_id,	20, %s,     diff ID
+FIELD    uri,		20, %s,     URI
+FIELD    bg,		20, %s,     background
+FIELD    bg_stdev,	20, %s,     standard deviation
Index: /branches/sc_branches/ippMonitorLap/def/diffSummary.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/diffSummary.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/diffSummary.d	(revision 31685)
@@ -0,0 +1,19 @@
+TABLE diffRun
+TITLE Diff Summary
+FILE  diffSummary.php
+MENU  ipp.stack.dat
+
+#     field           size  format  name         show    link to         extras
+FIELD label,    	 15, %s,     label
+FIELD data_group,    	 10, %s,     data_group
+FIELD workdir,    	 7, %s,     workdir
+FIELD tess_id,    	 7, %s,     tess_id
+FIELD state,    	 7, %s,     state
+FIELD count(state) as n, 7, %d,     count
+
+MODE  summary
+GROUP state
+GROUP label
+GROUP workdir
+GROUP data_group
+GROUP tess_id
Index: /branches/sc_branches/ippMonitorLap/def/diffSummary_Images.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/diffSummary_Images.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/diffSummary_Images.d	(revision 31685)
@@ -0,0 +1,52 @@
+TABLE diffRun, diffSkyfile, diffSummary
+TITLE Diff Summary w/ Images
+FILE  diffSummary_Images.php
+MENU  ipp.stack.dat
+
+WHERE diffRun.diff_id             = diffSkyfile.diff_id
+WHERE diffSummary.diff_id = diffRun.diff_id
+# WHERE diffRun.state = 'full'
+# WHERE diffSkyfile.fault = 0
+
+# define image names to be used below
+# IMAGE VAR basename filerule camera class_id
+IMAGE JPEG2 OP3 PPSKYCELL.JPEG2 GPC1 NONE
+OP   OP3  $diffSummary.path_base . $diffSummary.projection_cell
+ARGS ARG7 name=$diffSummary.path_base.$diffSummary.projection_cell
+ARGS ARG7 rule=PPSKYCELL.JPEG1
+ARGS ARG7 camera=GPC1
+ARGS ARG7 class_id=NONE
+
+# XXX need to get camera from lookup
+ARGS  ARG7 diffSkyfile.diff_id=$diffSkyfile.diff_id
+ARGS  ARG7 diffSkyfile.skycell_id=$diffSkyfile.skycell_id
+ARGS  ARG7 camera=GPC1
+ARGS  ARG7 basename=$diffSkyfile.path_base
+
+#     field                         size  format  name           show     link to         extras
+FIELD diffSkyfile.diff_id,             5, %d,     Diff ID
+FIELD diffSkyfile.skycell_id,          5, %s,     Skycell ID
+FIELD diffRun.label,    	       5, %s,     Label
+FIELD diffRun.data_group,    	       5, %s,     data grp
+FIELD diffRun.dist_group,    	       5, %s,     dist grp
+FIELD *,    	                       8, %s,     image, image=JPEG2, getimage.php, ARG7
+# FIELD diffRun.filter,    	       5, %s,     Filter
+FIELD diffRun.tess_id,    	       5, %s,     Tess ID
+FIELD diffRun.state,    	       7, %s,     State,         value,   diffProcessedSkyfile.php, ARG7
+FIELD diffSkyfile.bg,                  5, %.2f,   backgnd
+FIELD diffSkyfile.bg_stdev,            5, %.2f,   stdev    
+FIELD diffSkyfile.dtime_diff,          5, %.2f,   t(diff)
+FIELD diffSkyfile.dtime_match,         5, %.2f,   t(match)
+FIELD diffSkyfile.dtime_phot,          5, %.2f,   t(phot)
+FIELD diffSkyfile.dtime_script,        5, %.2f,   t(script)
+FIELD diffSkyfile.stamps_num,          5, %d,     n(stamps)
+FIELD diffSkyfile.stamps_mean,         5, %.2f,   mean(stamps)
+FIELD diffSkyfile.stamps_rms,          5, %.2f,   rms(stamps)
+FIELD diffSkyfile.sources,             5, %d,     n(sources)
+FIELD diffSkyfile.path_base,           5, %s,     path_base,     none
+
+FIELD diffSummary.path_base,           5, %s,     path_base,     none
+FIELD diffSummary.projection_cell,     5, %s,     projection_cell,     none
+
+# TAIL PHP insert_image ('PPSUB.OUTPUT.JPEG1', 'width=90%');
+TAIL PHP insert_log ('LOG.EXP');
Index: /branches/sc_branches/ippMonitorLap/def/distComponent.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/distComponent.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/distComponent.d	(revision 31685)
@@ -0,0 +1,14 @@
+TABLE distComponent
+TITLE Distribution Components
+FILE  distComponent.php
+MENU  ipp.dist.dat
+
+#     field                    size  format  name         show    link to                  extras
+FIELD distComponent.dist_id,   5, %d,     Dist ID
+FIELD distComponent.component, 5, %d,     Component
+FIELD distComponent.bytes,     5, %s,     Bytes
+FIELD distComponent.md5sum,    5, %d,     MD5
+FIELD distComponent.state,     5, %d,     State
+FIELD distComponent.outdir,    5, %s,     Outdir
+FIELD distComponent.name,      5, %s,     Name
+FIELD distComponent.fault,     5, %d,     Fault
Index: /branches/sc_branches/ippMonitorLap/def/distRun.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/distRun.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/distRun.d	(revision 31685)
@@ -0,0 +1,28 @@
+TABLE distRun, distComponent
+TITLE Distribution Runs
+FILE  distRun.php
+MENU  ipp.dist.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+
+WHERE distRun.dist_id = distComponent.dist_id
+
+#     field                   size  format  name         show    link to                  extras
+FIELD distinct(distRun.dist_id),        5, %d,     Dist ID
+FIELD distRun.target_id,      5, %d,     Target ID
+FIELD distRun.stage,          5, %s,     Stage
+FIELD distRun.stage_id,       5, %d,     Stage ID
+FIELD distRun.magic_ds_id,    5, %d,     Magic DS ID
+FIELD distRun.label,          5, %s,     Label
+FIELD distRun.data_group,          5, %s,     data grp
+FIELD distRun.outroot,        5, %s,     Outroot
+FIELD distRun.outdir,         5, %s,     Outdir
+FIELD distRun.clean,          5, %d,     Clean?
+FIELD distRun.no_magic,       5, %d,     Muggle?
+FIELD distRun.state,          5, %s,     State
+FIELD distRun.time_stamp,     5, %T,     Time
+FIELD distRun.fault,          5, %d,     Run Fault
+FIELD distComponent.fault,    5, %d,     Comp. Fault
+FIELD distRun.note,           5, %s,     Note
+
+GROUP dist_id
Index: /branches/sc_branches/ippMonitorLap/def/distSummary.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/distSummary.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/distSummary.d	(revision 31685)
@@ -0,0 +1,18 @@
+TABLE distRun
+TITLE Distribution Summary
+FILE  distSummary.php
+MENU  ipp.dist.dat
+
+#     field                   size  format  name         show    link to                  extras
+FIELD distRun.label,          15, %s,     Label
+#FIELD distRun.data_group,          15, %s,     data grp
+FIELD distRun.stage,          5, %s,     Stage
+FIELD distRun.state,          5, %s,     State
+FIELD distRun.data_group,     10, %s,     Data Group
+FIELD count(distRun.state) as n, 7, %d, count
+
+MODE  summary
+GROUP label
+GROUP stage
+GROUP state
+GROUP data_group
Index: /branches/sc_branches/ippMonitorLap/def/distTarget.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/distTarget.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/distTarget.d	(revision 31685)
@@ -0,0 +1,13 @@
+TABLE distTarget
+TITLE Distribution Targets
+FILE  distTarget.php
+MENU  ipp.dist.dat
+
+#     field                   size  format  name         show    link to                  extras
+FIELD distTarget.dist_group,  	 5, %s,     Dist Group
+FIELD distTarget.target_id,  	 5, %d,     ID
+FIELD distTarget.filter,  	 5, %s,     Filter
+FIELD distTarget.stage,  	 5, %s,     Stage
+FIELD distTarget.clean,  	 5, %d,     Clean?
+FIELD distTarget.state,  	 5, %s,     State
+FIELD distTarget.comment,  	 5, %s,     Comment
Index: /branches/sc_branches/ippMonitorLap/def/example.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/example.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/example.d	(revision 31685)
@@ -0,0 +1,32 @@
+# this file il
+# master detrend runs which have been accepted
+
+TABLE detRunSummary, detRun
+TITLE Master Detrend Images
+FILE  masterDetrendImages.php
+MENU  ipp.detrend.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+WHERE detRunSummary.accept = 1
+WHERE detRun.det_it = detRunSummary.det_id
+WHERE detRun.iteration = detRunSummary.iteration
+
+ARGS  ARG1 det_id=$detRunSummary.det_id
+ARGS  ARG1 iteration=$detRunSummary.iteration
+
+#     field                    width format  name           show         link to           extras
+FIELD detRunSummary.det_id,    7,    %s,     det_id
+FIELD detRun.det_type,         5,    %s,     type
+FIELD detRunSummary.iteration, 5,    %s,     iter
+FIELD *,                       20,   %s,     choose,       value=input, detInputExp.php,  ARG1
+FIELD *,                       20,   %s,     choose,       value=resid, detResidExp.php,  ARG1
+FIELD detRunSummary.bg,        20,   %s,     bg
+FIELD detRunSummary.bg_stdev,  20,   %s,     bg_stdev
+# FIELD bg_mean_stdev, 20,   bg_mean_stdev
+
+# this file illustrates a simple inner join to generate the output table
+# assuming no other dynamic restrictions are added, this generates the following query:
+# SELECT detRunSummary.det_id,detRunSummary.iteration,detRunSummary.iteration,detRun.det_type,detRunSummary.bg,detRunSummary.bg_stdev \
+# FROM detRunSummary, detRun \
+# WHERE detRunSummary.accept = 1 AND detRun.det_id = detRunSummary.det_id AND detRun.iteration = detRunSummary.iteration \
+# LIMIT 20
Index: /branches/sc_branches/ippMonitorLap/def/exposureStatus.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/exposureStatus.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/exposureStatus.d	(revision 31685)
@@ -0,0 +1,32 @@
+TABLE rawExp LEFT JOIN chipRun using(exp_id) LEFT JOIN camRun using(chip_id) LEFT JOIN fakeRun using(cam_id) LEFT JOIN warpRun using(fake_id) LEFT JOIN diffInputSkyfile AS diffInput ON diffInput.warp1 = warp_id LEFT JOIN diffRun AS diffInputRun ON diffInput.diff_id = diffInputRun.diff_id LEFT JOIN diffInputSkyfile AS diffTemplate ON diffTemplate.warp2 = warp_id LEFT JOIN diffRun AS diffTemplateRun ON diffTemplate.diff_id = diffTemplateRun.diff_id LEFT JOIN distRun ON stage = 'camera' AND distRun.stage_id = cam_id 
+TITLE Exposures Status
+FILE exposureStatus.php
+MENU ipp.imfiles.dat
+
+WHERE object != 'ENGINEERING'
+
+UNRESTRICTED AND dateobs >= CURDATE()
+
+#     field                    width format  name          show         link to                   extras
+FIELD DISTINCT rawExp.exp_id, 1,    %s,    'Dont use for filtering'
+FIELD dateobs, 15,    %T,     Date obs
+FIELD rawExp.exp_id, 5, %d,      Exp ID
+FIELD exp_name, 5,    %s,     Exp Name
+FIELD chipRun.data_group, 5,   %s,     Data grp
+FIELD chip_id, 5,    %d,     Chip ID
+FIELD chipRun.state, 5,    %s,     Chip State
+FIELD cam_id, 5,    %d,     Cam ID
+FIELD camRun.state, 5,    %s,     Cam ID
+FIELD camRun.magicked, 5,    %s,     Cam Magicked
+#FIELD publishRun.pub_id, 5,    %d,     Pub ID
+FIELD distRun.dist_id, 5,    %d,     Dist ID
+FIELD fake_id, 5,    %d,     Fake ID
+FIELD warp_id, 5,    %d,     Warp ID
+FIELD warpRun.state, 5,    %s,     Warp State
+FIELD diffInput.diff_id, 5,    %d,     Diff ID
+FIELD diffInputRun.state, 5,    %s,     Diff State
+FIELD diffTemplate.diff_id, 5,    %d,     Diff Templ ID
+FIELD diffTemplateRun.state, 5,    %s,     Diff Templ State
+FIELD filter, 5,    %s,     Filter
+FIELD object, 25,    %s,     Object
+FIELD comment, 50,    %s,     Comment
Index: /branches/sc_branches/ippMonitorLap/def/failedCamProcessedExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/failedCamProcessedExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/failedCamProcessedExp.d	(revision 31685)
@@ -0,0 +1,39 @@
+TABLE camRun, camProcessedExp, chipRun, rawExp
+TITLE Camera Failed Exposures
+FILE  failedCamProcessedExp.php
+MENU  ipp.science.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+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
+
+# define the arguments supplied to the links below (if any)
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+
+ARGS  ARG4 camRun.cam_id=$camRun.cam_id
+ARGS  ARG4 camera=$rawExp.camera
+ARGS  ARG4 basename=$camProcessedExp.path_base
+
+OP   OP1  ( $camProcessedExp.fault == 2 ? "cam.revert.on and cam.revert.off" : "camtool -revertprocessedexp -fault $camProcessedExp.fault -label $camRun.label -dbname ". $ID['proj'] )
+
+#     field                     	size  format  name          show   	 link to                      extras
+FIELD rawExp.exp_name,     	 	 5,   %s,     Exp Name
+FIELD rawExp.exp_id,	         	 5,   %d,     Exp ID,       value,  	 rawImfile.php,               ARG1
+FIELD chipRun.chip_id,           	 5,   %d,     Chip ID,      value,  	 chipProcessedImfile.php,     ARG2
+FIELD camRun.cam_id,            	 5,   %d,     Cam ID,       value,       camProcessedExp_failure.php, ARG3
+FIELD camRun.state,                      5,   %s,     state,        value,       camProcessedImfile.php,      ARG4
+FIELD camRun.label,                      5,   %s,     label
+FIELD camRun.data_group,                 5,   %s,     data grp
+FIELD camRun.dist_group,                 5,   %s,     dist grp
+FIELD camProcessedExp.fault,		 2,   %d,     Fault
+FIELD *,				 50,  %s,     Command <blink>(Experimental)</blink>, op=OP1
+
+FIELD camProcessedExp.path_base,     	 5,   %s,     path_base,    none
+FIELD rawExp.exp_id,     		 5,   %s,     Exp ID,       none
+
+
+TAIL PHP insert_log ('LOG.IMFILE');
Index: /branches/sc_branches/ippMonitorLap/def/failedChipProcessedImfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/failedChipProcessedImfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/failedChipProcessedImfile.d	(revision 31685)
@@ -0,0 +1,52 @@
+TABLE chipRun, rawExp, chipProcessedImfile
+TITLE Chip Failed Imfiles
+FILE  failedChipProcessedImfile.php
+MENU  ipp.science.dat
+
+# limit this table to non-OBJECT types of images
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE chipProcessedImfile.exp_id = chipRun.exp_id
+WHERE chipProcessedImfile.chip_id = chipRun.chip_id
+WHERE chipProcessedImfile.fault != 0
+
+ARGS  ARG1 rawImfile.exp_id=$rawExp.exp_id
+
+ARGS  ARG2 chipRun.chip_id=$chipRun.chip_id
+
+ARGS  ARG3 chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3 chipProcessedImfile.class_id=$chipProcessedImfile.class_id
+ARGS  ARG3 camera=$rawExp.camera
+ARGS  ARG3 basename=$chipProcessedImfile.path_base
+ARGS  ARG3 class=$chipProcessedImfile.class_id
+
+OP    OP1  ( $chipProcessedImfile.fault == 2 ? "chip.revert.on and chip.revert.off" : "chiptool -revertprocessedimfile -fault $chipProcessedImfile.fault -label $chipRun.label -dbname ". $ID['proj'] )
+
+#     field                            size  format  name         show    link to                          extras
+FIELD rawExp.exp_name,     	   	  5, %s,     Exp Name
+FIELD chipProcessedImfile.class_id,	  8, %s,     Class ID
+FIELD rawExp.exp_id,         	   	  5, %d,     Exp ID,      value,  rawImfile.php,                   ARG1
+FIELD chipRun.chip_id,        	   	  7, %d,     Chip ID,     value,  chipProcessedImfile_failure.php, ARG2
+FIELD chipRun.state,        	   	  7, %s,     State,       value,  chipProcessedImfile_failure.php, ARG3
+FIELD chipRun.label,        	   	  7, %s,     Label
+FIELD chipRun.data_group,        	   	  7, %s,     data grp
+FIELD chipRun.dist_group,        	   	  7, %s,     dist grp
+FIELD chipProcessedImfile.fault,      	  2, %d,     Fault
+FIELD *,				  50, %s,    Command <blink>Experimental</blink>, op=OP1
+
+# FIELD rawExp.telescope,      	   	 10, %s,     Telescope
+# FIELD rawExp.camera,         	   	 10, %s,     Camera
+# FIELD rawExp.dateobs,        	   	 19, %T,     Date/Time
+# FIELD rawExp.ra,           	 	  8, %C, RA,           op=OP1      
+# FIELD rawExp.decl,         	 	  8, %C, DEC,          op=OP2
+# FIELD rawExp.object,       	   	  8, %s,     Object
+# FIELD rawExp.filter,         	   	 10, %s,     FILTER
+# FIELD rawExp.exp_time,       	   	  5, %.2f,   exp_time    
+# FIELD rawExp.airmass,        	   	  5, %.4f,   airmass     
+# FIELD chipProcessedImfile.bg,             5, %.2f,   backgnd
+# FIELD chipProcessedImfile.bg_stdev,       5, %.2f,   stdev    
+# FIELD chipProcessedImfile.n_stars,  	  5, %d,     Nstars
+# FIELD chipProcessedImfile.fwhm_major, 	  5, %.2f,   FHWM
+# FIELD chipProcessedImfile.path_base,      5, %s,     path_base, none
+# FIELD rawExp.comment,  	                 65, %s,     Comment
+
+TAIL PHP insert_log ('LOG.IMFILE');
Index: /branches/sc_branches/ippMonitorLap/def/failedDiffSkyfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/failedDiffSkyfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/failedDiffSkyfile.d	(revision 31685)
@@ -0,0 +1,30 @@
+TABLE diffRun, diffSkyfile
+TITLE Diff Failed Skyfiles
+FILE  failedDiffSkyfile.php
+MENU  ipp.stack.dat
+
+WHERE diffRun.diff_id             = diffSkyfile.diff_id
+WHERE diffSkyfile.fault != 0
+
+ARGS  ARG7 diffSkyfile.diff_id=$diffSkyfile.diff_id
+ARGS  ARG7 diffSkyfile.skycell_id=$diffSkyfile.skycell_id
+ARGS  ARG7 camera=GPC1
+ARGS  ARG7 basename=$diffSkyfile.path_base
+
+OP    OP1  ( $fault == 2 ? "diff.revert.on and diff.revert.off" : "difftool -revertdiffskyfile -fault $diffSkyfile.fault -label $diffRun.label -dbname ". $ID['proj'] )
+
+#     field                         size  format  name           show     link to         extras
+FIELD diffSkyfile.diff_id,             5, %d,     Diff ID
+FIELD diffSkyfile.skycell_id,          5, %s,     Skycell ID
+FIELD diffRun.label,    	       5, %s,     Label
+FIELD diffRun.data_group,    	       5, %s,     data grp
+FIELD diffRun.dist_group,    	       5, %s,     dist grp
+# FIELD diffRun.filter,    	       5, %s,     Filter
+FIELD diffRun.tess_id,    	       5, %s,     Tess ID
+FIELD diffRun.state,    	       7, %s,     State,         value,   diffProcessedSkyfile.php, ARG7
+FIELD diffSkyfile.fault,               5, %d,     Fault
+FIELD *,		 	       50,  %s,   Command <blink>(Experimental)</blink>, op=OP1
+
+FIELD diffSkyfile.path_base,           5, %s,     path_base,     none
+
+TAIL PHP insert_log ('LOG.EXP');
Index: /branches/sc_branches/ippMonitorLap/def/failedFakeProcessedImfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/failedFakeProcessedImfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/failedFakeProcessedImfile.d	(revision 31685)
@@ -0,0 +1,40 @@
+TABLE fakeRun, fakeProcessedImfile, camRun, chipRun, rawExp
+TITLE fake Processed Imfile
+FILE  failedFakeProcessedImfile.php
+MENU  ipp.science.dat
+
+# limit this table to non-OBJECT types of images
+WHERE fakeRun.cam_id = camRun.cam_id
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE fakeProcessedImfile.fake_id = fakeRun.fake_id
+WHERE fakeProcessedImfile.fault != 0
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+ARGS  ARG4  fakeRun.fake_id=$fakeRun.fake_id
+
+ARGS  ARG5 fakeRun.fake_id=fakeRun.fake_id
+ARGS  ARG5 fakeProcessedImfile.class_id=$fakeProcessedImfile.class_id
+ARGS  ARG5 camera=$rawExp.camera
+ARGS  ARG5 basename=$fakeProcessedImfile.path_base
+ARGS  ARG5 class=$fakeProcessedImfile.class_id
+
+OP   OP1    ( $fakeProcessedImfile.fault == 2 ? "fake.revert.on and fake.revert.off" : "faketool -revertprocessedimfile -fault $fakeProcessedImfile.fault -label $fakeRun.label -dbname ". $ID['proj'] )
+
+#     field                         size  format  name         show    link to                  extras
+FIELD rawExp.exp_name,                10, %s,     Exp Name
+FIELD fakeProcessedImfile.class_id,    8, %s,     Class ID
+FIELD rawExp.exp_id,                   5, %d,     Exp ID,       value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,                 7, %d,     Chip ID,      value,  chipProcessedImfile.php, ARG2
+FIELD camRun.cam_id,                   7, %d,     Cam ID,       value,  camProcessedExp.php,     ARG3
+FIELD fakeRun.fake_id,                 7, %d,     Fake ID,      value,  fakeProcessedImfile_failure.php, ARG4
+FIELD fakeRun.state,                   7, %s,     State,       value,  fakeProcessedImfile_failure.php, ARG5
+FIELD fakeRun.label,                   7, %s,     Label
+FIELD fakeProcessedImfile.fault,       2, %d,     Fault
+FIELD *,			       50, %s,	  Command <blink>(Experimental/Not tested)</blink>, op=OP1
+
+FIELD fakeProcessedImfile.path_base,      5, %s,     path_base, none
+
+TAIL PHP insert_log ('LOG.IMFILE');
Index: /branches/sc_branches/ippMonitorLap/def/failedMagicMasks.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/failedMagicMasks.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/failedMagicMasks.d	(revision 31685)
@@ -0,0 +1,21 @@
+TABLE magicRun, magicMask
+TITLE Magic Failed Masks
+FILE  failedMagicMasks.php
+MENU  ipp.stack.dat
+
+WHERE magicRun.magic_id  = magicMask.magic_id
+WHERE magicMask.fault   != 0
+
+OP    OP1  ( $fault == 2 ? "magic.revert.on and magic.revert.off" : "magictool -revertmask -fault $magicMask.fault -label $label -dbname ". $ID['proj'] )
+
+#        field                   size  format  name           show     link to         extras
+FIELD    magicRun.magic_id,	 5,   %d,     Magic ID
+FIELD    magicRun.exp_id,	 5,   %d,     Exp ID
+FIELD    magicRun.diff_id,	 5,   %d,     Diff ID
+FIELD    magicRun.label, 	 5,   %s,     Label
+FIELD    magicRun.data_group, 	 5,   %s,     data grp
+FIELD    magicRun.inverse,	 5,   %d,     Inverse
+FIELD    magicRun.state,	 5,   %s,     State
+FIELD    magicMask.streaks,	 5,   %d,     Streaks
+FIELD    magicMask.fault,	 5,   %d,     Fault
+FIELD	 *,		 	 50,  %s,     Command <blink>(Experimental)</blink>, op=OP1
Index: /branches/sc_branches/ippMonitorLap/def/failedMagicNodes.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/failedMagicNodes.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/failedMagicNodes.d	(revision 31685)
@@ -0,0 +1,24 @@
+TABLE magicRun, magicTree, magicNodeResult
+TITLE Magic Failed Nodes
+FILE  failedMagicNodes.php
+MENU  ipp.stack.dat
+
+WHERE magicRun.magic_id        = magicTree.magic_id
+WHERE magicTree.magic_id       = magicNodeResult.magic_id
+WHERE magicTree.node           = magicNodeResult.node
+WHERE magicNodeResult.fault    != 0
+
+OP    OP1  ( $magicNodeResult.fault == 2 ? "magic.revert.on and magic.revert.off" : "magictool -revertnode -fault $magicNodeResult.fault -label $magicRun.label -dbname ". $ID['proj'] )
+
+#        field                   size  format  name           show     link to         extras
+FIELD    magicRun.magic_id,	 5,   %d,     Magic ID
+FIELD    magicRun.exp_id,	 5,   %d,     Exp ID
+FIELD    magicRun.diff_id,	 5,   %d,     Diff ID
+FIELD    magicRun.label, 	 5,   %s,     Label
+FIELD    magicRun.data_group, 	 5,   %s,     data grp
+FIELD    magicRun.inverse,	 5,   %d,     Inverse
+FIELD    magicRun.state,	 5,   %s,     State
+FIELD    magicTree.node,	 5,   %s,     Node
+FIELD    magicTree.dep,	 	 5,   %s,     Parent
+FIELD    magicNodeResult.fault,	 5,   %d,     Fault
+FIELD	 *,		 	 50,  %s,     Command <blink>(Experimental)</blink>, op=OP1
Index: /branches/sc_branches/ippMonitorLap/def/failedMagicTrees.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/failedMagicTrees.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/failedMagicTrees.d	(revision 31685)
@@ -0,0 +1,19 @@
+TABLE magicRun
+TITLE magic Failed Trees
+FILE  failedMagicTrees.php
+MENU  ipp.stack.dat
+
+WHERE fault != 0
+
+OP    OP1  ( $fault == 2 ? "magic.revert.on and magic.revert.off" : "magictool -reverttree -fault $fault -label $label -dbname ". $ID['proj'] )
+
+#        field          size  format  name           show     link to         extras
+FIELD    magic_id,	 5,   %d,     Magic ID
+FIELD    exp_id,	 5,   %d,     Exp ID
+FIELD    diff_id,	 5,   %d,     Diff ID
+FIELD    label,	 	 5,   %s,     Label
+FIELD    data_group, 	 5,   %s,     Data Grp
+FIELD    inverse,	 5,   %d,     Inverse
+FIELD    state,		 5,   %s,     State
+FIELD    fault,		 5,   %d,     Fault
+FIELD	 *,		 50,  %s,     Command <blink>(Experimental)</blink>, op=OP1
Index: /branches/sc_branches/ippMonitorLap/def/failedStackSkyfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/failedStackSkyfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/failedStackSkyfile.d	(revision 31685)
@@ -0,0 +1,31 @@
+TABLE stackRun, stackSumSkyfile
+TITLE Stack Failed Skyfiles
+FILE  failedStackSkyfile.php
+MENU  ipp.stack.dat
+
+WHERE stackRun.stack_id = stackSumSkyfile.stack_id
+WHERE stackSumSkyfile.fault != 0
+
+ARGS  ARG7 stackRun.stack_id=$stackRun.stack_id
+ARGS  ARG7 stackRun.skycell_id=$stackRun.skycell_id
+ARGS  ARG7 camera=GPC1
+ARGS  ARG7 basename=$stackSumSkyfile.path_base
+
+OP    OP1  ( $stackSumSkyfile.fault == 2 ? "stack.revert.on and stack.revert.off" : "stacktool -revertsumskyfile -fault $stackSumSkyfile.fault -label $stackRun.label -dbname ". $ID['proj'] )
+
+#        field                          size  format  name    show     link to         extras
+FIELD stackRun.stack_id,            5, %s,     Stack ID
+FIELD stackRun.skycell_id,          5, %s,     Skycell ID
+FIELD stackRun.label,    	    5, %s,     Label
+FIELD stackRun.data_group,    	    5, %s,     data grp
+FIELD stackRun.dist_group,    	    5, %s,     dist grp
+FIELD stackRun.filter,    	    5, %s,     Filter
+FIELD stackRun.tess_id,    	    5, %s,     Tess ID
+FIELD stackRun.state,    	    7, %s,     State,         value,   stackFailedSkyfile.php, ARG7
+FIELD stackSumSkyfile.fault,	    2, %d,     Fault
+
+FIELD *,        50, %s, Command you should try to run as the ipp user? <blink>(Experimental feature)</blink>, op=OP1
+
+FIELD stackSumSkyfile.path_base,    5, %s,     path_base,     none
+
+TAIL PHP insert_log ('LOG.EXP');
Index: /branches/sc_branches/ippMonitorLap/def/failedWarpSkyfiles.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/failedWarpSkyfiles.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/failedWarpSkyfiles.d	(revision 31685)
@@ -0,0 +1,42 @@
+TABLE warpSkyfile, warpRun, fakeRun, camRun, chipRun, rawExp
+TITLE Warp Failed Skyfiles
+FILE  failedWarpSkyfiles.php
+MENU  ipp.science.dat
+
+WHERE warpSkyfile.warp_id = warpRun.warp_id
+WHERE warpRun.fake_id = fakeRun.fake_id
+WHERE fakeRun.cam_id = camRun.cam_id
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE warpSkyfile.fault != 0
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+ARGS  ARG4  fakeRun.fake_id=$fakeRun.fake_id
+ARGS  ARG5  warpRun.warp_id=$warpRun.warp_id
+ARGS  ARG6  warpSkyfile.skycell_id=$warpSkyfile.skycell_id
+
+ARGS  ARG7 warpRun.warp_id=$warpRun.warp_id
+ARGS  ARG7 warpSkyfile.skycell_id=$warpSkyfile.skycell_id
+ARGS  ARG7 camera=$rawExp.camera
+ARGS  ARG7 basename=$warpSkyfile.path_base
+
+OP   OP1    ( $warpSkyfile.fault == 2 ? "warp.revert.on and warp.revert.off" : "warptool -revertwarped -fault $warpSkyfile.fault -label $warpRun.label -dbname ". $ID['proj'] )
+
+#     field                    size  format  name         show    link to         extras
+FIELD rawExp.exp_name,     	  5, %s,     Exp Name
+FIELD rawExp.exp_id,     	  5, %d,     Exp ID,       value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,    	  7, %d,     Chip ID,      value,  chipProcessedImfile.php, ARG2
+FIELD camRun.cam_id,    	  7, %d,     Cam ID,       value,  camProcessedExp.php,     ARG3
+FIELD fakeRun.fake_id,    	  7, %d,     Fake ID,      value,  fakeProcessedImfile.php, ARG4
+FIELD warpRun.warp_id,    	  7, %d,     Warp ID,      value,  warpStageExp.php,        ARG5
+FIELD warpSkyfile.skycell_id, 	 10, %s,     Skycell ID,      value,  warpFailedSkyfiles.php,  ARG6
+FIELD warpRun.state,    	  7, %s,     State,        value,  warpFailedSkyfiles.php,  ARG7
+FIELD warpRun.label,    	  7, %s,     Label
+FIELD warpSkyfile.fault,      	  2, %d,     Fault
+FIELD *,			  50, %s,    Command <blink>(Experimental)</blink>, op=OP1
+
+FIELD warpSkyfile.path_base,      5, %s,     path_base,   none
+
+TAIL PHP insert_log ('LOG.EXP');
Index: /branches/sc_branches/ippMonitorLap/def/fakePendingExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/fakePendingExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/fakePendingExp.d	(revision 31685)
@@ -0,0 +1,45 @@
+TABLE fakeRun, camRun, chipRun, rawExp
+TITLE fake Pending Exposures
+FILE  fakePendingExp.php
+MENU  ipp.science.dat
+
+# limit this table to non-OBJECT types of images
+WHERE fakeRun.state = 'new'
+WHERE fakeRun.cam_id = camRun.cam_id
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+ARGS  ARG4  fakeRun.fake_id=$fakeRun.fake_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                   size  format  name         show    link to         extras
+FIELD rawExp.exp_name,     	10, %s,     Exp Name
+FIELD rawExp.exp_id,     	 5, %d,     Exp ID,       value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,    	 7, %d,     Chip ID,      value,  chipProcessedImfile.php, ARG2
+FIELD camRun.cam_id,    	 7, %d,     Cam ID,       value,  camProcessedExp.php,     ARG3
+FIELD fakeRun.fake_id,    	 7, %d,     Fake ID,      value,  fakeProcessedImfile.php, ARG4
+FIELD fakeRun.state,    	 7, %s,     state
+FIELD fakeRun.label,    	 7, %s,     label
+FIELD fakeRun.data_group,    	 7, %s,     data grp
+FIELD fakeRun.dist_group,    	 7, %s,     dist grp
+FIELD rawExp.telescope,      	10, %s,     Telescope
+FIELD rawExp.camera,         	10, %s,     Camera
+FIELD rawExp.dateobs,        	19, %T,     Date/Time
+FIELD rawExp.ra,       	         8, %C, RA,          op=OP1    
+FIELD rawExp.decl,       	 8, %C, DEC,         op=OP2
+FIELD rawExp.object,         	 8, %s,     Object
+FIELD rawExp.filter,         	10, %s,     FILTER
+FIELD rawExp.exp_time,       	 5, %.2f,   exp_time    
+FIELD rawExp.airmass,        	 5, %.4f,   airmass     
+FIELD rawExp.bg,             	 5, %.2f,   backgnd
+FIELD rawExp.bg_stdev,       	 5, %.2f,   stdev    
+FIELD rawExp.comment,  	        65, %s,     Comment
+
+# FIELD rawExp.bg_mean_stdev,  	 5, %7.2f,  &lt;backgnd&gt;
+# FIELD chipPendingExp.reduction,    20,   reduction
+# FIELD chipPendingExp.guide_id,     20, guide ID
Index: /branches/sc_branches/ippMonitorLap/def/fakePendingImfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/fakePendingImfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/fakePendingImfile.d	(revision 31685)
@@ -0,0 +1,44 @@
+TABLE fakeRun, camRun, chipRun, rawExp, rawImfile
+TITLE Fake Pending Imfiles
+FILE  fakePendingImfile.php
+MENU  ipp.science.dat
+
+WHERE fakeRun.state = 'new'
+WHERE fakeRun.cam_id = camRun.cam_id
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE rawImfile.exp_id = rawExp.exp_id
+
+ARGS  ARG1 rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2 chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3 camRun.cam_id=$camRun.cam_id
+ARGS  ARG3 fakeRun.fake_id=$fakeRun.fake_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                   size  format  name         show    link to         extras
+FIELD rawExp.exp_name,     	10, %s,     Exp Name
+FIELD rawImfile.class_id,     	 8, %s,     Class ID
+FIELD rawExp.exp_id,     	 5, %d,     Exp ID,      value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,    	 7, %d,     Chip ID,     value,  chipProcessedImfile.php, ARG2
+FIELD camRun.cam_id,          	 5, %d,     Cam ID,      value,   camProcessedExp.php,     ARG3
+FIELD fakeRun.fake_id,        	 5, %d,     Fake ID,     value,  fakeProcessedImfile.php, ARG4
+FIELD fakeRun.state,    	 7, %s,     State
+FIELD fakeRun.label,    	 7, %s,     label
+FIELD fakeRun.data_group,    	 7, %s,     data grp
+FIELD fakeRun.dist_group,    	 7, %s,     dist grp
+FIELD rawExp.telescope,      	10, %s,     Telescope
+FIELD rawExp.camera,         	10, %s,     Camera
+FIELD rawExp.dateobs,        	19, %T,     Date/Time
+FIELD rawExp.ra,       	         8, %C, RA,          op=OP1    
+FIELD rawExp.decl,       	 8, %C, DEC,         op=OP2
+FIELD rawExp.object,         	 8, %s,     Object
+FIELD rawExp.filter,         	10, %s,     FILTER
+FIELD rawExp.exp_time,       	 5, %.2f,   exp_time    
+FIELD rawExp.airmass,        	 5, %.4f,   airmass     
+FIELD rawExp.bg,             	 5, %.2f,   backgnd
+FIELD rawExp.bg_stdev,       	 5, %.2f,   stdev    
+FIELD *,                         5, %d,     Nstars,      value=0
+FIELD *, 	                 5, %.2f,   FHWM,        value=0.0
+FIELD rawExp.comment,  	        65, %s,     Comment
Index: /branches/sc_branches/ippMonitorLap/def/fakeProcessedExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/fakeProcessedExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/fakeProcessedExp.d	(revision 31685)
@@ -0,0 +1,46 @@
+TABLE fakeRun, camRun, chipRun, rawExp
+TITLE fake Processed Exposures
+FILE  fakeProcessedExp.php
+MENU  ipp.science.dat
+
+# limit this table to non-OBJECT types of images
+WHERE fakeRun.state != 'new'
+WHERE fakeRun.cam_id = camRun.cam_id
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+ARGS  ARG4  fakeRun.fake_id=$fakeRun.fake_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                   size  format  name         show    link to                  extras
+FIELD rawExp.exp_name,     	10, %s,     Exp Name
+FIELD rawExp.exp_id,     	 5, %d,     Exp ID,       value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,    	 7, %d,     Chip ID,      value,  chipProcessedImfile.php, ARG2
+FIELD camRun.cam_id,    	 7, %d,     Cam ID,       value,  camProcessedExp.php,     ARG3
+FIELD fakeRun.fake_id,    	 7, %d,     Fake ID,      value,  fakeProcessedImfile.php, ARG4
+FIELD fakeRun.state,    	 7, %s,     state
+FIELD fakeRun.label,    	 7, %s,     label
+FIELD fakeRun.data_group,    	 7, %s,     data grp
+FIELD fakeRun.dist_group,    	 7, %s,     dist grp
+FIELD rawExp.telescope,      	10, %s,     Telescope
+FIELD rawExp.camera,         	10, %s,     Camera
+FIELD rawExp.dateobs,        	19, %T,     Date/Time
+FIELD rawExp.ra,           	 8, %C, RA,           op=OP1      
+FIELD rawExp.decl,         	 8, %C, DEC,          op=OP2
+FIELD rawExp.object,         	 8, %s,     Object
+FIELD rawExp.filter,         	10, %s,     FILTER
+FIELD rawExp.exp_time,       	 5, %.2f,     exp_time    
+FIELD rawExp.airmass,        	 5, %.4f,     airmass     
+FIELD rawExp.bg,             	 5, %.2f,     backgnd
+FIELD rawExp.bg_stdev,       	 5, %.2f,     stdev    
+FIELD rawExp.comment,  	        65, %s,     Comment
+
+# FIELD rawExp.bg_mean_stdev,  	 5, %s,     &lt;backgnd&gt;
+# FIELD rawExp.sat_pixel_frac, 	 5, %s,     f(sat pixels)
+# FIELD chipPendingExp.reduction,    20,   reduction
+# FIELD chipPendingExp.guide_id,     20, guide ID
Index: /branches/sc_branches/ippMonitorLap/def/fakeProcessedImfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/fakeProcessedImfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/fakeProcessedImfile.d	(revision 31685)
@@ -0,0 +1,56 @@
+TABLE fakeRun, fakeProcessedImfile, camRun, chipRun, rawExp
+TITLE fake Processed Imfile
+FILE  fakeProcessedImfile.php
+MENU  ipp.science.dat
+
+# limit this table to non-OBJECT types of images
+WHERE fakeRun.cam_id = camRun.cam_id
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE fakeProcessedImfile.fake_id = fakeRun.fake_id
+WHERE fakeProcessedImfile.fault = 0
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+ARGS  ARG4  fakeRun.fake_id=$fakeRun.fake_id
+
+ARGS  ARG5 fakeRun.fake_id=fakeRun.fake_id
+ARGS  ARG5 fakeProcessedImfile.class_id=$fakeProcessedImfile.class_id
+ARGS  ARG5 camera=$rawExp.camera
+ARGS  ARG5 basename=$fakeProcessedImfile.path_base
+ARGS  ARG5 class=$fakeProcessedImfile.class_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                         size  format  name         show    link to                  extras
+FIELD rawExp.exp_name,                10, %s,     Exp Name
+FIELD fakeProcessedImfile.class_id,    8, %s,     Class ID
+FIELD rawExp.exp_id,                   5, %d,     Exp ID,       value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,                 7, %d,     Chip ID,      value,  chipProcessedImfile.php, ARG2
+FIELD camRun.cam_id,                   7, %d,     Cam ID,       value,  camProcessedExp.php,     ARG3
+FIELD fakeRun.fake_id,                 7, %d,     Fake ID,      value,  fakeProcessedImfile.php, ARG4
+FIELD fakeRun.state,                   7, %s,     State,       value,  fakeProcessedImfile.php, ARG5
+FIELD fakeRun.label,                   7, %s,     Label
+FIELD fakeRun.data_group,                   7, %s,     data grp
+FIELD fakeRun.dist_group,                   7, %s,     dist grp
+FIELD rawExp.telescope,               10, %s,     Telescope
+FIELD rawExp.camera,                  10, %s,     Camera
+FIELD rawExp.dateobs,                 19, %T,     Date/Time
+FIELD rawExp.ra,                       8, %C, RA,           op=OP1      
+FIELD rawExp.decl,                     8, %C, DEC,          op=OP2
+FIELD rawExp.object,                   8, %s,     Object
+FIELD rawExp.filter,                  10, %s,     FILTER
+FIELD rawExp.exp_time,                 5, %.2f,   exp_time    
+FIELD rawExp.airmass,                  5, %.4f,   airmass     
+FIELD rawExp.comment,                 65, %s,     Comment
+
+FIELD fakeProcessedImfile.path_base,      5, %s,     path_base, none
+
+TAIL PHP insert_log ('LOG.IMFILE');
+
+# FIELD chipProcessedImfile.bg,          5, %.2f,   backgnd
+# FIELD chipProcessedImfile.bg_stdev,    5, %.2f,   stdev    
+# FIELD chipProcessedImfile.n_stars,     5, %d,     Nstars
+# FIELD chipProcessedImfile.fwhm_major,  5, %.2f,   FHWM
Index: /branches/sc_branches/ippMonitorLap/def/fakeProcessedImfile_failure.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/fakeProcessedImfile_failure.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/fakeProcessedImfile_failure.d	(revision 31685)
@@ -0,0 +1,56 @@
+TABLE fakeRun, fakeProcessedImfile, camRun, chipRun, rawExp
+TITLE fake Processed Imfile
+FILE  fakeProcessedImfile_failure.php
+MENU  ipp.science.dat
+
+# limit this table to non-OBJECT types of images
+WHERE fakeRun.cam_id = camRun.cam_id
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE fakeProcessedImfile.fake_id = fakeRun.fake_id
+WHERE fakeProcessedImfile.fault != 0
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+ARGS  ARG4  fakeRun.fake_id=$fakeRun.fake_id
+
+ARGS  ARG5 fakeRun.fake_id=fakeRun.fake_id
+ARGS  ARG5 fakeProcessedImfile.class_id=$fakeProcessedImfile.class_id
+ARGS  ARG5 camera=$rawExp.camera
+ARGS  ARG5 basename=$fakeProcessedImfile.path_base
+ARGS  ARG5 class=$fakeProcessedImfile.class_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                         size  format  name         show    link to                  extras
+FIELD rawExp.exp_name,                10, %s,     Exp Name
+FIELD fakeProcessedImfile.class_id,    8, %s,     Class ID
+FIELD rawExp.exp_id,                   5, %d,     Exp ID,       value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,                 7, %d,     Chip ID,      value,  chipProcessedImfile.php, ARG2
+FIELD camRun.cam_id,                   7, %d,     Cam ID,       value,  camProcessedExp.php,     ARG3
+FIELD fakeRun.fake_id,                 7, %d,     Fake ID,      value,  fakeProcessedImfile_failure.php, ARG4
+FIELD fakeRun.state,                   7, %s,     State,       value,  fakeProcessedImfile_failure.php, ARG5
+FIELD fakeRun.label,                   7, %s,     Label
+FIELD fakeRun.data_group,                   7, %s,     data grp
+FIELD fakeRun.dist_group,                   7, %s,     dist grp
+FIELD rawExp.telescope,               10, %s,     Telescope
+FIELD rawExp.camera,                  10, %s,     Camera
+FIELD rawExp.dateobs,                 19, %T,     Date/Time
+FIELD rawExp.ra,                       8, %C, RA,           op=OP1      
+FIELD rawExp.decl,                     8, %C, DEC,          op=OP2
+FIELD rawExp.object,                   8, %s,     Object
+FIELD rawExp.filter,                  10, %s,     FILTER
+FIELD rawExp.exp_time,                 5, %.2f,   exp_time    
+FIELD rawExp.airmass,                  5, %.4f,   airmass     
+FIELD rawExp.comment,                 65, %s,     Comment
+
+FIELD fakeProcessedImfile.path_base,      5, %s,     path_base, none
+
+TAIL PHP insert_log ('LOG.IMFILE');
+
+# FIELD chipProcessedImfile.bg,          5, %.2f,   backgnd
+# FIELD chipProcessedImfile.bg_stdev,    5, %.2f,   stdev    
+# FIELD chipProcessedImfile.n_stars,     5, %d,     Nstars
+# FIELD chipProcessedImfile.fwhm_major,  5, %.2f,   FHWM
Index: /branches/sc_branches/ippMonitorLap/def/fakeStageExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/fakeStageExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/fakeStageExp.d	(revision 31685)
@@ -0,0 +1,43 @@
+TABLE fakeRun, camRun, chipRun, rawExp
+TITLE Fake Stage Exposures
+FILE  fakeStageExp.php
+MENU  ipp.science.dat
+
+WHERE fakeRun.cam_id = camRun.cam_id
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+ARGS  ARG4  fakeRun.fake_id=$fakeRun.fake_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                   size  format  name         show    link to         extras
+FIELD rawExp.exp_name,     	10, %s,     Exp Name
+FIELD rawExp.exp_id,     	 5, %d,     Exp ID,       value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,    	 7, %d,     Chip ID,      value,  chipProcessedImfile.php, ARG2
+FIELD camRun.cam_id,    	 7, %d,     Cam ID,       value,  camProcessedExp.php,     ARG3
+FIELD fakeRun.fake_id,    	 7, %d,     Fake ID,      value,  fakeProcessedImfile.php, ARG4
+FIELD fakeRun.state,    	 7, %s,     state
+FIELD fakeRun.label,    	 7, %s,     label
+FIELD fakeRun.data_group,    	 7, %s,     data grp
+FIELD fakeRun.dist_group,    	 7, %s,     dist grp
+FIELD rawExp.telescope,      	10, %s,     Telescope
+FIELD rawExp.camera,         	10, %s,     Camera
+FIELD rawExp.dateobs,        	19, %T,     Date/Time
+FIELD rawExp.ra,       	         8, %C, RA,          op=OP1    
+FIELD rawExp.decl,       	 8, %C, DEC,         op=OP2
+FIELD rawExp.object,         	 8, %s,     Object
+FIELD rawExp.filter,         	10, %s,     FILTER
+FIELD rawExp.exp_time,       	 5, %.2f,   exp_time    
+FIELD rawExp.airmass,        	 5, %.4f,   airmass     
+FIELD rawExp.bg,             	 5, %.2f,   backgnd
+FIELD rawExp.bg_stdev,       	 5, %.2f,   stdev    
+FIELD rawExp.comment,  	        65, %s,     Comment
+
+# FIELD rawExp.bg_mean_stdev,  	 5, %7.2f,  &lt;backgnd&gt;
+# FIELD chipPendingExp.reduction,    20,   reduction
+# FIELD chipPendingExp.guide_id,     20, guide ID
Index: /branches/sc_branches/ippMonitorLap/def/fakeSummary.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/fakeSummary.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/fakeSummary.d	(revision 31685)
@@ -0,0 +1,19 @@
+TABLE fakeRun
+TITLE Fake Summary
+FILE  fakeSummary.php
+MENU  ipp.science.dat
+
+#     field           size  format  name         show    link to         extras
+FIELD label,    	 15, %s,     label
+FIELD data_group, 	 10, %s,     data_group
+FIELD workdir,    	 7, %s,     workdir
+FIELD tess_id,    	 7, %s,     tess_id
+FIELD state,    	 7, %s,     state
+FIELD count(state) as n, 7, %d,     count
+
+MODE  summary
+GROUP state
+GROUP label
+GROUP workdir
+GROUP data_group
+GROUP tess_id
Index: /branches/sc_branches/ippMonitorLap/def/flatcorrCamera.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/flatcorrCamera.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/flatcorrCamera.d	(revision 31685)
@@ -0,0 +1,35 @@
+TABLE flatcorrCamLink, flatcorrRun, camRun, chipRun, rawExp
+TITLE flatcorr Camera Runs
+FILE  flatcorrCamera.php
+MENU  ipp.detrend.dat
+
+WHERE flatcorrRun.corr_id = flatcorrCamLink.corr_id
+WHERE flatcorrCamLink.cam_id = camRun.cam_id
+WHERE flatcorrCamLink.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                   size  format  name         show    link to                  extras
+FIELD flatcorrRun.corr_id,     	 5, %s,     Corr ID
+FIELD rawExp.exp_name,     	 5, %s,     Exp Name
+FIELD rawExp.exp_id,     	 5, %d,     Exp ID,      value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,    	 7, %d,     Chip ID,     value,  chipProcessedImfile.php, ARG2
+FIELD camRun.state,    	         7, %s,     State
+FIELD chipRun.label,    	 7, %s,     Label
+FIELD chipRun.data_group,    	 7, %s,     data grp
+FIELD chipRun.dist_group,    	 7, %s,     dist grp
+FIELD rawExp.telescope,      	10, %s,     Telescope
+FIELD rawExp.camera,         	10, %s,     Camera
+FIELD rawExp.dateobs,        	19, %T,     Date/Time
+FIELD rawExp.ra,           	 8, %C, RA,           op=OP1      
+FIELD rawExp.decl,         	 8, %C, DEC,          op=OP2
+FIELD rawExp.object,         	 8, %s,     Object
+FIELD flatcorrRun.filter,     	10, %s,     FILTER
+FIELD rawExp.filter,         	10, %s,     FILTER
+FIELD rawExp.exp_time,       	 5, %.2f,     exp_time    
+FIELD rawExp.airmass,        	 5, %.4f,     airmass     
+FIELD rawExp.bg,             	 5, %.2f,     backgnd
+FIELD rawExp.bg_stdev,       	 5, %.2f,     stdev    
+FIELD rawExp.comment,  	        75, %s,     Comment
Index: /branches/sc_branches/ippMonitorLap/def/flatcorrChip.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/flatcorrChip.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/flatcorrChip.d	(revision 31685)
@@ -0,0 +1,34 @@
+TABLE flatcorrChipLink, flatcorrRun, chipRun, rawExp
+TITLE flatcorr Chip Runs
+FILE  flatcorrChip.php
+MENU  ipp.detrend.dat
+
+WHERE flatcorrRun.corr_id = flatcorrChipLink.corr_id
+WHERE flatcorrChipLink.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                   size  format  name         show    link to                  extras
+FIELD flatcorrRun.corr_id,     	 5, %s,     Corr ID
+FIELD rawExp.exp_name,     	 5, %s,     Exp Name
+FIELD rawExp.exp_id,     	 5, %d,     Exp ID,      value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,    	 7, %d,     Chip ID,     value,  chipProcessedImfile.php, ARG2
+FIELD chipRun.state,    	 7, %s,     State
+FIELD chipRun.label,    	 7, %s,     Label
+FIELD chipRun.data_group,    	 7, %s,     data grp
+FIELD chipRun.dist_group,    	 7, %s,     dist grp
+FIELD rawExp.telescope,      	10, %s,     Telescope
+FIELD rawExp.camera,         	10, %s,     Camera
+FIELD rawExp.dateobs,        	19, %T,     Date/Time
+FIELD rawExp.ra,           	 8, %C, RA,           op=OP1      
+FIELD rawExp.decl,         	 8, %C, DEC,          op=OP2
+FIELD rawExp.object,         	 8, %s,     Object
+FIELD flatcorrRun.filter,     	10, %s,     FILTER
+FIELD rawExp.filter,         	10, %s,     FILTER
+FIELD rawExp.exp_time,       	 5, %.2f,     exp_time    
+FIELD rawExp.airmass,        	 5, %.4f,     airmass     
+FIELD rawExp.bg,             	 5, %.2f,     backgnd
+FIELD rawExp.bg_stdev,       	 5, %.2f,     stdev    
+FIELD rawExp.comment,  	        75, %s,     Comment
Index: /branches/sc_branches/ippMonitorLap/def/flatcorrExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/flatcorrExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/flatcorrExp.d	(revision 31685)
@@ -0,0 +1,8 @@
+TABLE flatcorrExp
+TITLE flatcorrExp
+FILE  flatcorrExp.php
+MENU  ipp.detrend.dat
+
+#        field        size  format  name           show     link to         extras
+FIELD    corr_id,	20, %s,     correction ID
+FIELD    chip_id,	20, %s,     chip ID
Index: /branches/sc_branches/ippMonitorLap/def/flatcorrRun.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/flatcorrRun.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/flatcorrRun.d	(revision 31685)
@@ -0,0 +1,14 @@
+TABLE flatcorrRun
+TITLE flatcorrRun
+FILE  flatcorrRun.php
+MENU  ipp.detrend.dat
+
+#        field        size  format  name           show     link to         extras
+FIELD    corr_id,	 5, %d,     corr ID
+FIELD    label,	         8, %s,     label
+FIELD    filter,	 5, %s,     filter
+FIELD    state,	         5, %s,     state
+FIELD    det_type,       10, %s,    det_type
+FIELD    region,        10, %s,     region
+FIELD    dvodb,		10, %s,     dvodb
+FIELD    workdir,       10, %s,     workdir
Index: /branches/sc_branches/ippMonitorLap/def/gpc1MysqlProcessList.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/gpc1MysqlProcessList.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/gpc1MysqlProcessList.d	(revision 31685)
@@ -0,0 +1,13 @@
+TABLE INFORMATION_SCHEMA.PROCESSLIST
+TITLE GPC 1 MySql Process List
+FILE gpc1MysqlProcessList.php
+MENU ipp.imfiles.dat
+
+FIELD ID,   5,  %d, Process ID
+FIELD USER, 10, %s, User
+FIELD HOST, 30, %s, Host:port
+FIELD DB,   10, %s, Database
+FIELD TIME, 10, %s, Time
+FIELD STATE, 10, %s, State
+FIELD INFO, 40, %s, Info
+FIELD TIME_MS, 10, %s, Time (ms)
Index: /branches/sc_branches/ippMonitorLap/def/guidePendingExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/guidePendingExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/guidePendingExp.d	(revision 31685)
@@ -0,0 +1,12 @@
+TABLE guidePendingExp
+TITLE guidePendingExp
+FILE  guidePendingExp.php
+MENU  ipp.science.dat
+
+ARGS  ARG1  exp_id=$exp_id
+
+#     field          size format  name       show     link to         extras
+FIELD exp_id,        5,   %s,     Exp ID,    value,   rawImfile.php,  ARG1
+FIELD exp_name,      5,   %s,     Exp Name,  value,   rawImfile.php,  ARG1
+FIELD recipe,	     5,   %s,     recipe
+FIELD guide_version, 5,   %s,     guide version
Index: /branches/sc_branches/ippMonitorLap/def/histogramBackgroundImage.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/histogramBackgroundImage.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/histogramBackgroundImage.d	(revision 31685)
@@ -0,0 +1,31 @@
+TABLE camRun, chipRun, rawExp, camProcessedExp
+TITLE New histogram background
+FILE  histogramBackgroundImage.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 rawExp.bg
+PLOTTER plotHistogram.php
+PLOTTITLE Background values
Index: /branches/sc_branches/ippMonitorLap/def/histogramCamProcessedExpImage.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/histogramCamProcessedExpImage.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/histogramCamProcessedExpImage.d	(revision 31685)
@@ -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: /branches/sc_branches/ippMonitorLap/def/histogramChipProcessedImfileFwhmMajorImage.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/histogramChipProcessedImfileFwhmMajorImage.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/histogramChipProcessedImfileFwhmMajorImage.d	(revision 31685)
@@ -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: /branches/sc_branches/ippMonitorLap/def/histogramChipRunFwhmMajorImage.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/histogramChipRunFwhmMajorImage.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/histogramChipRunFwhmMajorImage.d	(revision 31685)
@@ -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: /branches/sc_branches/ippMonitorLap/def/histogramFwhmMajorImage.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/histogramFwhmMajorImage.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/histogramFwhmMajorImage.d	(revision 31685)
@@ -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: /branches/sc_branches/ippMonitorLap/def/histogramFwhmMinorImage.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/histogramFwhmMinorImage.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/histogramFwhmMinorImage.d	(revision 31685)
@@ -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: /branches/sc_branches/ippMonitorLap/def/histogramZptObsImage.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/histogramZptObsImage.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/histogramZptObsImage.d	(revision 31685)
@@ -0,0 +1,31 @@
+TABLE camRun, chipRun, rawExp, camProcessedExp
+TITLE Histogram of ZptObs
+FILE  histogramZptObsImage.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.zpt_obs
+PLOTTER plotHistogram.php
+PLOTTITLE ZptObs
Index: /branches/sc_branches/ippMonitorLap/def/keptDetrendFrames.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/keptDetrendFrames.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/keptDetrendFrames.d	(revision 31685)
@@ -0,0 +1,42 @@
+# this file is based on the detRunSummary.d file: it uses the same tables restricted to the 
+# master detrend runs which have been accepted
+
+TABLE detRunSummary, detRun
+TITLE Kept Detrend Frames
+FILE  masterDetrendFrames.php
+MENU  ipp.detrend.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+WHERE detRunSummary.accept = 1
+WHERE detRun.state = 'stop'
+WHERE detRun.det_id = detRunSummary.det_id
+WHERE detRun.iteration = detRunSummary.iteration
+
+ARGS  ARG1 detRunSummary.det_id=$detRunSummary.det_id
+
+ARGS  ARG2 detInputExp.det_id=$detRunSummary.det_id
+ARGS  ARG2 detInputExp.iteration=$detRunSummary.iteration
+
+ARGS  ARG3 detProcessedExp.det_id=$detRunSummary.det_id
+
+ARGS  ARG4 detResidExp.det_id=$detRunSummary.det_id
+ARGS  ARG4 detResidExp.iteration=$detRunSummary.iteration
+
+#     field                    width format  name          show         link to                   extras
+FIELD detRunSummary.det_id,    5,    %s,     det ID,       value,       detRunSummary.php,        ARG1
+FIELD detRunSummary.iteration, 3,    %s,     iter
+FIELD detRun.det_type,         5,    %s,     type
+FIELD detRun.state,            5,    %s,     state
+FIELD *,                       20,   %s,     choose,       value=input, detInputExp.php,          ARG2
+FIELD *,                       20,   %s,     choose,       value=proc,  detProcessedExp.php,      ARG3
+FIELD *,                       20,   %s,     choose,       value=resid, detResidExp.php,          ARG4
+FIELD detRunSummary.bg,        20,   %s,     bg
+FIELD detRunSummary.bg_stdev,  20,   %s,     bg_stdev
+# FIELD bg_mean_stdev, 20,   bg_mean_stdev
+
+# this file illustrates a simple inner join to generate the output table
+# assuming no other dynamic restrictions are added, this generates the following query:
+# SELECT detRunSummary.det_id,detRunSummary.iteration,detRunSummary.iteration,detRun.det_type,detRunSummary.bg,detRunSummary.bg_stdev \
+# FROM detRunSummary, detRun \
+# WHERE detRunSummary.accept = 1 AND detRun.det_id = detRunSummary.det_id AND detRun.iteration = detRunSummary.iteration \
+# LIMIT 20
Index: /branches/sc_branches/ippMonitorLap/def/magicFailedMasks.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/magicFailedMasks.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/magicFailedMasks.d	(revision 31685)
@@ -0,0 +1,18 @@
+TABLE magicRun, magicMask
+TITLE Magic Failed Masks
+FILE  magicFailedMasks.php
+MENU  ipp.stack.dat
+
+WHERE magicRun.magic_id  = magicMask.magic_id
+WHERE magicMask.fault   != 0
+
+#        field                   size  format  name           show     link to         extras
+FIELD    magicRun.magic_id,	 5,   %d,     Magic ID
+FIELD    magicRun.exp_id,	 5,   %d,     Exp ID
+FIELD    magicRun.diff_id,	 5,   %d,     Diff ID
+FIELD    magicRun.label, 	 5,   %s,     Label
+FIELD    magicRun.data_group, 	 5,   %s,     data grp
+FIELD    magicRun.inverse,	 5,   %d,     Inverse
+FIELD    magicRun.state,	 5,   %s,     State
+FIELD    magicMask.streaks,	 5,   %d,     Fault
+FIELD    magicMask.fault,	 5,   %d,     Fault
Index: /branches/sc_branches/ippMonitorLap/def/magicFailedNodes.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/magicFailedNodes.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/magicFailedNodes.d	(revision 31685)
@@ -0,0 +1,21 @@
+TABLE magicRun, magicTree, magicNodeResult
+TITLE Magic Failed Nodes
+FILE  magicFailedNodes.php
+MENU  ipp.stack.dat
+
+WHERE magicRun.magic_id        = magicTree.magic_id
+WHERE magicTree.magic_id       = magicNodeResult.magic_id
+WHERE magicTree.node           = magicNodeResult.node
+WHERE magicNodeResult.fault   != 0
+
+#        field                   size  format  name           show     link to         extras
+FIELD    magicRun.magic_id,	 5,   %d,     Magic ID
+FIELD    magicRun.exp_id,	 5,   %d,     Exp ID
+FIELD    magicRun.diff_id,	 5,   %d,     Diff ID
+FIELD    magicRun.label, 	 5,   %s,     Label
+FIELD    magicRun.data_group, 	 5,   %s,     data grp
+FIELD    magicRun.inverse,	 5,   %d,     Inverse
+FIELD    magicRun.state,	 5,   %s,     State
+FIELD    magicTree.node,	 5,   %s,     Node
+FIELD    magicTree.dep,	 	 5,   %s,     Parent
+FIELD    magicNodeResult.fault,	 5,   %d,     Fault
Index: /branches/sc_branches/ippMonitorLap/def/magicFailedTrees.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/magicFailedTrees.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/magicFailedTrees.d	(revision 31685)
@@ -0,0 +1,16 @@
+TABLE magicRun
+TITLE magic Failed Trees
+FILE  magicFailedTrees.php
+MENU  ipp.stack.dat
+
+WHERE fault != 0
+
+#        field          size  format  name           show     link to         extras
+FIELD    magic_id,	 5,   %d,     Magic ID
+FIELD    exp_id,	 5,   %d,     Exp ID
+FIELD    diff_id,	 5,   %d,     Diff ID
+FIELD    label,	 	 5,   %s,     Label
+FIELD    data_group, 	 5,   %s,     Data Grp
+FIELD    inverse,	 5,   %d,     Inverse
+FIELD    state,		 5,   %s,     State
+FIELD    fault,		 5,   %d,     Fault
Index: /branches/sc_branches/ippMonitorLap/def/magicProcessedMasks.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/magicProcessedMasks.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/magicProcessedMasks.d	(revision 31685)
@@ -0,0 +1,17 @@
+TABLE magicRun, magicMask
+TITLE Magic Processed Masks
+FILE  magicProcessedMasks.php
+MENU  ipp.stack.dat
+
+WHERE magicRun.magic_id  = magicMask.magic_id
+
+#        field                   size  format  name           show     link to         extras
+FIELD    magicRun.magic_id,	 5,   %d,     Magic ID
+FIELD    magicRun.exp_id,	 5,   %d,     Exp ID
+FIELD    magicRun.diff_id,	 5,   %d,     Diff ID
+FIELD    magicRun.label, 	 5,   %s,     Label
+FIELD    magicRun.data_group, 	 5,   %s,     data grp
+FIELD    magicRun.inverse,	 5,   %d,     Inverse
+FIELD    magicRun.state,	 5,   %s,     State
+FIELD    magicMask.streaks,	 5,   %d,     Streaks
+FIELD    magicMask.fault,	 5,   %d,     Fault
Index: /branches/sc_branches/ippMonitorLap/def/magicProcessedMasks_Images.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/magicProcessedMasks_Images.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/magicProcessedMasks_Images.d	(revision 31685)
@@ -0,0 +1,32 @@
+TABLE magicRun, magicMask
+TITLE Magic Processed Masks
+FILE  magicProcessedMasks_Images.php
+MENU  ipp.stack.dat
+
+WHERE magicRun.magic_id  = magicMask.magic_id
+
+IMAGE JPEG2 $magicRun.workdir_base PPSUB.OUTPUT.JPEG2 GPC1 NONE
+
+# XXX need to get camera from lookup
+ARGS  ARG7 magicRun.magic_id=$magicRun.magic_id
+ARGS  ARG7 camera=GPC1
+#ARGS  ARG7 basename=$magicRun.workdir/$magicRun.exp_id/$magicRun.exp_id.mgc.$magicRun.magic_id.verify/$magicRun.exp_id
+ARGS  ARG7 basename=$magicMask.path_base
+
+#        field                   size  format  name           show     link to         extras
+FIELD    magicRun.magic_id,	 5,   %d,     Magic ID
+FIELD    magicRun.exp_id,	 5,   %d,     Exp ID
+FIELD    magicRun.diff_id,	 5,   %d,     Diff ID,		value, magicProcessedMasks_Images.php,  ARG7
+# FIELD    *,                      8,   %s,     image,         image=JPEG2, diffProcessedSkyfile_Images.php,  ARG7
+FIELD    magicRun.label, 	 5,   %s,     Label
+FIELD    magicRun.data_group, 	 5,   %s,     data grp
+FIELD    magicRun.inverse,	 5,   %d,     Inverse
+FIELD    magicRun.state,	 5,   %s,     State
+FIELD    magicMask.streaks,	 5,   %d,     Streaks
+FIELD    magicMask.fault,	 5,   %d,     Fault
+FIELD    magicRun.workdir, 	 5,   %s,     Label, none
+FIELD    magicMask.path_base, 	 5,   %s,     Label, none
+
+TAIL PHP insert_image ('MAGIC.ORIGINAL.PNG', 'width=49%');
+TAIL PHP insert_image ('MAGIC.DUPLICATE.PNG', 'width=49%');
+# TAIL PHP insert_log ('LOG.EXP');
Index: /branches/sc_branches/ippMonitorLap/def/magicProcessedNodes.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/magicProcessedNodes.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/magicProcessedNodes.d	(revision 31685)
@@ -0,0 +1,20 @@
+TABLE magicRun, magicTree, magicNodeResult
+TITLE Magic Processed Nodes
+FILE  magicProcessedNodes.php
+MENU  ipp.stack.dat
+
+WHERE magicRun.magic_id  = magicTree.magic_id
+WHERE magicTree.magic_id = magicNodeResult.magic_id
+WHERE magicTree.node     = magicNodeResult.node
+
+#        field                   size  format  name           show     link to         extras
+FIELD    magicRun.magic_id,	 5,   %d,     Magic ID
+FIELD    magicRun.exp_id,	 5,   %d,     Exp ID
+FIELD    magicRun.diff_id,	 5,   %d,     Diff ID
+FIELD    magicRun.label, 	 5,   %s,     Label
+FIELD    magicRun.data_group, 	 5,   %s,     data grp
+FIELD    magicRun.inverse,	 5,   %d,     Inverse
+FIELD    magicRun.state,	 5,   %s,     State
+FIELD    magicTree.node,	 5,   %s,     Node
+FIELD    magicTree.dep,	 	 5,   %s,     Parent
+FIELD    magicNodeResult.fault,	 5,   %d,     Fault
Index: /branches/sc_branches/ippMonitorLap/def/magicRun.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/magicRun.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/magicRun.d	(revision 31685)
@@ -0,0 +1,14 @@
+TABLE magicRun
+TITLE magicRun
+FILE  magicRun.php
+MENU  ipp.stack.dat
+
+#        field          size  format  name           show     link to         extras
+FIELD    magic_id,	 5,   %d,     Magic ID
+FIELD    exp_id,	 5,   %d,     Exp ID
+FIELD    diff_id,	 5,   %d,     Diff ID
+FIELD    label,	 	 5,   %s,     Label
+FIELD    data_group, 	 5,   %s,     Data Grp
+FIELD    inverse,	 5,   %d,     Inverse
+FIELD    state,		 5,   %s,     State
+FIELD    fault,		 5,   %d,     Fault
Index: /branches/sc_branches/ippMonitorLap/def/magicSummary.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/magicSummary.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/magicSummary.d	(revision 31685)
@@ -0,0 +1,17 @@
+TABLE magicRun
+TITLE Magic Summary
+FILE  magicSummary.php
+MENU  ipp.stack.dat
+
+#     field           size  format  name         show    link to         extras
+FIELD label,    	 15, %s,     label
+FIELD data_group, 	 10, %s,     data_group
+FIELD workdir,    	 7, %s,     workdir
+FIELD state,    	 7, %s,     state
+FIELD count(state) as n, 7, %d,     count
+
+MODE  summary
+GROUP state
+GROUP label
+GROUP data_group
+GROUP workdir
Index: /branches/sc_branches/ippMonitorLap/def/magicTrees.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/magicTrees.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/magicTrees.d	(revision 31685)
@@ -0,0 +1,18 @@
+TABLE magicRun, magicTree
+TITLE Magic Trees
+FILE  magicTrees.php
+MENU  ipp.stack.dat
+
+WHERE magicRun.magic_id = magicTree.magic_id
+
+#        field                   size  format  name           show     link to         extras
+FIELD    magicRun.magic_id,	 5,   %d,     Magic ID
+FIELD    magicRun.exp_id,	 5,   %d,     Exp ID
+FIELD    magicRun.diff_id,	 5,   %d,     Diff ID
+FIELD    magicRun.label, 	 5,   %s,     Label
+FIELD    magicRun.data_group, 	 5,   %s,     data grp
+FIELD    magicRun.inverse,	 5,   %d,     Inverse
+FIELD    magicRun.state,	 5,   %s,     State
+FIELD    magicTree.node,	 5,   %s,     Node
+FIELD    magicTree.dep,	 	 5,   %s,     Parent
+FIELD    magicRun.fault,	 5,   %d,     Fault
Index: /branches/sc_branches/ippMonitorLap/def/maskStats.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/maskStats.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/maskStats.d	(revision 31685)
@@ -0,0 +1,50 @@
+TABLE rawExp, chipRun, camRun, fakeRun, warpRun
+TITLE Mask Stats
+FILE  maskStats.php
+MENU  ipp.imfiles.dat
+
+WHERE rawExp.exp_id = chipRun.exp_id
+WHERE chipRun.chip_id = camRun.chip_id
+WHERE camRun.cam_id = fakeRun.cam_id
+WHERE fakeRun.fake_id = warpRun.fake_id
+
+OP   OP1  $ra * 57.295783
+OP   OP2  $decl * 57.295783
+
+#        field              size format  name           show          link to   extras
+FIELD    rawExp.exp_name,    10,  %s,     Exp Name
+FIELD    rawExp.exp_id,       5,  %d,     Exp ID,        value,   rawImfile.php,  ARG1
+FIELD    rawExp.exp_type,     8,  %s,     Type    
+FIELD    rawExp.state,        5,  %s,     State
+FIELD    rawExp.obs_mode,     8,  %s,     obs mode
+FIELD    rawExp.dateobs,     19,  %T,     Date/Time
+FIELD    rawExp.ra,           8,  %C,     RA,           op=OP1      
+FIELD    rawExp.decl,         8,  %C,     DEC,          op=OP2
+FIELD    rawExp.filter,      10,  %s,     FILTER
+FIELD    rawExp.airmass,      5,  %.4f,   airmass     
+FIELD    rawExp.exp_time,     5,  %.2f,   exp_time    
+
+FIELD    chipRun.maskfrac_npix,         8,  %.3e,     chip npix   
+FIELD    camRun.maskfrac_ref_npix,     	8,  %.3e,     cam ref npix   
+FIELD    camRun.maskfrac_max_npix,     	8,  %.3e,     cam max npix   
+FIELD    warpRun.maskfrac_npix,     	8,  %.3e,     warp npix   
+
+FIELD    chipRun.maskfrac_static,   	8,  %.3f,     chip static 
+FIELD    camRun.maskfrac_ref_static,   	8,  %.3f,     cam ref static 
+FIELD    camRun.maskfrac_max_static,   	8,  %.3f,     cam max static 
+FIELD    warpRun.maskfrac_static,   	8,  %.3f,     warp static 
+
+FIELD    chipRun.maskfrac_dynamic,  	8,  %.3f,     chip dynamic
+FIELD    camRun.maskfrac_ref_dynamic,  	8,  %.3f,     cam ref dynamic
+FIELD    camRun.maskfrac_max_dynamic,  	8,  %.3f,     cam max dynamic
+FIELD    warpRun.maskfrac_dynamic,  	8,  %.3f,     warp dynamic
+
+FIELD    chipRun.maskfrac_magic,    	8,  %.3f,     chip magic  
+FIELD    camRun.maskfrac_ref_magic,    	8,  %.3f,     cam ref magic  
+FIELD    camRun.maskfrac_max_magic,    	8,  %.3f,     cam max magic  
+FIELD    warpRun.maskfrac_magic,    	8,  %.3f,     warp magic  
+
+FIELD    chipRun.maskfrac_advisory, 	8,  %.3f,     chip advisory
+FIELD    camRun.maskfrac_ref_advisory, 	8,  %.3f,     cam ref advisory
+FIELD    camRun.maskfrac_max_advisory, 	8,  %.3f,     cam max advisory
+FIELD    warpRun.maskfrac_advisory,     8,  %.3f,     warp advisory 
Index: /branches/sc_branches/ippMonitorLap/def/masterDetrendFrames.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/masterDetrendFrames.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/masterDetrendFrames.d	(revision 31685)
@@ -0,0 +1,58 @@
+# this file is based on the detRunSummary.d file: it uses the same tables restricted to the 
+# master detrend runs which have been accepted
+
+TABLE detRun LEFT JOIN detRunSummary ON detRun.det_id = detRunSummary.det_id
+TITLE Master Detrend Frames
+FILE  masterDetrendFrames.php
+MENU  ipp.detrend.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+WHERE (detRunSummary.accept = 1 or detRun.mode = 'register')
+WHERE detRun.state = 'stop'
+
+ARGS  ARG1 detRunSummary.det_id=$detRunSummary.det_id
+
+ARGS  ARG2 detInputExp.det_id=$detRunSummary.det_id
+ARGS  ARG2 detInputExp.iteration=$detRunSummary.iteration
+
+ARGS  ARG3 detProcessedExp.det_id=$detRunSummary.det_id
+
+ARGS  ARG4 detResidExp.det_id=$detRunSummary.det_id
+ARGS  ARG4 detResidExp.iteration=$detRunSummary.iteration
+
+ARGS  ARG5 det_id=$det_id
+
+#     field                    width format  name          show         link to                   extras
+FIELD detRun.det_id,           5,    %s,     det ID,       value,       detRunSummary.php,        ARG1
+FIELD detRunSummary.iteration, 3,    %s,     iter
+FIELD detRun.det_type,        12,    %s,     type
+FIELD detRun.state,            5,    %s,     state
+# FIELD detRun.mode,             5,    %s,     mode
+# FIELD detRunSummary.accept,    5,    %s,     accept
+FIELD *,                       5,    %s,     choose,       value=input, detInputExp.php,          ARG2
+FIELD *,                       5,    %s,     choose,       value=proc,  detProcessedExp.php,      ARG3
+FIELD *,                       5,    %s,     choose,       value=stack, detStackedImfile.php,  ARG5
+FIELD *,                       5,    %s,     choose,       value=resid, detResidExp.php,          ARG4
+FIELD mode,         	       5,    %s,     mode
+FIELD filter,       	      10,    %s,     filter     
+FIELD registered,             19,   %s,      registered 
+FIELD use_begin,              19,   %s,      use_begin  
+FIELD use_end,                19,   %s,      use_end    
+FIELD detRunSummary.bg,        8,   %.2f,    bg
+FIELD detRunSummary.bg_stdev,  8,   %.2f,    bg_stdev
+# FIELD airmass_min,             5,   %.2f,    min_airmass    
+# FIELD airmass_max,             5,   %.2f,    max     
+# FIELD exp_time_min,            5,   %.2f,    min_exp_time   
+# FIELD exp_time_max,            5,   %.2f,    max 
+# FIELD ccd_temp_min,            5,   %.2f,    min_ccd_temp   
+# FIELD ccd_temp_max,            5,   %.2f,    max    
+# FIELD posang_min,              5,   %.2f,    min_posang     
+# FIELD posang_max,              5,   %.2f,    max      
+# FIELD bg_mean_stdev, 20,   bg_mean_stdev
+
+# this file illustrates a simple inner join to generate the output table
+# assuming no other dynamic restrictions are added, this generates the following query:
+# SELECT detRunSummary.det_id,detRunSummary.iteration,detRunSummary.iteration,detRun.det_type,detRunSummary.bg,detRunSummary.bg_stdev \
+# FROM detRunSummary, detRun \
+# WHERE detRunSummary.accept = 1 AND detRun.det_id = detRunSummary.det_id AND detRun.iteration = detRunSummary.iteration \
+# LIMIT 20
Index: /branches/sc_branches/ippMonitorLap/def/masterDetrendImfiles.d.src
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/masterDetrendImfiles.d.src	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/masterDetrendImfiles.d.src	(revision 31685)
@@ -0,0 +1,19 @@
+# this file is based on the detRunSummary.d file: it uses the same tables restricted to the 
+# master detrend runs which have been accepted
+
+TABLE detStackedImfile
+TITLE Master Detrend Imfiles
+FILE  masterDetrendImfiles.php
+MENU  ipp.detrend.dat
+
+#     field      width name          show         link to            extras
+FIELD det_id,    7,    det_id
+FIELD iteration, 5,    iter
+FIELD uri,       5,    uri
+
+# this file illustrates a simple inner join to generate the output table
+# assuming no other dynamic restrictions are added, this generates the following query:
+# SELECT detRunSummary.det_id,detRunSummary.iteration,detRunSummary.iteration,detRun.det_type,detRunSummary.bg,detRunSummary.bg_stdev \
+# FROM detRunSummary, detRun \
+# WHERE detRunSummary.accept = 1 AND detRun.position = detRunSummary.det_id AND detRun.iteration = detRunSummary.iteration \
+# LIMIT 20
Index: /branches/sc_branches/ippMonitorLap/def/minidvodbCopy.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/minidvodbCopy.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/minidvodbCopy.d	(revision 31685)
@@ -0,0 +1,19 @@
+TABLE minidvodbCopy 
+TITLE Minidvodb Copies
+FILE  minidvodbCopy.php
+MENU  ipp.dvodb.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+
+WHERE minidvodbcopy_id >= 0
+
+#     field                   size  format  name         show    link to                  extras
+FIELD distinct(minidvodbCopy.minidvodbcopy_id),        5, %d,     Minidvodb Copy ID
+FIELD minidvodbCopy.minidvodb_id,        5, %d,     Minidvodb ID
+FIELD minidvodbCopy.minidvodb_rsync_path,          25, %s,     rsync path
+FIELD minidvodbCopy.destination_host,       5, %s,     destinatin host
+FIELD minidvodbCopy.fault,    5, %s,     Fault
+FIELD minidvodbCopy.state,          5, %s,     State
+FIELD minidvodbCopy.epoch,          5, %T,    Epoch
+FIELD minidvodbCopy.dtime,        5, %d,     dtime
+
Index: /branches/sc_branches/ippMonitorLap/def/minidvodbProcessed.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/minidvodbProcessed.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/minidvodbProcessed.d	(revision 31685)
@@ -0,0 +1,23 @@
+TABLE minidvodbRun, minidvodbProcessed 
+TITLE Processed minidvodbs
+FILE  minidvodbProcessed.php
+MENU  ipp.dvodb.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+
+WHERE minidvodbRun.minidvodb_id = minidvodbProcessed.minidvodb_id
+
+#     field                   size  format  name         show    link to                  extras
+FIELD distinct(minidvodbRun.minidvodb_id),        5, %d,     Minidvodb ID
+
+FIELD minidvodbRun.minidvodb_name,          5, %s,     minidvodb_name
+FIELD minidvodbRun.minidvodb_group,       5, %s,     minidvodb_group
+FIELD minidvodbProcessed.merge_order,        5, %d,     Merge Order
+FIELD minidvodbProcessed.dtime_resort,        5, %d,     resort time
+FIELD minidvodbProcessed.dtime_relphot,        5, %d,     relphot time
+FIELD minidvodbProcessed.dtime_merge,        5, %d,     dvomerge time
+FIELD minidvodbProcessed.mergedvodb_path,          25, %s,     mergedvodb_path
+FIELD state,          5, %s,    State
+FIELD minidvodbProcessed.fault,        5, %d,     Fault
+FIELD epoch,        5, %T,     epoch
+
Index: /branches/sc_branches/ippMonitorLap/def/minidvodbRun.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/minidvodbRun.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/minidvodbRun.d	(revision 31685)
@@ -0,0 +1,18 @@
+TABLE minidvodbRun 
+TITLE minidvodb Runs
+FILE  minidvodbRun.php
+MENU  ipp.dvodb.dat
+
+# the following WHERE clauses are added to all queries joined by AND
+
+WHERE minidvodb_id >= 0
+
+#     field                   size  format  name         show    link to                  extras
+FIELD distinct(minidvodbRun.minidvodb_id),        5, %d,     Minidvodb ID
+FIELD minidvodbRun.minidvodb_name,          5, %s,     minidvodb_name
+FIELD minidvodbRun.minidvodb_group,       5, %s,     minidvodb_group
+FIELD minidvodbRun.minidvodb_path,    25, %s,     minidvodb_path
+FIELD minidvodbRun.mergedvodb_path,          25, %s,     mergedvodb_path
+FIELD state,          5, %s,    State
+FIELD creation_date,        5, %T,     epoch
+
Index: /branches/sc_branches/ippMonitorLap/def/mopsStatus.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/mopsStatus.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/mopsStatus.d	(revision 31685)
@@ -0,0 +1,42 @@
+TABLE rawExp LEFT JOIN chipRun using(exp_id) LEFT JOIN camRun using(chip_id) LEFT JOIN fakeRun using(cam_id) LEFT JOIN warpRun using(fake_id) LEFT JOIN diffInputSkyfile AS diffInput ON diffInput.warp1 = warp_id LEFT JOIN diffRun AS diffInputRun ON diffInput.diff_id = diffInputRun.diff_id LEFT JOIN diffInputSkyfile AS diffTemplate ON diffTemplate.warp2 = warp_id LEFT JOIN diffRun AS diffTemplateRun ON diffTemplate.diff_id = diffTemplateRun.diff_id LEFT JOIN publishRun ON stage_id=diffInput.diff_id AND (client_id=1 OR client_id=5) LEFT JOIN publishRun AS pubRun2 ON pubRun2.stage_id=diffTemplate.diff_id AND (pubRun2.client_id=1 OR pubRun2.client_id=5) LEFT JOIN magicDSRun ON magicDSRun.magic_ds_id=camRun.magicked
+TITLE MOPS Status
+FILE mopsStatus.php
+MENU ipp.imfiles.dat
+
+UNRESTRICTED WHERE 0=1
+
+# OP  OP1   ($ddiff_id > 0 ? $ddiff_id : $tdiff_id)
+# OP  OP1   $ddiffId.":".$tdiffId
+OP OP1 ($row[8]>$row[9]?$row[8]. "(1)":($row[9]!=0?$row[9]. "(2)":"0"))
+# $diffInput.diff_id+$diffTemplate.diff_id
+# PUB ID
+OP OP2 ($row[12]>$row[13]?$row[12]. "(I)":($row[13]!=0?$row[13]. "(T)":"0"))
+#($row[13]>$row[14])
+
+#     field                    width format  name          show         link to                   extras
+FIELD dateobs, 		       13,   %T,     Date Obs
+FIELD exp_name, 	       5,    %s,     Exp Name
+FIELD rawExp.exp_id, 	       5,    %d,     Exp ID
+FIELD chipRun.data_group,      5,    %s,     Data grp
+FIELD chip_id, 		       5,    %d,     Chip ID (Stage 1)
+FIELD camRun.cam_id AS camID, 		       5,    %d,     Cam ID (Stage 2)
+FIELD fake_id, 		       5,    %d,     Fake ID (Stage 3)
+FIELD warp_id, 		       5,    %d,     Warp ID (Stage 4)
+FIELD diffInput.diff_id AS ddiff_id,       5,    %d,     ddiff_id, none
+FIELD diffTemplate.diff_id AS tdiff_id,    5,    %d,     tdiff_id, none
+FIELD *,		       5,    %s,     Diff ID (Stage 5),		op=OP1
+FIELD camRun.magicked, 	       5,    %d,     Magick ID (Stage 6)
+FIELD magicDSRun.magic_ds_id,       5,    %d, DestreakID (Stage 7)
+FIELD publishRun.pub_id AS pubId1,       5,    %d,     pubId1, none
+FIELD pubRun2.pub_id AS pubId2,       5,    %d,     pubId2, none
+FIELD *,	     		10, %s, Pub ID, op=OP2
+FIELD filter, 		       5,    %s,     Filter
+FIELD object, 		       15,    %s,     Object
+FIELD obs_mode, 	       5,    %s,     Obs Mode
+FIELD comment, 		       40,    %s,     Comment
+
+#FIELD diffInput.diff_id AS ddiffId,       5,    %s,     ddiffId,	none
+#FIELD diffTemplate.diff_id AS tdiffId,    5,    %s,     tdiffId, 	none
+
+MODE summary
+GROUP rawExp.exp_id
Index: /branches/sc_branches/ippMonitorLap/def/newExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/newExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/newExp.d	(revision 31685)
@@ -0,0 +1,13 @@
+TABLE newExp
+TITLE New Exposures
+FILE  newExp.php
+MENU  ipp.load.dat
+
+WHERE state != 'stop'
+
+#        field        size   format  name           show     link to         extras
+FIELD    exp_id,	5,   %d,     exposure ID
+FIELD    tmp_exp_name,	10,  %s,     exposure Name
+FIELD    tmp_camera,	5,   %s,     camera
+FIELD    tmp_telescope,	5,   %s,     telescope
+FIELD    state,	        5,   %s,     state
Index: /branches/sc_branches/ippMonitorLap/def/newImfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/newImfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/newImfile.d	(revision 31685)
@@ -0,0 +1,9 @@
+TABLE newImfile
+TITLE Raw Science Exposures
+FILE  newImfile.php
+MENU  ipp.load.dat
+
+#        field       size  format  name           show   link to         extras
+FIELD    exp_id,	5, %d,     exposure ID
+FIELD    tmp_class_id,	5, %s,     class ID
+FIELD    uri,		5, %s,     URI
Index: /branches/sc_branches/ippMonitorLap/def/publishClient.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/publishClient.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/publishClient.d	(revision 31685)
@@ -0,0 +1,12 @@
+TABLE publishClient
+TITLE Publish Clients
+FILE  publishClient.php
+MENU  ipp.dist.dat
+
+#     field                     size  format  name         show    link to                  extras
+FIELD publishClient.client_id,     5, %d,     Client ID
+FIELD publishClient.active,        2, %d,     Active?
+FIELD publishClient.product,       5, %s,     Product
+FIELD publishClient.stage,         5, %s,     Stage
+FIELD publishClient.workdir,       5, %s,     Workdir
+FIELD publishClient.comment,       5, %s,     Comment
Index: /branches/sc_branches/ippMonitorLap/def/publishDone.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/publishDone.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/publishDone.d	(revision 31685)
@@ -0,0 +1,19 @@
+TABLE publishRun, publishClient, publishDone
+TITLE Publish Done
+FILE  publishDone.php
+MENU  ipp.dist.dat
+
+WHERE publishRun.client_id = publishClient.client_id
+WHERE publishRun.pub_id    = publishDone.pub_id
+
+#     field                   size  format  name         show    link to                  extras
+FIELD publishRun.pub_id,         5, %d,     Publish ID
+FIELD publishRun.client_id,      5, %d,     Client ID
+FIELD publishRun.stage_id,       5, %d,     Stage ID
+FIELD publishClient.stage,       5, %s,     Stage
+FIELD publishClient.product,     5, %s,     Product
+FIELD publishRun.label,          5, %s,     Label
+FIELD publishRun.state,          5, %s,     State
+FIELD publishDone.dtime_script,  5, %.1f,   dTime
+FIELD publishDone.hostname,      5, %s,     Hostname
+FIELD publishDone.fault,         5, %d,     Fault
Index: /branches/sc_branches/ippMonitorLap/def/publishRun.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/publishRun.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/publishRun.d	(revision 31685)
@@ -0,0 +1,15 @@
+TABLE publishRun, publishClient
+TITLE Publish Runs
+FILE  publishRun.php
+MENU  ipp.dist.dat
+
+WHERE publishRun.client_id = publishClient.client_id
+
+#     field                   size  format  name         show    link to                  extras
+FIELD publishRun.pub_id,         5, %d,     Publish ID
+FIELD publishRun.client_id,      5, %d,     Client ID
+FIELD publishRun.stage_id,       5, %d,     Stage ID
+FIELD publishClient.stage,       5, %s,     Stage
+FIELD publishClient.product,     5, %s,     Product
+FIELD publishRun.label,          5, %s,     Label
+FIELD publishRun.state,          5, %s,     State
Index: /branches/sc_branches/ippMonitorLap/def/publishSummary.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/publishSummary.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/publishSummary.d	(revision 31685)
@@ -0,0 +1,19 @@
+TABLE publishRun, publishClient
+TITLE Publish Summary
+FILE  publishSummary.php
+MENU  ipp.dist.dat
+
+WHERE publishRun.client_id = publishClient.client_id
+
+#     field                   size  format  name         show    link to                  extras
+FIELD publishRun.label,          15, %s,     Label
+FIELD publishClient.product,     5, %s,     Product
+FIELD publishClient.stage,       5, %s,     Stage
+FIELD publishRun.state,          5, %s,     State
+FIELD count(publishRun.state),   5, %d,     Count
+
+MODE  summary
+GROUP publishRun.label
+GROUP publishClient.stage
+GROUP publishClient.product
+GROUP publishRun.state
Index: /branches/sc_branches/ippMonitorLap/def/pzDoneExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/pzDoneExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/pzDoneExp.d	(revision 31685)
@@ -0,0 +1,17 @@
+TABLE pzDownloadExp, summitExp
+TITLE Downloaded Exposures
+FILE  pzDoneExp.php
+MENU  ipp.load.dat
+
+WHERE pzDownloadExp.exp_name  = summitExp.exp_name
+WHERE pzDownloadExp.camera    = summitExp.camera
+WHERE pzDownloadExp.telescope = summitExp.telescope
+WHERE pzDownloadExp.state     = 'stop'
+
+#        field                  size format  name           show     link to         extras
+FIELD    summitExp.exp_name,	5,   %s,     exposures ID
+FIELD    summitExp.camera, 	5,   %s,     camera
+FIELD    summitExp.telescope,	5,   %s,     telescope
+FIELD    summitExp.dateobs,    19,   %T,     date/time
+FIELD    summitExp.exp_type,    5,   %s,     type
+FIELD    summitExp.uri,         5,   %s,     URI
Index: /branches/sc_branches/ippMonitorLap/def/pzDoneExp_failed.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/pzDoneExp_failed.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/pzDoneExp_failed.d	(revision 31685)
@@ -0,0 +1,20 @@
+TABLE pzDoneExp, summitExp, pzDoneImfile
+TITLE done exposures
+FILE  pzDoneExp.php
+MENU  ipp.load.dat
+
+WHERE pzDoneExp.exp_name  = summitExp.exp_name
+WHERE pzDoneExp.camera    = summitExp.camera
+WHERE pzDoneExp.telescope = summitExp.telescope
+WHERE pzDoneExp.exp_name  = pzDoneImfile.exp_name
+WHERE pzDoneExp.camera    = pzDoneImfile.camera
+WHERE pzDoneExp.telescope = pzDoneImfile.telescope
+WHERE pzDoneImfile.fault > 0
+
+#        field                  size format  name           show     link to         extras
+FIELD    summitExp.exp_name,	5,   %s,     exposures ID
+FIELD    summitExp.camera, 	5,   %s,     camera
+FIELD    summitExp.telescope,	5,   %s,     telescope
+FIELD    summitExp.dateobs,     5,   %T,     date/time
+FIELD    summitExp.exp_type,    5,   %s,     type
+FIELD    summitExp.uri,         5,   %s,     URI
Index: /branches/sc_branches/ippMonitorLap/def/pzDoneImfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/pzDoneImfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/pzDoneImfile.d	(revision 31685)
@@ -0,0 +1,14 @@
+TABLE pzDownloadImfile
+TITLE done exposures
+FILE  pzDoneImfile.php
+MENU  ipp.load.dat
+
+WHERE pzDownloadImfile.fault     = 0
+
+#        field                       size 	format  name           show     link to         extras
+FIELD    pzDownloadImfile.exp_name,  5,   	%s,     exposures ID
+FIELD    pzDownloadImfile.camera,    5,   	%s,     camera
+FIELD    pzDownloadImfile.telescope, 5,   	%s,     telescope
+FIELD    pzDownloadImfile.class,     5,        	%s,     class
+FIELD    pzDownloadImfile.class_id,  5,        	%s,     class ID
+FIELD    pzDownloadImfile.uri,       5,        	%s,     filename
Index: /branches/sc_branches/ippMonitorLap/def/pzDoneImfile_failed.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/pzDoneImfile_failed.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/pzDoneImfile_failed.d	(revision 31685)
@@ -0,0 +1,14 @@
+TABLE pzDownloadImfile
+TITLE done exposures
+FILE  pzDoneImfile_failed.php
+MENU  ipp.load.dat
+
+WHERE pzDownloadImfile.fault     != 0
+
+#        field                       size 	format  name           show     link to         extras
+FIELD    pzDownloadImfile.exp_name,  5,   	%s,     exposures ID
+FIELD    pzDownloadImfile.camera,    5,   	%s,     camera
+FIELD    pzDownloadImfile.telescope, 5,   	%s,     telescope
+FIELD    pzDownloadImfile.class,     5,        	%s,     class
+FIELD    pzDownloadImfile.class_id,  5,        	%s,     class ID
+FIELD    pzDownloadImfile.uri,       5,        	%s,     filename
Index: /branches/sc_branches/ippMonitorLap/def/pzPendingExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/pzPendingExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/pzPendingExp.d	(revision 31685)
@@ -0,0 +1,17 @@
+TABLE pzDownloadExp, summitExp
+TITLE pending exposures
+FILE  pzPendingExp.php
+MENU  ipp.load.dat
+
+WHERE pzDownloadExp.exp_name  = summitExp.exp_name
+WHERE pzDownloadExp.camera    = summitExp.camera
+WHERE pzDownloadExp.telescope = summitExp.telescope
+WHERE pzDownloadExp.state     = 'run'
+
+#        field                  size format  name           show     link to         extras
+FIELD    summitExp.exp_name,	5,   %s,     exposures ID
+FIELD    summitExp.camera, 	5,   %s,     camera
+FIELD    summitExp.telescope,	5,   %s,     telescope
+FIELD    summitExp.dateobs,     5,   %T,     date/time
+FIELD    summitExp.exp_type,    5,   %s,     type
+FIELD    summitExp.uri,         5,   %s,     URI
Index: /branches/sc_branches/ippMonitorLap/def/pzPendingImfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/pzPendingImfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/pzPendingImfile.d	(revision 31685)
@@ -0,0 +1,16 @@
+TABLE summitImfile, pzDownloadExp
+TITLE pending imfiles
+FILE  pzPendingImfile.php
+MENU  ipp.load.dat
+
+WHERE summitImfile.exp_name  = pzDownloadExp.exp_name 
+WHERE summitImfile.camera    = pzDownloadExp.camera   
+WHERE summitImfile.telescope = pzDownloadExp.telescope
+WHERE pzDownloadExp.state     = 'run'
+
+#        field                    size  format  name             show   link to         extras
+FIELD    summitImfile.exp_name,    5, %s,      Exp Name
+FIELD    summitImfile.camera,      5, %s,      camera
+FIELD    summitImfile.telescope,   5, %s,      telescope
+FIELD    summitImfile.class,	   5, %s,      class
+FIELD    summitImfile.class_id,    5, %s,      class ID 
Index: /branches/sc_branches/ippMonitorLap/def/rawBurntoolState.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/rawBurntoolState.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/rawBurntoolState.d	(revision 31685)
@@ -0,0 +1,22 @@
+TABLE rawImfile
+TITLE Burntool States
+FILE  rawBurntoolState.php
+MENU  ipp.load.dat
+
+# if no query restrictions are supplied, we want to limit the query or it is extremely long running:
+UNRESTRICTED WHERE exp_id = 0
+
+#        field        size format  name           show          link to   extras
+FIELD    exp_id,      	      5,  %d,     Exp ID,        value
+FIELD    exp_name,    	     10,  %s,     Exp Name
+FIELD    dateobs,            19, %T,      Date/Time
+FIELD    exp_type,            8,  %s,     Type    
+FIELD    obs_mode,            8,  %s,     obs mode
+FIELD    burntool_state,     10,  %s,     Burntool State
+FIELD    fault,               5,  %d,     Fault
+FIELD    count(exp_id) as n,  7,  %d,     count
+
+MODE  summary
+GROUP exp_id
+GROUP burntool_state
+GROUP fault
Index: /branches/sc_branches/ippMonitorLap/def/rawDetrendExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/rawDetrendExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/rawDetrendExp.d	(revision 31685)
@@ -0,0 +1,25 @@
+TABLE rawExp
+TITLE Raw Detrend Exposures
+FILE  rawDetrendExp.php
+MENU  ipp.load.dat
+
+# limit this table to non-OBJECT types of images
+WHERE (rawExp.exp_type != 'OBJECT' and rawExp.exp_type != 'LIGHT')
+
+ARGS ARG1 exp_id=$exp_id
+
+#        field        	size  format  name       show     link to         extras
+FIELD    exp_id,      	 5,   %d,     Exp ID
+FIELD    exp_name,    	 8,   %s,     Exp Name,  value,   rawImfile.php,  ARG1
+FIELD    telescope,   	 8,   %s,     Telescope
+FIELD    camera,      	 8,   %s,     Camera
+FIELD    exp_type,    	 8,   %s,     Type    
+FIELD    dateobs,     	19,   %T,     Date/Time
+FIELD    filter,      	10,   %s,     FILTER
+FIELD    airmass,      	 5,   %.2f,   airmass     
+FIELD    exp_time,    	 5,   %.2f,    exp_time    
+FIELD    ccd_temp,       5,   %.2f,   ccd_temp
+FIELD    sat_pixel_frac, 5,   %.4f,   f(sat pixels)
+FIELD    bg,           	 5,   %.2f,   backgnd
+FIELD    bg_stdev,     	 5,   %.2f,   stdev    
+FIELD    bg_mean_stdev,  5,   %.2f,   &lt;backgnd&gt;
Index: /branches/sc_branches/ippMonitorLap/def/rawDetrendExp_detrend.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/rawDetrendExp_detrend.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/rawDetrendExp_detrend.d	(revision 31685)
@@ -0,0 +1,24 @@
+TABLE rawExp
+TITLE Raw Detrend Exposures
+FILE  rawDetrendExp_detrend.php
+MENU  ipp.detrend.dat
+
+# limit this table to non-OBJECT types of images
+WHERE rawExp.exp_type != 'OBJECT'
+
+ARGS ARG1 rawImfile.exp_id=$exp_id
+
+#        field        	size  format  name           show     link to         extras
+FIELD    exp_id,      	 5,   %d,     Exp ID,     value,   rawImfile.php,  ARG1
+FIELD    exp_name,    	10,   %s,     Exp Name
+FIELD    telescope,   	10,   %s,     Telescope
+FIELD    camera,      	10,   %s,     Camera
+FIELD    exp_type,    	10,   %s,     Type    
+FIELD    filter,      	10,   %s,     FILTER
+FIELD    dateobs,     	19,   %T,     Date/Time
+FIELD    exp_time,    	 5,   %.2f,   exp_time    
+FIELD    sat_pixel_frac, 5,   %.2f,   f(sat pixels)
+FIELD    airmass,      	 5,   %.4f,   airmass     
+FIELD    bg,           	 5,   %.2f,   backgnd
+FIELD    bg_stdev,     	 5,   %.2f,   stdev    
+FIELD    bg_mean_stdev,  5,   %.2f,   &lt;backgnd&gt;
Index: /branches/sc_branches/ippMonitorLap/def/rawExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/rawExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/rawExp.d	(revision 31685)
@@ -0,0 +1,26 @@
+TABLE rawExp
+TITLE Raw Exposures
+FILE  rawExp.php
+MENU  ipp.load.dat
+
+ARGS ARG1 rawImfile.exp_id=$exp_id
+
+OP   OP1  $ra * 57.295783
+OP   OP2  $decl * 57.295783
+
+#        field        size format  name           show          link to   extras
+FIELD    exp_name,    10,  %s,     Exp Name
+FIELD    exp_id,       5,  %d,     Exp ID,        value,   rawImfile.php,  ARG1
+FIELD    telescope,   10,  %s,     Telescope
+FIELD    camera,      10,  %s,     Camera
+FIELD    exp_type,     8,  %s,     Type    
+FIELD    obs_mode,     8,  %s,     obs mode
+FIELD    dateobs,     19,  %T,     Date/Time
+FIELD    ra,           8,  %C, RA,           op=OP1      
+FIELD    decl,         8,  %C, DEC,          op=OP2
+FIELD    object,      10,  %s,     object
+FIELD    filter,      10,  %s,     FILTER
+FIELD    airmass,      5,  %.4f,   airmass     
+FIELD    exp_time,     5,  %.2f,   exp_time    
+FIELD    state,        10,  %s,     State
+FIELD    comment,      65,  %s,     Comment
Index: /branches/sc_branches/ippMonitorLap/def/rawExpStats.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/rawExpStats.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/rawExpStats.d	(revision 31685)
@@ -0,0 +1,33 @@
+TABLE rawExp
+TITLE Raw Exposure Stats
+FILE  rawExpStats.php
+MENU  ipp.load.dat
+
+ARGS ARG1 rawImfile.exp_id=$exp_id
+
+OP   OP1  $ra * 57.295783
+OP   OP2  $decl * 57.295783
+
+#        field        size format  name           show          link to   extras
+FIELD    exp_name,    10,  %s,     Exp Name
+FIELD    exp_id,       5,  %d,     Exp ID,        value,   rawImfile.php,  ARG1
+FIELD    telescope,   10,  %s,     Telescope
+FIELD    camera,      10,  %s,     Camera
+FIELD    exp_type,     8,  %s,     Type    
+FIELD    dateobs,     19,  %T,     Date/Time
+FIELD    ra,           8,  %C, RA,           op=OP1      
+FIELD    decl,         8,  %C, DEC,          op=OP2
+FIELD    object,      10,  %s,     object
+FIELD    filter,      10,  %s,     FILTER
+FIELD    airmass,      5,  %.4f,   airmass     
+FIELD    exp_time,     5,  %.2f,   exp_time    
+FIELD    ccd_temp,     5,  %.2f,   ccd_temp
+FIELD    pon_time,     5,  %.2f,   pon_time
+FIELD    sat_pixel_frac, 5,   %.4f,   f(sat pixels)
+FIELD    bg,	        8,  %.2f,   backgnd
+FIELD    bg_stdev,      8,  %.2f,   stdev
+FIELD    bg_mean_stdev, 8, %.2f,   [stdev]
+FIELD    moon_angle,    5,  %.2f,   moon angle
+FIELD    moon_phase,    5,  %.2f,   moon phase
+FIELD    sun_alt,       5,  %.2f,   sun altitude
+FIELD    comment,      65,  %s,     Comment
Index: /branches/sc_branches/ippMonitorLap/def/rawExp_failed.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/rawExp_failed.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/rawExp_failed.d	(revision 31685)
@@ -0,0 +1,38 @@
+TABLE rawExp
+TITLE Failed Raw Exposures
+FILE  rawExp_failed.php
+MENU  ipp.load.dat
+
+# limit this table to non-OBJECT types of images
+WHERE fault > 0
+WHERE rawExp.exp_type = 'OBJECT'
+
+ARGS ARG1 exp_id=$exp_id
+
+OP   OP1  $ra * 57.295783
+OP   OP2  $decl * 57.295783
+
+#        field        size  format  name       show     link to         extras
+FIELD    exp_id,      5,    %s,     Exp ID
+FIELD    exp_name,    10,   %s,     Exp Name,  value,   rawImfile.php,  ARG1
+FIELD    telescope,   10,   %s,     Telescope
+FIELD    camera,      10,   %s,     Camera
+FIELD    ra,           8,  %C, RA,           op=OP1      
+FIELD    decl,         8,  %C, DEC,          op=OP2
+FIELD    filter,      10,   %s,     FILTER
+FIELD    dateobs,     19,   %T,     Date/Time
+FIELD    exp_time,     5,   %s,     exp_time    
+FIELD    airmass,      5,   %s,     airmass     
+FIELD    bg,           5,   %s,     backgnd
+FIELD    bg_stdev,     5,   %s,     stdev    
+FIELD    bg_mean_stdev, 5,  %s,     &lt;backgnd&gt;
+# FIELD  ra,           8,   %s,     ra          
+# FIELD  decl,         8,   %s,     decl        
+# FIELD  object,      10,   %s,     object
+# FIELD  imfiles,     20,   %s,     imfiles     
+# FIELD  airmass,     20,   %s,     airmass     
+# FIELD  bg_mean_stdev, 20, %s,     bg_mean_stdev   
+# FIELD  alt,         20,   %s,     alt         
+# FIELD  az,	      20,   %s,     az          
+# FIELD  ccd_temp,    20,   %s,     ccd_temp    
+# FIELD  posang,      20,   %s,     posang      
Index: /branches/sc_branches/ippMonitorLap/def/rawImfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/rawImfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/rawImfile.d	(revision 31685)
@@ -0,0 +1,35 @@
+TABLE rawImfile
+TITLE Raw Image File
+FILE  rawImfile.php
+MENU  ipp.imfiles.dat
+
+# HEAD PHP insert_backref ("rawExp.php", "exp_id", $ID['link']);
+
+OP   OP1  $ra * 57.295783
+OP   OP2  $decl * 57.295783
+
+#        field                 size  format   name          show         link to         extras
+FIELD    rawImfile.exp_name,      5, %s,      Exposure
+FIELD    rawImfile.class_id,      8, %s,      Chip ID
+FIELD    rawImfile.exp_id,        5, %d,      Exp ID
+FIELD    rawImfile.telescope,    10, %s,      Telescope
+FIELD    rawImfile.camera,       10, %s,      Camera
+FIELD    rawImfile.exp_type,      8, %s,      exp_type
+FIELD    rawImfile.dateobs,      19, %T,      Date/Time
+FIELD    rawImfile.ra,            8, %C,  RA,           op=OP1      
+FIELD    rawImfile.decl,          8, %C,  DEC,          op=OP2
+FIELD    rawImfile.object,        8, %s,      object
+FIELD    rawImfile.filter,       10, %s,      FILTER
+FIELD    rawImfile.airmass,       5, %.4f,    airmass     
+FIELD    rawImfile.exp_time,      5, %.2f,    exp_time    
+FIELD    rawImfile.ccd_temp,      5, %.2f,    ccd_temp
+FIELD    rawImfile.bg,            8, %.2f,    backgnd
+FIELD    rawImfile.bg_stdev,      8, %.2f,    stdev
+FIELD    rawImfile.bg_mean_stdev, 8, %.2f,    [stdev]
+FIELD    rawImfile.burntool_state, 5, %d, BurnState
+FIELD    rawImfile.uri,          20, %s,      uri
+
+# FIELD    alt,       20,   alt
+# FIELD    az,        20,   az
+# FIELD    posang,    20,   posang
+# FIELD    object,    20,   object
Index: /branches/sc_branches/ippMonitorLap/def/rawImfile_failed.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/rawImfile_failed.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/rawImfile_failed.d	(revision 31685)
@@ -0,0 +1,34 @@
+TABLE rawImfile
+TITLE Failed Raw Image Files
+FILE  rawImfile_failed.php
+MENU  ipp.load.dat
+
+HEAD PHP insert_backref ("rawExp.php", "exp_id", $ID['link']);
+WHERE fault > 0
+
+OP   OP1  $ra * 57.295783
+OP   OP2  $decl * 57.295783
+
+#        field       size  format  name    show         link to         extras
+FIELD    exp_id,        5, %s,        Exp ID
+FIELD    exp_name,      5, %s,        Exposure
+FIELD    class_id,      8, %s,        Chip ID
+FIELD    ra,           8,  %C, RA,           op=OP1      
+FIELD    decl,         8,  %C, DEC,          op=OP2
+FIELD    bg,	        8, %s,        backgnd
+FIELD    bg_stdev,      8, %s,        stdev
+FIELD    bg_mean_stdev, 8, %s,        [stdev]
+FIELD    uri,	       10, %s,        uri
+# FIELD    class,      20, %s,        Class
+# FIELD    uri,	      20,   uri
+# FIELD    exp_type,  20,   exp_type
+# FIELD    filter,    20,   filter
+# FIELD    airmass,   20,   airmass
+# FIELD    ra,	      20,   ra
+# FIELD    decl,      20,   decl
+# FIELD    exp_time,  20,   exp_time
+# FIELD    alt,       20,   alt
+# FIELD    az,	      20,   az
+# FIELD    ccd_temp,  20,   ccd_temp
+# FIELD    posang,    20,   posang
+# FIELD    object,    20,   object
Index: /branches/sc_branches/ippMonitorLap/def/rawScienceExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/rawScienceExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/rawScienceExp.d	(revision 31685)
@@ -0,0 +1,33 @@
+TABLE rawExp
+TITLE Raw Science Exposures
+FILE  rawScienceExp.php
+MENU  ipp.load.dat
+
+# limit this table to OBJECT types of images
+WHERE (rawExp.exp_type = 'OBJECT' or rawExp.exp_type = 'LIGHT')
+
+ARGS ARG1 rawImfile.exp_id=$exp_id
+
+OP   OP1  $ra * 57.295783
+OP   OP2  $decl * 57.295783
+
+#        field        size format  name           show          link to   extras
+FIELD    exp_id,       5,  %d,     Exp ID
+FIELD    exp_name,     8,  %s,     Exp Name,     value,   rawImfile.php,  ARG1
+FIELD    telescope,    8,  %s,     Telescope
+FIELD    camera,       8,  %s,     Camera
+FIELD    dateobs,     19,  %T,     Date/Time
+FIELD    ra,           8,  %C,     RA,           op=OP1      
+FIELD    decl,         8,  %C,     DEC,          op=OP2
+FIELD    object,       8,  %s,     object
+FIELD    filter,      10,  %s,     FILTER
+FIELD    exp_time,     5,  %s,     exp_time    
+FIELD    airmass,      5,  %.4f,   airmass     
+FIELD    exp_time,     5,  %.2f,   exp_time    
+FIELD    ccd_temp,     5,  %.2f,   ccd_temp
+FIELD    pon_time,     5,  %.2f,   pon_time
+FIELD    sat_pixel_frac, 5,   %.4f,   f(sat pixels)
+FIELD    bg,	       8,  %.2f,   backgnd
+FIELD    bg_stdev,     8,  %.2f,   stdev
+FIELD    bg_mean_stdev, 8, %.2f,   [stdev]
+FIELD    comment,      80,  %s,     Comment
Index: /branches/sc_branches/ippMonitorLap/def/rawSummary.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/rawSummary.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/rawSummary.d	(revision 31685)
@@ -0,0 +1,17 @@
+TABLE rawExp
+TITLE Raw Summary
+FILE  rawSummary.php
+MENU  ipp.load.dat
+
+#     field            size  format  name         show    link to         extras
+FIELD exp_type,    	 15, %s,     OBSTYPE
+FIELD obs_mode,    	 15, %s,     OBS_MODE
+FIELD state,    	  7, %s,     state
+FIELD MIN(dateobs),    	  19, %T,    min date
+FIELD MAX(dateobs),    	  19, %T,    max date
+FIELD count(exp_id) as n, 7, %d,     count
+
+MODE  summary
+GROUP state
+GROUP exp_type
+GROUP obs_mode
Index: /branches/sc_branches/ippMonitorLap/def/rawUnknownExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/rawUnknownExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/rawUnknownExp.d	(revision 31685)
@@ -0,0 +1,38 @@
+TABLE rawExp
+TITLE Raw Unknown Exposures
+FILE  rawUnknownExp.php
+MENU  ipp.load.dat
+
+# limit this table to non-OBJECT types of images
+WHERE rawExp.exp_type is NULL
+
+ARGS ARG1 exp_id=$exp_id
+
+OP   OP1  $ra * 57.295783
+OP   OP2  $decl * 57.295783
+
+#        field        size  format  name           show     link to        extras
+FIELD    exp_id,       5,   %s,     Exp ID
+FIELD    exp_name,    10,   %s,     Exp Name,     value,   rawImfile.php,  ARG1
+FIELD    exp_type,     8,   %s,     Type    
+FIELD    telescope,   10,   %s,     Telescope
+FIELD    camera,      10,   %s,     Camera
+FIELD    dateobs,     19,   %T,     Date/Time
+FIELD    ra,           8,  %C, RA,           op=OP1      
+FIELD    decl,         8,  %C, DEC,          op=OP2
+FIELD    object,       8,   %s,     object
+FIELD    filter,      10,   %s,     FILTER
+FIELD    exp_time,     5,   %s,     exp_time    
+FIELD    airmass,      5,   %s,     airmass     
+FIELD    bg,           5,   %s,     backgnd
+FIELD    bg_stdev,     5,   %s,     stdev    
+# FIELD  bg_mean_stdev, 5,  %s,     &lt;backgnd&gt;
+# FIELD  ra,           8,   %s,     ra          
+# FIELD  decl,         8,   %s,     decl        
+# FIELD  imfiles,     20,   %s,     imfiles     
+# FIELD  airmass,     20,   %s,     airmass     
+# FIELD  bg_mean_stdev, 20, %s,     bg_mean_stdev   
+# FIELD  alt,         20,   %s,     alt         
+# FIELD  az,	      20,   %s,     az          
+# FIELD  ccd_temp,    20,   %s,     ccd_temp    
+# FIELD  posang,      20,   %s,     posang      
Index: /branches/sc_branches/ippMonitorLap/def/scatterCpiBgReMaImage.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/scatterCpiBgReMaImage.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/scatterCpiBgReMaImage.d	(revision 31685)
@@ -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: /branches/sc_branches/ippMonitorLap/def/scatterCpiBgReMpImage.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/scatterCpiBgReMpImage.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/scatterCpiBgReMpImage.d	(revision 31685)
@@ -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: /branches/sc_branches/ippMonitorLap/def/scatterCpiBgReSaImage.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/scatterCpiBgReSaImage.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/scatterCpiBgReSaImage.d	(revision 31685)
@@ -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: /branches/sc_branches/ippMonitorLap/def/scatterPlotAirMassFwhmImage.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/scatterPlotAirMassFwhmImage.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/scatterPlotAirMassFwhmImage.d	(revision 31685)
@@ -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: /branches/sc_branches/ippMonitorLap/def/simplePlotCamImage.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/simplePlotCamImage.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/simplePlotCamImage.d	(revision 31685)
@@ -0,0 +1,29 @@
+TABLE camRun, chipRun, rawExp
+TITLE New sky plot - cam
+FILE  simplePlotCamImage.php
+MENU  ipp.plots.dat
+
+WHERE camRun.state != 'new' 
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE camRun.chip_id = chipRun.chip_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 Cam
Index: /branches/sc_branches/ippMonitorLap/def/simplePlotChipImage.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/simplePlotChipImage.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/simplePlotChipImage.d	(revision 31685)
@@ -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: /branches/sc_branches/ippMonitorLap/def/simplePlotRawImage.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/simplePlotRawImage.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/simplePlotRawImage.d	(revision 31685)
@@ -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: /branches/sc_branches/ippMonitorLap/def/stackFailedSkyfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/stackFailedSkyfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/stackFailedSkyfile.d	(revision 31685)
@@ -0,0 +1,41 @@
+TABLE stackRun, stackSumSkyfile
+TITLE Stack Failed Skyfiles
+FILE  stackFailedSkyfile.php
+MENU  ipp.stack.dat
+
+WHERE stackRun.stack_id = stackSumSkyfile.stack_id
+WHERE stackSumSkyfile.fault != 0
+
+ARGS  ARG7 stackRun.stack_id=$stackRun.stack_id
+ARGS  ARG7 stackRun.skycell_id=$stackRun.skycell_id
+ARGS  ARG7 camera=GPC1
+ARGS  ARG7 basename=$stackSumSkyfile.path_base
+
+#        field                          size  format  name    show     link to         extras
+FIELD stackRun.stack_id,            5, %s,     Stack ID
+FIELD stackRun.skycell_id,          5, %s,     Skycell ID
+FIELD stackRun.label,    	    5, %s,     Label
+FIELD stackRun.data_group,    	    5, %s,     data grp
+FIELD stackRun.dist_group,    	    5, %s,     dist grp
+FIELD stackRun.filter,    	    5, %s,     Filter
+FIELD stackRun.tess_id,    	    5, %s,     Tess ID
+FIELD stackRun.state,    	    7, %s,     State,         value,   stackFailedSkyfile.php, ARG7
+FIELD stackSumSkyfile.bg,           5, %.2f,   backgnd
+FIELD stackSumSkyfile.bg_stdev,     5, %.2f,   stdev    
+FIELD stackSumSkyfile.dtime_stack,  5, %.2f,   t(stack)
+FIELD stackSumSkyfile.dtime_match_mean, 5, %.2f, t(match)
+FIELD stackSumSkyfile.dtime_initial, 5, %.2f,   t(initial)
+FIELD stackSumSkyfile.dtime_reject,  5, %.2f,   t(reject)
+FIELD stackSumSkyfile.dtime_final,   5, %.2f,   t(final)
+FIELD stackSumSkyfile.dtime_phot,    5, %.2f,   t(phot)
+FIELD stackSumSkyfile.dtime_script,  5, %.2f,   t(script)
+
+FIELD stackSumSkyfile.match_mean,    5, %.2f,   match
+FIELD stackSumSkyfile.match_stdev,   5, %.2f,   match err
+
+FIELD stackSumSkyfile.reject_images, 5, %d,   n(reject)
+FIELD stackSumSkyfile.sources,       5, %d,   n(sources)
+
+FIELD stackSumSkyfile.path_base,    5, %s,     path_base,     none
+
+TAIL PHP insert_log ('LOG.EXP');
Index: /branches/sc_branches/ippMonitorLap/def/stackInputSkyfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/stackInputSkyfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/stackInputSkyfile.d	(revision 31685)
@@ -0,0 +1,55 @@
+TABLE stackInputSkyfile, stackRun, warpRun, warpSkyfile, fakeRun, camRun, camProcessedExp, chipRun, rawExp
+TITLE Stack Input Exposures
+FILE  stackInputSkyfile.php
+MENU  ipp.stack.dat
+
+WHERE stackRun.stack_id = stackInputSkyfile.stack_id
+WHERE stackInputSkyfile.warp_id = warpRun.warp_id
+WHERE warpRun.fake_id = fakeRun.fake_id
+WHERE warpSkyfile.warp_id = warpRun.warp_id
+WHERE warpSkyfile.skycell_id = stackRun.skycell_id
+WHERE fakeRun.cam_id = camRun.cam_id
+WHERE camProcessedExp.cam_id = camRun.cam_id
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+
+# if no query restrictions are supplied, we want to limit the query or it is extremely long running:
+UNRESTRICTED AND stackRun.stack_id = 0
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+ARGS  ARG4  fakeRun.fake_id=$fakeRun.fake_id
+ARGS  ARG5  warpRun.warp_id=$warpRun.warp_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#        field                          size  format  name           show     link to         extras
+FIELD rawExp.exp_name,     	    5, %s,     Exp Name
+FIELD rawExp.exp_id,     	    5, %d,     Exp ID,       value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,    	    7, %d,     Chip ID,      value,  chipProcessedImfile.php, ARG2
+FIELD camRun.cam_id,    	    7, %d,     Cam ID,       value,  camProcessedExp.php,     ARG3
+FIELD fakeRun.fake_id,    	    7, %d,     Fake ID,      value,  fakeProcessedImfile.php, ARG4
+FIELD warpRun.warp_id,    	    7, %d,     Warp ID,      value,  warpStageExp.php,        ARG5
+FIELD stackInputSkyfile.stack_id,   5, %s,     Stack ID
+FIELD stackRun.skycell_id,          5, %s,     Skycell ID
+FIELD stackRun.state,    	    7, %s,     State
+FIELD stackRun.label,    	    7, %s,     Label
+FIELD stackRun.data_group,    	    7, %s,     data grp
+FIELD stackRun.dist_group,    	    7, %s,     dist grp
+FIELD rawExp.telescope,      	   10, %s,     Telescope
+FIELD rawExp.camera,         	   10, %s,     Camera
+FIELD rawExp.dateobs,        	   19, %T,     Date/Time
+FIELD rawExp.ra,       	            8, %C, RA,          op=OP1    
+FIELD rawExp.decl,       	    8, %C, DEC,         op=OP2
+FIELD rawExp.object,         	    8, %s,     Object
+FIELD rawExp.filter,         	   10, %s,     Filter
+FIELD rawExp.exp_time,       	    5, %.2f,   exp_time    
+FIELD rawExp.airmass,        	    5, %.4f,   airmass     
+FIELD camProcessedExp.fwhm_major,   5, %.4f,   FWHM     
+FIELD warpSkyfile.good_frac,   	    7, %.4f,   warp good f
+FIELD rawExp.bg,             	    5, %.2f,   backgnd
+FIELD rawExp.bg_stdev,       	    5, %.2f,   stdev    
+FIELD rawExp.comment,  	           65, %s,     Comment
+
Index: /branches/sc_branches/ippMonitorLap/def/stackProcessedSkyfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/stackProcessedSkyfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/stackProcessedSkyfile.d	(revision 31685)
@@ -0,0 +1,42 @@
+TABLE stackRun, stackSumSkyfile
+TITLE Stack Processed Skyfiles
+FILE  stackProcessedSkyfile.php
+MENU  ipp.stack.dat
+
+WHERE stackRun.stack_id = stackSumSkyfile.stack_id
+WHERE stackRun.state = 'full'
+WHERE stackSumSkyfile.fault = 0
+
+ARGS  ARG7 stackRun.stack_id=$stackRun.stack_id
+ARGS  ARG7 stackRun.skycell_id=$stackRun.skycell_id
+ARGS  ARG7 camera=GPC1
+ARGS  ARG7 basename=$stackSumSkyfile.path_base
+
+#        field                   size  format  name           show     link to         extras
+FIELD stackRun.stack_id,            5, %s,     Stack ID
+FIELD stackRun.skycell_id,          5, %s,     Skycell ID
+FIELD stackRun.label,    	    5, %s,     Label
+FIELD stackRun.data_group,    	    5, %s,     data grp
+FIELD stackRun.dist_group,    	    5, %s,     dist grp
+FIELD stackRun.filter,    	    5, %s,     Filter
+FIELD stackRun.tess_id,    	    5, %s,     Tess ID
+FIELD stackRun.state,    	    7, %s,     State,         value,   stackProcessedSkyfile.php, ARG7
+FIELD stackSumSkyfile.bg,           5, %.2f,   backgnd
+FIELD stackSumSkyfile.bg_stdev,     5, %.2f,   stdev    
+FIELD stackSumSkyfile.dtime_stack,  5, %.2f,   t(stack)
+FIELD stackSumSkyfile.dtime_match_mean, 5, %.2f, t(match)
+FIELD stackSumSkyfile.dtime_initial, 5, %.2f,   t(initial)
+FIELD stackSumSkyfile.dtime_reject,  5, %.2f,   t(reject)
+FIELD stackSumSkyfile.dtime_final,   5, %.2f,   t(final)
+FIELD stackSumSkyfile.dtime_phot,    5, %.2f,   t(phot)
+FIELD stackSumSkyfile.dtime_script,  5, %.2f,   t(script)
+
+FIELD stackSumSkyfile.match_mean,    5, %.2f,   match
+FIELD stackSumSkyfile.match_stdev,   5, %.2f,   match err
+
+FIELD stackSumSkyfile.reject_images, 5, %d,   n(reject)
+FIELD stackSumSkyfile.sources,       5, %d,   n(sources)
+
+FIELD stackSumSkyfile.path_base,    5, %s,     path_base,     none
+
+TAIL PHP insert_log ('LOG.EXP');
Index: /branches/sc_branches/ippMonitorLap/def/stackProcessedSkyfile_Images.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/stackProcessedSkyfile_Images.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/stackProcessedSkyfile_Images.d	(revision 31685)
@@ -0,0 +1,48 @@
+TABLE stackRun, stackSumSkyfile
+TITLE Stack Processed Skyfiles
+FILE  stackProcessedSkyfile_Images.php
+MENU  ipp.stack.dat
+
+WHERE stackRun.stack_id = stackSumSkyfile.stack_id
+WHERE stackRun.state = 'full'
+WHERE stackSumSkyfile.fault = 0
+
+# define image names to be used below
+# IMAGE VAR basename filerule camera class_id
+IMAGE JPEG2 $stackSumSkyfile.path_base PPSTACK.OUTPUT.JPEG2 GPC1 NONE
+
+ARGS  ARG7 stackRun.stack_id=$stackRun.stack_id
+ARGS  ARG7 stackRun.skycell_id=$stackRun.skycell_id
+ARGS  ARG7 camera=GPC1
+ARGS  ARG7 basename=$stackSumSkyfile.path_base
+
+#        field                   size  format  name           show     link to         extras
+FIELD stackRun.stack_id,            5, %s,     Stack ID
+FIELD stackRun.skycell_id,          5, %s,     Skycell ID
+FIELD stackRun.label,    	    5, %s,     Label
+FIELD stackRun.data_group,    	    5, %s,     data grp
+FIELD stackRun.dist_group,    	    5, %s,     dist grp
+FIELD *,    	                    8, %s,     image,         image=JPEG2, stackProcessedSkyfile_Images.php,  ARG7
+FIELD stackRun.filter,    	    5, %s,     Filter
+FIELD stackRun.tess_id,    	    5, %s,     Tess ID
+FIELD stackRun.state,    	    7, %s,     State
+FIELD stackSumSkyfile.bg,           5, %.2f,   backgnd
+FIELD stackSumSkyfile.bg_stdev,     5, %.2f,   stdev    
+FIELD stackSumSkyfile.dtime_stack,  5, %.2f,   t(stack)
+FIELD stackSumSkyfile.dtime_match_mean, 5, %.2f, t(match)
+FIELD stackSumSkyfile.dtime_initial, 5, %.2f,   t(initial)
+FIELD stackSumSkyfile.dtime_reject,  5, %.2f,   t(reject)
+FIELD stackSumSkyfile.dtime_final,   5, %.2f,   t(final)
+FIELD stackSumSkyfile.dtime_phot,    5, %.2f,   t(phot)
+FIELD stackSumSkyfile.dtime_script,  5, %.2f,   t(script)
+
+FIELD stackSumSkyfile.match_mean,    5, %.2f,   match
+FIELD stackSumSkyfile.match_stdev,   5, %.2f,   match err
+
+FIELD stackSumSkyfile.reject_images, 5, %d,   n(reject)
+FIELD stackSumSkyfile.sources,       5, %d,   n(sources)
+
+FIELD stackSumSkyfile.path_base,    5, %s,     path_base,     none
+
+TAIL PHP insert_image ('PPSTACK.OUTPUT.JPEG1', 'width=90%');
+TAIL PHP insert_log ('LOG.EXP');
Index: /branches/sc_branches/ippMonitorLap/def/stackRun.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/stackRun.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/stackRun.d	(revision 31685)
@@ -0,0 +1,18 @@
+TABLE stackRun
+TITLE stackRun
+FILE  stackRun.php
+MENU  ipp.stack.dat
+
+#        field          size  format  name           show     link to         extras
+FIELD    stack_id,	 5,   %s,     Stack ID
+FIELD    skycell_id,	 5,   %s,     Skycell ID
+FIELD    filter,	 5,   %s,     Filter
+FIELD    label,	 	 5,   %s,     Label
+FIELD    data_group, 	 5,   %s,     Data grp
+FIELD    dist_group,	 5,   %s,     Dist grp
+FIELD    tess_id,	 5,   %s,     Tess ID
+FIELD    state,		 5,   %s,     State
+
+#FIELD    registered,	 5,   %s,     time registered
+#FIELD    workdir,	10,   %s,     workdir
+#FIELD    dvodb,		10,   %s,     DVO database
Index: /branches/sc_branches/ippMonitorLap/def/stackSumSkyfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/stackSumSkyfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/stackSumSkyfile.d	(revision 31685)
@@ -0,0 +1,10 @@
+TABLE stackSumSkyfile
+TITLE stackSumSkyfile
+FILE  stackSumSkyfile.php
+MENU  ipp.stack.dat
+
+#        field           size format  name           show     link to         extras
+FIELD    stack_id,	 5,   %s,     stack ID
+FIELD    URI,		 5,   %s,     URI
+FIELD    bg,		 5,   %s,     background
+FIELD    bg_stdev,	 5,   %s,     standard deviation
Index: /branches/sc_branches/ippMonitorLap/def/stackSummary.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/stackSummary.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/stackSummary.d	(revision 31685)
@@ -0,0 +1,19 @@
+TABLE stackRun
+TITLE Stack Summary
+FILE  stackSummary.php
+MENU  ipp.stack.dat
+
+#     field           size  format  name         show    link to         extras
+FIELD label,    	 15, %s,     label
+FIELD data_group,        10, %s,     data_group
+FIELD workdir,    	 7, %s,     workdir
+FIELD tess_id,    	 7, %s,     tess_id
+FIELD state,    	 7, %s,     state
+FIELD count(state) as n, 7, %d,     count
+
+MODE  summary
+GROUP state
+GROUP label
+GROUP workdir
+GROUP data_group
+GROUP tess_id
Index: /branches/sc_branches/ippMonitorLap/def/stackSummary_Images.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/stackSummary_Images.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/stackSummary_Images.d	(revision 31685)
@@ -0,0 +1,29 @@
+TABLE stackAssociation, stackSummary
+TITLE Stack Summary w/ Images
+FILE  stackSummary_Images.php
+MENU  ipp.stack.dat
+
+# TODO
+WHERE stackSummary.sass_id = stackAssociation.sass_id
+
+# define image names to be used below
+# IMAGE VAR basename filerule camera class_id
+IMAGE JPEG2 OP1 PPSKYCELL.JPEG2 GPC1 NONE
+OP   OP1  $stackSummary.path_base . $stackSummary.projection_cell
+ARGS ARG7 name=$stackSummary.path_base.$stackSummary.projection_cell
+ARGS ARG7 rule=PPSKYCELL.JPEG1
+ARGS ARG7 camera=GPC1
+ARGS ARG7 class_id=NONE
+
+#        field                   size  format  name           show     link to         extras
+FIELD stackSummary.sass_id,         5, %s,     SASS ID
+FIELD stackAssociation.data_group,  5, %s,     data grp
+FIELD stackAssociation.tess_id,     5, %s,     Tess ID
+FIELD stackAssociation.filter,      5, %s,     Filter
+FIELD *,    	                    8, %s,     image,	       image=JPEG2, getimage.php, ARG7
+FIELD stackSummary.path_base,       5, %s,     path_base,      none
+FIELD stackSummary.projection_cell, 5, %s,     projection_cell, none
+FIELD stackAssociation.sass_id,     5, %s,     sAMsai,         none
+
+# TAIL PHP insert_image ('PPSTACK.OUTPUT.JPEG1', 'width=90%');
+TAIL PHP insert_log ('LOG.EXP');
Index: /branches/sc_branches/ippMonitorLap/def/staticskyFailedSkyfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/staticskyFailedSkyfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/staticskyFailedSkyfile.d	(revision 31685)
@@ -0,0 +1,26 @@
+TABLE staticskyInput, staticskyRun, stackRun, staticskyResult
+TITLE Static Sky Processed 
+FILE  staticskyFailedSkyfile.php
+MENU  ipp.stack.dat
+
+WHERE staticskyRun.sky_id = staticskyInput.sky_id
+WHERE staticskyInput.stack_id = stackRun.stack_id
+WHERE staticskyInput.sky_id = staticskyResult.sky_id
+WHERE staticskyResult.fault != 0
+
+#        field                          size  format  name           show     link to         extras
+FIELD staticskyRun.sky_id,          5, %s,     Sky ID
+FIELD staticskyRun.label,    	    7, %s,     Label
+FIELD staticskyRun.state,    	    7, %s,     State
+FIELD stackRun.stack_id,            5, %s,     Stack ID
+FIELD stackRun.skycell_id,          5, %s,     Skycell ID
+FIELD stackRun.tess_id,             5, %s,     Tess ID
+FIELD stackRun.filter,              5, %s,     Filter 
+FIELD stackRun.label,               5, %s,     Stack Label
+FIELD staticskyRun.data_group, 	    7, %s,     data grp
+FIELD staticskyRun.dist_group, 	    7, %s,     dist grp
+FIELD staticskyResult.dtime_phot,   7, %.2f,   t(phot)
+FIELD staticskyResult.dtime_script, 7, %.2f,   t(script)
+FIELD staticskyResult.sources,      7, %d,     n(sources)
+FIELD staticskyResult.fault,        7, %d,     fault
+FIELD staticskyResult.quality,      7, %d,     quality
Index: /branches/sc_branches/ippMonitorLap/def/staticskyInputSkyfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/staticskyInputSkyfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/staticskyInputSkyfile.d	(revision 31685)
@@ -0,0 +1,19 @@
+TABLE staticskyInput, staticskyRun, stackRun
+TITLE Static Sky Input Exposures
+FILE  staticskyInputSkyfile.php
+MENU  ipp.stack.dat
+
+WHERE staticskyRun.sky_id = staticskyInput.sky_id
+WHERE staticskyInput.stack_id = stackRun.stack_id
+
+#        field                          size  format  name           show     link to         extras
+FIELD staticskyRun.sky_id,          5, %s,     Sky ID
+FIELD staticskyRun.label,    	    7, %s,     Label
+FIELD staticskyRun.state,    	    7, %s,     State
+FIELD stackRun.stack_id,            5, %s,     Stack ID
+FIELD stackRun.skycell_id,          5, %s,     Skycell ID
+FIELD stackRun.tess_id,             5, %s,     Tess ID
+FIELD stackRun.filter,              5, %s,     Filter 
+FIELD stackRun.label,               5, %s,     Stack Label
+FIELD staticskyRun.data_group, 	    7, %s,     data grp
+FIELD staticskyRun.dist_group, 	    7, %s,     dist grp
Index: /branches/sc_branches/ippMonitorLap/def/staticskyProcessedSkyfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/staticskyProcessedSkyfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/staticskyProcessedSkyfile.d	(revision 31685)
@@ -0,0 +1,25 @@
+TABLE staticskyInput, staticskyRun, stackRun, staticskyResult
+TITLE Static Sky Processed 
+FILE  staticskyProcessedSkyfile.php
+MENU  ipp.stack.dat
+
+WHERE staticskyRun.sky_id = staticskyInput.sky_id
+WHERE staticskyInput.stack_id = stackRun.stack_id
+WHERE staticskyInput.sky_id = staticskyResult.sky_id
+
+#        field                          size  format  name           show     link to         extras
+FIELD staticskyRun.sky_id,          5, %s,     Sky ID
+FIELD staticskyRun.label,    	    7, %s,     Label
+FIELD staticskyRun.state,    	    7, %s,     State
+FIELD stackRun.stack_id,            5, %s,     Stack ID
+FIELD stackRun.skycell_id,          5, %s,     Skycell ID
+FIELD stackRun.tess_id,             5, %s,     Tess ID
+FIELD stackRun.filter,              5, %s,     Filter 
+FIELD stackRun.label,               5, %s,     Stack Label
+FIELD staticskyRun.data_group, 	    7, %s,     data grp
+FIELD staticskyRun.dist_group, 	    7, %s,     dist grp
+FIELD staticskyResult.dtime_phot,   7, %.2f,   t(phot)
+FIELD staticskyResult.dtime_script, 7, %.2f,   t(script)
+FIELD staticskyResult.sources,      7, %d,     n(sources)
+FIELD staticskyResult.fault,        7, %d,     fault
+FIELD staticskyResult.quality,      7, %d,     quality
Index: /branches/sc_branches/ippMonitorLap/def/staticskyRun.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/staticskyRun.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/staticskyRun.d	(revision 31685)
@@ -0,0 +1,15 @@
+TABLE staticskyRun
+TITLE staticskyRun
+FILE  staticskyRun.php
+MENU  ipp.stack.dat
+
+#        field          size  format  name           show     link to         extras
+FIELD    sky_id,	 5,   %s,     Sky ID
+# FIELD    skycell_id,	 5,   %s,     Skycell ID
+FIELD    label,	 	 5,   %s,     Label
+FIELD    data_group, 	 5,   %s,     Data grp
+FIELD    dist_group,	 5,   %s,     Dist grp
+FIELD    state,		 5,   %s,     State
+
+#FIELD    registered,	 5,   %s,     time registered
+#FIELD    workdir,	10,   %s,     workdir
Index: /branches/sc_branches/ippMonitorLap/def/staticskySummary.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/staticskySummary.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/staticskySummary.d	(revision 31685)
@@ -0,0 +1,16 @@
+TABLE staticskyRun
+TITLE Static Sky Summary
+FILE  staticskySummary.php
+MENU  ipp.stack.dat
+
+#     field           size  format  name         show    link to         extras
+FIELD label,    	 15, %s,    label
+FIELD data_group,        10, %s,    data_group
+FIELD workdir,    	 7, %s,     workdir
+FIELD state,    	 7, %s,     state
+FIELD count(state) as n, 7, %d,     count
+
+MODE  summary
+GROUP state
+GROUP label
+GROUP workdir
Index: /branches/sc_branches/ippMonitorLap/def/summitExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/summitExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/summitExp.d	(revision 31685)
@@ -0,0 +1,12 @@
+TABLE summitExp
+TITLE Pending Summit Exposures
+FILE  summitExp.php
+MENU  ipp.load.dat
+
+#        field        size, format  name           show    link to         extras
+FIELD    exp_name,    5,    %s,     exposure ID
+FIELD    camera,      5,    %s,     camera
+FIELD    telescope,   5,    %s,     telescope
+FIELD    dateobs,    19,    %T,     date/time
+FIELD    exp_type,    5,    %s,     type
+FIELD    uri,         5,    %s,     URI
Index: /branches/sc_branches/ippMonitorLap/def/summitImfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/summitImfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/summitImfile.d	(revision 31685)
@@ -0,0 +1,13 @@
+TABLE summitImfile
+TITLE Summit Image Files
+FILE  summitImfile.php
+MENU  ipp.load.dat
+
+#        field     size  format  name             show   link to         extras
+FIELD    exp_name,    5, %s,      Exp Name
+FIELD    camera,      5, %s,      camera
+FIELD    telescope,   5, %s,      telescope
+FIELD    file_id,     5, %s,      file_id
+FIELD    class,	      5, %s,      class
+FIELD    class_id,    5, %s,      class ID 
+FIELD    uri,         5, %s,      URI 
Index: /branches/sc_branches/ippMonitorLap/def/warpFailedSkyfiles.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/warpFailedSkyfiles.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/warpFailedSkyfiles.d	(revision 31685)
@@ -0,0 +1,59 @@
+TABLE warpSkyfile, warpRun, fakeRun, camRun, chipRun, rawExp
+TITLE Warp Failed Skyfiles
+FILE  warpFailedSkyfiles.php
+MENU  ipp.science.dat
+
+WHERE warpSkyfile.warp_id = warpRun.warp_id
+WHERE warpRun.fake_id = fakeRun.fake_id
+WHERE fakeRun.cam_id = camRun.cam_id
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE warpSkyfile.fault != 0
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+ARGS  ARG4  fakeRun.fake_id=$fakeRun.fake_id
+ARGS  ARG5  warpRun.warp_id=$warpRun.warp_id
+ARGS  ARG6  warpSkyfile.skycell_id=$warpSkyfile.skycell_id
+
+ARGS  ARG7 warpRun.warp_id=$warpRun.warp_id
+ARGS  ARG7 warpSkyfile.skycell_id=$warpSkyfile.skycell_id
+ARGS  ARG7 camera=$rawExp.camera
+ARGS  ARG7 basename=$warpSkyfile.path_base
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                    size  format  name         show    link to         extras
+FIELD rawExp.exp_name,     	  5, %s,     Exp Name
+FIELD rawExp.exp_id,     	  5, %d,     Exp ID,       value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,    	  7, %d,     Chip ID,      value,  chipProcessedImfile.php, ARG2
+FIELD camRun.cam_id,    	  7, %d,     Cam ID,       value,  camProcessedExp.php,     ARG3
+FIELD fakeRun.fake_id,    	  7, %d,     Fake ID,      value,  fakeProcessedImfile.php, ARG4
+FIELD warpRun.warp_id,    	  7, %d,     Warp ID,      value,  warpStageExp.php,        ARG5
+FIELD warpSkyfile.skycell_id, 	 10, %s,     skycell,      value,  warpFailedSkyfiles.php,  ARG6
+FIELD warpRun.state,    	  7, %s,     state,        value,  warpFailedSkyfiles.php,  ARG7
+FIELD warpRun.label,    	  7, %s,     label
+FIELD warpRun.data_group,    	  7, %s,     data grp
+FIELD warpRun.dist_group,    	  7, %s,     dist grp
+FIELD warpSkyfile.tess_id,    	 10, %s,     tess
+FIELD warpSkyfile.good_frac,  	  5, %s,     good_frac
+# FIELD warpSkyfile.ignored,     	  5, %s,     ignored
+FIELD warpSkyfile.fault,      	  5, %s,     fault
+FIELD rawExp.telescope,      	 10, %s,     Telescope
+FIELD rawExp.camera,         	 10, %s,     Camera
+FIELD rawExp.dateobs,        	 19, %T,     Date/Time
+FIELD rawExp.ra,       	          8, %C, RA,          op=OP1    
+FIELD rawExp.decl,       	  8, %C, DEC,         op=OP2
+FIELD rawExp.object,         	  8, %s,     Object
+FIELD rawExp.filter,         	 10, %s,     FILTER
+FIELD rawExp.exp_time,       	  5, %.2f,   exp_time    
+FIELD rawExp.airmass,        	  5, %.4f,   airmass     
+FIELD rawExp.bg,             	  5, %.2f,   backgnd
+FIELD rawExp.bg_stdev,       	  5, %.2f,   stdev    
+FIELD rawExp.comment,  	         65, %s,     Comment
+
+FIELD warpSkyfile.path_base,      5, %s,     path_base,   none
+
+TAIL PHP insert_log ('LOG.EXP');
Index: /branches/sc_branches/ippMonitorLap/def/warpProcessedSkyfiles.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/warpProcessedSkyfiles.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/warpProcessedSkyfiles.d	(revision 31685)
@@ -0,0 +1,62 @@
+TABLE warpSkyfile, warpRun, fakeRun, camRun, chipRun, rawExp
+TITLE Warp Processed Skyfiles
+FILE  warpProcessedSkyfiles.php
+MENU  ipp.science.dat
+
+WHERE warpSkyfile.warp_id = warpRun.warp_id
+WHERE warpRun.fake_id = fakeRun.fake_id
+WHERE fakeRun.cam_id = camRun.cam_id
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE warpSkyfile.fault = 0
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+ARGS  ARG4  fakeRun.fake_id=$fakeRun.fake_id
+ARGS  ARG5  warpRun.warp_id=$warpRun.warp_id
+ARGS  ARG6  warpSkyfile.skycell_id=$warpSkyfile.skycell_id
+
+ARGS  ARG8  warpRun.warp_id=$warpRun.warp_id
+ARGS  ARG8  warpSkyCellMap.skycell_id=$warpSkyfile.skycell_id
+
+ARGS  ARG7 warpRun.warp_id=$warpRun.warp_id
+ARGS  ARG7 warpSkyfile.skycell_id=$warpSkyfile.skycell_id
+ARGS  ARG7 camera=$rawExp.camera
+ARGS  ARG7 basename=$warpSkyfile.path_base
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                    size  format  name         show    link to         extras
+FIELD rawExp.exp_name,     	  5, %s,     Exp Name,     value,  warpStageSkyfileInputs.php, ARG8
+FIELD rawExp.exp_id,     	  5, %d,     Exp ID,       value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,    	  7, %d,     Chip ID,      value,  chipProcessedImfile.php, ARG2
+FIELD camRun.cam_id,    	  7, %d,     Cam ID,       value,  camProcessedExp.php,     ARG3
+FIELD fakeRun.fake_id,    	  7, %d,     Fake ID,      value,  fakeProcessedImfile.php, ARG4
+FIELD warpRun.warp_id,    	  7, %d,     Warp ID,      value,  warpStageExp.php,        ARG5
+FIELD warpSkyfile.skycell_id, 	 10, %s,     skycell,      value,  warpProcessedSkyfiles.php, ARG6
+FIELD warpRun.state,    	  7, %s,     state,        value,  warpProcessedSkyfiles.php, ARG7
+FIELD warpRun.label,    	  7, %s,     label,        value
+FIELD warpRun.data_group,    	  7, %s,     data grp
+FIELD warpRun.dist_group,    	  7, %s,     dist grp
+FIELD warpSkyfile.tess_id,    	 10, %s,     tess
+FIELD warpSkyfile.good_frac,  	  5, %s,     good_frac
+# FIELD warpSkyfile.ignored,     	  5, %s,     ignored
+FIELD warpSkyfile.fault,      	  5, %s,     fault
+FIELD rawExp.telescope,      	 10, %s,     Telescope
+FIELD rawExp.camera,         	 10, %s,     Camera
+FIELD rawExp.dateobs,        	 19, %T,     Date/Time
+FIELD rawExp.ra,       	          8, %C, RA,          op=OP1    
+FIELD rawExp.decl,       	  8, %C, DEC,         op=OP2
+FIELD rawExp.object,         	  8, %s,     Object
+FIELD rawExp.filter,         	 10, %s,     FILTER
+FIELD rawExp.exp_time,       	  5, %.2f,   exp_time    
+FIELD rawExp.airmass,        	  5, %.4f,   airmass     
+FIELD rawExp.bg,             	  5, %.2f,   backgnd
+FIELD rawExp.bg_stdev,       	  5, %.2f,   stdev    
+FIELD rawExp.comment,  	         65, %s,     Comment
+
+FIELD warpSkyfile.path_base,      5, %s,     path_base,   none
+
+TAIL PHP insert_log ('LOG.EXP');
Index: /branches/sc_branches/ippMonitorLap/def/warpProcessedSkyfiles_Images.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/warpProcessedSkyfiles_Images.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/warpProcessedSkyfiles_Images.d	(revision 31685)
@@ -0,0 +1,66 @@
+TABLE warpSkyfile, warpRun, fakeRun, camRun, chipRun, rawExp
+TITLE Warp Processed Skyfiles
+FILE  warpProcessedSkyfiles.php
+MENU  ipp.science.dat
+
+WHERE warpSkyfile.warp_id = warpRun.warp_id
+WHERE warpRun.fake_id = fakeRun.fake_id
+WHERE fakeRun.cam_id = camRun.cam_id
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE warpSkyfile.fault = 0
+
+# define image names to be used below
+# IMAGE VAR basename filerule camera class_id
+IMAGE JPEG2 $camProcessedExp.path_base PPIMAGE.JPEG2 $rawExp.camera NONE
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+ARGS  ARG4  fakeRun.fake_id=$fakeRun.fake_id
+ARGS  ARG5  warpRun.warp_id=$warpRun.warp_id
+ARGS  ARG6  warpSkyfile.skycell_id=$warpSkyfile.skycell_id
+
+ARGS  ARG8  warpRun.warp_id=$warpRun.warp_id
+ARGS  ARG8  warpSkyCellMap.skycell_id=$warpSkyfile.skycell_id
+
+ARGS  ARG7 warpRun.warp_id=$warpRun.warp_id
+ARGS  ARG7 warpSkyfile.skycell_id=$warpSkyfile.skycell_id
+ARGS  ARG7 camera=$rawExp.camera
+ARGS  ARG7 basename=$warpSkyfile.path_base
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                    size  format  name         show    link to         extras
+FIELD rawExp.exp_name,     	  5, %s,     Exp Name,     value,  warpStageSkyfileInputs.php, ARG8
+FIELD rawExp.exp_id,     	  5, %d,     Exp ID,       value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,    	  7, %d,     Chip ID,      value,  chipProcessedImfile.php, ARG2
+FIELD camRun.cam_id,    	  7, %d,     Cam ID,       value,  camProcessedExp.php,     ARG3
+FIELD fakeRun.fake_id,    	  7, %d,     Fake ID,      value,  fakeProcessedImfile.php, ARG4
+FIELD warpRun.warp_id,    	  7, %d,     Warp ID,      value,  warpStageExp.php,        ARG5
+FIELD warpSkyfile.skycell_id, 	 10, %s,     skycell,      value,  warpProcessedSkyfiles.php, ARG6
+FIELD warpRun.state,    	  7, %s,     state,        value,  warpProcessedSkyfiles.php, ARG7
+FIELD warpRun.label,    	  7, %s,     label,        value
+FIELD warpRun.data_group,    	  7, %s,     label,        data grp
+FIELD warpRun.dist_group,    	  7, %s,     label,        dist grp
+FIELD warpSkyfile.tess_id,    	 10, %s,     tess
+FIELD warpSkyfile.good_frac,  	  5, %s,     good_frac
+# FIELD warpSkyfile.ignored,     	  5, %s,     ignored
+FIELD warpSkyfile.fault,      	  5, %s,     fault
+FIELD rawExp.telescope,      	 10, %s,     Telescope
+FIELD rawExp.camera,         	 10, %s,     Camera
+FIELD rawExp.dateobs,        	 19, %T,     Date/Time
+FIELD rawExp.ra,       	          8, %C, RA,          op=OP1    
+FIELD rawExp.decl,       	  8, %C, DEC,         op=OP2
+FIELD rawExp.object,         	  8, %s,     Object
+FIELD rawExp.filter,         	 10, %s,     FILTER
+FIELD rawExp.exp_time,       	  5, %.2f,   exp_time    
+FIELD rawExp.airmass,        	  5, %.4f,   airmass     
+FIELD rawExp.bg,             	  5, %.2f,   backgnd
+FIELD rawExp.bg_stdev,       	  5, %.2f,   stdev    
+FIELD rawExp.comment,  	         65, %s,     Comment
+
+FIELD warpSkyfile.path_base,      5, %s,     path_base,   none
+
+TAIL PHP insert_log ('LOG.EXP');
Index: /branches/sc_branches/ippMonitorLap/def/warpSkycellMap.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/warpSkycellMap.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/warpSkycellMap.d	(revision 31685)
@@ -0,0 +1,37 @@
+TABLE warpSkyCellMap, warpRun, camProcessedExp, chipRun, rawExp
+TITLE warpSkyCellMap
+FILE  warpSkycellMap.php
+MENU  ipp.science.dat
+
+WHERE warpSkyCellMap.warp_id     = warpRun.warp_id
+WHERE warpSkyCellMap.cam_id      = camProcessedExp.cam_id
+WHERE camProcessedExp.chip_id    = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#        field                      size  format  name           show     link to         extras
+FIELD    chipRun.exp_id,  	      5,    %s,     Exp ID
+FIELD    rawExp.exp_name,             5,    %s,     Exp Name
+FIELD    chipRun.chip_id, 	      5,    %s,     Chip ID
+FIELD    camProcessedExp.cam_id,      5,    %s,     Cam ID
+FIELD    warpSkyCellMap.warp_id,      5,    %s,     Warp ID
+FIELD    warpRun.state,               5,    %s,     State
+FIELD    warpRun.label,               5,    %s,     Label
+FIELD    warpRun.data_group,               5,    %s,     data grp
+FIELD    warpRun.dist_group,               5,    %s,     dist grp
+FIELD    warpSkyCellMap.skycell_id,   5,    %s,     Skycell ID
+FIELD    warpSkyCellMap.tess_id,      5,    %s,     Tessellation ID
+FIELD    warpSkyCellMap.class_id,     5,    %s,     Class ID
+FIELD    rawExp.telescope,            10,   %s,     Telescope
+FIELD    rawExp.camera,               10,   %s,     Camera
+FIELD    rawExp.dateobs,              19,   %T,     Date/Time
+FIELD    rawExp.ra,                    8,   %C, RA,           op=OP1      
+FIELD    rawExp.decl,                  8,   %C, DEC,          op=OP2
+FIELD    rawExp.object,                8,   %s,     Object
+FIELD    rawExp.filter,               10,   %s,     Filter
+FIELD    rawExp.exp_time,              5,   %.2f,   exptime    
+FIELD    rawExp.airmass,               5,   %.4f,   airmass
+FIELD    rawExp.bg,                    5,   %.2f,   bg
+FIELD    rawExp.bg_stdev,              5,   %.2f,   bg_stdev
Index: /branches/sc_branches/ippMonitorLap/def/warpSkyfile.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/warpSkyfile.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/warpSkyfile.d	(revision 31685)
@@ -0,0 +1,12 @@
+TABLE warpSkyfile
+TITLE warpSkyfile
+FILE  warpSkyfile.php
+MENU  ipp.science.dat
+
+#        field          size  format  name       show     link to         extras
+FIELD    warp_id,	 5,   %s,     warp ID
+FIELD    skycell_id,	 5,   %s,     skycell ID
+FIELD    tess_id,	 5,   %s,     tessellation ID
+FIELD    uri,		10,   %s,     URI
+FIELD    bg,		 8,   %s,     background
+FIELD    bg_stdev,       8,   %s,     standard deviation
Index: /branches/sc_branches/ippMonitorLap/def/warpStageExp.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/warpStageExp.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/warpStageExp.d	(revision 31685)
@@ -0,0 +1,46 @@
+TABLE warpRun, fakeRun, camRun, chipRun, rawExp
+TITLE Warp Stage Exposures
+FILE  warpStageExp.php
+MENU  ipp.science.dat
+
+WHERE warpRun.fake_id = fakeRun.fake_id
+WHERE fakeRun.cam_id = camRun.cam_id
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+ARGS  ARG4  fakeRun.fake_id=$fakeRun.fake_id
+ARGS  ARG5  warpRun.warp_id=$warpRun.warp_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                   size  format  name         show    link to         extras
+FIELD rawExp.exp_name,     	 5, %s,     Exp Name
+FIELD rawExp.exp_id,     	 5, %d,     Exp ID,       value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,    	 7, %d,     Chip ID,      value,  chipProcessedImfile.php, ARG2
+FIELD camRun.cam_id,    	 7, %d,     Cam ID,       value,  camProcessedExp.php,     ARG3
+FIELD fakeRun.fake_id,    	 7, %d,     Fake ID,      value,  fakeProcessedImfile.php, ARG4
+FIELD warpRun.warp_id,    	 7, %d,     Warp ID,      value,  warpStageExp.php,        ARG5
+FIELD warpRun.state,    	 7, %s,     state
+FIELD warpRun.label,    	 7, %s,     label
+FIELD warpRun.data_group,    	 7, %s,     data grp
+FIELD warpRun.dist_group,    	 7, %s,     dist grp
+FIELD rawExp.telescope,      	10, %s,     Telescope
+FIELD rawExp.camera,         	10, %s,     Camera
+FIELD rawExp.dateobs,        	19, %T,     Date/Time
+FIELD rawExp.ra,       	         8, %C,     RA,          op=OP1    
+FIELD rawExp.decl,       	 8, %C,     DEC,         op=OP2
+FIELD rawExp.object,         	 8, %s,     Object
+FIELD rawExp.filter,         	10, %s,     FILTER
+FIELD rawExp.exp_time,       	 5, %.2f,   exp_time    
+FIELD rawExp.airmass,        	 5, %.4f,   airmass     
+FIELD rawExp.bg,             	 5, %.2f,   backgnd
+FIELD rawExp.bg_stdev,       	 5, %.2f,   stdev    
+FIELD rawExp.comment,  	        65, %s,     Comment
+
+# FIELD rawExp.bg_mean_stdev,  	 5, %7.2f,  &lt;backgnd&gt;
+# FIELD chipPendingExp.reduction,    20,   reduction
+# FIELD chipPendingExp.guide_id,     20, guide ID
Index: /branches/sc_branches/ippMonitorLap/def/warpStageSkyfileInputs.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/warpStageSkyfileInputs.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/warpStageSkyfileInputs.d	(revision 31685)
@@ -0,0 +1,64 @@
+TABLE warpSkyCellMap, warpRun, fakeRun, camRun, chipRun, rawExp, chipProcessedImfile
+TITLE Warp Stage Skyfile Inputs
+FILE  warpStageSkyfileInputs.php
+MENU  ipp.science.dat
+
+WHERE warpSkyCellMap.warp_id = warpRun.warp_id
+WHERE warpRun.fake_id = fakeRun.fake_id
+WHERE fakeRun.cam_id = camRun.cam_id
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+WHERE chipProcessedImfile.chip_id = chipRun.chip_id
+WHERE chipProcessedImfile.class_id = warpSkyCellMap.class_id
+
+# if no query restrictions are supplied, we want to limit the query or it is extremely long running:
+UNRESTRICTED AND warpRun.warp_id = 0
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+ARGS  ARG4  fakeRun.fake_id=$fakeRun.fake_id
+ARGS  ARG5  warpRun.warp_id=$warpRun.warp_id
+
+ARGS  ARG6  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG6  chipProcessedImfile.class_id=$warpSkyCellMap.class_id
+ARGS  ARG6  camera=$rawExp.camera
+ARGS  ARG6  basename=$chipProcessedImfile.path_base
+ARGS  ARG6  class=$warpSkyCellMap.class_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                    size  format  name         show    link to         extras
+FIELD rawExp.exp_name,     	 10, %s,     Exp Name
+FIELD warpSkyCellMap.class_id,    8, %s,     Class ID,     value,  chipProcessedImfile.php, ARG6
+FIELD rawExp.exp_id,     	  5, %d,     Exp ID,       value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,    	  7, %d,     Chip ID,      value,  chipProcessedImfile.php, ARG2
+FIELD camRun.cam_id,    	  7, %d,     Cam ID,       value,  camProcessedExp.php,     ARG3
+FIELD fakeRun.fake_id,    	  7, %d,     Fake ID,      value,  fakeProcessedImfile.php, ARG4
+FIELD warpRun.warp_id,    	  7, %d,     Warp ID,      value,  warpStageExp.php, ARG5
+FIELD warpRun.state,    	  7, %s,     state
+FIELD warpRun.label,    	  7, %s,     label
+FIELD warpRun.data_group,    	  7, %s,     data grp
+FIELD warpRun.dist_group,    	  7, %s,     dist grp
+FIELD warpSkyCellMap.skycell_id, 10, %s,     skycell
+FIELD warpSkyCellMap.tess_id,    10, %s,     tess
+FIELD warpSkyCellMap.fault,      10, %s,     fault
+FIELD rawExp.telescope,      	 10, %s,     Telescope
+FIELD rawExp.camera,         	 10, %s,     Camera
+FIELD rawExp.dateobs,        	 19, %T,     Date/Time
+FIELD rawExp.ra,       	          8, %C,     RA,          op=OP1    
+FIELD rawExp.decl,       	  8, %C,     DEC,         op=OP2
+FIELD rawExp.object,         	  8, %s,     Object
+FIELD rawExp.filter,         	 10, %s,     FILTER
+FIELD rawExp.exp_time,       	  5, %.2f,   exp_time    
+FIELD rawExp.airmass,        	  5, %.4f,   airmass     
+FIELD rawExp.bg,             	  5, %.2f,   backgnd
+FIELD rawExp.bg_stdev,       	  5, %.2f,   stdev    
+FIELD rawExp.comment,  	         65, %s,     Comment
+
+FIELD chipProcessedImfile.path_base, 65, %s, path_base, none
+
+# FIELD rawExp.bg_mean_stdev,  	 5, %7.2f,  &lt;backgnd&gt;
+# FIELD chipPendingExp.reduction,    20,   reduction
+# FIELD chipPendingExp.guide_id,     20, guide ID
Index: /branches/sc_branches/ippMonitorLap/def/warpStageSkyfiles.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/warpStageSkyfiles.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/warpStageSkyfiles.d	(revision 31685)
@@ -0,0 +1,51 @@
+TABLE warpSkyCellMap, warpRun, fakeRun, camRun, chipRun, rawExp
+TITLE Warp Stage Skyfiles
+FILE  warpStageSkyfiles.php
+MENU  ipp.science.dat
+
+WHERE warpSkyCellMap.warp_id = warpRun.warp_id
+WHERE warpRun.fake_id = fakeRun.fake_id
+WHERE fakeRun.cam_id = camRun.cam_id
+WHERE camRun.chip_id = chipRun.chip_id
+WHERE chipRun.exp_id = rawExp.exp_id
+
+ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
+ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
+ARGS  ARG3  camRun.cam_id=$camRun.cam_id
+ARGS  ARG4  fakeRun.fake_id=$fakeRun.fake_id
+ARGS  ARG5  warpRun.warp_id=$warpRun.warp_id
+ARGS  ARG6  warpSkyfile.skycell_id=$warpSkyCellMap.skycell_id
+
+OP   OP1  $rawExp.ra * 57.295783
+OP   OP2  $rawExp.decl * 57.295783
+
+#     field                    size  format  name         show    link to         extras
+FIELD rawExp.exp_name,     	  5, %s,     Exp Name
+FIELD rawExp.exp_id,     	  5, %d,     Exp ID,       value,  rawImfile.php,           ARG1
+FIELD chipRun.chip_id,    	  7, %d,     Chip ID,      value,  chipProcessedImfile.php, ARG2
+FIELD camRun.cam_id,    	  7, %d,     Cam ID,       value,  camProcessedExp.php,     ARG3
+FIELD fakeRun.fake_id,    	  7, %d,     Fake ID,      value,  fakeProcessedImfile.php, ARG4
+FIELD warpRun.warp_id,    	  7, %d,     Warp ID,      value,  warpStageExp.php, ARG5
+FIELD warpSkyCellMap.skycell_id, 10, %s,     skycell,      value,  warpProcessedSkyfiles.php, ARG6
+FIELD warpRun.state,    	  7, %s,     state
+FIELD warpRun.label,    	  7, %s,     label
+FIELD warpRun.data_group,    	  7, %s,     data grp
+FIELD warpRun.dist_group,    	  7, %s,     dist grp
+FIELD warpSkyCellMap.tess_id,    10, %s,     tess
+FIELD warpSkyCellMap.fault,      10, %s,     fault
+FIELD rawExp.telescope,      	 10, %s,     Telescope
+FIELD rawExp.camera,         	 10, %s,     Camera
+FIELD rawExp.dateobs,        	 19, %T,     Date/Time
+FIELD rawExp.ra,       	          8, %C, RA,          op=OP1    
+FIELD rawExp.decl,       	  8, %C, DEC,         op=OP2
+FIELD rawExp.object,         	  8, %s,     Object
+FIELD rawExp.filter,         	 10, %s,     FILTER
+FIELD rawExp.exp_time,       	  5, %.2f,   exp_time    
+FIELD rawExp.airmass,        	  5, %.4f,   airmass     
+FIELD rawExp.bg,             	  5, %.2f,   backgnd
+FIELD rawExp.bg_stdev,       	  5, %.2f,   stdev    
+FIELD rawExp.comment,  	         65, %s,     Comment
+
+# FIELD rawExp.bg_mean_stdev,  	 5, %7.2f,  &lt;backgnd&gt;
+# FIELD chipPendingExp.reduction,    20,   reduction
+# FIELD chipPendingExp.guide_id,     20, guide ID
Index: /branches/sc_branches/ippMonitorLap/def/warpSummary.d
===================================================================
--- /branches/sc_branches/ippMonitorLap/def/warpSummary.d	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/def/warpSummary.d	(revision 31685)
@@ -0,0 +1,21 @@
+TABLE warpRun
+TITLE Warp Summary
+FILE  warpSummary.php
+MENU  ipp.science.dat
+
+# WHERE warp_id > 200 
+
+#     field           size  format  name         show    link to         extras
+FIELD label,    	 15, %s,     label
+FIELD data_group,        10, %s,    data_group
+FIELD workdir,    	 7, %s,     workdir
+FIELD tess_id,    	 7, %s,     tess_id
+FIELD state,    	 7, %s,     state
+FIELD count(state) as n, 7, %d,     count
+
+MODE  summary
+GROUP state
+GROUP label
+GROUP workdir
+GROUP data_group
+GROUP tess_id
Index: /branches/sc_branches/ippMonitorLap/doc/notes.txt
===================================================================
--- /branches/sc_branches/ippMonitorLap/doc/notes.txt	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/doc/notes.txt	(revision 31685)
@@ -0,0 +1,35 @@
+
+Installation:
+
+the code currently requires three (3) hardwired paths to be set before
+installation:
+
+- the DESTBIN directory in the Makefile must be set to the directory
+  in your apache installation where the package will reside
+
+- the database hostname, user, and password must be set in ipp.php
+
+- the location of the ipprc.config file must be specific in
+  getimage.php
+
+** TODO: set these with a configure script.
+
+- to update the mysql database from a dump:
+  * mysql -u root -p
+    create database NAME;
+    grant all on NAME.* to ipp@localhost;
+  * mysql -u ipp NAME -p < DUMPFILE
+
+- norm exp need to use dettool (-toresid ?) to get the list.
+
+- select * from detNormalizedImfile where detid,iteration
+  union select from detStackedImfile where detid,iteration,normalize=0
+  
+- create users table:
+  create database ippadmin;
+  use ippadmin;
+  create table users (username char(20) not null, password varchar(255));
+  insert into users (username, password) values ('eugene', 'test1');
+
+  create table cookies (username char(20) not null, cookie varchar(255));
+  insert into cookies (username, cookie) values ('eugene', 'foobar');
Index: /branches/sc_branches/ippMonitorLap/raw/Login.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/Login.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/Login.php	(revision 31685)
@@ -0,0 +1,61 @@
+<?php 
+
+include 'ipp.php';
+
+if (($_SERVER[REQUEST_METHOD] != 'POST') && ($_SERVER[REQUEST_METHOD] != 'GET')) {
+  menu ('ipp.menu.dat', 'Login', 'ipp.css', '', '');
+  echo "Invalid Client Request<br>\n";
+  menu_end ();
+  exit ();
+}
+
+if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+
+  $ID = checkID ();
+
+  menu ('ipp.menu.dat', 'Login', 'ipp.css', $ID['link'], $ID['proj']);
+
+  $pass = $ID['pass'];
+  $name = $ID['name'];
+  echo "<p>You are currently logged in as $name.<br>\n";
+  echo "Click here to log out.\n";
+  echo "<form action=\"Login.php\" method=\"POST\">\n";
+  echo "<input type=\"hidden\" name=\"pass\" value=\"$pass\">\n";
+  echo "<input type=\"submit\" name=\"logout\" value=\"logout\">\n";
+  echo "</form></p>\n\n";
+  
+  menu_end ();
+  exit ();
+} 
+
+if ($_SERVER[REQUEST_METHOD] == 'POST') { 
+  if (key_exists (login, $_POST)) {
+
+    $ID = checkLogin ();
+
+    menu ('ipp.menu.dat', 'Login', 'ipp.css', $ID['link'], $ID['proj']);
+    echo "Login Accepted\n";
+    menu_end();
+    exit ();
+  }
+
+  if (key_exists (logout, $_POST)) {
+    menu ('ipp.menu.dat', 'Login', 'ipp.css', '', '');
+    echo "You are now logged out<br>\n";
+    logintext ();
+    loginform ("");
+    menu_end ();
+    exit ();
+  }
+
+  // missing a valid POST state (login or logout)
+  menu ('ipp.menu.dat', 'Login', 'ipp.css', '', '');
+  echo "Invalid Client Post Request<br>\n";
+  foreach ($_POST as $key => $value) {
+    echo "$key : $value<br>\n";
+  }
+  menu_end ();
+  exit ();
+}
+
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/SelectProject.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/SelectProject.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/SelectProject.php	(revision 31685)
@@ -0,0 +1,37 @@
+<?php 
+
+include 'ipp.php';
+
+if (($_SERVER[REQUEST_METHOD] != 'POST') && ($_SERVER[REQUEST_METHOD] != 'GET')) {
+  menu ('ipp.menu.dat', 'Select Project', 'ipp.css', '', '');
+  echo "Invalid Client Request<br>\n";
+  menu_end ();
+  exit ();
+}
+
+$ID = checkID ();
+
+if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+  projectform ($ID);
+}
+
+if ($_SERVER[REQUEST_METHOD] == 'POST') { 
+
+  if (key_exists (project, $_POST)) {
+    $myProj = $_POST[proj];
+    $ID['proj'] = $myProj;
+    // validate the existence of the project
+
+    // update ID['link']
+    // $link is attached to every nav link
+    $ID['link'] = "pass=" . $ID['pass'];
+    if ($ID['proj']) {
+      $ID['link'] = $ID['link'] . "&proj=" . $ID['proj'];
+    }
+
+    menu ('ipp.menu.dat', 'Select Project', 'ipp.css', $ID['link'], $ID['proj']);
+    echo "New project is : $myProj<br>\n";
+    menu_end();
+  }
+}
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/cleanTmpDirectory.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/cleanTmpDirectory.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/cleanTmpDirectory.php	(revision 31685)
@@ -0,0 +1,32 @@
+<?php
+
+
+include 'ipp.php';
+
+$ID = checkID ();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+menu('ipp.imfiles.dat', 'Imfile Tables', 'ipp.css', $ID['link'], $ID['proj']);
+
+// document body
+
+
+exec("find /tmp -user apache", $output, $status);
+
+echo "<html><body>\n";
+echo "Cleaning /tmp file (removing all files belonging to user apache)<br><br>\n";
+$count = 0;
+foreach ($output as $key => $value) {
+  echo "Deleting [$value]<br>\n";
+  exec("rm -f $value");
+  $count++;
+}
+echo "<br>/tmp cleaned ($count files were deleted)<br>\n";
+echo "</body></html>\n";
+
+
+menu_end();
+
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/columns_in_db.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/columns_in_db.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/columns_in_db.php	(revision 31685)
@@ -0,0 +1,155 @@
+<?php
+
+$pageTitle = 'Columns in DB Tables';
+
+include 'ipp.php';
+
+$ID = checkID ();
+
+if (! $ID['proj']) { projectform ($ID); }
+
+$db = dbconnect($ID['proj']);
+
+if ($ID['menu']) {
+  $myMenu = $ID['menu'];
+} else {
+  $myMenu = "ipp.menu.dat";
+}
+
+menu($myMenu, $pageTitle, 'ipp.css', $ID['link'], $ID['proj']);
+
+echo "<p> $pageTitle </p>";
+
+// Table names query
+$tableNames = array (
+		     "Label", 
+		     "addMask", 
+		     "addProcessedExp", 
+		     "addRun", 
+		     "calDB", 
+		     "calRun", 
+		     "camMask", 
+		     "camProcessedExp", 
+		     "camRun", 
+		     "chipBackgroundImfile", 
+		     "chipBackgroundRun", 
+		     "chipImfile", 
+		     "chipMask", 
+		     "chipProcessedImfile", 
+		     "chipRun", 
+		     "dbversion", 
+		     "detInputExp", 
+		     "detNormalizedExp", 
+		     "detNormalizedImfile", 
+		     "detNormalizedStatImfile", 
+		     "detProcessedExp", 
+		     "detProcessedImfile", 
+		     "detRegisteredImfile", 
+		     "detResidExp", 
+		     "detResidImfile", 
+		     "detRun", 
+		     "detRunSummary", 
+		     "detStackedImfile", 
+		     "diffInputSkyfile", 
+		     "diffPhotRun", 
+		     "diffPhotSkyfile", 
+		     "diffRun", 
+		     "diffSkyfile", 
+		     "diffSummary", 
+		     "distComponent", 
+		     "distRun", 
+		     "distTarget", 
+		     "dqstatsContent", 
+		     "dqstatsRun", 
+		     "fakeMask", 
+		     "fakeProcessedImfile", 
+		     "fakeRun", 
+		     "flatcorrAddstarLink", 
+		     "flatcorrCamLink", 
+		     "flatcorrChipLink", 
+		     "flatcorrRun", 
+		     "magicDSFile", 
+		     "magicDSRun", 
+		     "magicInputSkyfile", 
+		     "magicMask", 
+		     "magicNodeResult", 
+		     "magicRun", 
+		     "magicTree", 
+		     "minidvodbProcessed", 
+		     "minidvodbRun", 
+		     "newExp", 
+		     "newImfile", 
+		     "publishClient", 
+		     "publishDone", 
+		     "publishRun", 
+		     "pzDataStore", 
+		     "pzDownloadExp", 
+		     "pzDownloadImfile", 
+		     "rawExp", 
+		     "rawImfile", 
+		     "rcDSFileset", 
+		     "rcDestination", 
+		     "rcInterest", 
+		     "rcRun", 
+		     "receiveFile", 
+		     "receiveFileset", 
+		     "receiveResult", 
+		     "receiveSource", 
+		     "stackAssociation", 
+		     "stackAssociationMap", 
+		     "stackInputSkyfile", 
+		     "stackRun", 
+		     "stackSumSkyfile", 
+		     "stackSummary", 
+		     "staticskyInput", 
+		     "staticskyResult", 
+		     "staticskyRun", 
+		     "summitExp", 
+		     "summitImfile", 
+		     "warpBackgroundRun", 
+		     "warpBackgroundSkyfile", 
+		     "warpImfile", 
+		     "warpMask", 
+		     "warpRun", 
+		     "warpSkyCellMap", 
+		     "warpSkyfile", 
+		     "warpSummary", 
+		     );
+
+echo "<b>This script does not do anything but showing the current columns in the various db tables</b><br/><br/>";
+
+foreach ($tableNames as $tIndex => $tableName) {
+  $sql = "show columns from $tableName";
+  $qry = $db->query($sql);
+  if (dberror($qry)) {
+    echo "<b>error reading querying table</b><br>\n";
+    echo "<br><small><b> table query : $sql </b></small><br>\n";
+    menu_end();
+  }
+  $count = 0;
+  $line = "";
+  $values = array();
+  while ($qry->fetchInto($row)) {
+    // print "[".$row[0]."]<br>\n";
+    foreach ($row as $index => $value) {
+      if ($index == 0) {
+	$values[] = $value;
+      }
+    }
+  }
+  // print count($values)."<br>\n";
+  asort($values);
+  // print count($values)."<br>\n";
+  foreach ($values as $index => $value) {
+    // echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$count." => ".$value."<br>";
+    // $line .= "<option value=\"$value\">$count => $value</option>\n";
+    $line .= "<option value=\"$value\">$value</option>\n";
+    $count++;
+  }
+  echo "<b>Table name: $tableName</b><br>\n";
+  echo "Count = $count columns<br>\n";
+  echo "<select name=\"blah\">\n".$line."\n</select><br>\n";
+}
+
+menu_end();
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/czartool_exposures.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/czartool_exposures.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/czartool_exposures.php	(revision 31685)
@@ -0,0 +1,576 @@
+<?php
+include 'ipp.php';
+include 'site.php';
+
+$ID = checkID();
+
+if (! $ID['proj']) { projectform ($ID); }
+$gpc1db = dbconnect($ID['proj']);
+
+$PATH = getenv("PATH");
+putenv("PATH=$BINDIR:$PATH");
+
+$LD_LIBRARY_PATH = getenv("LD_LIBRARY_PATH");
+putenv("LD_LIBRARY_PATH=$LIBDIR:$LD_LIBRARY_PATH");
+
+if ($ID['menu']) {$myMenu = $ID['menu'];}
+else {$myMenu = "ipp.imfiles.dat";}
+
+$pass = $ID['pass'];
+$proj = $ID['proj'];
+$menu = $ID['menu'];
+
+$date = $_POST['date'];
+$survey = $_POST['survey'];
+
+// if no date chosen, use today
+if ($date == "") $date = date("Y-m-d");
+if ($survey == "") $survey = "";
+
+menu($myMenu, 'Exposure summary for '.$date , 'ipp.css', $ID['link'], $ID['proj']);
+
+// set up the form
+echo "<form action=\"czartool_exposures.php\" method=\"POST\">\n";
+
+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 method=post action=czartool_exposures.php?pass=$pass&proj=$proj&date=$date&survey=$survey>";
+echo "<p  align=\"center\"> Current status of all exposures taken on (UTC) <input type=text name=date value='$date'>";
+echo " for survey <input type=text name=survey value='$survey'> (leave blank for all surveys)";
+echo "<input type=submit value=Submit>";
+echo "</p>";
+
+echo "</form>\n";
+
+createTableForThisSurvey($gpc1db, $date, $survey);
+
+menu_end();
+
+###########################################################################
+#
+# Generates a table for the provided survey 
+#
+###########################################################################
+function createTableForThisSurvey($db, $date, $surveyStr) {
+
+    $conditions = "FROM rawExp 
+        LEFT JOIN chipRun USING (exp_id) 
+        LEFT JOIN camRun USING (chip_id) 
+        LEFT JOIN fakeRun USING (cam_id) 
+        LEFT JOIN warpRun USING (fake_id) 
+        LEFT JOIN warpImfile USING (warp_id) 
+        WHERE dateobs LIKE '$date%'
+        AND comment NOT LIKE '%calcite%'
+        AND comment NOT LIKE '%focus%'
+        AND comment NOT LIKE '%pointing%'
+        AND comment NOT LIKE '%stare%'
+        AND comment LIKE '%$surveyStr%'
+        AND exp_type = 'OBJECT'";
+
+    $sql = "SELECT COUNT(DISTINCT exp_id) " . $conditions;
+
+    $qry = $db->query($sql);
+    $qry->fetchInto($count);
+
+    if ($surveyStr == "") $surveyText = "all surveys";
+    else $surveyText = "$surveyStr survey";
+
+    echo "<p  align=\"center\"> Found " . $count[0] . " exposures for $surveyText </p>";
+
+    $chipDist = array(); getChipDist($db, $date, $surveyStr, &$chipDist);
+    $camDist = array(); getCamDist($db, $date, $surveyStr, &$camDist);
+    $warpDist = array(); getWarpDist($db, $date, $surveyStr, &$warpDist);
+    $stackDist = array(); getStackDist($db, $date, $surveyStr, &$stackDist);
+    $stack_hash = array(); getStackProduced($db, $date, $surveyStr, &$stack_hash);
+
+    $wsDiffProduced = array();
+    $ww1DiffProduced = array();
+    getWSDiffDist($db, $date, $surveyStr, &$wsDiffProduced, &$ww1DiffProduced);
+
+    $wsDiffDist = array();
+    $ww1DiffDist = array();
+    getWSAndWW1DiffDist($db, $date, $surveyStr, &$wsDiffDist, &$ww1DiffDist, $wsDiffProduced);
+
+    $ww2DiffDist = array(); getWW2DiffDist($db, $date, $surveyStr, &$ww2DiffDist);
+    $ssDiffDist = array(); getSSDiffDist($db, $date, $surveyStr, &$ssDiffDist);
+
+    $ww2DiffProduced = array(); getWW2DiffProduced($db, $date, $surveyStr, &$ww2DiffProduced);
+    $ssDiffProduced = array(); getSSDiffProduced($db, $date, $surveyStr, &$ssDiffProduced); 
+
+    // create table
+    echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"4\" style=\"font-size:80%\">\n";
+
+    // table headers
+    echo "<tr><td></td>\n";
+    echo "<th></th>";
+    echo "<th></th>";
+    echo "<th></th>";
+    echo "<th></th>";
+    echo "<th>Raw</th>";
+    echo "<th>Chip</th>";
+    echo "<th>Camera</th>";
+    echo "<th>Warp</th>";
+    echo "<th>Stack</th>";
+    echo "<th>Warp-Stack Diff</th>";
+    echo "<th>Warp-Warp1 Diff</th>";
+    echo "<th>Warp-Warp2 Diff</th>";
+    echo "<th>Stack-Stack Diff</th>";
+    echo "<tr><td></td>\n";
+    echo "<th>Exp ID</th>";
+    echo "<th>Exp Name</th>";
+    echo "<th>Filter</th>";
+    echo "<th>Comment</th>";
+    echo "<th>state</th>";
+    echo "<th>state/dist?</th>";
+    echo "<th>state/dist?</th>";
+    echo "<th>state/dist?</th>";
+    echo "<th>total/dist</th>";
+    echo "<th>total/dist</th>";
+    echo "<th>total/dist</th>";
+    echo "<th>total/dist</th>";
+    echo "<th>total/dist</th>";
+
+    $sql = 
+        "SELECT
+        exp_id,
+        exp_name, 
+        filter, 
+        comment, 
+        rawExp.state, 
+        chipRun.state, 
+        camRun.state, 
+        warpRun.state, 
+        COUNT(skycell_id) 
+            $conditions 
+            GROUP BY exp_name;"; 
+            //echo "$sql<br>";
+
+            if ($debug) {echo "$sql<br>";}
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n"; return;}
+
+    // loop through results in order to make html table
+    while ($qry->fetchInto($row)) {
+
+        $exp_id = $row[0];
+        $exp_name = $row[1];
+        $filter = preg_replace("/([a-z]{1})\.[0-9]+/", "$1", $row[2]);
+        $comment = $row[3];
+        $rawExp = $row[4];
+        $chipState = $row[5];
+        $camState = $row[6];
+        $warpState = $row[7];
+
+        echo "<tr><td></td>\n";
+
+        echo "<TD>$exp_id</td>";
+        echo "<TD>$exp_name</td>";
+        echo "<TD>$filter</td>";
+        echo "<TD>$comment</td>";
+        echo "<TD>$rawExp</td>";
+
+        // chip
+        if (!$chipDist[$exp_id]) $chipDistStr = "N";
+        else $chipDistStr = $chipDist[$exp_id];
+        echo "<TD>$chipState/$chipDistStr</td>";
+
+        // cam
+        if (!$camDist[$exp_id]) $camDistStr = "N";
+        else $camDistStr = $camDist[$exp_id];
+        echo "<TD>$camState/$camDistStr</td>";
+
+        // warp
+        if (!$warpDist[$exp_id]) $warpDistStr = "N";
+        else $warpDistStr = $warpDist[$exp_id];
+        echo "<TD>$warpState/$warpDistStr</td>";
+
+        // stack
+        if (!$stack_hash[$exp_id] && !$stackDist[$exp_id]) $stackDistStr = "&nbsp;";
+        else $stackDistStr = $stack_hash[$exp_id] . "/" . $stackDist[$exp_id];
+        $color = getColour($stack_hash[$exp_id], $stackDist[$exp_id]);
+        echo "<TD bgcolor=\"$color\" >$stackDistStr</td>";
+
+        // WS diff
+        if (!$wsDiffProduced[$exp_id] && !$wsDiffDist[$exp_id]) $wsDistStr = "&nbsp;";
+        else $wsDistStr = $wsDiffProduced[$exp_id] . "/" . $wsDiffDist[$exp_id];
+        $color = getColour($wsDiffProduced[$exp_id], $wsDiffDist[$exp_id]);
+        echo "<TD bgcolor=\"$color\" >$wsDistStr</td>";
+
+        // WW1 diff
+        if (!$ww1DiffProduced[$exp_id] && !$ww1DiffDist[$exp_id]) $ww1DistStr = "&nbsp;";
+        else $ww1DistStr = $ww1DiffProduced[$exp_id] . "/" . $ww1DiffDist[$exp_id];
+        $color = getColour($ww1DiffProduced[$exp_id], $ww1DiffDist[$exp_id]);
+        echo "<TD bgcolor=\"$color\" >$ww1DistStr</td>";
+
+        // WW2 dist
+        if (!$ww2DiffProduced[$exp_id] && !$ww2DiffDist[$exp_id]) $ww2DistStr = "&nbsp;";
+        else $ww2DistStr =  $ww2DiffProduced[$exp_id] . "/" . $ww2DiffDist[$exp_id];
+        $color = getColour($ww2DiffProduced[$exp_id], $ww2DiffDist[$exp_id]);
+        echo "<TD bgcolor=\"$color\" >$ww2DistStr</td>";
+
+        // SS dist
+        if (!$ssDiffProduced[$exp_id] && !$ssDiffDist[$exp_id]) $ssDistStr = "&nbsp;";
+        else $ssDistStr = $ssDiffProduced[$exp_id] . "/" . $ssDiffDist[$exp_id];
+        $color = getColour($ssDiffProduced[$exp_id], $ssDiffDist[$exp_id]);
+        echo "<TD bgcolor=\"$color\" >$ssDistStr</td>";
+
+        echo "</tr>\n";
+    }
+
+    echo "</table>\n";
+}
+
+###########################################################################
+#
+# Gets the right cell colour provided number created and distributed 
+#
+###########################################################################
+function getColour($created, $distributed) {
+
+    if ($distributed > 0 && $created > 0 && $distributed % $created != 0) return "red";
+    return "";
+}
+
+###########################################################################
+#
+# Gets count of chips distributed 
+#
+###########################################################################
+function getChipDist($db, $date, $surveyStr, $hash) {
+
+    $sql = "
+        SELECT exp_id, rawExp.state, COUNT(stage_id) 
+        FROM rawExp 
+        LEFT JOIN chipRun USING (exp_id) 
+        LEFT JOIN distRun ON chip_id = stage_id 
+        AND stage = 'chip' 
+        WHERE dateobs like '$date%' 
+        AND exp_type = 'OBJECT' 
+        AND comment LIKE '%$surveyStr%'
+        GROUP BY exp_id;
+    ";
+
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+
+    while ($qry->fetchInto($row)) {
+
+        if ($row[2] > 0) $hash[$row[0]] = "Y";
+        else $hash[$row[0]] = "N";
+    }
+}
+
+###########################################################################
+#
+# Gets count of cams distributed
+#
+###########################################################################
+function getCamDist($db, $date, $surveyStr, $hash) {
+
+    $sql = "
+        SELECT exp_id, rawExp.state, COUNT(stage_id) 
+        FROM rawExp 
+        LEFT JOIN chipRun USING (exp_id) 
+        LEFT JOIN camRun USING (chip_id) 
+        LEFT JOIN distRun ON cam_id = stage_id 
+        WHERE dateobs like '$date%' 
+        AND stage = 'camera' 
+        AND exp_type = 'OBJECT' 
+        AND comment LIKE '%$surveyStr%'
+        GROUP BY exp_id;
+    ";
+
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+
+    while ($qry->fetchInto($row)) {
+
+        if ($row[2] > 0) $hash[$row[0]] = "Y";
+        else $hash[$row[0]] = "N";
+    }
+}
+
+###########################################################################
+#
+# Gets count of warps distributed
+#
+###########################################################################
+function getWarpDist($db, $date, $surveyStr, $hash) {
+
+    $sql = "
+        SELECT exp_id, rawExp.state, COUNT(stage_id) 
+        FROM rawExp 
+        LEFT JOIN chipRun USING (exp_id) 
+        LEFT JOIN camRun USING (chip_id) 
+        LEFT JOIN fakeRun USING (cam_id) 
+        LEFT JOIN warpRun USING (fake_id)
+        LEFT JOIN distRun ON warp_id = stage_id 
+        WHERE dateobs like '$date%' 
+        AND stage = 'warp' 
+        AND exp_type = 'OBJECT' 
+        AND comment LIKE '%$surveyStr%'
+        GROUP BY exp_id;
+    ";
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+
+    while ($qry->fetchInto($row)) {
+
+        if ($row[2] > 0) $hash[$row[0]] = "Y";
+        else $hash[$row[0]] = "N";
+    }
+}
+
+###########################################################################
+#
+# Gets count of stacks distributed
+#
+###########################################################################
+function getStackDist($db, $date, $surveyStr, $hash) {
+
+    $sql = "
+        SELECT exp_id, rawExp.state, COUNT(stage_id) 
+        FROM rawExp 
+        LEFT JOIN chipRun USING (exp_id) 
+        LEFT JOIN camRun USING (chip_id) 
+        LEFT JOIN fakeRun USING (cam_id) 
+        LEFT JOIN warpRun USING (fake_id) 
+        LEFT JOIN stackInputSkyfile USING (warp_id) 
+        LEFT JOIN distRun ON stack_id = stage_id 
+        WHERE dateobs like '$date%' 
+        AND stage = 'stack' 
+        AND exp_type = 'OBJECT' 
+        AND comment LIKE '%$surveyStr%'
+        GROUP BY exp_id;
+    ";
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+
+    while ($qry->fetchInto($row)) {
+
+        if ($row[2] > 0) $hash[$row[0]] = $row[2];
+    }
+}
+
+###########################################################################
+#
+# Gets count of stacks produced
+#
+###########################################################################
+function getStackProduced($db, $date, $surveyStr, $hash) {
+
+    $sql = "
+        SELECT exp_id, rawExp.state, COUNT(stack_id) 
+        FROM rawExp 
+        LEFT JOIN chipRun USING (exp_id) 
+        LEFT JOIN camRun USING (chip_id) 
+        LEFT JOIN fakeRun USING (cam_id) 
+        LEFT JOIN warpRun USING (fake_id) 
+        LEFT JOIN stackInputSkyfile USING (warp_id) 
+        LEFT JOIN stackRun USING (stack_id) 
+        WHERE dateobs like '$date%' 
+        AND exp_type = 'OBJECT' 
+        AND comment LIKE '%$surveyStr%'
+        GROUP BY exp_id;
+    ";
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+
+    while ($qry->fetchInto($row)) {
+
+        if ($row[2] > 0) $hash[$row[0]] = $row[2];
+    }
+}
+
+###########################################################################
+#
+# Gets count of WS and WW1 diffs distributed
+#
+###########################################################################
+function getWSAndWW1DiffDist($db, $date, $surveyStr, $hash1, $hash2, $wsDiffProduced) {
+
+    $sql = "
+        SELECT exp_id, rawExp.state, COUNT(diff_id), stack1 
+        FROM rawExp 
+        LEFT JOIN chipRun USING (exp_id) 
+        LEFT JOIN camRun USING (chip_id) 
+        LEFT JOIN fakeRun USING (cam_id) 
+        LEFT JOIN warpRun USING (fake_id) 
+        LEFT JOIN diffInputSkyfile ON warp_id = warp1 
+        LEFT JOIN distRun ON stage_id = diff_id AND stage = 'diff' 
+        WHERE dateobs like '$date%' 
+        AND exp_type = 'OBJECT' GROUP BY exp_id;
+    ";
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+
+    while ($qry->fetchInto($row)) {
+
+        if ($row[2] > 0) {
+
+            if ($wsDiffProduced[$row[0]] != null)
+                $hash1[$row[0]] = $row[2];
+            else 
+                $hash2[$row[0]] = $row[2];
+        }
+    }
+}
+
+###########################################################################
+#
+# Gets count of WW2 diffs distributed
+#
+###########################################################################
+function getWW2DiffDist($db, $date, $surveyStr, $hash) {
+
+    $sql = "
+        SELECT exp_id, rawExp.state, COUNT(diff_id) 
+        FROM rawExp 
+        LEFT JOIN chipRun USING (exp_id) 
+        LEFT JOIN camRun USING (chip_id) 
+        LEFT JOIN fakeRun USING (cam_id) 
+        LEFT JOIN warpRun USING (fake_id) 
+        LEFT JOIN diffInputSkyfile ON warp_id = warp2 
+        LEFT JOIN distRun ON stage_id = diff_id AND stage = 'diff' 
+        WHERE dateobs like '$date%' 
+        AND comment LIKE '%$surveyStr%'
+        AND exp_type = 'OBJECT' 
+        GROUP BY exp_id
+        ";
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+
+    while ($qry->fetchInto($row)) {
+
+        if ($row[2] > 0) $hash[$row[0]] = $row[2];
+    }
+}
+
+###########################################################################
+#
+# Gets count of SS diffs distributed
+#
+###########################################################################
+function getSSDiffDist($db, $date, $surveyStr, $hash) {
+
+    $sql = "
+        SELECT exp_id, rawExp.state, COUNT(diff_id) 
+        FROM rawExp 
+        LEFT JOIN chipRun USING (exp_id) 
+        LEFT JOIN camRun USING (chip_id) 
+        LEFT JOIN fakeRun USING (cam_id) 
+        LEFT JOIN warpRun USING (fake_id) 
+        LEFT JOIN stackInputSkyfile USING (warp_id) 
+        LEFT JOIN diffInputSkyfile ON stack_id = stack1 
+        LEFT JOIN distRun ON stage_id = diff_id AND stage = 'diff' 
+        WHERE dateobs like '$date%' 
+        AND exp_type = 'OBJECT'
+        AND comment LIKE '%$surveyStr%'
+        GROUP BY exp_id;
+    ";
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+
+    while ($qry->fetchInto($row)) {
+
+        if ($row[2] > 0) $hash[$row[0]] = $row[2];
+    }
+}
+
+###########################################################################
+#
+# Gets count of WW2 diffs produced
+#
+###########################################################################
+function getWW2DiffProduced($db, $date, $surveyStr, $hash) {
+
+    $sql = "
+        SELECT rawExp.exp_id, COUNT(warp2), diff_mode 
+        FROM rawExp, chipRun, camRun, fakeRun, warpRun, diffInputSkyfile, diffRun  
+        WHERE rawExp.exp_id = chipRun.exp_id 
+        AND chipRun.chip_id = camRun.chip_id 
+        AND camRun.cam_id = fakeRun.cam_id 
+        AND fakeRun.fake_id = warpRun.fake_id 
+        AND diffInputSkyfile.warp2 = warpRun.warp_id 
+        AND diffInputSkyfile.diff_id = diffRun.diff_id 
+        AND dateobs like '$date%' 
+        AND exp_type = 'OBJECT' 
+        AND comment LIKE '%$surveyStr%'
+        GROUP BY exp_id, diff_mode
+        ";
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+
+    while ($qry->fetchInto($row)) {
+
+        $hash[$row[0]] = $row[1];
+    }
+}
+
+###########################################################################
+#
+# Gets count of SS diffs produced
+#
+###########################################################################
+function getSSDiffProduced($db, $date, $surveyStr, $hash) {
+
+    $sql = "
+        SELECT exp_id, rawExp.state, COUNT(stack1), diff_mode 
+        FROM rawExp 
+        LEFT JOIN chipRun USING (exp_id) 
+        LEFT JOIN camRun USING (chip_id) 
+        LEFT JOIN fakeRun USING (cam_id) 
+        LEFT JOIN warpRun USING (fake_id) 
+        LEFT JOIN stackInputSkyfile USING (warp_id) 
+        LEFT JOIN diffInputSkyfile ON stack_id = stack1 
+        LEFT JOIN diffRun USING (diff_id) 
+        WHERE dateobs like '$date%' 
+        AND exp_type = 'OBJECT' 
+        AND comment LIKE '%$surveyStr%'
+        GROUP BY exp_id, diff_mode;
+    ";
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+
+    while ($qry->fetchInto($row)) {
+
+        if ($row[2] > 0) $hash[$row[0]] = $row[2];
+    }
+}
+
+###########################################################################
+#
+# Gets count of WS diffs distributed
+#
+###########################################################################
+function getWSDiffDist($db, $date, $surveyStr, $hash1, $hash2) {
+
+    $sql = "
+        SELECT rawExp.exp_id, COUNT(warp1), diff_mode 
+        FROM rawExp, chipRun, camRun, fakeRun, warpRun, diffInputSkyfile, diffRun  
+        WHERE rawExp.exp_id = chipRun.exp_id 
+        AND chipRun.chip_id = camRun.chip_id 
+        AND camRun.cam_id = fakeRun.cam_id 
+        AND fakeRun.fake_id = warpRun.fake_id 
+        AND diffInputSkyfile.warp1 = warpRun.warp_id 
+        AND diffInputSkyfile.diff_id = diffRun.diff_id 
+        AND dateobs like '$date%' 
+        AND exp_type = 'OBJECT' 
+        AND comment LIKE '%$surveyStr%'
+        GROUP BY exp_id, diff_mode
+        ";
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+    $hash = array();
+    while ($qry->fetchInto($row)) {
+
+        if ($row[2] == 2) $hash1[$row[0]] = $row[1];
+        else  $hash2[$row[0]] = $row[1];
+    }
+}
+
+
+
Index: /branches/sc_branches/ippMonitorLap/raw/czartool_getplot.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/czartool_getplot.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/czartool_getplot.php	(revision 31685)
@@ -0,0 +1,39 @@
+<?php
+
+$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 ();
+}
+
+$type = $_GET[type];
+$label = $_GET[label];
+$stage = $_GET[stage];
+$plottype = $_GET[plottype];
+
+if ($type=="t" || $type=="r" || $type=="rt" || $type=="rh")
+$filePath = "/tmp/czarplot_".$plottype."_".$label."_".$stage."_".$type.".png";
+else if ($type=="h")
+$filePath = "/tmp/czarplot_".$plottype."_".$label."_all_stages_".$type.".png";
+else if ($type=="s")
+$filePath = "/tmp/czarplot_hosts_space.png";
+else if ($type=="st")
+$filePath = "/tmp/czarplot_cluster.png";
+
+
+$file = fopen ($filePath, "r");
+if ($file && !$debug) {
+    header ('Content-Type: image/png');
+    fpassthru ($file);
+}
+
+
+exit();
+
+?>
+~                                 
Index: /branches/sc_branches/ippMonitorLap/raw/czartool_labels.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/czartool_labels.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/czartool_labels.php	(revision 31685)
@@ -0,0 +1,900 @@
+<?php
+include 'ipp.php';
+include 'site.php';
+
+$ID = checkID();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+//$db = dbconnect($ID['proj']);
+$czardb = dbconnect("czardb"); // HACK to connect to czarDb 
+$lastUpdateTime = getLastUpdateTime($czardb);
+
+$gpc1db = dbconnect($ID['proj']);
+
+
+$PATH = getenv("PATH");
+putenv("PATH=$BINDIR:$PATH");
+
+$LD_LIBRARY_PATH = getenv("LD_LIBRARY_PATH");
+putenv("LD_LIBRARY_PATH=$LIBDIR:$LD_LIBRARY_PATH");
+
+
+if ($ID['menu']) {$myMenu = $ID['menu'];}
+else {$myMenu = "ipp.imfiles.dat";}
+
+menu($myMenu, 'Czartool on '.$lastUpdateTime, 'ipp.css', $ID['link'], $ID['proj']);
+
+$states=array("full","new","drop","wait");
+$stages=array("burntool", "chip","cam","fake","warp","stack","diff","magic","magicDS","dist", "pub");
+$servers=array(
+        "addstar",
+        "cleanup",
+        "detrend",
+        "distribution",
+        "pstamp",
+        "update",
+        "publishing",
+        "registration",
+        "replication",
+        "stdscience",
+        "summitcopy");
+
+$pass = $ID['pass'];
+$proj = $ID['proj'];
+$menu = $ID['menu'];
+
+$selectedStage = $_GET[stage];
+$selectedLabel = $_GET[label];
+$selectedServer = $_GET[server];
+$selectedRevertStage = $_GET[revertstage];
+$selectedRevertMode = $_GET[revertmode];
+$plotType = $_GET[plottype];
+$serverCmd = $_GET[servercmd];
+$allServerCmd = $_GET[allservercmd];
+
+if ($selectedLabel == "") { $selectedLabel = "all_stdscience_labels"; }
+if ($selectedStage == "") { $selectedStage = "all_stages"; }
+if ($plotType == "") { $plotType = "linear"; }
+
+// deal with reverts: turn on or off if requested and pass current revert state for this stage onto labels table later
+if ($selectedRevertStage && $selectedRevertMode) turnRevertsOnOff($czardb, $selectedRevertStage, $selectedRevertMode);
+
+// tell selected server to stop or run
+if ($selectedServer && $serverCmd) serverStopRun($czardb, $selectedServer,  $serverCmd);
+
+// tell all servers to stop or run
+if ($allServerCmd) {
+
+    foreach ($servers as &$server) serverStopRun($czardb, $server,  $allServerCmd);
+}
+
+
+$debug = 0;
+
+$stdsLabels = getLabels($czardb, "stdscience");
+$distLabels = getLabels($czardb, "distribution");
+$pubLabels = getLabels($czardb, "publishing");
+$updateLabels = getLabels($czardb, "update");
+
+if ($debug) {
+    echo "prog returned $status, and output:<br>";
+    for ($i = 0; $i < count($distLabels); $i++) {
+        echo "$distLabels[$i]<br>";
+    }
+}
+
+
+// set up the form
+echo "<form action=\"czartool_labels.php\" method=\"POST\">\n";
+
+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";
+
+echo "<table border=\"0\">";
+
+echo "<tr>";
+echo "<td colspan=\"2\" style=\"background-color:#0080c0;\">";
+echo "<h1 align=\"middle\">Czartool</h1>";
+echo "</td>";
+echo "</tr>";
+
+echo "<tr valign=\"top\">";
+echo "<td style=\"background-color:#EEEEEE;width:100px;text-align:top;\">";
+ # time series plot
+ echo "<img src=\"czartool_getplot.php?type=t&label=$selectedLabel&stage=$selectedStage&plottype=$plotType\"><br>";
+ # rate time series plot
+ echo "<img src=\"czartool_getplot.php?type=rt&label=$selectedLabel&stage=$selectedStage&plottype=linear\"><br>";
+ # rate stacked histo plot
+ echo "<img src=\"czartool_getplot.php?type=rh&label=$selectedLabel&stage=$selectedStage&plottype=linear\"><br>";
+ # histogram plot
+ echo "<img src=\"czartool_getplot.php?type=h&label=$selectedLabel&stage=$selectedStage&plottype=linear\"><br>";
+ # storage timeseries
+ echo "<img src=\"czartool_getplot.php?type=st\"><br>";
+ # storage plot
+ echo "<img src=\"czartool_getplot.php?type=s\"><br>";
+ # pantasks server status, if requested
+ if ($selectedServer && !$serverCmd) showServerStatus($selectedServer);
+echo "</td>";
+echo "<td style=\"background-color:#EEEEEE;height:200px;width:400px;text-align:top;\">";
+
+echo "<br><br>";
+
+// status table at top
+$nsStatus = getNightlyScienceStatus($czardb);
+$plotTypeLink = ($plotType == "linear") ? "log" : "linear";
+$link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=" . $selectedLabel . "&stage=" . $selectedStage . "&revertstage=" . $stage . "&plottype=$plotTypeLink";
+echo "<table align=\"middle\" border=\"1\" cellspacing=\"0\" cellpadding=\"4\" style=\"font-size:80%\">\n";
+echo "<tr>\n";
+echo "<tr><td>Time of last update</td><td>$lastUpdateTime</td></tr>";
+echo "<tr><td>ippMonitor SVN version</td><td>"; include 'version.php'; echo "</td></tr>"; 
+echo "<tr><td>Current nightly science status</td><td>$nsStatus</td></tr>"; 
+echo "<tr><td>Postage stamp server status</td><td><a href=\"http://pstamp.ipp.ifa.hawaii.edu/status.php\"><font color=\"blue\">here</font></a></td></tr>";
+echo "<tr><td>Documentation</td><td><a href=\"http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/Processing\"><font color=\"blue\">here</font></a></td></tr>";
+echo "<tr><td>Cluster load</td><td><a href=\"http://ganglia.pan-starrs.ifa.hawaii.edu/?r=hour&s=descending&c=IPP%2520Production\"><font color=\"blue\">here</font></a></td></tr>";
+echo "<tr><td>Who's using the cluster?</td><td><a href=\"http://ipp004.ifa.hawaii.edu/clusterMonitor/top.html\"><font color=\"blue\">here</font></a></td></tr>";
+echo "<tr><td>IPP metrics</td><td><a href=\"http://ipp004.ifa.hawaii.edu/ippMetrics\"><font color=\"blue\">here</font></a></td></tr>";
+echo "<tr><td>Czar log pages</td><td><a href=\"http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/PS1_IPP_CzarLogs\"><font color=\"blue\">here</font></a></td></tr>";
+echo "<tr><td>Exposure summary</td><td><a href=\"czartool_exposures.php?pass=$pass&proj=$proj\"><font color=\"blue\">here</font></a></td></tr>";
+echo "</table>\n";
+
+echo "<br><br>";
+
+       createLabelsTable($pass, 
+         $proj, 
+         $czardb, 
+         "stdscience", 
+         $stdsLabels, 
+         $distLabels, 
+         $pubLabels, 
+         $stages, 
+         $states, 
+         "new", 
+         $selectedLabel, 
+         $selectedStage, 
+         $plotType);
+
+echo "<br><br>";
+      createLabelsTable($pass, 
+         $proj, 
+         $czardb, 
+         "update", 
+         $updateLabels, 
+         $distLabels, 
+         $pubLabels, 
+         $stages, 
+         $states, 
+         "new", 
+         $selectedLabel, 
+         $selectedStage, 
+         $plotType);
+echo "<br><br>";
+      createServersTable($pass, $proj,$czardb, $servers, $selectedLabel, $selectedStage, $plotType);
+echo "<br><br>";
+      createSummitDataTable($gpc1db);
+echo "<br><br>";
+      createDatesTable($czardb);
+echo "<br><br>";
+      createPStampDataTable();
+echo "<br><br>";
+      # This is awful
+      echo "<table align=\"middle\" border=\"1\" cellspacing=\"0\" cellpadding=\"4\" style=\"font-size:80%\">\n";
+      echo "<tr>";
+      echo "<th colspan=\"2\">Database replication status (update fix log <a href=\"http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/Replication_Issues\">here</a>)</th>";
+      echo "<tr>";
+      echo "<th>Database</th>";
+      echo "<th>Status</th>";
+      showReplicationsStatus($REPL_HOST_GPC1, $REPL_USER_GPC1, $REPL_PASSWORD_GPC1, $REPL_DBNAME_GPC1);
+      showReplicationsStatus($REPL_HOST_NEBULOUS, $REPL_USER_NEBULOUS, $REPL_PASSWORD_NEBULOUS, $REPL_DBNAME_NEBULOUS);
+      showReplicationsStatus($REPL_HOST_PSTAMP, $REPL_USER_PSTAMP, $REPL_PASSWORD_PSTAMP, $REPL_DBNAME_PSTAMP);
+      showReplicationsStatus($REPL_HOST_IPPADMIN, $REPL_USER_IPPADMIN, $REPL_PASSWORD_IPPADMIN, $REPL_DBNAME_IPPADMIN);
+      echo "</table>";
+
+echo "</table>";
+
+menu_end();
+
+
+###########################################################################
+#
+# Creates a postage stamp status table
+#
+###########################################################################
+function createPStampDataTable() {
+
+    $sql = "SELECT label, COUNT(job_id) AS 'Unfinished Jobs', IFNULL(priority,10000) AS priority FROM pstampRequest JOIN pstampJob USING(req_id) LEFT JOIN Label USING(label) WHERE pstampJob.state ='run' and pstampRequest.state ='run' GROUP by label";
+
+    $pstampdb = DB::connect("mysql://ippuser:ippuser@ippc17/ippRequestServer");
+    $qry = $pstampdb->query($sql);
+    if (dberror($qry)) {
+        echo "<b>error reading pstamp table</b><br>\n";
+        echo "<br><small><b> table query : $sql </b></small><br>\n";
+        menu_end();
+    }
+
+    // set up the table
+    echo "<table align=\"middle\" border=\"1\" cellspacing=\"0\" cellpadding=\"4\" style=\"font-size:80%\">\n";
+    echo "<tr>";
+    echo "<th colspan=\"3\">Postage stamp requests</th>";
+    echo "<tr>";
+    echo "<th>Label</th>";
+    echo "<th>Unfinished jobs</th>";
+    echo "<th>Priority</th>";
+
+    // list the results
+    while ($qry->fetchInto($row)) {
+
+        echo "<tr>";
+
+        echo "<td>$row[0]</td>";
+        echo "<td>$row[1]</td>";
+        echo "<td>$row[2]</td>";
+        
+        echo "</tr>";
+    }
+
+    echo "</table>\n";
+
+}
+
+###########################################################################
+#
+# Creates a table of summitExp against rawExp
+#
+###########################################################################
+function createSummitDataTable($gpc1db) {
+
+    $date = date("Y-m-d");
+    $sql = "SELECT DISTINCT exp_type FROM summitExp WHERE dateobs > '$date'";
+
+    $qry = $gpc1db->query($sql);
+    if (dberror($qry)) {
+        echo "<b>error reading newExp table</b><br>\n";
+        echo "<br><small><b> table query : $sql </b></small><br>\n";
+        menu_end();
+    }
+
+    // set up the table
+    echo "<table align=\"middle\" border=\"1\" cellspacing=\"0\" cellpadding=\"4\" style=\"font-size:80%\">\n";
+    echo "<tr>";
+    echo "<th colspan=\"3\">Status of last night's data</th>";
+    echo "<tr>";
+    echo "<th>Exposure type</th>";
+    echo "<th>At summit</th>";
+    echo "<th>Registered at MHPCC</th>";
+
+    $msg = "No science images taken since $date";
+
+    // list the results
+    while ($qry->fetchInto($expType)) {
+
+        $sql = "SELECT COUNT(*) FROM summitExp WHERE dateobs > '$date' AND exp_type = '$expType[0]'";
+        $qry2 = $gpc1db->query($sql);
+        $qry2->fetchInto($summit);
+        $sql = "SELECT COUNT(*) FROM summitExp JOIN rawExp ON summitExp.exp_name = rawExp.exp_name WHERE summitExp.dateobs > '$date' AND summitExp.exp_type = '$expType[0]'";
+        $qry2 = $gpc1db->query($sql);
+        $qry2->fetchInto($mhpcc);
+
+        echo "<tr>";
+
+        if ($summit[0] == $mhpcc[0]) {
+
+            if ($expType[0] == "OBJECT") $msg = "All science exposures taken since $date<br>have been registered at MHPCC";
+            $error = 0;
+        }
+        else {
+            if ($expType[0] == "OBJECT") $msg = "<font color=\"red\">Warning: Not all science exposures taken since $date<br>have been registered at MHPCC</a>";
+            $error = 1;
+        }
+
+        echo "<td>$expType[0]</td>";
+        echo "<td>$summit[0]</td>";
+        
+
+
+        #echo "<td bgcolor=\"$color\">$mhpcc[0]</td>";
+        createFormattedTableCell("", "", $mhpcc[0], $error);
+
+        echo "</tr>";
+    }
+
+    echo "<td colspan=\"3\">$msg</td>";
+    echo "</table>\n";
+
+}
+
+###########################################################################
+#
+# Gets labels for this server
+#
+###########################################################################
+function getLabels($db, $server) {
+
+    # order by descending priority as set in gpc1 database
+    $sql = "SELECT label FROM current_labels WHERE server LIKE '$server' ORDER BY priority DESC";
+    if ($debug) {echo "$sql<br>";}
+
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+    while ($qry->fetchInto($row)) {
+
+        $labels[] = $row[0];
+    }
+
+    return $labels;
+}
+
+###########################################################################
+#
+# Creates table for all labels showing all stages for given 'state'
+#
+###########################################################################
+function createLabelsTable(
+        $pass, 
+        $proj, 
+        $db, 
+        $server, 
+        $labels, 
+        $distLabels, 
+        $pubLabels, 
+        $stages, 
+        $states, 
+        $selectedState, 
+        $selectedLabel, $selectedStage, $plotType) {
+
+    // setup table
+    echo "<table align=\"middle\" border=\"1\" cellspacing=\"0\" cellpadding=\"4\" style=\"font-size:80%\">\n";
+    echo "<tr>\n";
+    echo "<th colspan=\"13\">";
+    
+    $link = "czartool_labels.php?pass=".$pass
+        ."&proj=".$proj
+        ."&label=".$selectedLabel
+        ."&stage=all_stages"
+        ."&plottype=".$plotType;
+    if ($selectedStage != "all_stages") echo "<a href=\"$link\"><font color=\"blue\">";
+    else echo "<a><font color=\"black\">";
+    echo "Plot all stages</font></a> | ";
+    $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=all_".$server."_labels&stage=".$selectedStage."&plottype=".$plotType;
+    echo "<a ";
+    if ($selectedLabel != "all_".$server."_labels") echo "<a href=\"$link\"><font color=\"blue\">";
+    else echo "<a><font color=\"black\">";
+    echo "Plot all ".$server."_labels</a> | ";
+    $plotTypeLink = ($plotType == "linear") ? "log" : "linear";
+    $plotTypeText = ($plotType == "linear") ? "Use log plots" : "Use linear plots";
+    $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=" . $selectedLabel . "&stage=" . $selectedStage . "&revertstage=" . $stage . "&plottype=$plotTypeLink";
+    echo "<a href=\"$link\"><font color=\"blue\">$plotTypeText</font></a>";
+
+
+    echo "</th>";
+    echo "</tr>\n";
+
+    echo "<tr>\n";
+    //echo "<th></th>";
+    echo "<th colspan=\"2\">$server server</th>";
+    echo "<th>Reverts:</th>";
+
+    foreach ($stages as &$stage) {
+
+        if ($stage == "burntool") continue;
+        $reverting = getRevertStatus($db, $stage);
+        $link = 
+            "czartool_labels.php?pass=".$pass
+            ."&proj=".$proj
+            ."&label=".$selectedLabel
+            ."&stage=".$selectedStage
+            ."&plottype=".$plotType
+            ."&revertstage=".$stage
+            ."&revertmode=";
+
+        if(!$reverting) {$label =  "Start";$link = $link . "on";}
+        if($reverting) {$label = "Stop";$link = $link . "off";}
+        unset($reverting);
+        echo "<td><a href=\"$link\"><font color=\"blue\">$label</font></td>";
+
+    }
+
+    echo "</tr>\n";
+    echo "<tr>\n";
+    //echo "<th> </th>";
+    echo "<th colspan=\"2\">Label (in order of priority)</th>";
+    foreach ($stages as &$stage) {
+
+        if ($stage == $selectedStage) $showLink = 0;
+        else $showLink = 1;
+        $link = 
+            "czartool_labels.php?pass=".$pass
+            ."&proj=".$proj 
+            ."&label=".$selectedLabel
+            ."&stage=".$stage
+            ."&plottype=".$plotType;
+
+        createFormattedTableCell($showLink, $link, $stage, 0);
+    }
+
+
+    // setup default link
+    $defaultlink = 
+        "czartool_labels.php?pass=".$pass
+        ."&proj=".$proj
+        ."&label=".$selectedLabel
+        ."&stage=".$selectedStage
+        ."&plottype=".$plotType;
+
+    $searchState = "new";
+    if ($server == "update") $searchState = "update";
+
+    // write rows
+    foreach ($labels as &$thisLabel) {
+
+        $distributing = false;
+        $publishing = false;
+        foreach ($distLabels as &$distLabel) {
+
+            if ($thisLabel == $distLabel) { $distributing = true; break;}
+        }
+        foreach ($pubLabels as &$pubLabel) {
+
+            if ($thisLabel == $pubLabel) { $publishing = true; break;}
+        }
+
+        // show distribution/publishing status
+        echo "<tr>\n";
+        $distPub = "&nbsp;";
+        if ($distributing) $distPub = "D";
+        if ($publishing) $distPub = $distPub . "P";
+        echo "<td>$distPub</td>";
+
+        // create link to label summary page for each label
+        if ($thisLabel == $selectedLabel) $showLink = 0;
+        else $showLink = 1;
+        $link = 
+            "czartool_labels.php?pass=".$pass
+            ."&proj=".$proj
+            ."&label=".$thisLabel
+            ."&stage=".$selectedStage
+            ."&plottype=".$plotType;
+        createFormattedTableCell($showLink, $link, $thisLabel, 0);
+
+        $str = "";
+        $anyFaults = false; 
+
+        $link = $defaultlink;
+        getStateAndFaults($db, $thisLabel, $selectedState, "burntool", $str, $anyFaults);
+        createFormattedTableCell($anyFaults, $link, $str, $anyFaults);
+
+        $link = "failedChipProcessedImfile.php?pass=" . $pass . "&proj=" . $proj . "&chipRun.label=" . $thisLabel . "&chipRun.state=".$searchState;
+        getStateAndFaults($db, $thisLabel, $selectedState, "chip", $str, $anyFaults);
+        createFormattedTableCell($anyFaults, $link, $str, $anyFaults);
+
+        $link = "failedCamProcessedExp.php?pass=" . $pass . "&proj=" . $proj . "&camRun.label=" . $thisLabel . "&camRun.state=".$searchState;
+        getStateAndFaults($db, $thisLabel, $selectedState, "cam", $str, $anyFaults);
+        createFormattedTableCell($anyFaults, $link, $str, $anyFaults);
+
+        $link =  "failedFakeProcessedImfile.php?pass=" . $pass . "&proj=" . $proj . "&fakeRun.label=" . $thisLabel . "&fakeRun.state=".$searchState;
+        getStateAndFaults($db, $thisLabel, $selectedState, "fake", $str, $anyFaults);
+        createFormattedTableCell($anyFaults, $link, $str, $anyFaults);
+
+        $link = "failedWarpSkyfiles.php?pass=" . $pass . "&proj=" . $proj . "&warpRun.label=" . $thisLabel . "&warpRun.state=".$searchState;
+        getStateAndFaults($db, $thisLabel, $selectedState, "warp", $str, $anyFaults);
+        createFormattedTableCell($anyFaults, $link, $str, $anyFaults);
+
+        $link = "failedStackSkyfile.php?pass=" . $pass . "&proj=" . $proj . "&stackRun.label=" . $thisLabel . "&stackRun.state=".$searchState;
+        getStateAndFaults($db, $thisLabel, $selectedState, "stack", $str, $anyFaults);
+        createFormattedTableCell($anyFaults, $link, $str, $anyFaults);
+
+        $link = "failedDiffSkyfile.php?pass=" . $pass . "&proj=" . $proj . "&diffRun.label=" . $thisLabel . "&diffRun.state=".$searchState;
+        getStateAndFaults($db, $thisLabel, $selectedState, "diff", $str, $anyFaults);
+        createFormattedTableCell($anyFaults, $link, $str, $anyFaults);
+
+        $link = $defaultlink;
+        getStateAndFaults($db, $thisLabel, $selectedState, "magic", $str, $anyFaults);
+        createFormattedTableCell($anyFaults, $link, $str, $anyFaults);
+
+        $link = $defaultlink;
+        getStateAndFaults($db, $thisLabel, $selectedState, "magicDS", $str, $anyFaults);
+        createFormattedTableCell($anyFaults, $link, $str, $anyFaults);
+
+        $link = $defaultlink;
+        getStateAndFaults($db, $thisLabel, $selectedState, "dist", $str, $anyFaults);
+        createFormattedTableCell($anyFaults, $link, $str, $anyFaults);
+
+        $link = "publishDone.php?pass=" . $pass . "&proj=" . $proj . "&publishRun.label=" . $thisLabel . "&publishRun.state=".$searchState;
+        getStateAndFaults($db, $thisLabel, $selectedState, "pub", $str, $anyFaults);
+        createFormattedTableCell($anyFaults, $link, $str, $anyFaults);
+
+        echo "</tr>\n";
+    }
+
+    if ($selectedLabel == "all_".$server."_labels") $showLink = 0;
+    else  $showLink = 1;
+    $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=all_".$server."_labels&stage=".$selectedStage."&plottype=".$plotType;
+
+    echo "</tr>\n";
+    echo "</table>\n";
+}
+
+
+###########################################################################
+#
+# Creates table cell with a red background if an error
+#
+###########################################################################
+function createFormattedTableCell($showLink, $link, $str, $error) {
+
+    $fontColor = $error ? "black" : "blue";
+
+    if ($error) echo "<td bgcolor=\"red\">";
+    else  echo "<td>";
+    if ($showLink) echo "<a href=\"$link\"><font color=\"$fontColor\">$str</font></td>";
+    else if ($str) echo "$str</td>";
+    else echo "&nbsp;</td>";
+}
+
+###########################################################################
+#
+# Sets reverts status 
+#
+###########################################################################
+function setRevertStatus($db, $stage, $reverting) {
+
+    $sql = "UPDATE reverts SET reverting = $reverting WHERE stage LIKE '$stage'";
+    if ($debug) {echo "$sql<br>";}
+
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+}
+
+###########################################################################
+#
+# Returns current nightly science status 
+#
+###########################################################################
+function getNightlyScienceStatus($db) {
+
+    $sql = "SELECT status FROM nightlyscience";
+    if ($debug) {echo "$sql<br>";}
+
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+    $qry->fetchInto($row);
+
+    return $row[0];
+}
+
+###########################################################################
+#
+#  Turns reverts on or off for a given task
+#
+###########################################################################
+function turnRevertsOnOff($db, $stage, $mode) {
+
+    exec("czartool_revert.pl -t $stage -o $mode", $response, $status);
+    $currentRevertMode;
+    if ($response[0] == "off") $currentRevertMode = 0;
+    else if ($response[0] == "on") $currentRevertMode = 1;
+
+    setRevertStatus($db, $stage, $currentRevertMode);
+}
+
+###########################################################################
+#
+# Returns whether this stage is reverting or not
+#
+###########################################################################
+function getRevertStatus($db, $stage) {
+
+    $anyFaults = false;
+
+    $sql = "SELECT reverting FROM reverts WHERE stage LIKE '$stage'";
+    if ($debug) {echo "$sql<br>";}
+
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+    $qry->fetchInto($row);
+
+    return $row[0];
+}
+
+###########################################################################
+#
+# Returns state and fault-count (if new) as a string
+#
+###########################################################################
+function getStateAndFaults($db, $label, $state, $stage, &$str, &$anyFaults) {
+
+    $anyFaults = false;
+    $sql = "SELECT pending, faults FROM $stage WHERE label LIKE '$label' ORDER BY timestamp DESC LIMIT 1";
+    if ($debug) {echo "$sql<br>";}
+
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+    $qry->fetchInto($row);
+
+    $pending = $row[0];
+    $faults = $row[1];
+
+    if ($pending == 0)
+        $str = "";
+    else
+        $str = "$pending";
+
+    if ($state == "new") {
+
+        if ($faults > 0) {
+
+            $str = $str."(".$faults.")";
+            $anyFaults = true;
+        }
+    }
+}
+
+###########################################################################
+#
+# Populates a tables with the current dates listed in the server_dates table 
+#
+###########################################################################
+function createDatesTable($db) {
+
+    echo "<table align=\"middle\" border=\"1\" cellspacing=\"0\" cellpadding=\"4\" style=\"font-size:80%\">\n";
+    echo "<tr>\n";
+    echo "<th colspan=\"3\">Current dates for selected pantasks servers</th>";
+    echo "<tr>\n";
+    echo "<th>Server</th>";
+    echo "<th>Dates</th>";
+    echo "</tr>\n";
+
+    createServerDateRow($db, "stdscience");
+    createServerDateRow($db, "registration");
+
+    echo "</table>\n";
+}
+
+
+###########################################################################
+#
+# Checks the status of all the pantasks servers 
+#
+###########################################################################
+function createServerDateRow($db, $server) {
+
+    $sql = "SELECT date FROM server_dates WHERE server LIKE '$server' ORDER BY date";
+    if ($debug) {echo "$sql<br>";}
+
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+    $dates = ""; 
+    $firstIn = true;
+    while ($qry->fetchInto($row)) {
+
+        if ($firstIn) {
+
+            $dates = $row[0];
+            $firstIn = false;
+        }
+        else $dates = $dates . ", " . $row[0];
+    }
+
+    echo "<tr>";
+    echo "<td>$server</td>";
+    echo "<td>$dates</td>";
+    echo "</tr>";
+
+}
+
+###########################################################################
+#
+# Checks the status of all the pantasks servers 
+#
+###########################################################################
+function createServersTable($pass, $proj, $db, $servers, $selectedLabel, $selectedStage, $plotType) {
+
+    // set up table columns
+    echo "<table align=\"middle\" border=\"1\" cellspacing=\"0\" cellpadding=\"4\" style=\"font-size:80%\">\n";
+    echo "<tr>";
+    echo "<th colspan=\"3\">Pantasks server status</th>";
+    echo "<tr>";
+    echo "<th>Server</th>";
+    echo "<th>Alive?</th>";
+    echo "<th>Running?</th>";
+
+    //write_header_cell($class, "Server");
+    //write_header_cell($class, "Alive?");
+    //$link = "czartool_labels.php?pass=".$pass
+    //    ."&proj=".$proj
+    //    ."&label=".$selectedLabel
+    //    ."&stage=".$selectedStage
+    //    ."&plottype=".$plotType
+    //    ."&allservercmd=stop";
+
+    //$link = ""; # TODO removed links temporarily
+    //    write_table_cell($class, '%s', $link, "Stop all");
+    //$link = "czartool_labels.php?pass=".$pass
+    //    ."&proj=".$proj
+    //    ."&label=".$selectedLabel
+    //    ."&stage=".$selectedStage
+    //    ."&plottype=".$plotType
+    //    ."&allservercmd=run";
+
+    //$link = ""; # TODO removed links temporarily
+    //    write_table_cell($class, '%s', $link, "Run all");
+    echo "</tr>\n";
+
+    foreach ($servers as &$server) {
+
+        getServerStatus($db, $server, $alive, $running);
+
+        echo "<tr>\n";
+        $link = "czartool_labels.php?pass=".$pass
+            ."&proj=".$proj
+            ."&server=".$server
+            ."&label=".$selectedLabel
+            ."&stage=".$selectedStage
+            ."&plottype=".$plotType;
+
+        #$link = ""; # TODO removed links temporarily
+        //write_table_cell($class, '%s', $link, $server);
+        //write_table_cell($class, '%s', "", $alive ? "yes" : "NO");
+        //echo "<td>$server</td>";
+        createFormattedTableCell(1, $link, $server, 0);
+        createFormattedTableCell(0, "", $alive ? "yes" : "NO", !$alive);
+        createFormattedTableCell(0, "", $running ? "yes" : "NO", !$running);
+
+        //if ($alive) {
+
+          //  $link = "czartool_labels.php?pass=".$pass
+            //    ."&proj=".$proj
+              //  ."&label=".$selectedLabel
+              //  ."&stage=".$selectedStage
+              //  ."&plottype=".$plotType
+              //  ."&server=".$server
+              //  ."&servercmd=";
+
+            //if ($running)  {
+
+              //  $link = $link . "stop";
+              //  $link = ""; # TODO removed links temporarily
+              //      write_table_cell($class, '%s', $link, "stop");
+              //  write_table_cell($class, '%s', "", "");
+           // }
+           // else {
+
+             //   $link = $link . "run";
+              //  write_table_cell($class, '%s', "", "");
+              //  $link = ""; # TODO removed links temporarily
+               //     write_table_cell($class, '%s', $link, "run");
+           // }
+       // }
+       // else {
+
+         //   write_table_cell($class, '%s', "", "");
+         //   write_table_cell($class, '%s', "", "");
+       // }
+        echo "</tr>\n";
+    }
+
+    echo "</table>\n";
+}
+
+###########################################################################
+#
+#  Commands a server to stop or run 
+#
+###########################################################################
+function serverStopRun($db, $server, $cmd) {
+
+    exec("czartool_serverstoprun.pl -s $server -c $cmd", $response, $status);
+    $alive = 0;
+    $running = 0;
+    if ($response[0] == "running") {$alive = 1; $running = 1;}
+    else if ($response[0] == "stopped") {$alive = 1; $running = 0;} 
+    else if ($response[0] == "dead") {$alive = 0; $running = 0;}
+    setServerStatus($db, $server, $alive, $running);
+}
+
+###########################################################################
+#
+# Sets server status 
+#
+###########################################################################
+function setServerStatus($db, $server, $alive, $running) {
+
+    $sql = "INSERT INTO servers (server, alive, running) VALUES ('$server', $alive, $running)";
+
+    if ($debug) {echo "$sql<br>";}
+
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+}
+
+
+###########################################################################
+#
+# Returns state and fault-count (if new) as a string
+#
+###########################################################################
+function getServerStatus($db, $server, &$alive, &$running) {
+
+    $sql = "SELECT alive, running FROM servers WHERE server LIKE '$server' ORDER BY timestamp DESC LIMIT 1";
+    if($debug){echo "$sql<br>";}
+
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+    $qry->fetchInto($row);
+
+    $alive = $row[0];
+    $running = $row[1];
+}
+
+###########################################################################
+#
+# Returns time of last czarDb update 
+#
+###########################################################################
+function getLastUpdateTime($db) {
+
+    $anyFaults = false;
+    $sql = "SELECT timestamp FROM chip ORDER BY timestamp DESC LIMIT 1";
+    if ($debug) {echo "$sql<br>";}
+
+    $qry = $db->query($sql);
+    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
+    $qry->fetchInto($row);
+
+    return $row[0];
+}
+
+###########################################################################
+#
+# Shows the status of the provided pantasks server 
+#
+###########################################################################
+function showServerStatus($server) {
+
+    echo "<p> Status for $server server </p>";
+
+    $results=array();
+    exec("czartool_getServerStatus.pl -s $server", $results, $status);
+
+    foreach ($results as &$line) {
+        echo "<pre>\n";
+        echo "$line\n";
+        echo "</pre>\n";
+
+    }
+}
+
+###########################################################################
+#
+# Shows the status of the various replication mysql servers
+#
+###########################################################################
+function showReplicationsStatus($replHost, $replUser, $replPassword, $replDatabaseName) {
+    #print "<br>$replHost, $replUser, $replPassword, $replDatabaseName<br/>";
+    $dbRepl = DB::connect("mysql://$replUser:$replPassword@$replHost");
+    if (PEAR::isError($dbRepl)) {
+        echo "<tr><td>$replDatabaseName</td><td bgcolor=\"red\">MySQL DB connection error - check configuration</td></tr>";
+        //die("MySQL DB connection error: Check the configuration for $replDatabaseName");
+        die("");
+        return;
+
+    }
+    $res = $dbRepl->query('SHOW SLAVE STATUS');
+    while ($res->fetchInto($row)) {
+        # Have a look for Last_Errno in http://dev.mysql.com/doc/refman/5.0/en/show-slave-status.html
+        $errorStatusInMySql = $row[18];
+        $replStatus = ($errorStatusInMySql==0?"OK":"<font color=\"red\">PROBLEM</font>");
+        echo "<tr><td>$replDatabaseName</td><td>$replStatus</td></tr>";
+        if ($errorStatusInMySql!=0) {
+            echo "<tr><td colspan=\"2\">Connect to $replDatabaseName replication host, execute 'SHOW SLAVE STATUS', and fix the problem.<br/>";
+            echo "Information <a href=\"http://dev.mysql.com/doc/refman/5.0/en/show-slave-status.html\">here</a></td></tr>";
+        }
+    }
+    $dbRepl->disconnect();
+}
+
+?>
+
Index: /branches/sc_branches/ippMonitorLap/raw/czartool_servers.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/czartool_servers.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/czartool_servers.php	(revision 31685)
@@ -0,0 +1,125 @@
+<?php
+include 'ipp.php';
+include 'site.php';
+
+$ID = checkID ();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+$db = dbconnect($ID['proj']);
+
+if ($ID['menu']) {$myMenu = $ID['menu'];}
+else {$myMenu = "ipp.czartool.dat";}
+
+menu($myMenu, 'Czartool', 'ipp.css', $ID['link'], $ID['proj']);
+
+$pass = $ID['pass'];
+$proj = $ID['proj'];
+$menu = $ID['menu'];
+
+$userSelection = $_GET[server];
+
+if ($userSelection == "") {$userSelection = $_POST['state'];}
+if ($userSelection == "") {$userSelection = "new";}
+
+$debug = 0;
+
+$PATH = getenv("PATH");
+putenv("PATH=$BINDIR:$PATH");
+
+$LD_LIBRARY_PATH = getenv("LD_LIBRARY_PATH");
+putenv("LD_LIBRARY_PATH=$LIBDIR:$LD_LIBRARY_PATH");
+
+$servers=array(
+        "addstar", 
+        "cleanup", 
+        "detrend", 
+        "distribution", 
+        "pstamp", 
+        "update", 
+        "publishing", 
+        "registration", 
+        "replication", 
+        "stdscience", 
+        "summitcopy");
+
+// set up the form
+echo "<form action=\"czartool_servers.php\" method=\"POST\">\n";
+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";
+
+
+$serverChosen = 0;
+foreach ($servers as &$server) {
+
+    if ($userSelection == $server) {
+        showServerStatus($server);
+        $serverChosen=1;
+        break;
+    }
+}
+if (!$serverChosen) showAllServerStatus($pass, $proj,$servers);
+
+menu_end();
+
+###########################################################################
+#
+# Shows the status of the provided pantasks server 
+#
+###########################################################################
+function showServerStatus($server) {
+
+    echo "<p> Status for $server server </p>";
+
+    $results=array();
+    exec("czartool_getServerStatus.pl -s $server", $results, $status);
+
+    foreach ($results as &$line) {
+        echo "<pre>\n";
+        echo "$line\n";
+        echo "</pre>\n";
+
+    }
+
+}
+
+###########################################################################
+#
+# Checks the status of all the pantasks servers 
+#
+###########################################################################
+function showAllServerStatus($pass, $proj, $servers) {
+
+    echo "<p> Status for all pantasks servers </p>";
+
+    // set up table columns
+    $class = "list";
+    echo "<table class=$class>\n";
+    echo "<tr><td></td>\n";
+    write_header_cell($class, "Server");
+    write_header_cell($class, "Alive?");
+    write_header_cell($class, "Scheduler running?");
+    echo "</tr>\n";
+
+    foreach ($servers as &$server) {
+
+        $link = "czartool_servers.php?pass=" . $pass . "&proj=" . $proj . "&server=" . $server;
+
+        $results=array();
+        exec("czartool_checkServer.pl -s $server", $results, $status);
+
+        echo "<tr><td></td>\n";
+        write_table_cell($class, '%s', $link, $server);
+        write_table_cell($class, '%s', "", $results[0]);
+        write_table_cell($class, '%s', "", $results[1]);
+        echo "</tr>\n";
+    }
+
+    echo "</table>\n";
+    echo "<p> Click on a server to see its current status </p>";
+
+}
+
Index: /branches/sc_branches/ippMonitorLap/raw/diskUsage.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/diskUsage.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/diskUsage.php	(revision 31685)
@@ -0,0 +1,206 @@
+<?php 
+
+$restricted = 0;
+$TbyteAll = 0;
+
+include 'ipp.php';
+
+function table_section ($db, $WHERE, $TABLE) {
+
+  global $TbytesAll;
+
+  if ("$TABLE" == "rawExp") {
+    # $sql = "SELECT count(exp_id) as n, state, data_state FROM rawExp join rawImfile using (exp_id) $WHERE";
+    $sql = "SELECT count(exp_id) as n, data_state FROM rawImfile where data_state != 'lossy' and data_state != 'missing' group by data_state";
+    # 3GB per exposures (2 copies, compressed)
+    $unitSize = 50;
+  }
+
+  if ("$TABLE" == "chipRun") {
+    # $sql = "SELECT count(chip_id) as n, state, data_state FROM chipRun join chipProcessedImfile using (chip_id) $WHERE";
+    $sql = "SELECT count(chip_id) as n, data_state FROM chipProcessedImfile where data_state != 'cleaned' and data_state != 'purged' and data_state != 'scrubbed' group by data_state";
+    $unitSize = 60;
+  }
+
+  if ("$TABLE" == "warpRun") {
+    # $sql = "SELECT count(warp_id) as n, state, data_state FROM warpRun join warpSkyfile using (warp_id) $WHERE";
+    $sql = "SELECT count(warp_id) as n, data_state FROM warpSkyfile where data_state != 'cleaned' and data_state != 'purged' and data_state != 'scrubbed' group by data_state";
+    $unitSize = 80;
+  }
+
+  if ("$TABLE" == "diffRun") {
+    # $sql = "SELECT count(diff_id) as n, state, data_state FROM diffRun join diffSkyfile using (diff_id) $WHERE";
+    $sql = "SELECT count(diff_id) as n, data_state FROM diffSkyfile where data_state != 'cleaned' and data_state != 'purged' and data_state != 'scrubbed' group by data_state";
+    $unitSize = 80;
+  }
+
+  $FILTER = "distRun.clean = 1 and distRun.state != 'cleaned'";
+  if ("$TABLE" == "distRawClean") {
+    $sql = "SELECT count(dist_id) as n, distRun.state from distRun join distComponent using (dist_id) where distRun.stage = 'raw' and $FILTER group by distRun.state";
+    echo "<b>$sql</b>\n";
+    $unitSize = 0.5;
+  }
+  
+  if ("$TABLE" == "distChipClean") {
+    $sql = "SELECT count(dist_id) as n, distRun.state from distRun join distComponent using (dist_id) where distRun.stage = 'chip' and $FILTER group by distRun.state";
+    $unitSize = 0.5;
+  }
+
+  if ("$TABLE" == "distWarpClean") {
+    $sql = "SELECT count(dist_id) as n, distRun.state from distRun join distComponent using (dist_id) where distRun.stage = 'warp' and $FILTER  group by distRun.state";
+    $unitSize = 0.5;
+  }
+  
+  if ("$TABLE" == "distDiffClean") {
+    $sql = "SELECT count(dist_id) as n, distRun.state from distRun join distComponent using (dist_id) where distRun.stage = 'diff' and $FILTER  group by distRun.state";
+    $unitSize = 0.5;
+  }
+  
+  $FILTER = "distRun.clean = 0 and distRun.state != 'cleaned'";
+  if ("$TABLE" == "distRawFull") {
+    $sql = "SELECT count(dist_id) as n, distRun.state from distRun join distComponent using (dist_id) where distRun.stage = 'raw' and $FILTER  group by distRun.state";
+    $unitSize = 50;
+  }
+  
+  if ("$TABLE" == "distChipFull") {
+    $sql = "SELECT count(dist_id) as n, distRun.state from distRun join distComponent using (dist_id) where distRun.stage = 'chip' and $FILTER  group by distRun.state";
+    $unitSize = 60;
+  }
+  
+  if ("$TABLE" == "distWarpFull") {
+    $sql = "SELECT count(dist_id) as n, distRun.state from distRun join distComponent using (dist_id) where distRun.stage = 'warp' and $FILTER  group by distRun.state";
+    $unitSize = 80;
+  }
+  
+  if ("$TABLE" == "distDiffFull") {
+    $sql = "SELECT count(dist_id) as n, distRun.state from distRun join distComponent using (dist_id) where distRun.stage = 'diff' and $FILTER  group by distRun.state";
+    $unitSize = 80;
+  }
+
+  $qry = $db->query($sql);
+  if (dberror($qry)) {
+    echo "<tr><td><b>error reading $TABLE table</b></td></tr>\n";
+    echo "<tr><td><br><small><b> table query : $sql </b></small></td></tr>\n";
+  }
+  
+  $class = "list";
+  $nlines = 0;
+  
+  $TbytesSum = 0;
+
+  // list the results
+  while ($qry->fetchInto($row)) {
+    echo "<tr><td class=\"$class\"><b>$TABLE</b></td>\n";
+    // ** TABLE DATA **
+
+    $Tbytes = $row[0]*$unitSize/1000000.0;
+    $TbytesSum += $Tbytes;
+    $TbytesAll += $Tbytes;
+
+    write_table_cell ($class, '%s', "", $row[0]);
+    write_table_cell ($class, '%s', "", $row[1]);
+    write_table_cell ($class, '%s', "", $Tbytes);
+    write_table_cell ($class, '%s', "", $TbytesSum);
+    write_table_cell ($class, '%s', "", $TbytesAll);
+    echo "</tr>\n";
+    $nlines ++;
+  }
+  echo "<tr><td class\"$class\">------</td></tr>\n";
+
+  if ($nlines == 0) {
+    echo "<tr><td class\"$class\"><b>$TABLE</b></td><td>no match</td></tr>\n";
+  }
+}
+
+$ID = checkID ();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+$db = dbconnect($ID['proj']);
+
+if ($ID['menu']) {
+  $myMenu = $ID['menu'];
+} else {
+  $myMenu = "ipp.imfiles.dat";
+}
+
+menu($myMenu, 'Disk Usage', 'ipp.css', $ID['link'], $ID['proj']);
+
+echo "<p> Night Summary </p>\n";
+
+// set up the form
+echo "<form action=\"diskUsage.php\" method=\"POST\">\n";
+
+$restricted = 0;
+
+// define restrictions to the queries
+// ** TABLE RESTRICTIONS **
+$WHERE = check_restrict ('state', $WHERE, 'string', 1.0);
+
+// ensure no valid results
+if ($restricted == 0) {
+   $WHERE = "$WHERE WHERE (0 > 1)";
+}
+
+$WHERE = check_ordering ('state,label', $WHERE);
+
+// 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><td></td>\n";
+write_header_cell ("list", "N items");
+write_header_cell ("list", "state");
+write_header_cell ("list", "Tbytes");
+write_header_cell ("list", "Sum(TB)");
+write_header_cell ("list", "All(TB)");
+echo "</tr>\n";
+
+// query restriction form
+// echo "<tr>\n";
+// echo "<td class=list> <input type=\"text\" name=\"expID\"></td>\n";
+// ** TABLE QUERY ** (restictions)
+echo "<tr><td>Dataset</td>\n";
+write_query_row ('N items', 15, 'string');
+write_query_row ('state', 10, 'string');
+write_query_row ('Mbytes', 7, 'string');
+write_query_row ('Sum(MB)', 7, 'string');
+echo "</tr>\n";
+
+// query the database (limit is 10, but should be 1
+table_section($db, $WHERE, "rawExp");
+table_section($db, $WHERE, "chipRun");
+table_section($db, $WHERE, "warpRun");
+table_section($db, $WHERE, "diffRun");
+
+table_section($db, $WHERE, "distRawClean");
+table_section($db, $WHERE, "distChipClean");
+table_section($db, $WHERE, "distWarpClean");
+table_section($db, $WHERE, "distDiffClean");
+
+table_section($db, $WHERE, "distRawFull");
+table_section($db, $WHERE, "distChipFull");
+table_section($db, $WHERE, "distWarpFull");
+table_section($db, $WHERE, "distDiffFull");
+
+// 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: /branches/sc_branches/ippMonitorLap/raw/getimage.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/getimage.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/getimage.php	(revision 31685)
@@ -0,0 +1,128 @@
+<?php
+
+$debug = 0;
+include 'site.php';
+
+// these are defined by site.php
+// global $PERLLIB;
+// global $BINDIR;
+// global $SITE;
+// global $PSCONFDIR
+// global $PSCONFIG
+
+
+### these need to be set to the correct locations!!
+$MISSING = "missing.png";
+
+// load an image file from the image directory
+// validate request
+if ($_SERVER[REQUEST_METHOD] != 'GET') { 
+  exit ();
+}
+
+putenv("PSCONFDIR=$PSCONFDIR");
+putenv("PSCONFIG=$PSCONFIG");
+putenv("PERL5LIB=$PERLLIB:");
+$PATH = getenv("PATH");
+putenv("PATH=$BINDIR:$PATH");
+
+if ($debug) {
+  echo "DEBUG1<br>";
+  echo "args: $args<br>";
+  echo "path: $PATH<br>";
+  echo "perl: $PERLLIB<br>";
+  echo "bindir: $BINDIR<br>";
+  echo "site=$SITE<br>\n";
+}
+
+// $basename may contain filename@filerule
+$basename = $_GET[name];
+if ($basename == "noimage.noimage") {
+  $file = fopen ("noimage.png", "r");//$MISSING?
+  if ($file && !$debug) {
+    # do I need to use image/jpg? can I modify this to image/png, etc, based on the type?
+	   header ('Content-Type: image/jpg');
+    fpassthru ($file);
+  }
+  exit ();
+}
+$filerule = $_GET[rule];
+$camera   = $_GET[camera];
+$class_id = $_GET[class_id];
+
+# $filerule = strtok("@");
+
+if ($debug) {
+  echo "DEBUG2<br>";
+  echo "basename: $basename<br>";
+  echo "filerule: $filerule<br>";
+}
+
+# need to supply the camera as well...
+
+# if ($filerule) {
+#   if ($filerule == "PPIMAGE.JPEG1") {
+#     $basename = "$basename.b1.jpg";
+#   }
+#   if ($filerule == "PPIMAGE.JPEG2") {
+#     $basename = "$basename.b2.jpg";
+#   }
+# }
+# exec ("ipp_datapath.pl --site=$SITE $basename", $output, $status);
+
+# do I need to do this to the output result as well?
+$basename = escapeshellarg($basename);
+$basename = str_replace ('..','',$basename);
+
+if ($debug) {
+  echo "DEBUG3<br>";
+  $output = array();
+  exec ("which $BINDIR/ipp_filename.pl", $output, $status);
+  echo "which $BINDIR/ipp_filename.pl output:<br>";
+  for ($i = 0; $i < count($output); $i++) {
+    echo "output $i: $output[$i]<br>";
+  }
+  echo "status:   $status<br>";
+
+  $output = array();
+  exec ("whoami", $output, $status);
+  echo "which whoami output:<br>";
+  for ($i = 0; $i < count($output); $i++) {
+    echo "output $i: $output[$i]<br>";
+  }
+  echo "status:   $status<br>";
+}
+
+/* --site=$SITE */
+$output = array();
+exec ("ipp_filename.pl --site=$SITE --basename $basename --filerule $filerule --camera $camera --class_id $class_id 2> /tmp/errors", $output, $status);
+
+# use these to check the environment
+# passthru ("env");
+# passthru ("perl --version");
+
+$filename = $output[0];
+if ($status) {
+  $filename = $MISSING;
+}
+
+if ($debug) {
+  echo "DEBUG4<br>";
+  echo "Command = ipp_filename.pl --site=$SITE --basename $basename --filerule $filerule --camera $camera --class_id $class_id<br>\n";
+  echo "basename: $basename<br>";
+  for ($i = 0; $i < count($output); $i++) {
+    echo "output $i: $output[$i]<br>";
+  }
+  echo "status:   $status<br>";
+  echo "filename: $filename<br>";
+  exit ();
+}
+
+$file = fopen ($filename, "r");
+if ($file && !$debug) {
+  # do I need to use image/jpg? can I modify this to image/png, etc, based on the type?
+  header ('Content-Type: image/jpg');
+  fpassthru ($file);
+}
+exit ();
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/getlog.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/getlog.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/getlog.php	(revision 31685)
@@ -0,0 +1,66 @@
+<?php
+
+### these need to be set to the correct locations!!
+$PERLLIB = "/home/kiawe/eugene/psconfig/dev.linux/lib";
+$BINDIR = "/home/kiawe/eugene/psconfig/dev.linux/bin";
+$SITE = "/home/kiawe/eugene/.ipprc";
+$MISSING = "missing.png";
+
+// load an image file from the image directory
+// validate request
+if ($_SERVER[REQUEST_METHOD] != 'GET') { 
+  exit ();
+}
+
+putenv("PERL5LIB=$PERLLIB:");
+$PATH = getenv("PATH");
+putenv("PATH=$BINDIR:$PATH");
+
+# echo "args: $args<br>";
+
+# $basename may contain filename@filerule
+$basename = strtok($_GET[name],"@");
+$filerule = strtok("@");
+
+# echo "basename: $basename<br>";
+# echo "filerule: $filerule<br>";
+
+# need to supply the camera as well...
+
+# if ($filerule) {
+#   if ($filerule == "PPIMAGE.JPEG1") {
+#     $basename = "$basename.b1.jpg";
+#   }
+#   if ($filerule == "PPIMAGE.JPEG2") {
+#     $basename = "$basename.b2.jpg";
+#   }
+# }
+# exec ("ipp_datapath.pl --site=$SITE $basename", $output, $status);
+
+# do I need to do this to the output result as well?
+$basename = escapeshellarg($basename);
+$basename = str_replace ('..','',$basename);
+
+exec ("ipp_filename.pl --site=$SITE --basename $basename --camera $camera --class_id $class_id", $output, $status);
+
+$filename = $output[0];
+if ($status) {
+  $filename = $MISSING;
+}
+
+if (0) {
+  echo "basename: $basename<br>";
+  echo "output:   $output[0]<br>";
+  echo "status:   $status<br>";
+  echo "filename: $filename<br>";
+  exit ();
+}
+
+$file = fopen ($filename, "r");
+if ($file) {
+  # do I need to use image/jpg? can I modify this to image/png, etc, based on the type?
+  header ('Content-Type: image/jpg');
+  fpassthru ($file);
+}
+exit ();
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/histogram.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/histogram.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/histogram.php	(revision 31685)
@@ -0,0 +1,472 @@
+<?php 
+
+$debug = 0;
+
+include 'ipp.php';
+
+$ID = checkID ();
+
+$filesToRemove = array();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+$db = dbconnect($ID['proj']);
+
+if ($ID['menu']) {
+  $myMenu = $ID['menu'];
+} else {
+  $myMenu = "ipp.imfiles.dat";
+}
+
+menu($myMenu, 'Histogram', 'ipp.css', $ID['link'], $ID['proj']);
+
+echo "<p> Histogram </p>";
+
+// set up the form
+echo "<form action=\"histogram.php\" method=\"POST\">\n";
+
+$restricted = 0;
+
+// define restrictiosn to the queries
+// ** TABLE RESTRICTIONS **
+$WHERE = "WHERE camRun.state = 'full' AND camRun.chip_id = chipRun.chip_id AND chipRun.exp_id = rawExp.exp_id AND camProcessedExp.cam_id  = camRun.cam_id AND camProcessedExp.fault = 0";
+$WHERE = check_restrict ('rawExp.exp_name', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('chipRun.label', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('chipRun.data_group', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('chipRun.dist_group', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.dateobs', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.dateobs', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.dateobs', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.filter', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_time', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_time', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.exp_time', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.airmass', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.airmass', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.airmass', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('camProcessedExp.fwhm_major', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('camProcessedExp.fwhm_major', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('camProcessedExp.fwhm_major', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('camProcessedExp.fwhm_minor', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('camProcessedExp.fwhm_minor', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('camProcessedExp.fwhm_minor', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('camProcessedExp.fwhm_major_uq', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('camProcessedExp.fwhm_major_uq', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('camProcessedExp.fwhm_major_uq', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('camProcessedExp.fwhm_major_lq', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('camProcessedExp.fwhm_major_lq', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('camProcessedExp.fwhm_major_lq', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('camProcessedExp.fwhm_minor_uq', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('camProcessedExp.fwhm_minor_uq', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('camProcessedExp.fwhm_minor_uq', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('camProcessedExp.fwhm_minor_lq', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('camProcessedExp.fwhm_minor_lq', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('camProcessedExp.fwhm_minor_lq', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('camProcessedExp.iq_fwhm_major', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('camProcessedExp.iq_fwhm_major', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('camProcessedExp.iq_fwhm_major', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('camProcessedExp.iq_fwhm_minor', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('camProcessedExp.iq_fwhm_minor', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('camProcessedExp.iq_fwhm_minor', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('camProcessedExp.iq_m2', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('camProcessedExp.iq_m2', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('camProcessedExp.iq_m2', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('camProcessedExp.iq_m3', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('camProcessedExp.iq_m3', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('camProcessedExp.iq_m3', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('camProcessedExp.iq_m4', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('camProcessedExp.iq_m4', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('camProcessedExp.iq_m4', $WHERE, 'max', 1.0);
+$WHERE = check_ordering ('', $WHERE);
+
+if ($restricted == 0) {
+  if ("none" != "none") {
+    $WHERE = "$WHERE none";
+  }
+}
+
+// get the result table count
+if (basic == "basic") {
+  $sql = "SELECT count(*) FROM camRun, chipRun, rawExp, camProcessedExp $WHERE";
+}
+if (basic == "summary") {
+  $sql = "SELECT count(*) FROM (SELECT rawExp.exp_name,chipRun.label,chipRun.data_group,chipRun.dist_group,rawExp.dateobs,rawExp.filter,rawExp.exp_time,rawExp.airmass,camProcessedExp.fwhm_major,camProcessedExp.fwhm_minor,camProcessedExp.fwhm_major_uq,camProcessedExp.fwhm_major_lq,camProcessedExp.fwhm_minor_uq,camProcessedExp.fwhm_minor_lq,camProcessedExp.iq_fwhm_major,camProcessedExp.iq_fwhm_minor,camProcessedExp.iq_m2,camProcessedExp.iq_m3,camProcessedExp.iq_m4 FROM camRun, chipRun, rawExp, camProcessedExp $WHERE) as TEMP";
+}
+
+$qry = $db->query($sql);
+if (dberror($qry)) {
+  echo "<b>error reading camRun, chipRun, rawExp, camProcessedExp 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 camRun, chipRun, rawExp, camProcessedExp table count</b><br>\n";
+  echo "<br><small><b> count query : $sql </b></small><br>\n";
+  menu_end();
+}
+// set up the row counter variables
+if ($ID['from']) {
+  $rowStart = $ID['from'];
+} else {
+  $rowStart = 0;
+}
+$rowLast = $rowStart + $dTABLE;
+$rowTotal = $row[0];
+if ($rowLast > $rowTotal) { $rowLast = $rowTotal; }
+echo "<b> $rowStart to $rowLast of $rowTotal items</b><br>\n";
+
+// query the database
+if (basic == "basic") {
+  $sql = "SELECT rawExp.exp_name,chipRun.label,chipRun.data_group,chipRun.dist_group,rawExp.dateobs,rawExp.filter,rawExp.exp_time,rawExp.airmass,camProcessedExp.fwhm_major,camProcessedExp.fwhm_minor,camProcessedExp.fwhm_major_uq,camProcessedExp.fwhm_major_lq,camProcessedExp.fwhm_minor_uq,camProcessedExp.fwhm_minor_lq,camProcessedExp.iq_fwhm_major,camProcessedExp.iq_fwhm_minor,camProcessedExp.iq_m2,camProcessedExp.iq_m3,camProcessedExp.iq_m4 FROM camRun, chipRun, rawExp, camProcessedExp $WHERE";
+}
+if (basic == "summary") {
+  $sql = "SELECT rawExp.exp_name,chipRun.label,chipRun.data_group,chipRun.dist_group,rawExp.dateobs,rawExp.filter,rawExp.exp_time,rawExp.airmass,camProcessedExp.fwhm_major,camProcessedExp.fwhm_minor,camProcessedExp.fwhm_major_uq,camProcessedExp.fwhm_major_lq,camProcessedExp.fwhm_minor_uq,camProcessedExp.fwhm_minor_lq,camProcessedExp.iq_fwhm_major,camProcessedExp.iq_fwhm_minor,camProcessedExp.iq_m2,camProcessedExp.iq_m3,camProcessedExp.iq_m4 FROM camRun, chipRun, rawExp, camProcessedExp $WHERE";
+}
+
+$qry = $db->query($sql);
+if (dberror($qry)) {
+  echo "<b>error reading camRun, chipRun, rawExp, camProcessedExp table</b><br>\n";
+  echo "<br><small><b> table query : $sql </b></small><br>\n";
+  menu_end();
+}
+
+// ** HEAD CODE **
+
+// ** BUTTON RESTRICTIONS **
+$buttonLink = button_restrict_string ('rawExp.exp_name', $buttonLink);
+$buttonLink = button_restrict_string ('chipRun.label', $buttonLink);
+$buttonLink = button_restrict_string ('chipRun.data_group', $buttonLink);
+$buttonLink = button_restrict_string ('chipRun.dist_group', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.dateobs', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.dateobs', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.dateobs', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.filter', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.exp_time', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.exp_time', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.exp_time', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.airmass', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.airmass', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.airmass', $buttonLink);
+$buttonLink = button_restrict_string ('camProcessedExp.fwhm_major', $buttonLink);
+$buttonLink = button_restrict_min ('camProcessedExp.fwhm_major', $buttonLink);
+$buttonLink = button_restrict_max ('camProcessedExp.fwhm_major', $buttonLink);
+$buttonLink = button_restrict_string ('camProcessedExp.fwhm_minor', $buttonLink);
+$buttonLink = button_restrict_min ('camProcessedExp.fwhm_minor', $buttonLink);
+$buttonLink = button_restrict_max ('camProcessedExp.fwhm_minor', $buttonLink);
+$buttonLink = button_restrict_string ('camProcessedExp.fwhm_major_uq', $buttonLink);
+$buttonLink = button_restrict_min ('camProcessedExp.fwhm_major_uq', $buttonLink);
+$buttonLink = button_restrict_max ('camProcessedExp.fwhm_major_uq', $buttonLink);
+$buttonLink = button_restrict_string ('camProcessedExp.fwhm_major_lq', $buttonLink);
+$buttonLink = button_restrict_min ('camProcessedExp.fwhm_major_lq', $buttonLink);
+$buttonLink = button_restrict_max ('camProcessedExp.fwhm_major_lq', $buttonLink);
+$buttonLink = button_restrict_string ('camProcessedExp.fwhm_minor_uq', $buttonLink);
+$buttonLink = button_restrict_min ('camProcessedExp.fwhm_minor_uq', $buttonLink);
+$buttonLink = button_restrict_max ('camProcessedExp.fwhm_minor_uq', $buttonLink);
+$buttonLink = button_restrict_string ('camProcessedExp.fwhm_minor_lq', $buttonLink);
+$buttonLink = button_restrict_min ('camProcessedExp.fwhm_minor_lq', $buttonLink);
+$buttonLink = button_restrict_max ('camProcessedExp.fwhm_minor_lq', $buttonLink);
+$buttonLink = button_restrict_string ('camProcessedExp.iq_fwhm_major', $buttonLink);
+$buttonLink = button_restrict_min ('camProcessedExp.iq_fwhm_major', $buttonLink);
+$buttonLink = button_restrict_max ('camProcessedExp.iq_fwhm_major', $buttonLink);
+$buttonLink = button_restrict_string ('camProcessedExp.iq_fwhm_minor', $buttonLink);
+$buttonLink = button_restrict_min ('camProcessedExp.iq_fwhm_minor', $buttonLink);
+$buttonLink = button_restrict_max ('camProcessedExp.iq_fwhm_minor', $buttonLink);
+$buttonLink = button_restrict_string ('camProcessedExp.iq_m2', $buttonLink);
+$buttonLink = button_restrict_min ('camProcessedExp.iq_m2', $buttonLink);
+$buttonLink = button_restrict_max ('camProcessedExp.iq_m2', $buttonLink);
+$buttonLink = button_restrict_string ('camProcessedExp.iq_m3', $buttonLink);
+$buttonLink = button_restrict_min ('camProcessedExp.iq_m3', $buttonLink);
+$buttonLink = button_restrict_max ('camProcessedExp.iq_m3', $buttonLink);
+$buttonLink = button_restrict_string ('camProcessedExp.iq_m4', $buttonLink);
+$buttonLink = button_restrict_min ('camProcessedExp.iq_m4', $buttonLink);
+$buttonLink = button_restrict_max ('camProcessedExp.iq_m4', $buttonLink);
+
+$buttonLink = button_restrict_checkbox ('hist.exp_time', $buttonLink);
+$buttonLink = button_restrict_checkbox ('hist.airmass', $buttonLink);
+$buttonLink = button_restrict_checkbox ('hist.fwhm_major_psf', $buttonLink);
+$buttonLink = button_restrict_checkbox ('hist.fwhm_minor_psf', $buttonLink);
+$buttonLink = button_restrict_checkbox ('hist.fwhm_uq', $buttonLink);
+$buttonLink = button_restrict_checkbox ('hist.fwhm_lq', $buttonLink);
+$buttonLink = button_restrict_checkbox ('hist.fwhm_major_moments', $buttonLink);
+$buttonLink = button_restrict_checkbox ('hist.fwhm_minor_moments', $buttonLink);
+$buttonLink = button_restrict_checkbox ('hist.fwhm_m2_moment', $buttonLink);
+$buttonLink = button_restrict_checkbox ('hist.fwhm_m3_moment', $buttonLink);
+$buttonLink = button_restrict_checkbox ('hist.fwhm_m4_moment', $buttonLink);
+
+$buttonLink = button_restrict_string ('hist_delta.exp_time', $buttonLink);
+$buttonLink = button_restrict_string ('hist_delta.airmass', $buttonLink);
+$buttonLink = button_restrict_string ('hist_delta.fwhm_major_psf', $buttonLink);
+$buttonLink = button_restrict_string ('hist_delta.fwhm_minor_psf', $buttonLink);
+$buttonLink = button_restrict_string ('hist_delta.fwhm_uq', $buttonLink);
+$buttonLink = button_restrict_string ('hist_delta.fwhm_lq', $buttonLink);
+$buttonLink = button_restrict_string ('hist_delta.fwhm_major_moments', $buttonLink);
+$buttonLink = button_restrict_string ('hist_delta.fwhm_minor_moments', $buttonLink);
+$buttonLink = button_restrict_string ('hist_delta.fwhm_m2_moment', $buttonLink);
+$buttonLink = button_restrict_string ('hist_delta.fwhm_m3_moment', $buttonLink);
+$buttonLink = button_restrict_string ('hist_delta.fwhm_m4_moment', $buttonLink);
+
+navigate_buttons ($rowStart, $rowLast, $dTABLE, $rowTotal, $buttonLink, $ID, 'histogram.php');
+
+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><td></td>\n";
+write_header_cell ("list", "Exp Name");
+write_header_cell ("list", "Label");
+write_header_cell ("list", "data grp");
+write_header_cell ("list", "dist grp");
+write_header_cell ("list", "Date/Time");
+write_header_cell ("list", "FILTER");
+write_header_cell ("list", "exp_time    ");
+write_header_cell ("list", "airmass     ");
+write_header_cell ("list", "fwhm major psf");
+write_header_cell ("list", "fwhm minor psf");
+write_header_cell ("list", "fwhm UQ");
+write_header_cell ("list", "fwhm LQ");
+write_header_cell ("list", "fwhm major moments");
+write_header_cell ("list", "fwhm minor moments");
+write_header_cell ("list", "m2 moment");
+write_header_cell ("list", "m3 moment");
+write_header_cell ("list", "m4 moment");
+echo "</tr>\n";
+
+// query restriction form
+// echo "<tr>\n";
+// echo "<td class=list> <input type=\"text\" name=\"expID\"></td>\n";
+// ** TABLE QUERY **
+echo "<tr><td>&ge;</td>\n";
+write_query_row ('rawExp.exp_name', 5, 'string');
+write_query_row ('chipRun.label', 7, 'string');
+write_query_row ('chipRun.data_group', 7, 'string');
+write_query_row ('chipRun.dist_group', 7, 'string');
+write_query_row ('rawExp.dateobs', 19, 'min');
+write_query_row ('rawExp.filter', 10, 'string');
+write_query_row ('rawExp.exp_time', 5, 'min');
+write_query_row ('rawExp.airmass', 5, 'min');
+write_query_row ('camProcessedExp.fwhm_major', 5, 'min');
+write_query_row ('camProcessedExp.fwhm_minor', 5, 'min');
+write_query_row ('camProcessedExp.fwhm_major_uq', 5, 'min');
+write_query_row ('camProcessedExp.fwhm_major_lq', 5, 'min');
+write_query_row ('camProcessedExp.iq_fwhm_major', 5, 'min');
+write_query_row ('camProcessedExp.iq_fwhm_minor', 5, 'min');
+write_query_row ('camProcessedExp.iq_m2', 5, 'min');
+write_query_row ('camProcessedExp.iq_m3', 5, 'min');
+write_query_row ('camProcessedExp.iq_m4', 5, 'min');
+echo "</tr><tr><td>&le;</td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+write_query_row ('rawExp.dateobs', 19, 'max');
+echo "<td> &nbsp; </td>\n";
+write_query_row ('rawExp.exp_time', 5, 'max');
+write_query_row ('rawExp.airmass', 5, 'max');
+write_query_row ('camProcessedExp.fwhm_major', 5, 'max');
+write_query_row ('camProcessedExp.fwhm_minor', 5, 'max');
+write_query_row ('camProcessedExp.fwhm_major_uq', 5, 'max');
+write_query_row ('camProcessedExp.fwhm_major_lq', 5, 'max');
+write_query_row ('camProcessedExp.iq_fwhm_major', 5, 'max');
+write_query_row ('camProcessedExp.iq_fwhm_minor', 5, 'max');
+write_query_row ('camProcessedExp.iq_m2', 5, 'max');
+write_query_row ('camProcessedExp.iq_m3', 5, 'max');
+write_query_row ('camProcessedExp.iq_m4', 5, 'max');
+echo "</tr>\n";
+// echo "</tr>\n";
+
+//checkboxes
+echo "<tr><td></td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";//dateobs
+echo "<td> &nbsp; </td>\n";
+write_query_checkbox ('hist.exp_time', 'Histogram?');
+write_query_checkbox ('hist.airmass', 'Histogram?');
+write_query_checkbox ('hist.fwhm_major_psf', 'Histogram?');
+write_query_checkbox ('hist.fwhm_minor_psf', 'Histogram?');
+write_query_checkbox ('hist.fwhm_uq', 'Histogram?');
+write_query_checkbox ('hist.fwhm_lq', 'Histogram?');
+write_query_checkbox ('hist.fwhm_major_moments', 'Histogram?');
+write_query_checkbox ('hist.fwhm_minor_moments', 'Histogram?');
+write_query_checkbox ('hist.fwhm_m2_moment', 'Histogram?');
+write_query_checkbox ('hist.fwhm_m3_moment', 'Histogram?');
+write_query_checkbox ('hist.fwhm_m4_moment', 'Histogram?');
+echo "</tr>\n";
+
+echo "<tr><td></td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> Bin size (delta)</td>\n";
+write_query_row ('hist.exp_time_delta', 5, 'string');
+write_query_row ('hist.airmass_delta', 5, 'string');
+write_query_row ('hist.fwhm_major_psf_delta', 5, 'string');
+write_query_row ('hist.fwhm_minor_psf_delta', 5, 'string');
+write_query_row ('hist.fwhm_uq_delta', 5, 'string');
+write_query_row ('hist.fwhm_lq_delta', 5, 'string');
+write_query_row ('hist.fwhm_major_moments_delta', 5, 'string');
+write_query_row ('hist.fwhm_minor_moments_delta', 5, 'string');
+write_query_row ('hist.fwhm_m2_moment_delta', 5, 'string');
+write_query_row ('hist.fwhm_m3_moment_delta', 5, 'string');
+write_query_row ('hist.fwhm_m4_moment_delta', 5, 'string');
+echo "</tr>\n";
+
+echo "<tr><td></td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> Bins number (default: 100)</td>\n";
+write_query_row ('hist.exp_time_count', 5, 'string');
+write_query_row ('hist.airmass_count', 5, 'string');
+write_query_row ('hist.fwhm_major_psf_count', 5, 'string');
+write_query_row ('hist.fwhm_minor_psf_count', 5, 'string');
+write_query_row ('hist.fwhm_uq_count', 5, 'string');
+write_query_row ('hist.fwhm_lq_count', 5, 'string');
+write_query_row ('hist.fwhm_major_moments_count', 5, 'string');
+write_query_row ('hist.fwhm_minor_moments_count', 5, 'string');
+write_query_row ('hist.fwhm_m2_moment_count', 5, 'string');
+write_query_row ('hist.fwhm_m3_moment_count', 5, 'string');
+write_query_row ('hist.fwhm_m4_moment_count', 5, 'string');
+echo "</tr>\n";
+
+// close the table and form
+echo "</table>\n";
+echo "<a href=\"http://en.wikipedia.org/wiki/Histogram#Number_of_bins_and_width\">About the \"good\" number of bins<br><br></a>\n";
+echo "<input type=\"submit\" name=\"constraints\" value=\"refine search/show histograms\">\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";
+
+$keysToRowIndex = array( 
+      'hist.exp_time' => 6,
+      'hist.airmass' => 7,
+      'hist.fwhm_major_psf' => 8,
+      'hist.fwhm_minor_psf' => 9,
+      'hist.fwhm_uq'=> 10,
+      'hist.fwhm_lq' => 11,
+      'hist.fwhm_major_moments' => 12,
+      'hist.fwhm_minor_moments' => 13,
+      'hist.fwhm_m2_moment' => 14,
+      'hist.fwhm_m3_moment' => 15,
+      'hist.fwhm_m4_moment' =>16);
+$handles = array();
+$filenames = array();
+foreach ($keysToRowIndex as $i => $value) {
+    if (get_value_from_key($i, TRUE) == "on") {
+       $filenames[$i] = tempnam("/tmp/serge", "histodat.");
+       if ($debug) {
+          echo "<b>Using $filenames[$i] for $i</b>\n";
+       }
+       $handles[$i] = fopen($filenames[$i], "w");
+    }
+}
+// ** TAIL CODE **
+while ($qry->fetchInto($row)) {
+  foreach ($keysToRowIndex as $i => $value) {
+    if (get_value_from_key($i, TRUE) == "on") {
+      fwrite($handles[$i],
+	sprintf("%.3f\n", $row[$value]));
+    }
+  }
+}
+foreach ($keysToRowIndex as $i => $value) {
+  if ($handles[$i] != NULL) {
+    fclose($handles[$i]);
+    chmod($filenames[$i], 0777);
+  }
+}
+
+if ($debug) {
+   $show = get_value_from_key('hist.exp_time', TRUE);
+   $show .= " && ".get_value_from_key('hist.airmass', TRUE);
+   $show .= " && ".get_value_from_key('hist.fwhm_major_psf', TRUE);
+   $show .= " && ".get_value_from_key('hist.fwhm_minor_psf', TRUE);
+   $show .= " && ".get_value_from_key('hist.fwhm_uq', TRUE);
+   $show .= " && ".get_value_from_key('hist.fwhm_lq', TRUE);
+   $show .= " && ".get_value_from_key('hist.fwhm_major_moments', TRUE);
+   $show .= " && ".get_value_from_key('hist.fwhm_minor_moments', TRUE);
+   $show .= " && ".get_value_from_key('hist.fwhm_m2_moment', TRUE);
+   $show .= " && ".get_value_from_key('hist.fwhm_m3_moment', TRUE);
+   $show .= " && ".get_value_from_key('hist.fwhm_m4_moment', TRUE);
+   echo "==&gt; ($show)<br>\n";
+}
+
+//Get environment
+$PATH = getenv("PATH");
+putenv("PATH=$BINDIR:$PATH");
+$LD_LIBRARY_PATH = getenv("LD_LIBRARY_PATH");
+putenv("LD_LIBRARY_PATH=$LIBDIR:$LD_LIBRARY_PATH");
+
+echo "<br>\n";
+foreach ($filenames as $i => $value) {
+  $outfile = $value.".png";
+  $deltaValue = get_value_from_key($i."_delta", TRUE);
+  $binValue = get_value_from_key($i."_count", TRUE);
+  if ($binValue == "") {
+     $binValue = "-1";
+     if ($deltaValue == "") {
+       $binValue = "100";
+       $deltaValue = "-1";
+     }    
+  } else {
+    if ($deltaValue != "") {
+      echo "<font color=red>Warning! Both 'Bins number' and 'delta value' are specified =&gt; 'delta value' will be ignored<br></font>\n";
+      $deltaValue = "-1";
+    } else {
+      $deltaValue = "-1";
+    }
+  }
+  $title = preg_replace ('|hist\.|', '', $i);
+  $title = preg_replace ('|_|', '-', $title);
+
+  echo "Showing histogram for [$title] /  delta = $deltaValue / bins = $binValue<br>\n";
+  exec("build_histogram.dvo $value $outfile $deltaValue $binValue $title",
+  	$output, $status);
+  if ($debug) {
+    echo "&nbsp;&nbsp;&nbsp;&nbsp;Status = $status<br>\n";
+    for ($i = 0; $i < count($output); $i++) {
+      echo "&nbsp;&nbsp;&nbsp;&nbsp;output $i: $output[$i]<br>";
+    }
+  }
+  $blah=count($output);
+  if ($debug) {
+    echo "&nbsp;&nbsp;&nbsp;&nbsp;end: $output / $blah<br>\n";
+  }
+  echo "<img src=\"show_and_delete_image.php?file=$outfile\"><br><br>\n";
+  unset($output);
+  $filesToRemove[$value] = '';
+}
+
+echo "<small> WHERE: $WHERE<br><br></small>\n";
+echo "<small> SQL: $sql<br><br></small>\n";
+
+if ($debug) {
+  echo "Cleaning<br>\n";
+}
+foreach ($filesToRemove as $index => $value) {
+  if ($debug) {
+    echo "Deleting $index<br>\n";
+  }
+  unlink($index);
+}
+if ($debug) {
+  echo "Cleaning end<br>\n";
+}
+
+menu_end();
+
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.cal.dat
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.cal.dat	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.cal.dat	(revision 31685)
@@ -0,0 +1,5 @@
+input     | ipp.menu.dat 
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect   | link    | Calibration DBs              | calDB.php
+menulink  | menuselect   | link    | Calibration Runs             | calRun.php
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.cal.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.cal.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.cal.php	(revision 31685)
@@ -0,0 +1,17 @@
+<?php 
+
+include 'ipp.php';
+
+$ID = checkID ();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+menu('ipp.cal.dat', 'Calibration Steps', 'ipp.css', $ID['link'], $ID['proj']);
+
+// document body
+echo "Calibration Steps<br>\n";
+
+menu_end();
+
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.css
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.css	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.css	(revision 31685)
@@ -0,0 +1,328 @@
+
+/* internal link line: c0d0d0 : d8d0f0
+   external link line: 303070 
+   border:             0080c0
+ */
+
+body  { 
+    background-color: #a0d0e0; 
+    padding: 5px; 
+    margin: 5px
+}
+
+div.debug {
+    height: 15%;
+    background-color: #ffffaa;
+    overflow: auto;
+}
+
+a:link, a:visited, a:active { 
+    text-decoration: underline; 
+    font-weight: bold; 
+    color: #ff0000
+}
+
+a.button      { 
+    text-decoration: none; 
+    font-weight: bold;   
+    color: #000000; 
+    background: #0080c0
+}
+a.menutop     { 
+    text-decoration: none; 
+    font-weight: bold;   
+    color: #ffffff
+}
+a.menutops    { 
+    text-decoration: none; 
+    font-weight: bold;   
+    color: #80f0ff
+}
+a.menuext     { 
+    text-decoration: none; 
+    font-weight: bold;   
+    color: #ffffff
+}
+a.menulink    { 
+    text-decoration: none; 
+    font-weight: normal; 
+    color: #000000
+}
+a.menuselect  { 
+    text-decoration: none; 
+    font-weight: normal; 
+    color: #0000ff
+}
+a.piclink     { 
+    text-decoration: none; 
+    font-weight: normal; 
+    color: #0080c0
+}
+
+td.menutop    { 
+    text-align: left; 
+    background: #0080c0; 
+    font-size: small; 
+    color: #ffffff; 
+    padding: 2px; 
+}
+td.menutops   { 
+    text-align: left; 
+    background: #0080c0; 
+    font-size: small; 
+    color: #000000; 
+    padding: 2px; 
+}
+td.menuext    { 
+    text-align: left; 
+    background: #303070; 
+    font-size: small; 
+    color: #ffffff; 
+    padding: 2px; 
+}
+td.menulink   { 
+    text-align: left; 
+    background: #d0d0ff; 
+    font-size: small; 
+    color: #000000; 
+    padding: 2px; 
+    font-weight: normal; 
+    text-indent: 0px; 
+}
+td.menuselect { 
+    text-align: left; 
+    background: #d0d0ff; 
+    font-size: small; 
+    color: #ff0000; 
+    padding: 2px; 
+    font-weight: normal; 
+    text-indent: 0px; 
+}
+td.menuline   { 
+    text-align: left; 
+    background: #d0d0ff; 
+    font-size: small; 
+    color: #000000; 
+    padding: 2px; 
+    font-weight: normal; 
+    text-indent: 0px; 
+}
+
+td.picture    { 
+    text-align: left; 
+    background: #00ffff; 
+    font-size: small; 
+    color: #ff0000; 
+    padding: 0px; 
+    text-indent: 2px; 
+    font-weight: normal; 
+}
+td.piclink    { 
+    text-align: left; 
+    background: #0080c0; 
+    font-size: small; 
+    color: #ff0000; 
+    padding: 0px; 
+    text-indent: 0px; 
+    font-weight: normal; 
+}
+
+table.page { 
+    border: 0px solid #0080c0; 
+    background: #a0d0e0; 
+    padding: 0px
+}
+
+td.title { 
+    background-color: #ff0000; 
+    padding: 5px; 
+    font-size: x-large; 
+    text-align: left; 
+    vertical-align: top
+}
+
+td.body  { 
+           text-align: left; 
+           font-size: small;  
+           font-weight: normal;  
+           vertical-align: top;
+	   background: #d0d0ff; 
+	   background-color: #d0d0ff; 
+	   border: 3px solid #0080c0; 
+	   padding: 5px; 
+}
+
+table.menu { 
+    text-align: left; 
+    font-size: small; 
+    font-weight: normal; 
+    background: #ff0000; 
+    border: 3px solid #0080c0; 
+    padding: 0px; 
+}
+
+table.select { 
+    text-align: left; 
+    font-size: small; 
+    font-weight: normal; 
+    background: #0080c0; 
+    border: 1px solid #0080c0; 
+    padding: 0px; 
+}
+
+td.select  { 
+    text-align: left; 
+    font-size: small;  
+    font-weight: bold;  
+    vertical-align: top;
+    color: #ffffff; 
+    background: #0080c0; 
+    background-color: #0080c0; 
+    border: 2px solid #0080c0; 
+    padding: 2px; 
+}
+
+th.select  { 
+           text-align: left; 
+           font-size: small;  
+           font-weight: bold;  
+           vertical-align: top;
+	   color: #000000; 
+	   background: #d0d0ff; 
+	   background-color: #d0d0ff; 
+	   border: 0px solid #0080c0; 
+	   padding: 2px; 
+}
+
+table.list { text-align: left; 
+             font-size: small; 
+	     font-weight: normal; 
+	     background: #d0d0ff; 
+	     border: 2px solid #ffffff; 
+	     padding: 0px; 
+}
+
+td.list  { 
+           text-align: left; 
+           font-size: small;  
+           font-weight: normal;  
+           vertical-align: top;
+	   background: #d0d0ff; 
+	   background-color: #d0d0ff; 
+	   border: 2px solid #000000; 
+	   padding: 2px; 
+}
+
+td.list_off  { 
+           text-align: left; 
+           font-size: small;  
+           font-weight: normal;  
+           vertical-align: top;
+	   background: #a0a0a0; 
+	   background-color: #a0a0a0;
+	   border: 2px solid #000000; 
+	   padding: 2px; 
+}
+
+td.list_drop  { 
+           text-align: left; 
+           font-size: small;  
+           font-weight: normal;  
+           vertical-align: top;
+	   background: #a0a0a0; 
+	   background-color: #a0a0a0;
+	   border: 2px solid #000000; 
+	   padding: 2px; 
+}
+
+td.list_run  { 
+           text-align: left; 
+           font-size: small;  
+           font-weight: normal;  
+           vertical-align: top;
+	   background: #ffa0a0; 
+	   background-color: #ffa0a0;
+	   border: 2px solid #000000; 
+	   padding: 2px; 
+}
+
+td.det_off  { 
+           text-align: left; 
+           font-size: small;  
+           font-weight: normal;  
+           vertical-align: top;
+	   background: #a0a0a0; 
+	   background-color: #a0a0a0;
+	   border: 2px solid #000000; 
+	   padding: 2px; 
+}
+
+td.det_drop  { 
+           text-align: left; 
+           font-size: small;  
+           font-weight: normal;  
+           vertical-align: top;
+	   background: #a0a0a0; 
+	   background-color: #ffa0a0;
+	   border: 2px solid #000000; 
+	   padding: 2px; 
+}
+
+td.det_add  { 
+           text-align: left; 
+           font-size: small;  
+           font-weight: normal;  
+           vertical-align: top;
+	   background: #ffa0a0; 
+	   background-color: #a0a0ff;
+	   border: 2px solid #000000; 
+	   padding: 2px; 
+}
+
+th.list  { 
+           text-align: left; 
+           font-size: small;  
+           font-weight: bold;  
+           vertical-align: top;
+	   background: #d0d0ff; 
+	   background-color: #d0d0ff; 
+	   border: 2px solid #000000; 
+	   padding: 2px; 
+}
+
+td.ul3x2    { 
+    text-align: right; 
+    vertical-align: bottom;
+    padding: 0px; 
+    text-indent: 0px; 
+}
+td.uc3x2    { 
+    text-align: center; 
+    vertical-align: bottom;
+    padding: 0px; 
+    text-indent: 0px; 
+}
+td.ur3x2    { 
+    text-align: left; 
+    vertical-align: bottom;
+    padding: 0px; 
+    text-indent: 0px; 
+}
+td.ll3x2    { 
+    text-align: right; 
+    vertical-align: top;
+    padding: 0px; 
+    text-indent: 0px; 
+}
+td.lc3x2    { 
+    text-align: center; 
+    vertical-align: top;
+    padding: 0px; 
+    text-indent: 0px; 
+}
+td.lr3x2    { 
+    text-align: left; 
+    vertical-align: top;
+    padding: 0px; 
+    text-indent: 0px; 
+}
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.czartool.dat
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.czartool.dat	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.czartool.dat	(revision 31685)
@@ -0,0 +1,6 @@
+input     | ipp.imfiles.dat 
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect 	 | link    | Processing status            | czartool_labels.php  
+menulink  | menuselect 	 | link    | Last night's data         	  | czartool_summit.php  
+menulink  | menuselect 	 | link    | Pantasks servers             | czartool_servers.php                         
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.detrend.dat
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.detrend.dat	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.detrend.dat	(revision 31685)
@@ -0,0 +1,32 @@
+input     | ipp.menu.dat 
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect 	 | link    | Detrend Frames               | masterDetrendFrames.php
+menulink  | menuselect 	 | link    | Detrend Runs                 | detRun.php             
+menulink  | menuselect 	 | link    | Detrend Runs (Active)        | detRunActive.php             
+menulink  | menuselect 	 | link    | Detrend Iterations           | detRunSummary.php             
+
+menutop   | menutop      | plain   | &nbsp;                          | 
+menulink  | menuselect 	 | link    | Raw Detrend Exp                 | rawDetrendExp_detrend.php
+menulink  | menuselect 	 | link    | Input Detrend Exp               | detInputExp.php
+menulink  | menuselect 	 | link    | Proc Detrend Exp                | detProcessedExp.php
+menulink  | menuselect 	 | link    | Proc Detrend Exp<br>(no image)  | detProcessedExp_noimage.php
+menulink  | menuselect 	 | link    | Norm Detrend Exp                | detNormalizedExp.php
+menulink  | menuselect 	 | link    | Resid Detrend Exp               | detResidExp.php
+menulink  | menuselect 	 | link    | Resid Detrend Exp<br>(no images)| detResidExp_noimage.php
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menutop   | menutop      | plain   | Failures                     | 
+menulink  | menuselect 	 | link    | DetProc Fail Imfiles         | detProcessedImfile_failure.php
+menulink  | menuselect 	 | link    | DetProc Fail Exp             | detProcessedExp_failure.php
+menulink  | menuselect 	 | link    | DetStack Fail Imfile         | detStackedImfile_failure.php
+menulink  | menuselect 	 | link    | DetNormStat Fail Imfile      | detNormalizedStatImfile_failure.php
+menulink  | menuselect 	 | link    | DetNorm Fail Imfile          | detNormalizedImfile_failure.php
+menulink  | menuselect 	 | link    | DetNorm Fail Exp             | detNormalizedExp_failure.php
+menulink  | menuselect 	 | link    | DetResid Fail Imfile         | detResidImfile_failure.php
+menulink  | menuselect 	 | link    | DetResid Fail Exp            | detResidExp_failure.php
+
+menutop   | menutop      | plain   | Flat Correction              | 
+menulink  | menuselect 	 | link    | Flat Corr Runs               | flatcorrRun.php
+menulink  | menuselect 	 | link    | Flat Corr Chip Runs          | flatcorrChip.php
+menulink  | menuselect 	 | link    | Flat Corr Camera Runs        | flatcorrCamera.php
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.detrend.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.detrend.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.detrend.php	(revision 31685)
@@ -0,0 +1,24 @@
+<?php 
+
+include 'ipp.php';
+
+$ID = checkID ();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+menu('ipp.detrend.dat', 'Detrend Steps', 'ipp.css', $ID['link'], $ID['proj']);
+
+// document body
+echo "Detrend Image Creation<br>\n
+
+The pages in this section allow you to examine the master detrend
+images and the processing steps involved in their creation.  You may
+search through the detrend images which have been accepted by
+the detrend analysis system by selecting the Master Detrend Images tab.
+
+";
+
+menu_end();
+
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.diff.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.diff.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.diff.php	(revision 31685)
@@ -0,0 +1,17 @@
+<?php 
+
+include 'ipp.php';
+
+$ID = checkID ();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+menu('ipp.diff.dat', 'Diff Steps', 'ipp.css', $ID['link'], $ID['proj']);
+
+// document body
+echo "diff steps<br>\n";
+
+menu_end();
+
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.dist.dat
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.dist.dat	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.dist.dat	(revision 31685)
@@ -0,0 +1,18 @@
+input     | ipp.menu.dat 
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect   | link    | Destreak Summary             | destreakSummary.php
+menulink  | menuselect 	 | link    | Destreak Runs                | destreakRun.php            
+menulink  | menuselect 	 | link    | Destreak Files               | destreakFile.php            
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect   | link    | Dist Summary                 | distSummary.php            
+menulink  | menuselect 	 | link    | Dist Runs                    | distRun.php            
+menulink  | menuselect 	 | link    | Dist Targets                 | distTarget.php            
+menulink  | menuselect 	 | link    | Dist Components              | distComponent.php            
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect   | link    | Publish Summary              | publishSummary.php            
+menulink  | menuselect 	 | link    | Publish Clients              | publishClient.php            
+menulink  | menuselect 	 | link    | Publish Runs                 | publishRun.php            
+menulink  | menuselect 	 | link    | Publish Done                 | publishDone.php            
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.dist.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.dist.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.dist.php	(revision 31685)
@@ -0,0 +1,17 @@
+<?php 
+
+include 'ipp.php';
+
+$ID = checkID ();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+menu('ipp.dist.dat', 'Data Distribution', 'ipp.css', $ID['link'], $ID['proj']);
+
+// document body
+echo "Data Distribution<br>\n";
+
+menu_end();
+
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.dvodb.dat
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.dvodb.dat	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.dvodb.dat	(revision 31685)
@@ -0,0 +1,13 @@
+input     | ipp.menu.dat 
+
+menutop   | menutop      | plain   | &nbsp;   |   
+   
+menulink  | menuselect 	 | link    | addRun Runs                | addRunRun.php            
+menulink  | menuselect 	 | link    | addRun ProcessedExp        | addRunProcessed.php            
+
+menutop   | menutop      | plain   | &nbsp;   |
+             
+menulink  | menuselect   | link    | minidvodbRun              | minidvodbRun.php
+menulink  | menuselect 	 | link    | minidvodbProcessed         | minidvodbProcessed.php            
+menulink  | menuselect 	 | link    | minidvodbCopy               | minidvodbCopy.php            
+
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.dvodb.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.dvodb.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.dvodb.php	(revision 31685)
@@ -0,0 +1,17 @@
+<?php 
+
+include 'ipp.php';
+
+$ID = checkID ();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+menu('ipp.dvodb.dat', 'addstar and dvoDB steps', 'ipp.css', $ID['link'], $ID['proj']);
+
+// document body
+echo "dvoDB<br>\n";
+
+menu_end();
+
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.imfiles.dat
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.imfiles.dat	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.imfiles.dat	(revision 31685)
@@ -0,0 +1,45 @@
+input     | ipp.menu.dat 
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect 	 | link    | newImfile                	  | newImfile.php                         
+menulink  | menuselect 	 | link    | rawImfile                	  | rawImfile.php                         
+menulink  | menuselect 	 | link    | detProcessedImfile       	  | detProcessedImfile.php                
+menulink  | menuselect 	 | link    | detStackedImfile         	  | detStackedImfile.php                  
+menulink  | menuselect 	 | link    | detNormalizedImfile      	  | detNormalizedImfile.php               
+menulink  | menuselect 	 | link    | detNormalizedStatImfile  	  | detNormalizedStatImfile.php           
+menulink  | menuselect 	 | link    | detResidImfile           	  | detResidImfile.php            
+menulink  | menuselect 	 | link    | detRegisteredImfile	  | detRegisteredImfile.php
+menulink  | menuselect 	 | link    | pzPendingImfile          	  | pzPendingImfile.php                   
+menulink  | menuselect 	 | link    | chipPendingImfile            | chipPendingImfile.php                   
+menulink  | menuselect 	 | link    | chipProcessedImfile          | chipProcessedImfile.php                 
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menutop   | menutop      | plain   | External Links               | none            
+menutop   | menutop      | link    | test page                    | phptest.php     
+menutop   | menutop      | link    | night summary                | nightSummary.php
+menutop   | menutop      | link    | simple plot - raw (to remove?) | simplePlotraw.php
+menutop   | menutop      | link    | simple plot - chip (to remove?) | simplePlot.php
+menutop   | menutop      | link    | simple plot - cam (to remove?) | simplePlotcam.php
+menutop   | menutop      | link    | czartool                     | czartool_labels.php
+menutop   | menutop      | link    | mask stats                   | maskStats.php
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menutop   | menutop      | link    | New failed chip              | failedChipProcessedImfile.php
+menutop   | menutop      | link    | New failed cam               | failedCamProcessedExp.php
+menutop   | menutop      | link    | New failed fake              | failedFakeProcessedImfile.php
+menutop   | menutop      | link    | New failed warp              | failedWarpSkyfiles.php
+menutop   | menutop      | link    | New failed stack             | failedStackSkyfile.php
+menutop   | menutop      | link    | New failed diff              | failedDiffSkyfile.php
+menutop   | menutop      | link    | New failed magic tree        | failedMagicTrees.php
+menutop   | menutop      | link    | New failed magic node        | failedMagicNodes.php
+menutop   | menutop      | link    | New failed magic mask        | failedMagicMasks.php
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect 	 | link    | Tables columns               | columns_in_db.php
+menulink  | menuselect 	 | link    | Clean /tmp directory         | cleanTmpDirectory.php
+menutop   | menutop      | link    | disk usage                   | diskUsage.php
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect 	 | link    | Exposures Status             | exposureStatus.php
+menulink  | menuselect 	 | link    | MOPS Exposures Status        | mopsStatus.php
+menulink  | menuselect 	 | link    | GPC1 MySql ProcessList            | gpc1MysqlProcessList.php
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.imfiles.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.imfiles.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.imfiles.php	(revision 31685)
@@ -0,0 +1,17 @@
+<?php 
+
+include 'ipp.php';
+
+$ID = checkID ();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+menu('ipp.imfiles.dat', 'Imfile Tables', 'ipp.css', $ID['link'], $ID['proj']);
+
+// document body
+echo "browse the imfile tables<br>\n";
+
+menu_end();
+
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.load.dat
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.load.dat	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.load.dat	(revision 31685)
@@ -0,0 +1,26 @@
+input     | ipp.menu.dat 
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect 	 | link    | Raw Exp Summary              | rawSummary.php             
+menulink  | menuselect 	 | link    | Raw Exposures                | rawExp.php             
+menulink  | menuselect 	 | link    | Raw Detrend Exp              | rawDetrendExp.php             
+menulink  | menuselect 	 | link    | Raw Science Exp              | rawScienceExp.php             
+menulink  | menuselect 	 | link    | Raw Unknown Exp              | rawUnknownExp.php             
+menulink  | menuselect 	 | link    | Raw Exp Stats                | rawExpStats.php             
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect 	 | link    | Summit Exp                   | summitExp.php                         
+menulink  | menuselect 	 | link    | pz Pending Exp               | pzPendingExp.php              
+menulink  | menuselect 	 | link    | pz Copied Exp                | pzDoneExp.php              
+menulink  | menuselect 	 | link    | New Exp                      | newExp.php                    
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect 	 | link    | Failed Raw Imfiles           | rawImfile_failed.php
+menulink  | menuselect 	 | link    | Failed Raw Exp               | rawExp_failed.php                    
+menulink  | menuselect 	 | link    | Failed Copy Imfiles          | pzDoneImfile_failed.php
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect 	 | link    | Summit Imfile                | summitImfile.php                         
+menulink  | menuselect 	 | link    | pz Pending Imfile            | pzPendingImfile.php              
+menulink  | menuselect 	 | link    | pz Copied Imfile             | pzDoneImfile.php              
+menulink  | menuselect 	 | link    | New Imfile                   | newImfile.php                    
+menulink  | menuselect 	 | link    | Raw Imfile                   | rawImfile.php                    
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect 	 | link    | Burntool State               | rawBurntoolState.php                         
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.load.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.load.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.load.php	(revision 31685)
@@ -0,0 +1,17 @@
+<?php 
+
+include 'ipp.php';
+
+$ID = checkID ();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+menu('ipp.load.dat', 'Load and Setup', 'ipp.css', $ID['link'], $ID['proj']);
+
+// document body
+echo "load and setup page<br>\n";
+
+menu_end();
+
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.menu.dat
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.menu.dat	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.menu.dat	(revision 31685)
@@ -0,0 +1,29 @@
+# style   | select-style | type    | menu line                    | link page       
+
+# we have four valid menu types: picture, piclink, link, plain
+# picture   | picture    | picture | PScolorlogo2.jpg             | none
+# piclink   | piclink    | piclink | PScolorlogo2.jpg             | http://panstarrs.ifa.hawaii.edu
+# menulink  | menuselect | link    | other page                   | notest.php     
+# menutop   | menutop    | plain   | foo bar                      | none            
+
+piclink   | piclink      | piclink | PScolorlogo2.jpg             | http://panstarrs.ifa.hawaii.edu
+menuext   | menuext      | link    | Pan-STARRS public            | http://panstarrs.ifa.hawaii.edu
+menuext   | menuext      | link    | Pan-STARRS project           | http://panstarrs.ifa.hawaii.edu/project
+menuext   | menuext      | link    | Pan-STARRS IPP               | http://panstarrs.ifa.hawaii.edu/project/IPP
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect   | link    | Login                        | Login.php     
+menulink  | menuselect   | link    | Select Project               | SelectProject.php     
+menulink  | menuselect   | link    | [$PROJECT]                   | SelectProject.php     
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menutop   | menutop      | link    | Load and Setup               | ipp.load.php
+menutop   | menutop      | link    | Detrend Steps                | ipp.detrend.php
+menutop   | menutop      | link    | Science Steps                | ipp.science.php
+menutop   | menutop      | link    | Stack Steps                  | ipp.stack.php
+menutop   | menutop      | link    | Distribution                 | ipp.dist.php
+menutop   | menutop      | link    | dvoDB                        | ipp.dvodb.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: /branches/sc_branches/ippMonitorLap/raw/ipp.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.php	(revision 31685)
@@ -0,0 +1,906 @@
+<?php
+
+$dTABLE = 80;
+include 'site.php';
+
+function logintext () {
+  echo '<p>Welcome to the IPP status pages.<br><br>', "\n";
+  echo 'From these pages, you may examine summary information about the IPP processing results.<br>', "\n";
+  echo 'In order to continue, it is necessary to login as an authorized IPP user.</p>', "\n\n";
+}
+
+function loginform ($username) { 
+  echo '<form action="Login.php" method="POST">', "\n";
+  if ($username) {
+    echo "Username: <input type=\"text\" name=\"username\" value=\"$username\"><br>\n";
+  } else {
+    echo "Username: <input type=\"text\" name=\"username\"><br>\n";
+  }
+  echo 'Password: <input type="password" name="password"><br>', "\n";
+  echo '<input type="submit" name="login" value="login">', "\n";
+  echo '</form>', "\n\n";
+}
+
+function projectform ($ID) {
+
+  menu ('ipp.menu.dat', 'Select Project', 'ipp.css', $ID['link'], $ID['proj']);
+  if ($_GET['new'] && $_GET['proj']) {
+    echo "<p> Project is now <b>" . $_GET['proj'] . "</b></p>\n";
+  }
+  echo "<p> Please select the project of interest </p>\n";
+  // echo "<form action=\"SelectProject.php\" method=\"POST\">\n";
+  // echo "Project: <input type=\"text\" name=\"proj\"><br>\n";
+  // echo "<input type=\"submit\" name=\"project\">\n";
+
+  $pass = $ID['pass'];
+  // echo "<input type=\"hidden\" name=\"pass\" value=\"$pass\">\n";
+  // echo "</form>\n";
+
+  $db = dbconnect('ippadmin');
+
+  // make this a DB lookup
+  $sql = "SELECT projname FROM projects order by projname";
+
+  $qry = $db->query($sql);
+  if (dberror($db)) {
+    echo "<b>error reading project list</b><br>\n";
+    menu_end();
+  }
+  
+  echo "<table class=select>\n";
+  echo "<tr class=select><th class=select> projects </th></tr>\n";
+  while ($qry->fetchInto($row)) {
+    // add a link here to set the database
+    $tmp_proj = $row[0];
+    $tmp_link = "pass=$pass";
+    echo "<tr class=select><td class=select><a class=\"menutop\" href=\"SelectProject.php?$tmp_link&proj=$tmp_proj&new=1\"> $row[0] </a></td></tr>\n";
+    // echo "<tr class=select><td class=select> $row[0] </td></tr>\n";
+  }
+  echo "</table>\n";
+
+  menu_end ();
+}
+
+function dbconnect ($database) {
+
+  // these are set in 'site.php'
+  global $DBI;
+  global $DBHOST;
+  global $DBUSER;
+  global $DBPASS;
+
+  $success = 0;
+  if ($DBI == "MDB2") {
+    $success = include_once('MDB2.php');
+  }
+  if ($DBI == "DB") {
+    $success = include_once('DB.php');
+  }
+  if ($success != 1) {
+    echo "<b>installation error: php file for $DBI not found.</b><br>\n";
+    echo "<b>please consult the IPP Wiki for install help (get $DBI.php via Pear)</b><br>\n";
+    menu_end();
+    return 0;
+  }
+
+  // connect to the database
+  if ($DBI == "DB") {
+    $db = DB::connect("mysql://$DBUSER:$DBPASS@$DBHOST/$database");
+  }
+  if ($DBI == "MDB2") {
+    $db = MDB2::connect("mysql://$DBUSER:$DBPASS@$DBHOST/$database");
+  }
+
+  if (dberror($db)) {
+    echo "<b>error accessing database</b><br>\n";
+    echo "<b>tried mysql://$DBUSER:XXX@$DBHOST/$database</b><br>\n";
+    $result = $db->getMessage();
+    echo "$result<br>";
+    menu_end();
+  }
+  return $db;
+}
+
+function dberror ($db) {
+  global $DBI;
+
+  if ($DBI == "MDB2") {
+    $dberr = MDB2::isError($db);
+  }
+  if ($DBI == "DB") {
+    $dberr = DB::isError($db);
+  }
+
+  return $dberr;
+}
+
+// there are three pieces of data that are used to define a user:
+// - name (the username: available somewhere: db table?)
+// - proj (defines which database is being used)
+// - pass (NOT the same as the user password: randomly generated for the session and given a timeout) 
+
+// have this function take the current menu and style?
+function checkLogin () {
+
+  $username = $_POST[username];
+  $password = $_POST[password];
+
+  // if password is not specified, keep username and ask again
+  if ($password == "") {
+    menu ('ipp.menu.dat', 'Login', 'ipp.css', '', '');
+    loginform ($username);
+    menu_end ();
+  }
+
+  $db = dbconnect('ippadmin');
+
+  // get the users from the DB
+  $sql = "SELECT username FROM users WHERE username = '$username' AND password = '$password'";
+
+  $qry = $db->query($sql);
+  if (dberror($db)) {
+    menu ('ipp.menu.dat', 'Login', 'ipp.css', '', '');
+    echo "<b>error reading users table</b><br>\n";
+    echo "Login Failed, please try again<br>\n";
+    loginform ("");
+    menu_end();
+  }
+  
+  $success = $qry->fetchInto($row);
+  if (!$success) {  
+    menu ('ipp.menu.dat', 'Login', 'ipp.css', '', '');
+    echo "Login Failed, please try again<br>\n";
+    loginform ("");
+    menu_end ();
+    exit ();
+  }
+  
+  // generate an random ephemeral ID
+  $ID['name'] = $username;
+  $ID['proj'] = "";
+
+  // generate a cookie for the user
+  $sql = "SELECT username,cookie FROM cookies WHERE username = '$username'";
+  $qry = $db->query($sql);
+  if (dberror($db)) {
+    echo "Cookie Failed, please try again<br>\n";
+    menu_end();
+  }
+
+  if ($qry->fetchInto($row)) {
+    $ID['pass'] = $row[1];
+  } else {
+    $cookie = rand(0,100000);
+    $ID['pass'] = $cookie;
+    $sql = "INSERT into cookies (username, cookie) values ('$username', '$cookie')";
+    $qry = $db->query($sql);
+    if (dberror($db)) {
+      echo "Cookie Failed, please try again<br>\n";
+      menu_end();
+    }
+  }
+
+  // the link is attached to every nav link
+  $ID['link'] = "pass=" . $ID['pass'];
+  if ($ID['proj']) {
+    $ID['link'] = $link . "&proj=" . $ID['proj'];
+  }
+
+  return $ID;
+}
+
+function checkID () {
+
+  $VERBOSE = 0;
+
+  // check for valid server method
+  if (($_SERVER[REQUEST_METHOD] != 'POST') && ($_SERVER[REQUEST_METHOD] != 'GET')) {
+    menu ('ipp.menu.dat', 'Login', 'ipp.css', '', '');
+    echo "Invalid Client Request<br>\n";
+    menu_end ();
+    exit ();
+  }
+
+  // look for pass & proj in appropriate location
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $ID['pass'] = $_GET[pass];
+    $ID['proj'] = $_GET[proj];
+    $ID['menu'] = $_GET[menu];
+    $ID['from'] = $_GET[from];
+
+    if ($VERBOSE) {
+      echo "using GET: ", $ID['pass'], $ID['proj'], "<br>\n";
+      echo "GET list<br>\n";
+      foreach ($_GET as $key => $value) {
+	echo "$key : $value<br>\n";
+      }
+    }
+  }
+  if ($_SERVER[REQUEST_METHOD] == 'POST') { 
+    $ID['pass'] = $_POST[pass];
+    $ID['proj'] = $_POST[proj];
+    $ID['menu'] = $_POST[menu];
+    $ID['from'] = $_POST[from];
+
+    if ($VERBOSE) {
+      echo "using POST: ", $ID['pass'], $ID['proj'], "<br>\n";
+      echo "POST list<br>\n";
+      foreach ($_POST as $key => $value) {
+	echo "$key : $value<br>\n";
+      }
+    }
+  }
+
+  // user is not logged in at all
+  if ($ID['pass'] == "") {
+    menu('ipp.menu.dat', 'Login', 'ipp.css', '', '');
+    logintext ();    
+    loginform ("");
+    menu_end ();
+  }
+
+  $db = dbconnect ('ippadmin');
+
+  $pass = $ID['pass'];
+
+  // search for password
+  $sql = "SELECT username FROM cookies WHERE cookie = '$pass'";
+  $qry = $db->query($sql);
+  if (dberror($db)) {
+    echo "<b>error reading users table</b><br>\n";
+    echo "Login Failed, please try again<br>\n";
+    loginform ("");
+    menu_end();
+  }
+  
+  $success = $qry->fetchInto($row);
+  if (! $success) {
+    menu('ipp.menu.dat', 'Login', 'ipp.css', '', '');
+    echo "unknown user, please login again<br>\n";
+    loginform ("");
+    menu_end ();
+  }
+  // use the pass value to find the corresponding user
+  $ID['name'] = $row[0];
+
+  // $link is attached to every nav link
+  $ID['link'] = "pass=" . $ID['pass'];
+  if ($ID['proj']) {
+    $ID['link'] = $ID['link'] . "&proj=" . $ID['proj'];
+  }
+  
+  return $ID;
+}
+
+function head ($title) {
+  echo "<head>\n";
+  echo "  <title> $title </title>\n";
+  /* JavaScript code */
+  echo "  <script type=\"text/javascript\">\n";
+  echo "  function changeCell(cellId, newContent){\n";
+  echo "    document.getElementById(cellId).innerHTML=newContent;\n";
+  echo "  }\n";
+  echo "  </script>\n";
+  echo "</head>\n\n";
+}
+
+function menu ($source, $title, $sheet, $append, $project) {
+
+  echo "<html>\n";
+  head($title);
+  echo "<link rel=\"STYLESHEET\" HREF=\"$sheet\">\n";
+  echo "<body>\n";
+
+  $root = "/ippMonitor";
+
+  if (! $project) { $project = "none"; }
+
+  // these are defined in site.php
+  global $DBHOST;
+  global $WWWHOST;
+
+  echo "<p style=\"font-size:50%\">host: $WWWHOST, db: $DBHOST</p>\n";
+  echo "<table class=page cellspacing=10px><tr><td valign=top>\n";
+  echo "<table class=menu cellspacing=0px>\n";
+
+  menulines ($source, $root, $append, $project);
+
+  echo '</table></td><td class="body" valign=top>', "\n\n";
+}
+
+function menulines ($source, $root, $append, $project) {
+
+  $file = fopen ($source, "r");
+
+  // loop over the lines in the file and generate lines in the menu
+  while ($line = fgetcsv ($file, 1024, "|")) {
+    if (ereg ('^[:blank:]*#', $line[0])) continue;
+    if (count($line) < 2) continue;
+
+    if (count($line) == 2) {
+      $value = trim($line[0]);
+      if ($value == "input") {
+        $value = trim($line[1]);
+        menulines ($value, $root, $append, $project);
+      }
+      continue;
+    }
+    if (count($line) != 5) continue;
+
+    $type = trim($line[2]);
+    $name = trim($line[3]);
+    $base = trim($line[4]);
+
+    if (preg_match ('|\$PROJECT|', $name)) {
+      $name = preg_replace ('|\$PROJECT|', $project, $name);
+    }
+
+    if ($append) {
+      $link = $base . "?" . $append;
+    } else {
+      $link = $base;
+    }
+	
+    $thisname = $_SERVER[SCRIPT_NAME]; 
+    $page = "$root/" . $base;
+    if ($page == $thisname) {
+      $style = trim($line[1]);
+    } else { 
+      $style = trim($line[0]);
+    }       
+
+    switch ($type) { 
+    case 'plain':
+      echo "<tr><td class=\"$style\"> $name </td></tr>\n";  
+      break;
+    case 'picture':
+      echo "<tr><td class=\"$style\"> <img src=\"$name\"> </td></tr>\n";     
+      break;
+    case 'piclink':
+      echo "<tr><td class=\"$style\"> <a class=\"$style\" href=\"$link\"> <img class=\"$style\" src=\"$name\"> </a></td></tr>\n";     
+      break;
+    default:
+      echo "<tr><td class=\"$style\"> <a class=\"$style\" href=\"$link\"> $name </a></td></tr>\n";     
+      break;
+    } 
+  }
+  fclose ($file);
+}
+
+function menu_end () { 
+  echo "</td></tr></table>\n";
+  echo "</body></html>\n\n";
+  exit ();
+}
+
+function navigate_buttons ($rowStart, $rowLast, $dTABLE, $rowTotal, $buttonLink, $ID, $file) {
+
+  // add a sort key?
+  $sortKey = "";
+  // try sort forward
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $sortVal = $_GET['sort']; 
+  } else {
+    $sortVal = $_POST['sort'];
+  }
+  if ($sortVal != "") {
+    $sortKey = "&sort=" . $sortVal;
+  }
+  // try sort reverse
+  if ($sortKey == "") {
+    if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+      $sortVal = $_GET['rsort']; 
+    } else {
+      $sortVal = $_POST['rsort'];
+    }
+    if ($sortVal != "") {
+      $sortKey = "&rsort=" . $sortVal;
+    }
+  }
+
+  if ($rowStart > 0) {
+    $value = 0;
+    $link = "$file" . "?" . $ID['link'] . "&from=$value";
+    if ($buttonLink != "") {
+      $link = $link . "&$buttonLink";
+    }
+    $link = $link . $sortKey;
+    echo "<a width=10 class=\"button\" href=\"$link\"><img src=\"left.png\"><img src=\"left.png\"></a>\n";
+  } else {
+    echo "<img src=\"left_sel.png\"><img src=\"left_sel.png\">\n";
+  }
+  if ($rowStart >= $dTABLE) {
+    $value = $rowStart - $dTABLE;
+    $link = "$file" . "?" . $ID['link'] . "&from=$value";
+    if ($buttonLink != "") {
+      $link = $link . "&$buttonLink";
+    }
+    $link = $link . $sortKey;
+    echo "<a class=\"button\" href=\"$link\"><img src=\"left.png\"></a>\n";
+  } else {
+    echo "<img src=\"left_sel.png\">\n";
+  }
+
+  if ($rowLast < $rowTotal) {
+    $value = $rowStart + $dTABLE;
+    $link = "$file" . "?" . $ID['link'] . "&from=$value";
+    if ($buttonLink != "") {
+      $link = $link . "&$buttonLink";
+    }
+    $link = $link . $sortKey;
+    echo "<a class=\"button\" href=\"$link\"><img src=\"right.png\"></a>\n";
+  } else {
+    echo "<img src=\"right_sel.png\">\n";
+  }
+
+  if ($rowLast < $rowTotal) {
+    $value = $rowTotal - $dTABLE;
+    $link = "$file" . "?" . $ID['link'] . "&from=$value";
+    if ($buttonLink != "") {
+      $link = $link . "&$buttonLink";
+    }
+    $link = $link . $sortKey;
+    echo "<a class=\"button\" href=\"$link\"><img src=\"right.png\"><img src=\"right.png\"></a>\n";
+  } else {
+    echo "<img src=\"right_sel.png\"><img src=\"right_sel.png\">\n";
+  }
+}
+
+function check_restrict ($key, $where, $mode, $scale) {
+  $htmlkey = preg_replace ('|\.|', '_', $key);
+  if ($mode == 'min') {
+    $htmlkey = $htmlkey . "_min";
+  }
+  if ($mode == 'max') {
+    $htmlkey = $htmlkey . "_max";
+  }
+
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $value = $_GET[$htmlkey]; 
+  } else {
+    $value = $_POST[$htmlkey];
+  }
+  if ($value == "") { return $where; }
+
+  global $restricted;
+  $restricted = 1;
+
+  if ($where) { 
+    $where = $where . " AND"; 
+  } else {
+    $where = "WHERE";
+  }
+
+  if ($scale != 1.0) {
+    $fvalue = $value * $scale;
+  } else {
+    $fvalue = $value;
+  }
+
+  if ($mode == 'string') {
+    // can we pass the '%' through the html?
+    $where = $where . " $key like '$value'";
+  } 
+  if ($mode == 'min') {
+    // can we pass the '%' through the html?
+    $where = $where . " $key >= '$fvalue'";
+  } 
+  if ($mode == 'max') {
+    // can we pass the '%' through the html?
+    $where = $where . " $key <= '$fvalue'";
+  } 
+
+  return $where;
+}
+
+function check_ordering ($groups, $where) {
+
+  if ($groups != "") {
+    $where = $where . " GROUP BY $groups";
+  }
+
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $value = $_GET['sort']; 
+  } else {
+    $value = $_POST['sort'];
+  }
+  if ($value != "") {
+    $where = $where . " ORDER BY $value";
+    return $where;
+  }
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $value = $_GET['rsort']; 
+  } else {
+    $value = $_POST['rsort'];
+  }
+  if ($value != "") {
+    $where = $where . " ORDER BY $value DESC";
+    return $where;
+  }
+  return $where;
+}
+
+// if we have a restriction for a string-valued field, supply it to outgoing links
+function button_restrict_string ($key, $line) {
+  $htmlkey = preg_replace ('|\.|', '_', $key);
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $value = $_GET[$htmlkey]; 
+  } else {
+    $value = $_POST[$htmlkey];
+  }
+  # a search restriction may include an SQL wild-card.  we have to mangle these so that the http 
+  # does not get converted to a special character
+  $value = preg_replace ('|%|', '%25', $value);
+  if ($value != "") {
+    if ($line) {
+      $line = $line . "&$key=$value";
+    } else {
+      $line = "$key=$value";
+    }
+  }
+  return $line;
+}
+
+// for numerical fields, test for both 'min' and plain values
+function button_restrict_min ($key, $line) {
+  $htmlkey = preg_replace ('|\.|', '_', $key);
+  $htmlkey = $htmlkey . '_min';
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $value = $_GET[$htmlkey]; 
+  } else {
+    $value = $_POST[$htmlkey];
+  }
+  if ($value != "") {
+    if ($line) {
+      $line = $line . "&$htmlkey=$value";
+    } else {
+      $line = "$htmlkey=$value";
+    }
+  }
+  return $line;
+}
+
+// for numerical fields, test for both 'min' and 'max' values
+function button_restrict_max ($key, $line) {
+  $htmlkey = preg_replace ('|\.|', '_', $key);
+  $htmlkey = $htmlkey . '_max';
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $value = $_GET[$htmlkey]; 
+  } else {
+    $value = $_POST[$htmlkey];
+  }
+  if ($value != "") {
+    if ($line) {
+      $line = $line . "&$htmlkey=$value";
+    } else {
+      $line = "$htmlkey=$value";
+    }
+  }
+  return $line;
+}
+
+// 
+function button_restrict_checkbox ($key, $line) {
+  $htmlkey = preg_replace ('|\.|', '_', $key);
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $value = $_GET[$htmlkey]; 
+  } else {
+    $value = $_POST[$htmlkey];
+  }
+  if ($value != "") {
+    if ($line) {
+      $line = $line . "&$htmlkey=$value";
+    } else {
+      $line = "$htmlkey=$value";
+    }
+  }
+  return $line;
+}
+
+// 
+function button_restrict_radio ($key, $line) {
+  $htmlkey = preg_replace ('|\.|', '_', $key);
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $value = $_GET[$htmlkey]; 
+  } else {
+    $value = $_POST[$htmlkey];
+  }
+  if ($value != "") {
+    if ($line) {
+      $line = $line . "&$htmlkey=$value";
+    } else {
+      $line = "$htmlkey=$value";
+    }
+  }
+  return $line;
+}
+
+function write_header_cell ($class, $name) {
+  echo "<th class=\"$class\">$name</th>\n";
+}
+
+// write a table cell with the up and down sort arrows
+function write_sort_cell ($class, $value, $buttonLink, $ID, $file) {
+  
+  echo "<td>";
+
+  // base link
+  $baselink = "$file" . "?" . $ID['link'];
+  if ($buttonLink != "") {
+    $baselink = $baselink . "&$buttonLink";
+  }
+
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $up   = $_GET['rsort']; 
+    $down = $_GET['sort']; 
+    $from = $_GET['from']; 
+  } else {
+    $up   = $_POST['rsort']; 
+    $down = $_POST['sort']; 
+    $from = $_POST['from']; 
+  }
+
+  // down button link
+  $link = "$baselink" . "&sort=$value";
+  if ($from != "") {
+    $link = $link . "&from=$from";
+  }
+  if ($down == $value) {
+    echo "<a href=\"$link\"><img src=\"down_sel.png\"></a>";
+  } else {
+    echo "<a href=\"$link\"><img src=\"down.png\"></a>";
+  }
+
+  // up button link
+  $link = "$baselink" . "&rsort=$value";
+  if ($from != "") {
+    $link = $link . "&from=$from";
+  }
+  if ($up == $value) {
+    echo "<a href=\"$link\"><img src=\"up_sel.png\"></a>";
+  } else {
+    echo "<a href=\"$link\"><img src=\"up.png\"></a>";
+  }
+
+  echo "</td>\n";
+}
+
+// there are two query rows: for strings, only the first is set; for numbers, the first = min, the second = max
+// mode == string, min, max
+function write_query_row ($key, $width, $mode) {
+  $htmlkey = preg_replace ('|\.|', '_', $key);
+
+  // optional bits by mode
+  if ($mode == 'min') {
+    $htmlkey = $htmlkey . "_min";
+  }
+  if ($mode == 'max') {
+    $htmlkey = $htmlkey . "_max";
+  }
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $value = $_GET[$htmlkey]; 
+  } else {
+    $value = $_POST[$htmlkey];
+  }
+
+  // full table element includes optionally the <= or >= words
+  echo "<td class=\"list\"> <input type=\"text\" name=\"$htmlkey\" size=\"$width\"";
+  if ($value != "") { 
+    echo "value=\"$value\">";
+  } else {
+    echo ">";
+  }
+  echo "</td>\n";
+}
+
+// checkbox
+function write_query_checkbox ($key, $comment) {
+  $htmlkey = preg_replace ('|\.|', '_', $key);
+
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $value = $_GET[$htmlkey]; 
+  } else {
+    $value = $_POST[$htmlkey];
+  }
+  echo "<td> <input type=\"checkbox\" name=\"$htmlkey\"";
+  if ($value == "on") { 
+    echo " checked>";
+  } else {
+    echo ">";
+  }
+  echo "$comment ($htmlkey/$value)</td>\n";
+}
+
+// checkbox
+function write_query_radio ($value, $key) {
+  $htmlkey = preg_replace ('| |', '_', $key);
+  $htmlvalue = preg_replace ('|\.|', '_', $value);
+
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $value = $_GET[$htmlkey]; 
+  } else {
+    $value = $_POST[$htmlkey];
+  }
+  if ($htmlvalue == get_value_from_key($htmlkey, TRUE)) {
+    $checked = "checked";
+  } else {
+    $checked = "";
+  }
+  echo "<td> <input type=\"radio\" name=\"$htmlkey\" value=\"$htmlvalue\" $checked/>";
+  echo "$key ($htmlkey/$htmlvalue)</td>\n";
+}
+
+function write_table_cell ($class, $format, $link, $value) {
+
+  if ($format == '%T') {
+    $format = '%s';
+  }
+  if ($format == '%C') {
+    $format = '%10.6f';
+  }
+  if ($format == '%t') {
+    $format = '%s';
+    if ($value == 0) { 
+      $value = 'N'; 
+    } else {
+      $value = 'Y';
+    }
+  }
+
+  $myValue = sprintf ($format, $value);
+  if ($myValue == "") { $myValue = "&nbsp;"; }
+
+  if ($link) {
+    echo "<td class=\"$class\"><a href=\"$link\"> $myValue </a></td>\n";
+  } else {
+    echo "<td class=\"$class\"> $myValue </td>\n";
+  }
+}
+
+// expect image supplied with key=name
+// this function should define matching hidden inputs in the form
+function insert_image ($rule, $size) {
+
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $basename = $_GET['basename']; 
+    $class_id = $_GET['class']; 
+    $camera   = $_GET['camera']; 
+  } else {
+    $basename = $_POST['basename']; 
+    $class_id = $_POST['class']; 
+    $camera   = $_POST['camera']; 
+  }
+
+  if (! $class_id) { $class_id = "NONE"; }
+
+  if ($basename && $camera && $rule) {
+    echo "<a href=\"showimage.php?name=$basename&rule=$rule&camera=$camera&class_id=$class_id\">\n";
+    echo "<img $size src=\"getimage.php?name=$basename&rule=$rule&camera=$camera&class_id=$class_id\">\n";
+    echo "</a>\n";
+  }
+}
+
+// expect image supplied with key=name
+// this function should define matching hidden inputs in the form
+function insert_log ($filerule) {
+
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $basename = $_GET['basename']; 
+    $class_id = $_GET['class']; 
+    $camera   = $_GET['camera']; 
+  } else {
+    $basename = $_POST['basename']; 
+    $class_id = $_POST['class']; 
+    $camera   = $_POST['camera']; 
+  }
+
+  // echo "<b>insert log</b><br>\n";
+  // echo "<b>basename: $basename</b><br>\n";
+  // echo "<b>class_id: $class_id</b><br>\n";
+  // echo "<b>camera:   $camera</b><br>\n";
+
+  if (! $class_id) { $class_id = "NONE"; }
+
+  if ($basename && $camera && $filerule) {
+
+    // do I need to do this to the output result as well?
+    $basename = escapeshellarg($basename);
+    $basename = str_replace ('..','',$basename);
+
+    // these are defined by site.php
+    global $PERLLIB;
+    global $BINDIR;
+    global $SITE;
+    global $PSCONFDIR;
+    global $PSCONFIG;
+
+    putenv("PSCONFDIR=$PSCONFDIR");
+    putenv("PSCONFIG=$PSCONFIG");
+    putenv("PERL5LIB=$PERLLIB:");
+    $PATH = getenv("PATH");
+    putenv("PATH=$BINDIR:$PATH");
+
+    // be careful of the definition of PATH in SITE: cannot contain HOME
+    echo "<br>ipp_filename.pl --site=$SITE --basename $basename --filerule $filerule --camera $camera --class_id $class_id<br>\n";
+    exec ("ipp_filename.pl --site=$SITE --basename $basename --filerule $filerule --camera $camera --class_id $class_id", $output, $status);
+
+    if (0) {
+      echo "basename: $basename<br>";
+      for ($i = 0; $i < count($output); $i++) {
+	echo "output $i: $output[$i]<br>";
+      }
+      echo "output:   $output[0]<br>";
+      echo "status:   $status<br>";
+      echo "filename: $filename<br>";
+      exit ();
+    }
+
+    $filename = $output[0];
+    if ($status) {
+      echo "log file ($filerule, $basename) not found<br>\n";
+      return;
+    }
+
+    echo "<pre>\n";
+    $file = fopen ($filename, "r");
+    if ($file && !$debug) {
+      fpassthru ($file);
+    }
+    echo "</pre>\n";
+  }
+}
+
+// expect image supplied with key=name
+// this function should define matching hidden inputs in the form
+function insert_backref ($page, $key, $link) {
+
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    $name = $_GET[$key]; 
+  } else {
+    $name = $_POST[$key]; 
+  }
+
+  if ($name) {
+    echo "back to <a href=\"$page?$link&$key=$name\"> $name </a><br>\n";
+  }
+}
+
+// $myPage = $_SERVER[SCRIPT_NAME] . "?pass=$pass";
+
+//////////////////////////////////////////////////////////////////////////
+// Return the value associated to the key (GET or POST method)
+// If convertKeyToHtmlkey is true, the key is converted to a 
+// so-called HTML, i.e. the key where '.' are replaced by '_'
+// (e.g. the conversion of 'f.o.o.b_a_r' is 'f_o_o_b_a_r'.
+//
+function get_value_from_key ($key, $convertKeyToHtmlkey) {
+  if ($convertKeyToHtmlkey) {
+    $htmlkey = preg_replace ('|\.|', '_', $key);
+  } else {
+    $htmlkey = $key;
+  }
+  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
+    return $_GET[$htmlkey]; 
+  } else {
+    return $_POST[$htmlkey]; 
+  }
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Extra filtering parameters array
+$filteringParameters = array();
+
+//
+// Delete temporary files if they are older than $expire_time minutes
+//
+function delete_old_tmp_files() {
+  global $DELETION_USER;    // defined in raw/site.php.in
+  global $DELETION_DELAY;   // defined in raw/site.php.in
+  exec("find /tmp -user $DELETION_USER -amin +$DELETION_DELAY", $output, $status);
+  foreach ($output as $key => $value) {
+    exec("rm -f $value");
+    $count++;
+  }
+}
+
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.plots.dat
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.plots.dat	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.plots.dat	(revision 31685)
@@ -0,0 +1,17 @@
+input     | ipp.menu.dat 
+
+menutop   | menutop      | plain   | &nbsp;                                 | 
+menulink  | menuselect      | link    | Simple plot - raw            	    | simplePlotRawImage.php
+menulink  | menuselect      | link    | Simple plot - chip           	    | simplePlotChipImage.php
+menulink  | menuselect      | link    | Simple plot - cam            	    | simplePlotCamImage.php
+
+menutop   | menutop      | plain   | &nbsp;                                 | 
+menulink  | menuselect      | link    | Histogram background                   | histogramBackgroundImage.php
+menulink  | menuselect      | link    | Histogram Fwhm Major (camProcessedExp) | histogramCamProcessedExpImage.php
+menulink  | menuselect      | link    | Histogram Zpt Obs (camProcessedExp)  | histogramZptObsImage.php
+
+menutop   | menutop      | plain   | &nbsp;                                 | 
+menulink  | menuselect      | link    | Plot airmass vs fwhm_major (chipProcessedImfile) | scatterPlotAirMassFwhmImage.php
+menulink  | menuselect      | link    | Plot Background (chipProcessedImfile) vs Moon Angle (rawExp) | scatterCpiBgReMaImage.php
+menulink  | menuselect      | link    | Plot Background (chipProcessedImfile) vs Moon Phase (rawExp) | scatterCpiBgReMpImage.php
+menulink  | menuselect      | link    | Plot Background (chipProcessedImfile) vs Sun Angle (rawExp) | scatterCpiBgReSaImage.php
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.plots.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.plots.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.plots.php	(revision 31685)
@@ -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: /branches/sc_branches/ippMonitorLap/raw/ipp.science.dat
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.science.dat	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.science.dat	(revision 31685)
@@ -0,0 +1,42 @@
+input     | ipp.menu.dat 
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect   | link    | Chip Summary                 | chipSummary.php
+menulink  | menuselect 	 | link    | Chip-Stage Exp               | chipStageExp.php            
+menulink  | menuselect 	 | link    | Chip Pending Exp             | chipPendingExp.php              
+menulink  | menuselect 	 | link    | Chip Processed Exp           | chipProcessedExp.php            
+menulink  | menuselect 	 | link    | Chip Pending Imfiles         | chipPendingImfile.php            
+menulink  | menuselect 	 | link    | Chip Processed Imfiles       | chipProcessedImfile.php            
+menulink  | menuselect 	 | link    | Chip IQ Stats                | chipIQstats.php            
+menulink  | menuselect 	 | link    | Chip Failed Imfiles          | chipProcessedImfile_failure.php
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect   | link    | Cam Summary                  | camSummary.php
+menulink  | menuselect 	 | link    | Cam-Stage Exp                | camStageExp.php            
+menulink  | menuselect 	 | link    | Cam Pending Exp              | camPendingExp.php              
+menulink  | menuselect 	 | link    | Cam IQ Stats                 | camIQstats.php            
+menulink  | menuselect 	 | link    | Cam Processed Exp            | camProcessedExp.php            
+menulink  | menuselect 	 | link    | Cam Proc. w/ Images          | camProcessedExp_Images.php            
+menulink  | menuselect 	 | link    | Cam Failed Exp               | camProcessedExp_failure.php
+menulink  | menuselect 	 | link    | Cam Processed Imfiles        | camProcessedImfile.php            
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect   | link    | Fake Summary                 | fakeSummary.php
+menulink  | menuselect 	 | link    | Fake-Stage Exp               | fakeStageExp.php            
+menulink  | menuselect 	 | link    | Fake Pending Exp             | fakePendingExp.php              
+menulink  | menuselect 	 | link    | Fake Processed Exp           | fakeProcessedExp.php            
+menulink  | menuselect 	 | link    | Fake Pending Imfiles         | fakePendingImfile.php            
+menulink  | menuselect 	 | link    | Fake Processed Imfiles       | fakeProcessedImfile.php            
+menulink  | menuselect 	 | link    | Fake Failed Imfiles          | fakeProcessedImfile_failure.php
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect   | link    | Warp Summary                 | warpSummary.php
+menulink  | menuselect   | link    | Warp Stage Exp               | warpStageExp.php
+menulink  | menuselect   | link    | Warp Processed Exp           | warpProcessedExp.php
+menulink  | menuselect   | link    | Warp Processed Exp w/ Skycell Images | warpProcessedExp_Images.php
+menulink  | menuselect   | link    | Warp Stage Skyfiles          | warpStageSkyfiles.php
+menulink  | menuselect   | link    | Warp Skyfile Inputs          | warpStageSkyfileInputs.php
+menulink  | menuselect   | link    | Warp Processed Skyfiles      | warpProcessedSkyfiles.php
+menulink  | menuselect   | link    | Warp Failed Skyfiles         | warpFailedSkyfiles.php
+
+# warp is not yet generating jpegs...
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.science.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.science.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.science.php	(revision 31685)
@@ -0,0 +1,17 @@
+<?php 
+
+include 'ipp.php';
+
+$ID = checkID ();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+menu('ipp.science.dat', 'Science Steps', 'ipp.css', $ID['link'], $ID['proj']);
+
+// document body
+echo "science image steps<br>\n";
+
+menu_end();
+
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.stack.dat
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.stack.dat	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.stack.dat	(revision 31685)
@@ -0,0 +1,37 @@
+input     | ipp.menu.dat 
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect   | link    | Stack Summary                | stackSummary.php
+menulink  | menuselect   | link    | Stack Summary w/ Images        | stackSummary_Images.php
+menulink  | menuselect   | link    | Stack Run                    | stackRun.php
+menulink  | menuselect   | link    | Stack Input Skyfile          | stackInputSkyfile.php
+menulink  | menuselect   | link    | Stack Processed Skyfile      | stackProcessedSkyfile.php
+menulink  | menuselect   | link    | Stack Proc. w/ Images        | stackProcessedSkyfile_Images.php
+menulink  | menuselect   | link    | Stack Failed Skyfile         | stackFailedSkyfile.php
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect   | link    | Diff Summary                 | diffSummary.php
+menulink  | menuselect   | link    | Diff Summary w/ Images       | diffSummary_Images.php
+menulink  | menuselect   | link    | Diff Run                     | diffRun.php
+menulink  | menuselect   | link    | Diff Input Skyfile           | diffInputSkyfile.php
+menulink  | menuselect   | link    | Diff Processed Skyfile       | diffProcessedSkyfile.php
+menulink  | menuselect   | link    | Diff Proc. w/ Images         | diffProcessedSkyfile_Images.php
+menulink  | menuselect   | link    | Diff Failed Skyfile          | diffFailedSkyfile.php
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect   | link    | Magic Summary                | magicSummary.php
+menulink  | menuselect   | link    | Magic Run                    | magicRun.php
+menulink  | menuselect   | link    | Magic Trees                  | magicTrees.php
+menulink  | menuselect   | link    | Magic Processed Nodes        | magicProcessedNodes.php
+menulink  | menuselect   | link    | Magic Processed Masks        | magicProcessedMasks.php
+menulink  | menuselect   | link    | Magic Masks w/ Images        | magicProcessedMasks_Images.php
+menulink  | menuselect   | link    | Magic Failed Trees           | magicFailedTrees.php
+menulink  | menuselect   | link    | Magic Failed Nodes           | magicFailedNodes.php
+menulink  | menuselect   | link    | Magic Failed Masks           | magicFailedMasks.php
+
+menutop   | menutop      | plain   | &nbsp;                       | 
+menulink  | menuselect   | link    | Static Sky Summary           | staticskySummary.php
+menulink  | menuselect   | link    | Static Sky Run               | staticskyRun.php
+menulink  | menuselect   | link    | Static Sky Input Skyfile     | staticskyInputSkyfile.php
+menulink  | menuselect   | link    | Static Sky Processed Skyfile | staticskyProcessedSkyfile.php
+menulink  | menuselect   | link    | Static Sky Failed Skyfile    | staticskyFailedSkyfile.php
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.stack.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.stack.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.stack.php	(revision 31685)
@@ -0,0 +1,17 @@
+<?php 
+
+include 'ipp.php';
+
+$ID = checkID ();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+menu('ipp.stack.dat', 'Stack Steps', 'ipp.css', $ID['link'], $ID['proj']);
+
+// document body
+echo "stack steps<br>\n";
+
+menu_end();
+
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/ipp.warp.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/ipp.warp.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/ipp.warp.php	(revision 31685)
@@ -0,0 +1,17 @@
+<?php 
+
+include 'ipp.php';
+
+$ID = checkID ();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+menu('ipp.warp.dat', 'Warp Steps', 'ipp.css', $ID['link'], $ID['proj']);
+
+// document body
+echo "warp steps<br>\n";
+
+menu_end();
+
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/masterDetrendImfiles.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/masterDetrendImfiles.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/masterDetrendImfiles.php	(revision 31685)
@@ -0,0 +1,95 @@
+<?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 = "ipp.detrend.dat";
+}
+
+menu($myMenu, 'Master Detrend Imfiles', 'ipp.css', $ID['link'], $ID['proj']);
+
+echo "<p> Master Detrend Imfiles </p>";
+
+// define restrictiosn to the queries
+// ** TABLE RESTRICTIONS **
+$WHERE = check_restrict ('det_id', $WHERE);
+$WHERE = check_restrict ('iteration', $WHERE);
+$WHERE = check_restrict ('uri', $WHERE);
+
+// query the database
+if ($WHERE) {
+  $sql = "SELECT det_id,iteration,uri FROM detNormalizedImfile WHERE $WHERE UNION SELECT det_id,iteration,uri FROM detStackedImfile WHERE normalize = 0 AND $WHERE LIMIT 20";
+} else {
+  $sql = "SELECT det_id,iteration,uri FROM detNormalizedImfile UNION SELECT det_id,iteration,uri FROM detStackedImfile WHERE normalize = 0 LIMIT 20";
+}
+
+$qry = $db->query($sql);
+if (dberror($db)) {
+  echo "<b>error reading detStackedImfile table</b><br>\n";
+  menu_end();
+}
+
+// ** HEAD CODE **
+
+// set up the table and form
+echo "<form action=\"masterDetrendImfiles.php\" method=\"POST\">\n";
+
+echo "<table class=list>\n";
+echo "<tr>\n";
+// ** TABLE HEADER **
+echo "<th class=\"list\"> det_id </th>\n";
+echo "<th class=\"list\"> iter </th>\n";
+echo "<th class=\"list\"> uri </th>\n";
+// echo "<th class=list> FIELD </th>\n";
+echo "</tr>\n";
+
+// list the results
+while ($qry->fetchInto($row)) {
+  // $link = "masterDetrendImfiles.php" . "?expID=" . $row[0] . "&" . $ID['link'];
+
+  echo "<tr>\n";
+  // ** TABLE DATA **
+  echo "<td class=\"list\"> $row[0] </td>\n";
+  echo "<td class=\"list\"> $row[1] </td>\n";
+  echo "<td class=\"list\"> $row[2] </td>\n";
+  // echo "<td class=list><a href=\"$link\"> $row[0] </a></td>\n";
+  // echo "<td class=list> $row[1] </td>\n";
+  echo "</tr>\n";
+}
+
+// query restriction form
+echo "<tr>\n";
+// echo "<td class=list> <input type=\"text\" name=\"expID\"></td>\n";
+// ** TABLE QUERY **
+write_query_row ('det_id', 7);
+write_query_row ('iteration', 5);
+write_query_row ('uri', 5);
+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: /branches/sc_branches/ippMonitorLap/raw/nightSummary.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/nightSummary.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/nightSummary.php	(revision 31685)
@@ -0,0 +1,144 @@
+<?php 
+
+$restricted = 0;
+
+include 'ipp.php';
+
+function table_section ($db, $WHERE, $TABLE) {
+
+  $sql = "SELECT label,data_group,workdir,state,count(state) as n FROM $TABLE $WHERE LIMIT 10";
+  if ("$TABLE" == "destreakRun") {
+    $sql = "SELECT label,data_group,outroot,state,count(state) as n FROM magicDSRun $WHERE LIMIT 10";
+  }
+  if ("$TABLE" == "distRun") {
+    $sql = "SELECT label,data_group,outroot,state,count(state) as n FROM $TABLE $WHERE LIMIT 10";
+  }
+
+  $qry = $db->query($sql);
+  if (dberror($qry)) {
+    echo "<tr><td><b>error reading $TABLE table</b></td></tr>\n";
+    echo "<tr><td><br><small><b> table query : $sql </b></small></td></tr>\n";
+  }
+  
+  $class = "list";
+  $nlines = 0;
+
+  // list the results
+  while ($qry->fetchInto($row)) {
+    echo "<tr><td class=\"$class\"><b>$TABLE</b></td>\n";
+    // ** TABLE DATA **
+    write_table_cell ($class, '%s', "", $row[0]);
+    write_table_cell ($class, '%s', "", $row[1]);
+    write_table_cell ($class, '%s', "", $row[2]);
+    write_table_cell ($class, '%s', "", $row[3]);
+    write_table_cell ($class, '%s', "", $row[4]);
+    echo "</tr>\n";
+    $nlines ++;
+  }
+
+  if ($nlines == 0) {
+    echo "<tr><td class\"$class\"><b>$TABLE</b></td></tr>\n";
+  }
+}
+
+$ID = checkID ();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+$db = dbconnect($ID['proj']);
+
+if ($ID['menu']) {
+  $myMenu = $ID['menu'];
+} else {
+  $myMenu = "ipp.imfiles.dat";
+}
+
+menu($myMenu, 'Night Summary', 'ipp.css', $ID['link'], $ID['proj']);
+
+echo "<p> Night Summary </p>\n";
+
+// set up the form
+echo "<form action=\"nightSummary.php\" method=\"POST\">\n";
+
+$restricted = 0;
+
+// define restrictiosn to the queries
+// ** TABLE RESTRICTIONS **
+$WHERE = check_restrict ('label', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('data_group', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('workdir', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('state', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('n', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('n', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('n', $WHERE, 'max', 1.0);
+
+// ensure no valid results
+if ($restricted == 0) {
+  $WHERE = "$WHERE WHERE (0 > 1)";
+}
+
+$WHERE = check_ordering ('state,label', $WHERE);
+
+// 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><td></td>\n";
+write_header_cell ("list", "label");
+write_header_cell ("list", "data_group");
+write_header_cell ("list", "workdir");
+write_header_cell ("list", "state");
+write_header_cell ("list", "count");
+echo "</tr>\n";
+
+// query restriction form
+// echo "<tr>\n";
+// echo "<td class=list> <input type=\"text\" name=\"expID\"></td>\n";
+// ** TABLE QUERY ** (restictions)
+echo "<tr><td>&ge;</td>\n";
+write_query_row ('label', 15, 'string');
+write_query_row ('data_group', 10, 'string');
+write_query_row ('workdir', 7, 'string');
+write_query_row ('state', 7, 'string');
+write_query_row ('n', 7, 'min');
+echo "</tr><tr><td>&le;</td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+write_query_row ('n', 7, 'max');
+echo "</tr>\n";
+
+// query the database (limit is 10, but should be 1
+table_section($db, $WHERE, "chipRun");
+table_section($db, $WHERE, "camRun");
+table_section($db, $WHERE, "fakeRun");
+table_section($db, $WHERE, "warpRun");
+table_section($db, $WHERE, "stackRun");
+table_section($db, $WHERE, "diffRun");
+table_section($db, $WHERE, "magicRun");
+table_section($db, $WHERE, "destreakRun");
+table_section($db, $WHERE, "distRun");
+// table_section($db, $WHERE, "publishRun");
+
+// 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: /branches/sc_branches/ippMonitorLap/raw/phptest.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/phptest.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/phptest.php	(revision 31685)
@@ -0,0 +1,25 @@
+<?php 
+
+include 'ipp.php';
+
+menu('ipp.menu.dat', 'test.page', 'ipp.css', '', '');
+
+$varlist = array ('SERVER_NAME', 'GATEWAY_INTERFACE', 'SERVER_PROTOCOL',
+'SERVER_PORT', 'REQUEST_METHOD', 'PATH_INFO', 'PATH_TRANSLATED', 'SCRIPT_NAME',
+'QUERY_STRING', 'REMOTE_HOST', 'REMOTE_ADDR', 'AUTH_TYPE', 'REMOTE_USER',
+'REMOTE_IDENT', 'CONTENT_TYPE', 'CONTENT_LENGTH');
+
+foreach ($varlist as $name) {
+  echo "$name : $_SERVER[$name]<br>\n";
+}
+
+echo "get list<br>\n";
+foreach ($_GET as $key => $value) {
+  echo "$key : $value<br>\n";
+}
+
+$value = system ("ls /etc", $status);
+echo "status: $status\n";
+
+menu_end();
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/plotHistogram.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/plotHistogram.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/plotHistogram.php	(revision 31685)
@@ -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: /branches/sc_branches/ippMonitorLap/raw/scatterPlot.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/scatterPlot.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/scatterPlot.php	(revision 31685)
@@ -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: /branches/sc_branches/ippMonitorLap/raw/show_and_delete_image.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/show_and_delete_image.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/show_and_delete_image.php	(revision 31685)
@@ -0,0 +1,18 @@
+<?php
+
+### we must have been past arguments with GET:
+if ($_SERVER[REQUEST_METHOD] != 'GET') { 
+  exit ();
+}
+
+$filename = $_GET[file];
+
+$file = fopen ($filename, "r");
+if ($file && !$debug) {
+  header ('Content-Type: image/png');
+  fpassthru ($file);
+}
+
+unlink($filename);
+exit ();
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/showimage.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/showimage.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/showimage.php	(revision 31685)
@@ -0,0 +1,54 @@
+<?php
+
+include 'site.php';
+
+global $WWWHOST;
+global $DBHOST;
+
+$debug = 0;
+$sheet = 'ipp.css';
+
+// load an image file from the image directory
+// validate request
+if ($_SERVER[REQUEST_METHOD] != 'GET') { 
+  exit ();
+}
+
+if ($debug) {
+  echo "args: $args<br>";
+}
+
+# $basename may contain filename@filerule
+$basename = $_GET[name];
+$filerule = $_GET[rule];
+$camera   = $_GET[camera];
+$class_id = $_GET[class_id];
+
+$title = $basename;
+
+if ($debug) {
+  echo "basename: $basename<br>";
+  echo "filerule: $filerule<br>";
+  echo "filerule: $filerule<br>";
+  echo "camera:   $camera<br>";
+  echo "class_id: $class_id<br>";
+  exit ();
+}
+
+  echo "<html><head><title> $title </title></head>\n\n";
+  echo "<link rel=\"STYLESHEET\" HREF=\"$sheet\">\n";
+  echo "<body>\n";
+
+  $root = "/ippMonitor";
+
+  echo "<p style=\"font-size:50%\">host: $WWWHOST, db: $DBHOST</p>\n";
+  echo "<table class=page cellspacing=10px><tr><td valign=top>\n";
+  echo "base: $basename, camera: $camera, class_id: $class_id<br></td>\n";
+
+  echo "<tr><td>\n";
+  echo "<img src=\"getimage.php?name=$basename&rule=$filerule&camera=$camera&class_id=$class_id\">\n";
+  echo "</td></tr></table>\n";
+  echo "</body></html>\n\n";
+
+exit ();
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/simplePlot.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/simplePlot.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/simplePlot.php	(revision 31685)
@@ -0,0 +1,300 @@
+<?php 
+
+include 'ipp.php';
+include 'site.php';
+
+$ID = checkID ();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+$db = dbconnect($ID['proj']);
+
+if ($ID['menu']) {
+  $myMenu = $ID['menu'];
+} else {
+  $myMenu = "ipp.imfiles.dat";
+}
+
+menu($myMenu, 'test simple plot - chip', 'ipp.css', $ID['link'], $ID['proj']);
+
+echo "<p> test sky plot - chip </p>";
+
+// set up the form
+echo "<form action=\"simplePlot.php\" method=\"POST\">\n";
+
+$restricted = 0;
+
+// define restrictiosn to the queries
+// ** TABLE RESTRICTIONS **
+$WHERE = "WHERE chipRun.state != 'new' AND chipRun.exp_id = rawExp.exp_id";
+$WHERE = check_restrict ('rawExp.exp_name', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_id', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_id', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.exp_id', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('chipRun.chip_id', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('chipRun.chip_id', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('chipRun.chip_id', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('chipRun.state', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('chipRun.label', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.telescope', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.camera', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.dateobs', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.dateobs', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.dateobs', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.ra', $WHERE, 'min', 0.017453);
+$WHERE = check_restrict ('rawExp.ra', $WHERE, 'max', 0.017453);
+$WHERE = check_restrict ('rawExp.decl', $WHERE, 'min', 0.017453);
+$WHERE = check_restrict ('rawExp.decl', $WHERE, 'max', 0.017453);
+$WHERE = check_restrict ('rawExp.object', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.filter', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_time', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_time', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.exp_time', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.airmass', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.airmass', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.airmass', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.bg', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.bg', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.bg', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.bg_stdev', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.bg_stdev', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.bg_stdev', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.comment', $WHERE, 'string', 1.0);
+$WHERE = check_ordering ('', $WHERE);
+
+if ($restricted == 0) {
+  if ($WHERE == "") {
+    $WHERE = "$WHERE AND (0 > 1)";
+  } else {
+    $WHERE = "WHERE (0 > 1)";
+  }
+}
+
+// get the result table count
+$sql = "SELECT count(*) FROM chipRun, rawExp $WHERE";
+
+$qry = $db->query($sql);
+if (dberror($qry)) {
+  echo "<b>error reading chipRun, rawExp 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 chipRun, rawExp table count</b><br>\n";
+  echo "<br><small><b> count query : $sql </b></small><br>\n";
+  menu_end();
+}
+$Npoints = $row[0];
+
+echo "<b>$Npoints exposures match selection</b><br>\n";
+
+// ** HEAD CODE **
+
+// ** BUTTON RESTRICTIONS **
+$buttonLink = button_restrict_string ('rawExp.exp_name', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.exp_id', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.exp_id', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.exp_id', $buttonLink);
+$buttonLink = button_restrict_string ('chipRun.chip_id', $buttonLink);
+$buttonLink = button_restrict_min ('chipRun.chip_id', $buttonLink);
+$buttonLink = button_restrict_max ('chipRun.chip_id', $buttonLink);
+$buttonLink = button_restrict_string ('chipRun.state', $buttonLink);
+$buttonLink = button_restrict_string ('chipRun.label', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.telescope', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.camera', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.dateobs', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.dateobs', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.dateobs', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.ra', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.ra', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.ra', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.decl', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.decl', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.decl', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.object', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.filter', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.exp_time', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.exp_time', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.exp_time', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.airmass', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.airmass', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.airmass', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.bg', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.bg', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.bg', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.bg_stdev', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.bg_stdev', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.bg_stdev', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.comment', $buttonLink);
+
+// set up the table
+echo "<table class=list>\n";
+
+// ** TABLE HEADER **
+echo "<tr><td></td>\n";
+write_header_cell ("list", "Exp Name");
+write_header_cell ("list", "Exp ID");
+write_header_cell ("list", "Chip ID");
+write_header_cell ("list", "State");
+write_header_cell ("list", "Label");
+write_header_cell ("list", "Telescope");
+write_header_cell ("list", "Camera");
+write_header_cell ("list", "RA");
+write_header_cell ("list", "DEC");
+write_header_cell ("list", "Comment");
+echo "</tr>\n";
+
+// query restriction form
+// ** TABLE QUERY **
+echo "<tr><td>&ge;</td>\n";
+write_query_row ('rawExp.exp_name', 5, 'string');
+write_query_row ('rawExp.exp_id', 5, 'min');
+write_query_row ('chipRun.chip_id', 7, 'min');
+write_query_row ('chipRun.state', 7, 'string');
+write_query_row ('chipRun.label', 7, 'string');
+write_query_row ('rawExp.telescope', 10, 'string');
+write_query_row ('rawExp.camera', 10, 'string');
+write_query_row ('rawExp.ra', 8, 'min');
+write_query_row ('rawExp.decl', 8, 'min');
+write_query_row ('rawExp.comment', 65, 'string');
+echo "</tr><tr><td>&le;</td>\n";
+echo "<td> &nbsp; </td>\n";
+write_query_row ('rawExp.exp_id', 5, 'max');
+write_query_row ('chipRun.chip_id', 7, 'max');
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+write_query_row ('rawExp.ra', 8, 'max');
+write_query_row ('rawExp.decl', 8, 'max');
+echo "<td> &nbsp; </td>\n";
+echo "</tr>\n";
+
+// ** TABLE HEADER **
+echo "<tr><td></td>\n";
+write_header_cell ("list", "Object");
+write_header_cell ("list", "FILTER");
+write_header_cell ("list", "exp_time    ");
+write_header_cell ("list", "airmass     ");
+write_header_cell ("list", "backgnd");
+write_header_cell ("list", "stdev    ");
+write_header_cell ("list", "Date/Time");
+echo "</tr>\n";
+
+// query restriction form
+// ** TABLE QUERY **
+echo "<tr><td>&ge;</td>\n";
+write_query_row ('rawExp.object', 8, 'string');
+write_query_row ('rawExp.filter', 10, 'string');
+write_query_row ('rawExp.exp_time', 5, 'min');
+write_query_row ('rawExp.airmass', 5, 'min');
+write_query_row ('rawExp.bg', 5, 'min');
+write_query_row ('rawExp.bg_stdev', 5, 'min');
+write_query_row ('rawExp.dateobs', 19, 'min');
+echo "</tr><tr><td>&le;</td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+write_query_row ('rawExp.exp_time', 5, 'max');
+write_query_row ('rawExp.airmass', 5, 'max');
+write_query_row ('rawExp.bg', 5, 'max');
+write_query_row ('rawExp.bg_stdev', 5, 'max');
+write_query_row ('rawExp.dateobs', 19, 'max');
+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 there are no results, don't make an empty figure
+if ($row[0] == 0) {
+  menu_end();
+}
+
+// we write the ra & dec to tmp file 1 and have the plotter generate tmp file 2:
+
+$datfilename = tempnam("/tmp", "dvodat.");
+$pngfilename = tempnam("/tmp", "dvopng.");
+
+$datfile = fopen($datfilename, "w");
+
+// query the database
+$sql = "SELECT rawExp.ra,rawExp.decl,rawExp.filter FROM chipRun, rawExp $WHERE";
+
+$qry = $db->query($sql);
+if (dberror($qry)) {
+  echo "<b>error reading chipRun, rawExp table</b><br>\n";
+  echo "<br><small><b> table query : $sql </b></small><br>\n";
+  menu_end();
+}
+
+// list the results
+while ($qry->fetchInto($row)) {
+  switch ($row[2]) {
+   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 'g':
+    $filter = 1;
+    break;
+   case 'r':
+    $filter = 2;
+    break;
+   case 'i':
+    $filter = 3;
+    break;
+   case 'z':
+    $filter = 4;
+    break;
+   case 'y':
+    $filter = 5;
+    break;
+   case 'w':
+    $filter = 6;
+    break;
+   default:
+    $filter = 0;
+    break;
+  }
+
+  $line = "$row[0] $row[1] $filter\n";
+  fwrite ($datfile, $line);
+}
+fclose($datfile);
+
+echo "<img src=\"skyplot.php?input=$datfilename&output=$pngfilename\"><br>\n";
+
+// ** TAIL CODE **
+
+echo "<small> WHERE: $WHERE<br><br></small>\n";
+echo "<small> SQL: $sql<br><br></small>\n";
+
+menu_end();
+
+unlink ($datfilename);
+unlink ($pngfilename);
+
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/simplePlotcam.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/simplePlotcam.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/simplePlotcam.php	(revision 31685)
@@ -0,0 +1,300 @@
+<?php 
+
+include 'ipp.php';
+include 'site.php';
+
+$ID = checkID ();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+$db = dbconnect($ID['proj']);
+
+if ($ID['menu']) {
+  $myMenu = $ID['menu'];
+} else {
+  $myMenu = "ipp.imfiles.dat";
+}
+
+menu($myMenu, 'test simple plot', 'ipp.css', $ID['link'], $ID['proj']);
+
+echo "<p> test sky plot - cam</p>";
+
+// set up the form
+echo "<form action=\"simplePlotcam.php\" method=\"POST\">\n";
+
+$restricted = 0;
+
+// define restrictiosn to the queries
+// ** TABLE RESTRICTIONS **
+$WHERE = "WHERE camRun.state != 'new' AND chipRun.exp_id = rawExp.exp_id AND camRun.chip_id = chipRun.chip_id";
+$WHERE = check_restrict ('rawExp.exp_name', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_id', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_id', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.exp_id', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('camRun.cam_id', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('camRun.cam_id', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('camRun.cam_id', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('camRun.state', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('camRun.label', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.telescope', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.camera', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.dateobs', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.dateobs', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.dateobs', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.ra', $WHERE, 'min', 0.017453);
+$WHERE = check_restrict ('rawExp.ra', $WHERE, 'max', 0.017453);
+$WHERE = check_restrict ('rawExp.decl', $WHERE, 'min', 0.017453);
+$WHERE = check_restrict ('rawExp.decl', $WHERE, 'max', 0.017453);
+$WHERE = check_restrict ('rawExp.object', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.filter', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_time', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_time', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.exp_time', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.airmass', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.airmass', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.airmass', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.bg', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.bg', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.bg', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.bg_stdev', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.bg_stdev', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.bg_stdev', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.comment', $WHERE, 'string', 1.0);
+$WHERE = check_ordering ('', $WHERE);
+
+if ($restricted == 0) {
+  if ($WHERE == "") {
+    $WHERE = "$WHERE AND (0 > 1)";
+  } else {
+    $WHERE = "WHERE (0 > 1)";
+  }
+}
+
+// get the result table count
+$sql = "SELECT count(*) FROM camRun, chipRun, rawExp $WHERE";
+
+$qry = $db->query($sql);
+if (dberror($qry)) {
+  echo "<b>error reading camRun, chipRun, rawExp 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 camRun, chipRun, rawExp table count</b><br>\n";
+  echo "<br><small><b> count query : $sql </b></small><br>\n";
+  menu_end();
+}
+$Npoints = $row[0];
+
+echo "<b>$Npoints exposures match selection</b><br>\n";
+
+// ** HEAD CODE **
+
+// ** BUTTON RESTRICTIONS **
+$buttonLink = button_restrict_string ('rawExp.exp_name', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.exp_id', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.exp_id', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.exp_id', $buttonLink);
+$buttonLink = button_restrict_string ('camRun.cam_id', $buttonLink);
+$buttonLink = button_restrict_min ('camRun.cam_id', $buttonLink);
+$buttonLink = button_restrict_max ('camRun.cam_id', $buttonLink);
+$buttonLink = button_restrict_string ('camRun.state', $buttonLink);
+$buttonLink = button_restrict_string ('camRun.label', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.telescope', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.camera', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.dateobs', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.dateobs', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.dateobs', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.ra', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.ra', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.ra', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.decl', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.decl', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.decl', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.object', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.filter', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.exp_time', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.exp_time', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.exp_time', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.airmass', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.airmass', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.airmass', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.bg', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.bg', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.bg', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.bg_stdev', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.bg_stdev', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.bg_stdev', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.comment', $buttonLink);
+
+// set up the table
+echo "<table class=list>\n";
+
+// ** TABLE HEADER **
+echo "<tr><td></td>\n";
+write_header_cell ("list", "Exp Name");
+write_header_cell ("list", "Exp ID");
+write_header_cell ("list", "Cam ID");
+write_header_cell ("list", "State");
+write_header_cell ("list", "Label");
+write_header_cell ("list", "Telescope");
+write_header_cell ("list", "Camera");
+write_header_cell ("list", "RA");
+write_header_cell ("list", "DEC");
+write_header_cell ("list", "Comment");
+echo "</tr>\n";
+
+// query restriction form
+// ** TABLE QUERY **
+echo "<tr><td>&ge;</td>\n";
+write_query_row ('rawExp.exp_name', 5, 'string');
+write_query_row ('rawExp.exp_id', 5, 'min');
+write_query_row ('camRun.cam_id', 7, 'min');
+write_query_row ('camRun.state', 7, 'string');
+write_query_row ('camRun.label', 7, 'string');
+write_query_row ('rawExp.telescope', 10, 'string');
+write_query_row ('rawExp.camera', 10, 'string');
+write_query_row ('rawExp.ra', 8, 'min');
+write_query_row ('rawExp.decl', 8, 'min');
+write_query_row ('rawExp.comment', 65, 'string');
+echo "</tr><tr><td>&le;</td>\n";
+echo "<td> &nbsp; </td>\n";
+write_query_row ('rawExp.exp_id', 5, 'max');
+write_query_row ('camRun.cam_id', 7, 'max');
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+write_query_row ('rawExp.ra', 8, 'max');
+write_query_row ('rawExp.decl', 8, 'max');
+echo "<td> &nbsp; </td>\n";
+echo "</tr>\n";
+
+// ** TABLE HEADER **
+echo "<tr><td></td>\n";
+write_header_cell ("list", "Object");
+write_header_cell ("list", "FILTER");
+write_header_cell ("list", "exp_time    ");
+write_header_cell ("list", "airmass     ");
+write_header_cell ("list", "backgnd");
+write_header_cell ("list", "stdev    ");
+write_header_cell ("list", "Date/Time");
+echo "</tr>\n";
+
+// query restriction form
+// ** TABLE QUERY **
+echo "<tr><td>&ge;</td>\n";
+write_query_row ('rawExp.object', 8, 'string');
+write_query_row ('rawExp.filter', 10, 'string');
+write_query_row ('rawExp.exp_time', 5, 'min');
+write_query_row ('rawExp.airmass', 5, 'min');
+write_query_row ('rawExp.bg', 5, 'min');
+write_query_row ('rawExp.bg_stdev', 5, 'min');
+write_query_row ('rawExp.dateobs', 19, 'min');
+echo "</tr><tr><td>&le;</td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+write_query_row ('rawExp.exp_time', 5, 'max');
+write_query_row ('rawExp.airmass', 5, 'max');
+write_query_row ('rawExp.bg', 5, 'max');
+write_query_row ('rawExp.bg_stdev', 5, 'max');
+write_query_row ('rawExp.dateobs', 19, 'max');
+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 there are no results, don't make an empty figure
+if ($row[0] == 0) {
+  menu_end();
+}
+
+// we write the ra & dec to tmp file 1 and have the plotter generate tmp file 2:
+
+$datfilename = tempnam("/tmp", "dvodat.");
+$pngfilename = tempnam("/tmp", "dvopng.");
+
+$datfile = fopen($datfilename, "w");
+
+// query the database
+$sql = "SELECT rawExp.ra,rawExp.decl,rawExp.filter FROM camRun, chipRun, rawExp $WHERE";
+
+$qry = $db->query($sql);
+if (dberror($qry)) {
+  echo "<b>error reading camRun, rawExp table</b><br>\n";
+  echo "<br><small><b> table query : $sql </b></small><br>\n";
+  menu_end();
+}
+
+// list the results
+while ($qry->fetchInto($row)) {
+  switch ($row[2]) {
+   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 'g':
+    $filter = 1;
+    break;
+   case 'r':
+    $filter = 2;
+    break;
+   case 'i':
+    $filter = 3;
+    break;
+   case 'z':
+    $filter = 4;
+    break;
+   case 'y':
+    $filter = 5;
+    break;
+   case 'w':
+    $filter = 6;
+    break;   
+   default:
+    $filter = 0;
+    break;
+  }
+
+  $line = "$row[0] $row[1] $filter\n";
+  fwrite ($datfile, $line);
+}
+fclose($datfile);
+
+echo "<img src=\"skyplot.php?input=$datfilename&output=$pngfilename\"><br>\n";
+
+// ** TAIL CODE **
+
+echo "<small> WHERE: $WHERE<br><br></small>\n";
+echo "<small> SQL: $sql<br><br></small>\n";
+
+menu_end();
+
+unlink ($datfilename);
+unlink ($pngfilename);
+
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/simplePlotraw.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/simplePlotraw.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/simplePlotraw.php	(revision 31685)
@@ -0,0 +1,280 @@
+<?php 
+
+include 'ipp.php';
+include 'site.php';
+
+$ID = checkID ();
+
+// require an explicit project
+if (! $ID['proj']) { projectform ($ID); }
+
+$db = dbconnect($ID['proj']);
+
+if ($ID['menu']) {
+  $myMenu = $ID['menu'];
+} else {
+  $myMenu = "ipp.imfiles.dat";
+}
+
+menu($myMenu, 'test simple plot', 'ipp.css', $ID['link'], $ID['proj']);
+
+echo "<p> test sky plot - raw </p>";
+
+// set up the form
+echo "<form action=\"simplePlotraw.php\" method=\"POST\">\n";
+
+$restricted = 0;
+
+// define restrictiosn to the queries
+// ** TABLE RESTRICTIONS **
+$WHERE = check_restrict ('rawExp.exp_name', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_id', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_id', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.exp_id', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.telescope', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.camera', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.dateobs', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.dateobs', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.dateobs', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.ra', $WHERE, 'min', 0.017453);
+$WHERE = check_restrict ('rawExp.ra', $WHERE, 'max', 0.017453);
+$WHERE = check_restrict ('rawExp.decl', $WHERE, 'min', 0.017453);
+$WHERE = check_restrict ('rawExp.decl', $WHERE, 'max', 0.017453);
+$WHERE = check_restrict ('rawExp.object', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.filter', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_time', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_time', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.exp_time', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.airmass', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.airmass', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.airmass', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.bg', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.bg', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.bg', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.bg_stdev', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.bg_stdev', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.bg_stdev', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.comment', $WHERE, 'string', 1.0);
+$WHERE = check_ordering ('', $WHERE);
+
+if ($restricted == 0) {
+  if ($WHERE == "") {
+    $WHERE = "WHERE (0 > 1)";
+  } else {
+    $WHERE = "WHERE (0 > 1)";
+  }
+}
+
+// get the result table count
+$sql = "SELECT count(*) FROM rawExp $WHERE";
+
+$qry = $db->query($sql);
+if (dberror($qry)) {
+  echo "<b>error reading rawExp 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 rawExp table count</b><br>\n";
+  echo "<br><small><b> count query : $sql </b></small><br>\n";
+  menu_end();
+}
+$Npoints = $row[0];
+
+echo "<b>$Npoints exposures match selection</b><br>\n";
+
+// ** HEAD CODE **
+
+// ** BUTTON RESTRICTIONS **
+$buttonLink = button_restrict_string ('rawExp.exp_name', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.exp_id', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.exp_id', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.exp_id', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.telescope', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.camera', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.dateobs', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.dateobs', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.dateobs', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.ra', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.ra', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.ra', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.decl', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.decl', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.decl', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.object', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.filter', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.exp_time', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.exp_time', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.exp_time', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.airmass', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.airmass', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.airmass', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.bg', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.bg', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.bg', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.bg_stdev', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.bg_stdev', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.bg_stdev', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.comment', $buttonLink);
+
+// set up the table
+echo "<table class=list>\n";
+
+// ** TABLE HEADER **
+echo "<tr><td></td>\n";
+write_header_cell ("list", "Exp Name");
+write_header_cell ("list", "Exp ID");
+write_header_cell ("list", "Telescope");
+write_header_cell ("list", "Camera");
+write_header_cell ("list", "RA");
+write_header_cell ("list", "DEC");
+write_header_cell ("list", "Comment");
+echo "</tr>\n";
+
+// query restriction form
+// ** TABLE QUERY **
+echo "<tr><td>&ge;</td>\n";
+write_query_row ('rawExp.exp_name', 5, 'string');
+write_query_row ('rawExp.exp_id', 5, 'min');
+write_query_row ('rawExp.telescope', 10, 'string');
+write_query_row ('rawExp.camera', 10, 'string');
+write_query_row ('rawExp.ra', 8, 'min');
+write_query_row ('rawExp.decl', 8, 'min');
+write_query_row ('rawExp.comment', 65, 'string');
+echo "</tr><tr><td>&le;</td>\n";
+echo "<td> &nbsp; </td>\n";
+write_query_row ('rawExp.exp_id', 5, 'max');
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+write_query_row ('rawExp.ra', 8, 'max');
+write_query_row ('rawExp.decl', 8, 'max');
+echo "<td> &nbsp; </td>\n";
+echo "</tr>\n";
+
+// ** TABLE HEADER **
+echo "<tr><td></td>\n";
+write_header_cell ("list", "Object");
+write_header_cell ("list", "FILTER");
+write_header_cell ("list", "exp_time    ");
+write_header_cell ("list", "airmass     ");
+write_header_cell ("list", "backgnd");
+write_header_cell ("list", "stdev    ");
+write_header_cell ("list", "Date/Time");
+echo "</tr>\n";
+
+// query restriction form
+// ** TABLE QUERY **
+echo "<tr><td>&ge;</td>\n";
+write_query_row ('rawExp.object', 8, 'string');
+write_query_row ('rawExp.filter', 10, 'string');
+write_query_row ('rawExp.exp_time', 5, 'min');
+write_query_row ('rawExp.airmass', 5, 'min');
+write_query_row ('rawExp.bg', 5, 'min');
+write_query_row ('rawExp.bg_stdev', 5, 'min');
+write_query_row ('rawExp.dateobs', 19, 'min');
+echo "</tr><tr><td>&le;</td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+write_query_row ('rawExp.exp_time', 5, 'max');
+write_query_row ('rawExp.airmass', 5, 'max');
+write_query_row ('rawExp.bg', 5, 'max');
+write_query_row ('rawExp.bg_stdev', 5, 'max');
+write_query_row ('rawExp.dateobs', 19, 'max');
+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 there are no results, don't make an empty figure
+if ($row[0] == 0) {
+  menu_end();
+}
+
+// we write the ra & dec to tmp file 1 and have the plotter generate tmp file 2:
+
+$datfilename = tempnam("/tmp", "dvodat.");
+$pngfilename = tempnam("/tmp", "dvopng.");
+
+$datfile = fopen($datfilename, "w");
+
+// query the database
+$sql = "SELECT rawExp.ra,rawExp.decl,rawExp.filter FROM rawExp $WHERE";
+
+$qry = $db->query($sql);
+if (dberror($qry)) {
+  echo "<b>error reading rawExp table</b><br>\n";
+  echo "<br><small><b> table query : $sql </b></small><br>\n";
+  menu_end();
+}
+
+// list the results
+while ($qry->fetchInto($row)) {
+  switch ($row[2]) {
+   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 'g':
+    $filter = 1;
+    break;
+   case 'r':
+    $filter = 2;
+    break;
+   case 'i':
+    $filter = 3;
+    break;
+   case 'z':
+    $filter = 4;
+    break;
+   case 'y':
+    $filter = 5;
+    break;
+   case 'w':
+    $filter = 6;
+    break;
+   default:
+    $filter = 0;
+    break;
+  }
+
+  $line = "$row[0] $row[1] $filter\n";
+  fwrite ($datfile, $line);
+}
+fclose($datfile);
+
+echo "<img src=\"skyplot.php?input=$datfilename&output=$pngfilename\"><br>\n";
+
+// ** TAIL CODE **
+
+echo "<small> WHERE: $WHERE<br><br></small>\n";
+echo "<small> SQL: $sql<br><br></small>\n";
+
+menu_end();
+
+unlink ($datfilename);
+unlink ($pngfilename);
+
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/site.php.in
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/site.php.in	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/site.php.in	(revision 31685)
@@ -0,0 +1,44 @@
+<?php
+
+$WWWHOST = "@HOST@";
+$DBHOST  = "@DBHOST@";
+$DBUSER  = "@DBUSER@";
+$DBPASS  = "@DBPASS@";
+
+$PERLLIB = "@PERLLIB@";
+$BINDIR  = "@BINDIR@";
+$LIBDIR  = "@LIBDIR@";
+$SITE    = "@SITE@";
+
+$PSCONFDIR = "@PSCONFDIR@";
+$PSCONFIG  = "@PSCONFIG@";
+
+$DBI     = "@DBI@";
+
+// Temporary files belonging to DELETION_USER and older than 
+// DELETION_DELAY minutes will be delayed by the
+// delete_old_tmp_files() function (see raw/ipp.php)
+$DELETION_USER  = "apache";
+$DELETION_DELAY = 15;
+
+$REPL_HOST_IPPADMIN = "ipp0012.IfA.Hawaii.Edu";
+$REPL_USER_IPPADMIN = "ipp";
+$REPL_PASSWORD_IPPADMIN = "ipp";
+$REPL_DBNAME_IPPADMIN = "ippadmin";
+
+$REPL_HOST_NEBULOUS = "ippdb02.IfA.Hawaii.Edu";
+$REPL_USER_NEBULOUS = "ippMonitor";
+$REPL_PASSWORD_NEBULOUS = "ippMonitor";
+$REPL_DBNAME_NEBULOUS = "Nebulous";
+
+$REPL_HOST_PSTAMP = "ippc19.IfA.Hawaii.Edu";
+$REPL_USER_PSTAMP = "ippMonitor";
+$REPL_PASSWORD_PSTAMP = "ippMonitor";
+$REPL_DBNAME_PSTAMP = "ippRequestServer";
+
+$REPL_HOST_GPC1 = "ippdb03.IfA.Hawaii.Edu";
+$REPL_USER_GPC1 = "ippMonitor";
+$REPL_PASSWORD_GPC1 = "ippMonitor";
+$REPL_DBNAME_GPC1 = "gpc1";
+
+?>
Index: /branches/sc_branches/ippMonitorLap/raw/skyplot.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/skyplot.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/skyplot.php	(revision 31685)
@@ -0,0 +1,70 @@
+<?php
+
+# this program takes two arguments: 
+# an input list of RA, DEC, n(FILTER)
+# an output png filename
+# it generates a sky plot showing the locations of the given list of points
+
+$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 skyplot.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];
+
+$output = shell_exec("skyplot.dvo $infile $outfile");//, $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: /branches/sc_branches/ippMonitorLap/raw/warpProcessedExp.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/warpProcessedExp.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/warpProcessedExp.php	(revision 31685)
@@ -0,0 +1,367 @@
+<?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 = "ipp.science.dat";
+}
+
+menu($myMenu, 'Warp Processed Exposures', 'ipp.css', $ID['link'], $ID['proj']);
+
+echo "<p> Warp Processed Exposures </p>";
+
+// set up the form
+echo "<form action=\"warpProcessedExp.php\" method=\"POST\">\n";
+
+$restricted = 0;
+
+// define restrictiosn to the queries
+// ** TABLE RESTRICTIONS **
+$WHERE = "WHERE warpRun.fake_id = fakeRun.fake_id AND fakeRun.cam_id = camRun.cam_id AND camRun.chip_id = chipRun.chip_id  AND chipRun.exp_id = rawExp.exp_id";
+$WHERE = check_restrict ('rawExp.exp_name', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_id', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_id', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.exp_id', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('chipRun.chip_id', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('chipRun.chip_id', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('chipRun.chip_id', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('camRun.cam_id', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('camRun.cam_id', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('camRun.cam_id', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('fakeRun.fake_id', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('fakeRun.fake_id', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('fakeRun.fake_id', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('warpRun.warp_id', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('warpRun.warp_id', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('warpRun.warp_id', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('warpRun.state', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('warpRun.label', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('warpRun.data_group', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('warpRun.dist_group', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.telescope', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.camera', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.dateobs', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.dateobs', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.dateobs', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.ra', $WHERE, 'min', 0.017453);
+$WHERE = check_restrict ('rawExp.ra', $WHERE, 'max', 0.017453);
+$WHERE = check_restrict ('rawExp.decl', $WHERE, 'min', 0.017453);
+$WHERE = check_restrict ('rawExp.decl', $WHERE, 'max', 0.017453);
+$WHERE = check_restrict ('rawExp.object', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.filter', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_time', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_time', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.exp_time', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.airmass', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.airmass', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.airmass', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.bg', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.bg', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.bg', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.bg_stdev', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.bg_stdev', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.bg_stdev', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.comment', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('warpSummary.path_base', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('warpSummary.projection_cell', $WHERE, 'string', 1.0);
+$WHERE = check_ordering ('', $WHERE);
+
+if ($restricted == 0) {
+  if ("none" != "none") {
+    $WHERE = "$WHERE none";
+  }
+}
+
+// get the result table count
+if (basic == "basic") {
+  $sql = "SELECT count(*) FROM warpRun, fakeRun, camRun, chipRun, rawExp, warpSummary $WHERE";
+}
+if (basic == "summary") {
+  $sql = "SELECT count(*) FROM (SELECT rawExp.exp_name,rawExp.exp_id,chipRun.chip_id,camRun.cam_id,fakeRun.fake_id,warpRun.warp_id,warpRun.state,warpRun.label,warpRun.data_group,warpRun.dist_group,rawExp.telescope,rawExp.camera,rawExp.dateobs,rawExp.ra,rawExp.decl,rawExp.object,rawExp.filter,rawExp.exp_time,rawExp.airmass,rawExp.bg,rawExp.bg_stdev,rawExp.comment,warpSummary.path_base,warpSummary.projection_cell FROM warpRun, fakeRun, camRun, chipRun, rawExp, warpSummary $WHERE) as TEMP";
+}
+
+$qry = $db->query($sql);
+if (dberror($qry)) {
+  echo "<b>error reading warpRun, fakeRun, camRun, chipRun, rawExp, warpSummary 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 warpRun, fakeRun, camRun, chipRun, rawExp, warpSummary table count</b><br>\n";
+  echo "<br><small><b> count query : $sql </b></small><br>\n";
+  menu_end();
+}
+// set up the row counter variables
+if ($ID['from']) {
+  $rowStart = $ID['from'];
+} else {
+  $rowStart = 0;
+}
+$rowLast = $rowStart + $dTABLE;
+$rowTotal = $row[0];
+if ($rowLast > $rowTotal) { $rowLast = $rowTotal; }
+echo "<b> $rowStart to $rowLast of $rowTotal items</b><br>\n";
+
+// query the database
+if (basic == "basic") {
+  $sql = "SELECT rawExp.exp_name,rawExp.exp_id,chipRun.chip_id,camRun.cam_id,fakeRun.fake_id,warpRun.warp_id,warpRun.state,warpRun.label,warpRun.data_group,warpRun.dist_group,rawExp.telescope,rawExp.camera,rawExp.dateobs,rawExp.ra,rawExp.decl,rawExp.object,rawExp.filter,rawExp.exp_time,rawExp.airmass,rawExp.bg,rawExp.bg_stdev,rawExp.comment,ifnull(warpSummary.path_base,'noimage'),ifnull(warpSummary.projection_cell,'noimage') FROM fakeRun,camRun,chipRun,rawExp,warpRun LEFT JOIN warpSummary ON warpSummary.warp_id = warpRun.warp_id $WHERE LIMIT $dTABLE OFFSET $rowStart";
+}
+
+$qry = $db->query($sql);
+if (dberror($qry)) {
+  echo "<b>error reading warpRun, fakeRun, camRun, chipRun, rawExp, warpSummary table</b><br>\n";
+  echo "<br><small><b> table query : $sql </b></small><br>\n";
+  menu_end();
+}
+
+// ** HEAD CODE **
+
+// ** BUTTON RESTRICTIONS **
+$buttonLink = button_restrict_string ('rawExp.exp_name', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.exp_id', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.exp_id', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.exp_id', $buttonLink);
+$buttonLink = button_restrict_string ('chipRun.chip_id', $buttonLink);
+$buttonLink = button_restrict_min ('chipRun.chip_id', $buttonLink);
+$buttonLink = button_restrict_max ('chipRun.chip_id', $buttonLink);
+$buttonLink = button_restrict_string ('camRun.cam_id', $buttonLink);
+$buttonLink = button_restrict_min ('camRun.cam_id', $buttonLink);
+$buttonLink = button_restrict_max ('camRun.cam_id', $buttonLink);
+$buttonLink = button_restrict_string ('fakeRun.fake_id', $buttonLink);
+$buttonLink = button_restrict_min ('fakeRun.fake_id', $buttonLink);
+$buttonLink = button_restrict_max ('fakeRun.fake_id', $buttonLink);
+$buttonLink = button_restrict_string ('warpRun.warp_id', $buttonLink);
+$buttonLink = button_restrict_min ('warpRun.warp_id', $buttonLink);
+$buttonLink = button_restrict_max ('warpRun.warp_id', $buttonLink);
+$buttonLink = button_restrict_string ('warpRun.state', $buttonLink);
+$buttonLink = button_restrict_string ('warpRun.label', $buttonLink);
+$buttonLink = button_restrict_string ('warpRun.data_group', $buttonLink);
+$buttonLink = button_restrict_string ('warpRun.dist_group', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.telescope', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.camera', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.dateobs', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.dateobs', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.dateobs', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.ra', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.ra', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.ra', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.decl', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.decl', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.decl', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.object', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.filter', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.exp_time', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.exp_time', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.exp_time', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.airmass', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.airmass', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.airmass', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.bg', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.bg', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.bg', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.bg_stdev', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.bg_stdev', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.bg_stdev', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.comment', $buttonLink);
+$buttonLink = button_restrict_string ('warpSummary.path_base', $buttonLink);
+$buttonLink = button_restrict_string ('warpSummary.projection_cell', $buttonLink);
+navigate_buttons ($rowStart, $rowLast, $dTABLE, $rowTotal, $buttonLink, $ID, 'warpProcessedExp.php');
+
+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><td></td>\n";
+write_header_cell ("list", "Exp Name");
+write_header_cell ("list", "Exp ID");
+write_header_cell ("list", "Chip ID");
+write_header_cell ("list", "Cam ID");
+write_header_cell ("list", "Fake ID");
+write_header_cell ("list", "Warp ID");
+write_header_cell ("list", "image");
+write_header_cell ("list", "state");
+write_header_cell ("list", "label");
+write_header_cell ("list", "data grp");
+write_header_cell ("list", "dist grp");
+write_header_cell ("list", "Telescope");
+write_header_cell ("list", "Camera");
+write_header_cell ("list", "Date/Time");
+write_header_cell ("list", "RA");
+write_header_cell ("list", "DEC");
+write_header_cell ("list", "Object");
+write_header_cell ("list", "FILTER");
+write_header_cell ("list", "exp_time    ");
+write_header_cell ("list", "airmass     ");
+write_header_cell ("list", "backgnd");
+write_header_cell ("list", "stdev    ");
+write_header_cell ("list", "Comment");
+echo "</tr>\n";
+echo "<tr><td></td>\n";
+write_sort_cell ("list", "rawExp.exp_name", $buttonLink, $ID, 'warpProcessedExp.php');
+write_sort_cell ("list", "rawExp.exp_id", $buttonLink, $ID, 'warpProcessedExp.php');
+write_sort_cell ("list", "chipRun.chip_id", $buttonLink, $ID, 'warpProcessedExp.php');
+write_sort_cell ("list", "camRun.cam_id", $buttonLink, $ID, 'warpProcessedExp.php');
+write_sort_cell ("list", "fakeRun.fake_id", $buttonLink, $ID, 'warpProcessedExp.php');
+write_sort_cell ("list", "warpRun.warp_id", $buttonLink, $ID, 'warpProcessedExp.php');
+echo "<td></td>\n";
+write_sort_cell ("list", "warpRun.state", $buttonLink, $ID, 'warpProcessedExp.php');
+write_sort_cell ("list", "warpRun.label", $buttonLink, $ID, 'warpProcessedExp.php');
+write_sort_cell ("list", "warpRun.data_group", $buttonLink, $ID, 'warpProcessedExp.php');
+write_sort_cell ("list", "warpRun.dist_group", $buttonLink, $ID, 'warpProcessedExp.php');
+write_sort_cell ("list", "rawExp.telescope", $buttonLink, $ID, 'warpProcessedExp.php');
+write_sort_cell ("list", "rawExp.camera", $buttonLink, $ID, 'warpProcessedExp.php');
+write_sort_cell ("list", "rawExp.dateobs", $buttonLink, $ID, 'warpProcessedExp.php');
+write_sort_cell ("list", "rawExp.ra * 57.295783", $buttonLink, $ID, 'warpProcessedExp.php');
+write_sort_cell ("list", "rawExp.decl * 57.295783", $buttonLink, $ID, 'warpProcessedExp.php');
+write_sort_cell ("list", "rawExp.object", $buttonLink, $ID, 'warpProcessedExp.php');
+write_sort_cell ("list", "rawExp.filter", $buttonLink, $ID, 'warpProcessedExp.php');
+write_sort_cell ("list", "rawExp.exp_time", $buttonLink, $ID, 'warpProcessedExp.php');
+write_sort_cell ("list", "rawExp.airmass", $buttonLink, $ID, 'warpProcessedExp.php');
+write_sort_cell ("list", "rawExp.bg", $buttonLink, $ID, 'warpProcessedExp.php');
+write_sort_cell ("list", "rawExp.bg_stdev", $buttonLink, $ID, 'warpProcessedExp.php');
+write_sort_cell ("list", "rawExp.comment", $buttonLink, $ID, 'warpProcessedExp.php');
+echo "</tr>\n";
+// echo "</tr>\n";
+
+// query restriction form
+// echo "<tr>\n";
+// echo "<td class=list> <input type=\"text\" name=\"expID\"></td>\n";
+// ** TABLE QUERY **
+echo "<tr><td>&ge;</td>\n";
+write_query_row ('rawExp.exp_name', 5, 'string');
+write_query_row ('rawExp.exp_id', 5, 'min');
+write_query_row ('chipRun.chip_id', 7, 'min');
+write_query_row ('camRun.cam_id', 7, 'min');
+write_query_row ('fakeRun.fake_id', 7, 'min');
+write_query_row ('warpRun.warp_id', 7, 'min');
+echo "<td> &nbsp; </td>\n";
+write_query_row ('warpRun.state', 7, 'string');
+write_query_row ('warpRun.label', 7, 'string');
+write_query_row ('warpRun.data_group', 7, 'string');
+write_query_row ('warpRun.dist_group', 7, 'string');
+write_query_row ('rawExp.telescope', 10, 'string');
+write_query_row ('rawExp.camera', 10, 'string');
+write_query_row ('rawExp.dateobs', 19, 'min');
+write_query_row ('rawExp.ra', 8, 'min');
+write_query_row ('rawExp.decl', 8, 'min');
+write_query_row ('rawExp.object', 8, 'string');
+write_query_row ('rawExp.filter', 10, 'string');
+write_query_row ('rawExp.exp_time', 5, 'min');
+write_query_row ('rawExp.airmass', 5, 'min');
+write_query_row ('rawExp.bg', 5, 'min');
+write_query_row ('rawExp.bg_stdev', 5, 'min');
+write_query_row ('rawExp.comment', 65, 'string');
+echo "</tr><tr><td>&le;</td>\n";
+echo "<td> &nbsp; </td>\n";
+write_query_row ('rawExp.exp_id', 5, 'max');
+write_query_row ('chipRun.chip_id', 7, 'max');
+write_query_row ('camRun.cam_id', 7, 'max');
+write_query_row ('fakeRun.fake_id', 7, 'max');
+write_query_row ('warpRun.warp_id', 7, 'max');
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+write_query_row ('rawExp.dateobs', 19, 'max');
+write_query_row ('rawExp.ra', 8, 'max');
+write_query_row ('rawExp.decl', 8, 'max');
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+write_query_row ('rawExp.exp_time', 5, 'max');
+write_query_row ('rawExp.airmass', 5, 'max');
+write_query_row ('rawExp.bg', 5, 'max');
+write_query_row ('rawExp.bg_stdev', 5, 'max');
+echo "<td> &nbsp; </td>\n";
+echo "</tr>\n";
+// echo "</tr>\n";
+
+// list the results
+while ($qry->fetchInto($row)) {
+  // $link = "warpProcessedExp.php" . "?expID=" . $row[0] . "&" . $ID['link'];
+
+  $class = "list";
+  // ** TD CLASS **
+
+  echo "<tr><td></td>\n";
+  // ** TABLE DATA **
+  write_table_cell ($class, '%s', "", $row[0]);
+  $link = "rawImfile.php" . "?menu=ipp.science.dat&" . $ID['link'];
+  $link = $link . "&rawImfile.exp_id=$row[1]";
+  write_table_cell ($class, '%d', $link, $row[1]);
+  $link = "chipProcessedImfile.php" . "?menu=ipp.science.dat&" . $ID['link'];
+  $link = $link . "&chipRun.chip_id=$row[2]";
+  write_table_cell ($class, '%d', $link, $row[2]);
+  $link = "camProcessedExp.php" . "?menu=ipp.science.dat&" . $ID['link'];
+  $link = $link . "&camRun.cam_id=$row[3]";
+  write_table_cell ($class, '%d', $link, $row[3]);
+  $link = "fakeProcessedImfile.php" . "?menu=ipp.science.dat&" . $ID['link'];
+  $link = $link . "&fakeRun.fake_id=$row[4]";
+  write_table_cell ($class, '%d', $link, $row[4]);
+  $link = "warpStageExp.php" . "?menu=ipp.science.dat&" . $ID['link'];
+  $link = $link . "&warpRun.warp_id=$row[5]";
+  write_table_cell ($class, '%d', $link, $row[5]);
+  $link = "getimage.php" . "?menu=ipp.science.dat&" . $ID['link'];
+  $link = $link . "&name=$row[22].$row[23]";
+  $link = $link . "&rule=PPSKYCELL.JPEG1";
+  $link = $link . "&camera=GPC1";
+  $link = $link . "&class_id=NONE";
+  echo "<td class=\"$class\"><a href=\"$link\"> <img src=\"getimage.php?name=$row[22].$row[23]&rule=PPSKYCELL.JPEG2&camera=$row[11]&class_id=NONE\"> </a></td>\n";
+  write_table_cell ($class, '%s', "", $row[6]);
+  write_table_cell ($class, '%s', "", $row[7]);
+  write_table_cell ($class, '%s', "", $row[8]);
+  write_table_cell ($class, '%s', "", $row[9]);
+  write_table_cell ($class, '%s', "", $row[10]);
+  write_table_cell ($class, '%s', "", $row[11]);
+  write_table_cell ($class, '%T', "", $row[12]);
+  write_table_cell ($class, '%C', "", $row[13] * 57.295783);
+  write_table_cell ($class, '%C', "", $row[14] * 57.295783);
+  write_table_cell ($class, '%s', "", $row[15]);
+  write_table_cell ($class, '%s', "", $row[16]);
+  write_table_cell ($class, '%.2f', "", $row[17]);
+  write_table_cell ($class, '%.4f', "", $row[18]);
+  write_table_cell ($class, '%.2f', "", $row[19]);
+  write_table_cell ($class, '%.2f', "", $row[20]);
+  write_table_cell ($class, '%s', "", $row[21]);
+  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: /branches/sc_branches/ippMonitorLap/raw/warpProcessedExp_Images.php
===================================================================
--- /branches/sc_branches/ippMonitorLap/raw/warpProcessedExp_Images.php	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/raw/warpProcessedExp_Images.php	(revision 31685)
@@ -0,0 +1,478 @@
+<?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 = "ipp.science.dat";
+}
+
+menu($myMenu, 'Warp Stage Exposures w/ Images', 'ipp.css', $ID['link'], $ID['proj']);
+
+echo "<p> Warp Stage Exposures w/ Images</p>";
+
+// set up the form
+echo "<form action=\"warpProcessedExp_Images.php\" method=\"POST\">\n";
+
+$restricted = 0;
+
+// define restrictiosn to the queries
+// ** TABLE RESTRICTIONS **
+$WHERE = "WHERE warpRun.fake_id = fakeRun.fake_id AND fakeRun.cam_id = camRun.cam_id AND camRun.chip_id = chipRun.chip_id AND chipRun.exp_id = rawExp.exp_id";
+$WHERE = check_restrict ('rawExp.exp_name', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_id', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_id', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.exp_id', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('chipRun.chip_id', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('chipRun.chip_id', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('chipRun.chip_id', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('camRun.cam_id', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('camRun.cam_id', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('camRun.cam_id', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('fakeRun.fake_id', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('fakeRun.fake_id', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('fakeRun.fake_id', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('warpRun.warp_id', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('warpRun.warp_id', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('warpRun.warp_id', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('warpRun.state', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('warpRun.label', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('warpRun.data_group', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('warpRun.dist_group', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.telescope', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.camera', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.dateobs', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.dateobs', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.dateobs', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.ra', $WHERE, 'min', 0.017453);
+$WHERE = check_restrict ('rawExp.ra', $WHERE, 'max', 0.017453);
+$WHERE = check_restrict ('rawExp.decl', $WHERE, 'min', 0.017453);
+$WHERE = check_restrict ('rawExp.decl', $WHERE, 'max', 0.017453);
+$WHERE = check_restrict ('rawExp.object', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.filter', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_time', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.exp_time', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.exp_time', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.airmass', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.airmass', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.airmass', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.bg', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.bg', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.bg', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.bg_stdev', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('rawExp.bg_stdev', $WHERE, 'min', 1.0);
+$WHERE = check_restrict ('rawExp.bg_stdev', $WHERE, 'max', 1.0);
+$WHERE = check_restrict ('rawExp.comment', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('warpSummary.path_base', $WHERE, 'string', 1.0);
+$WHERE = check_restrict ('warpSummary.projection_cell', $WHERE, 'string', 1.0);
+$WHERE = check_ordering ('', $WHERE);
+
+if ($restricted == 0) {
+  if ("none" != "none") {
+    $WHERE = "$WHERE none";
+  }
+}
+
+// get the result table count
+if (basic == "basic") {
+  $sql = "SELECT count(*) FROM fakeRun,camRun,chipRun,rawExp,warpRun LEFT JOIN warpSummary ON warpSummary.warp_id = warpRun.warp_id $WHERE";
+}
+
+$qry = $db->query($sql);
+if (dberror($qry)) {
+  echo "<b>error reading warpRun, fakeRun, camRun, chipRun, rawExp, warpSummary 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 warpRun, fakeRun, camRun, chipRun, rawExp, warpSummary table count</b><br>\n";
+  echo "<br><small><b> count query : $sql </b></small><br>\n";
+  menu_end();
+}
+// set up the row counter variables
+if ($ID['from']) {
+  $rowStart = $ID['from'];
+} else {
+  $rowStart = 0;
+}
+$rowLast = $rowStart + $dTABLE;
+$rowTotal = $row[0];
+if ($rowLast > $rowTotal) { $rowLast = $rowTotal; }
+echo "<b> $rowStart to $rowLast of $rowTotal items</b><br>\n";
+
+// query the database
+if (basic == "basic") {
+  $sql = "SELECT rawExp.exp_name,rawExp.exp_id,chipRun.chip_id,camRun.cam_id,fakeRun.fake_id,warpRun.warp_id,warpRun.state,warpRun.label,warpRun.data_group,warpRun.dist_group,rawExp.telescope,rawExp.camera,rawExp.dateobs,rawExp.ra,rawExp.decl,rawExp.object,rawExp.filter,rawExp.exp_time,rawExp.airmass,rawExp.bg,rawExp.bg_stdev,rawExp.comment,ifnull(warpSummary.path_base,'noimage'),ifnull(warpSummary.projection_cell,'noimage') FROM fakeRun,camRun,chipRun,rawExp,warpRun LEFT JOIN warpSummary ON warpSummary.warp_id = warpRun.warp_id $WHERE LIMIT $dTABLE OFFSET $rowStart";
+}
+
+/* echo "<tr><td>SQL = $sql</td></tr>\n"; */
+/* menu_end(); */
+
+$qry = $db->query($sql);
+if (dberror($qry)) {
+  echo "<b>error reading warpRun, fakeRun, camRun, chipRun, rawExp, warpSummary table</b><br>\n";
+  echo "<br><small><b> table query : $sql </b></small><br>\n";
+  menu_end();
+}
+
+// ** HEAD CODE **
+
+// ** BUTTON RESTRICTIONS **
+$buttonLink = button_restrict_string ('rawExp.exp_name', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.exp_id', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.exp_id', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.exp_id', $buttonLink);
+$buttonLink = button_restrict_string ('chipRun.chip_id', $buttonLink);
+$buttonLink = button_restrict_min ('chipRun.chip_id', $buttonLink);
+$buttonLink = button_restrict_max ('chipRun.chip_id', $buttonLink);
+$buttonLink = button_restrict_string ('camRun.cam_id', $buttonLink);
+$buttonLink = button_restrict_min ('camRun.cam_id', $buttonLink);
+$buttonLink = button_restrict_max ('camRun.cam_id', $buttonLink);
+$buttonLink = button_restrict_string ('fakeRun.fake_id', $buttonLink);
+$buttonLink = button_restrict_min ('fakeRun.fake_id', $buttonLink);
+$buttonLink = button_restrict_max ('fakeRun.fake_id', $buttonLink);
+$buttonLink = button_restrict_string ('warpRun.warp_id', $buttonLink);
+$buttonLink = button_restrict_min ('warpRun.warp_id', $buttonLink);
+$buttonLink = button_restrict_max ('warpRun.warp_id', $buttonLink);
+$buttonLink = button_restrict_string ('warpRun.state', $buttonLink);
+$buttonLink = button_restrict_string ('warpRun.label', $buttonLink);
+$buttonLink = button_restrict_string ('warpRun.data_group', $buttonLink);
+$buttonLink = button_restrict_string ('warpRun.dist_group', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.telescope', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.camera', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.dateobs', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.dateobs', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.dateobs', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.ra', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.ra', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.ra', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.decl', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.decl', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.decl', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.object', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.filter', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.exp_time', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.exp_time', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.exp_time', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.airmass', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.airmass', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.airmass', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.bg', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.bg', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.bg', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.bg_stdev', $buttonLink);
+$buttonLink = button_restrict_min ('rawExp.bg_stdev', $buttonLink);
+$buttonLink = button_restrict_max ('rawExp.bg_stdev', $buttonLink);
+$buttonLink = button_restrict_string ('rawExp.comment', $buttonLink);
+$buttonLink = button_restrict_string ('warpSummary.path_base', $buttonLink);
+$buttonLink = button_restrict_string ('warpSummary.projection_cell', $buttonLink);
+navigate_buttons ($rowStart, $rowLast, $dTABLE, 
+		  $rowTotal, $buttonLink, $ID, 'warpProcessedExp_Images.php');
+
+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><td></td>\n";
+write_header_cell ("list", "Exp Name");
+write_header_cell ("list", "Exp ID");
+write_header_cell ("list", "Chip ID");
+write_header_cell ("list", "Cam ID");
+write_header_cell ("list", "Fake ID");
+write_header_cell ("list", "Warp ID");
+write_header_cell ("list", "image");
+write_header_cell ("list", "image");
+write_header_cell ("list", "state");
+write_header_cell ("list", "label");
+write_header_cell ("list", "data grp");
+write_header_cell ("list", "dist grp");
+write_header_cell ("list", "Telescope");
+write_header_cell ("list", "Camera");
+write_header_cell ("list", "Date/Time");
+write_header_cell ("list", "RA");
+write_header_cell ("list", "DEC");
+write_header_cell ("list", "Object");
+write_header_cell ("list", "FILTER");
+write_header_cell ("list", "exp_time    ");
+write_header_cell ("list", "airmass     ");
+write_header_cell ("list", "backgnd");
+write_header_cell ("list", "stdev    ");
+write_header_cell ("list", "Comment");
+echo "</tr>\n";
+echo "<tr><td></td>\n";
+write_sort_cell ("list", "rawExp.exp_name", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+write_sort_cell ("list", "rawExp.exp_id", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+write_sort_cell ("list", "chipRun.chip_id", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+write_sort_cell ("list", "camRun.cam_id", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+write_sort_cell ("list", "fakeRun.fake_id", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+write_sort_cell ("list", "warpRun.warp_id", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+echo "<td></td>\n";
+echo "<td></td>\n";
+write_sort_cell ("list", "warpRun.state", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+write_sort_cell ("list", "warpRun.label", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+write_sort_cell ("list", "warpRun.data_group", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+write_sort_cell ("list", "warpRun.dist_group", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+write_sort_cell ("list", "rawExp.telescope", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+write_sort_cell ("list", "rawExp.camera", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+write_sort_cell ("list", "rawExp.dateobs", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+write_sort_cell ("list", "rawExp.ra * 57.295783", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+write_sort_cell ("list", "rawExp.decl * 57.295783", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+write_sort_cell ("list", "rawExp.object", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+write_sort_cell ("list", "rawExp.filter", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+write_sort_cell ("list", "rawExp.exp_time", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+write_sort_cell ("list", "rawExp.airmass", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+write_sort_cell ("list", "rawExp.bg", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+write_sort_cell ("list", "rawExp.bg_stdev", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+write_sort_cell ("list", "rawExp.comment", $buttonLink, $ID, 'warpProcessedExp_Images.php');
+echo "</tr>\n";
+// echo "</tr>\n";
+
+// query restriction form
+// echo "<tr>\n";
+// echo "<td class=list> <input type=\"text\" name=\"expID\"></td>\n";
+// ** TABLE QUERY **
+echo "<tr><td>&ge;</td>\n";
+write_query_row ('rawExp.exp_name', 5, 'string');
+write_query_row ('rawExp.exp_id', 5, 'min');
+write_query_row ('chipRun.chip_id', 7, 'min');
+write_query_row ('camRun.cam_id', 7, 'min');
+write_query_row ('fakeRun.fake_id', 7, 'min');
+write_query_row ('warpRun.warp_id', 7, 'min');
+echo "<td> &nbsp; </td>\n";
+echo "<td></td>\n";
+write_query_row ('warpRun.state', 7, 'string');
+write_query_row ('warpRun.label', 7, 'string');
+write_query_row ('warpRun.data_group', 7, 'string');
+write_query_row ('warpRun.dist_group', 7, 'string');
+write_query_row ('rawExp.telescope', 10, 'string');
+write_query_row ('rawExp.camera', 10, 'string');
+write_query_row ('rawExp.dateobs', 19, 'min');
+write_query_row ('rawExp.ra', 8, 'min');
+write_query_row ('rawExp.decl', 8, 'min');
+write_query_row ('rawExp.object', 8, 'string');
+write_query_row ('rawExp.filter', 10, 'string');
+write_query_row ('rawExp.exp_time', 5, 'min');
+write_query_row ('rawExp.airmass', 5, 'min');
+write_query_row ('rawExp.bg', 5, 'min');
+write_query_row ('rawExp.bg_stdev', 5, 'min');
+write_query_row ('rawExp.comment', 65, 'string');
+echo "</tr><tr><td>&le;</td>\n";
+echo "<td> &nbsp; </td>\n";
+write_query_row ('rawExp.exp_id', 5, 'max');
+write_query_row ('chipRun.chip_id', 7, 'max');
+write_query_row ('camRun.cam_id', 7, 'max');
+write_query_row ('fakeRun.fake_id', 7, 'max');
+write_query_row ('warpRun.warp_id', 7, 'max');
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+write_query_row ('rawExp.dateobs', 19, 'max');
+write_query_row ('rawExp.ra', 8, 'max');
+write_query_row ('rawExp.decl', 8, 'max');
+echo "<td> &nbsp; </td>\n";
+echo "<td> &nbsp; </td>\n";
+write_query_row ('rawExp.exp_time', 5, 'max');
+write_query_row ('rawExp.airmass', 5, 'max');
+write_query_row ('rawExp.bg', 5, 'max');
+write_query_row ('rawExp.bg_stdev', 5, 'max');
+echo "<td> &nbsp; </td>\n";
+echo "</tr>\n";
+// echo "</tr>\n";
+
+/* $warpIdCollection[$warpId]["00"] = "ul"; */
+/* $warpIdCollection[$warpId]["01"] = "ur"; */
+/* $warpIdCollection[$warpId]["10"] = "ll"; */
+/* $warpIdCollection[$warpId]["11"] = "lr"; */
+$warpIdCollection = array();
+
+$noImageValue = "<a href=\"noimage.png\"><img src=\"noimage.png\"></a>";
+
+// list the results
+while ($qry->fetchInto($row)) {
+  // $link = "warpProcessedExp_Images.php" . "?expID=" . $row[0] . "&" . $ID['link'];
+
+  $class = "list";
+  // ** TD CLASS **
+
+  //Identify current warpId
+  $warpId = $row[5];
+/*   echo "<tr><td>Number of elements in warpIdCollection: ".count($warpIdCollection)."</td></tr>\n"; */
+/*   echo "<tr><td>(warpId=$warpId)</td></tr>\n"; */
+
+  if (!isSet($warpIdCollection[$warpId])) {
+/*     echo "<tr><td>$warpId not in warpIdCollection</td></tr>"; */
+    $warpIdCollection[$warpId] = array();
+    $skyCellValue = preg_replace("|skycell[.]|","",$row[23]);
+    $warpIdCollection[$warpId]["12"] = $skyCellValue;
+/*     echo "<tr><td>Skycell is [$skyCellValue]</td></tr>"; */
+
+    echo "<tr>\n";
+    // ** TABLE DATA **
+    echo "<td></td>\n";
+    write_table_cell ($class, '%s', "", $row[0]);
+    $link = "rawImfile.php" . "?menu=ipp.science.dat&" . $ID['link'];
+    $link = $link . "&rawImfile.exp_id=$row[1]";
+    write_table_cell ($class, '%d', $link, $row[1]);
+    $link = "chipProcessedImfile.php" . "?menu=ipp.science.dat&" . $ID['link'];
+    $link = $link . "&chipRun.chip_id=$row[2]";
+    write_table_cell ($class, '%d', $link, $row[2]);
+    $link = "camProcessedExp.php" . "?menu=ipp.science.dat&" . $ID['link'];
+    $link = $link . "&camRun.cam_id=$row[3]";
+    write_table_cell ($class, '%d', $link, $row[3]);
+    $link = "fakeProcessedImfile.php" . "?menu=ipp.science.dat&" . $ID['link'];
+    $link = $link . "&fakeRun.fake_id=$row[4]";
+    write_table_cell ($class, '%d', $link, $row[4]);
+    $link = "warpStageExp.php" . "?menu=ipp.science.dat&" . $ID['link'];
+    $link = $link . "&warpRun.warp_id=$row[5]";
+    write_table_cell ($class, '%d', $link, $row[5]);
+    /* Image */
+    echo "<td class=\"$class\">\n";
+    echo "<table border=\"1\"><tr>\n";
+/*     echo "  <td class=\"ul3x2\" id=\"$warpId.00\">$noImageValue</td>\n"; */
+    echo "  <td class=\"ul3x2\" id=\"$warpId.00\"></td>\n";
+    echo "  <td class=\"uc3x2\" id=\"$warpId.01\">$noImageValue</td>\n";
+    echo "  <td class=\"ur3x2\" id=\"$warpId.02\">$noImageValue</td>\n";
+    echo "</tr><tr>\n";
+/*     echo "  <td class=\"ll3x2\" id=\"$warpId.10\">$noImageValue</td>\n"; */
+    echo "  <td class=\"ll3x2\" id=\"$warpId.10\"></td>\n";
+    echo "  <td class=\"lc3x2\" id=\"$warpId.11\">$noImageValue</td>\n";
+    echo "  <td class=\"lr3x2\" id=\"$warpId.12\">$noImageValue</td>\n";
+    echo "</tr></table>\n";
+    echo "</td>\n";
+    $link = "getimage.php" . "?menu=ipp.science.dat&" . $ID['link'];
+    $link = $link . "&name=$row[22].$row[23]";
+    $link = $link . "&rule=PPSKYCELL.JPEG1";
+    $link = $link . "&camera=GPC1";
+    $link = $link . "&class_id=NONE";
+
+    /* Image as Text */
+    echo "<td class=\"$class\">\n";
+    echo "<table border=\"1\"><tr>\n";
+/*     echo "  <td class=\"ul3x2\" id=\"t$warpId.00\">No image</td>\n"; */
+    echo "  <td class=\"ul3x2\" id=\"t$warpId.00\"></td>\n";
+    echo "  <td class=\"uc3x2\" id=\"t$warpId.01\">No image</td>\n";
+    echo "  <td class=\"ur3x2\" id=\"t$warpId.02\">No image</td>\n";
+    echo "</tr><tr>\n";
+/*     echo "  <td class=\"ll3x2\" id=\"t$warpId.10\">No image</td>\n"; */
+    echo "  <td class=\"ll3x2\" id=\"t$warpId.10\"></td>\n";
+    echo "  <td class=\"lc3x2\" id=\"t$warpId.11\">No image</td>\n";
+    echo "  <td class=\"lr3x2\" id=\"t$warpId.12\">No image</td>\n";
+    echo "</tr></table>\n";
+    echo "</td>\n";
+
+    $cellContent = "<a href=\\\"$link\\\"> <img src=\\\"getimage.php?name=$row[22].$row[23]&rule=PPSKYCELL.JPEG2&camera=$row[11]&class_id=NONE\\\"> </a>";
+    echo "<script type=\"text/javascript\">changeCell(\"$warpId.12\", \"$cellContent\");</script>";
+    $imageNameValue = ($row[23]=="noimage" ?
+		       "No image" : $row[23]);
+    echo "<script type=\"text/javascript\">changeCell(\"t$warpId.12\", \"$imageNameValue\");</script>";
+
+    //resume with "regular" columns
+    write_table_cell ($class, '%s', "", $row[6]);
+    write_table_cell ($class, '%s', "", $row[7]);
+    write_table_cell ($class, '%s', "", $row[8]);
+    write_table_cell ($class, '%s', "", $row[9]);
+    write_table_cell ($class, '%s', "", $row[10]);
+    write_table_cell ($class, '%s', "", $row[11]);
+    write_table_cell ($class, '%T', "", $row[12]);
+    write_table_cell ($class, '%C', "", $row[13] * 57.295783);
+    write_table_cell ($class, '%C', "", $row[14] * 57.295783);
+    write_table_cell ($class, '%s', "", $row[15]);
+    write_table_cell ($class, '%s', "", $row[16]);
+    write_table_cell ($class, '%.2f', "", $row[17]);
+    write_table_cell ($class, '%.4f', "", $row[18]);
+    write_table_cell ($class, '%.2f', "", $row[19]);
+    write_table_cell ($class, '%.2f', "", $row[20]);
+    write_table_cell ($class, '%s', "", $row[21]);
+    echo "</tr>\n";
+
+  } else {
+    // Update table cell content
+/*     echo "<tr><td>$warpId in warpIdCollection</td></tr>"; */
+    $lrValue =  $warpIdCollection[$warpId]["12"];
+    $skyCellValue = preg_replace("|skycell[.]|","",$row[23]);
+/*     echo "<tr><td>Current skycell is [$skyCellValue] / LowerRight is [$lrValue]</td></tr>"; */
+
+    $link = "getimage.php" . "?menu=ipp.science.dat&" . $ID['link'];
+    $link = $link . "&name=$row[22].$row[23]";
+    $link = $link . "&rule=PPSKYCELL.JPEG1";
+    $link = $link . "&camera=GPC1";
+    $link = $link . "&class_id=NONE";
+    $cellContent = "<a href=\\\"$link\\\"> <img src=\\\"getimage.php?name=$row[22].$row[23]&rule=PPSKYCELL.JPEG2&camera=$row[11]&class_id=NONE\\\"> </a>";
+
+    if ($skyCellValue == $lrValue + 1) {
+      $warpIdCollection[$warpId]["11"] = $skyCellValue;
+      echo "<script type=\"text/javascript\">changeCell(\"$warpId.11\", \"$cellContent\");</script>";
+      echo "<script type=\"text/javascript\">changeCell(\"t$warpId.11\", \"$row[23]\");</script>";
+    } else {
+      if ($skyCellValue == $lrValue + 2) {
+	$warpIdCollection[$warpId]["10"] = $skyCellValue;
+	echo "<script type=\"text/javascript\">changeCell(\"$warpId.10\", \"$cellContent\");</script>";
+	echo "<script type=\"text/javascript\">changeCell(\"t$warpId.10\", \"$row[23]\");</script>";
+      } else {
+	if (!isSet($warpIdCollection[$warpId]["02"])) {
+	  /* 	echo "<tr><td>Update UpperRight</td></tr>"; */
+	  $warpIdCollection[$warpId]["02"] = $skyCellValue;
+	  echo "<script type=\"text/javascript\">changeCell(\"$warpId.02\", \"$cellContent\");</script>";
+	  echo "<script type=\"text/javascript\">changeCell(\"t$warpId.02\", \"$row[23]\");</script>";
+	} else {
+	  $urValue = $warpIdCollection[$warpId]["02"];
+	  if ($urValue + 1 == $skyCellValue) {
+	    echo "<script type=\"text/javascript\">changeCell(\"$warpId.01\", \"$cellContent\");</script>";
+	    echo "<script type=\"text/javascript\">changeCell(\"t$warpId.01\", \"$row[23]\");</script>";
+	  } else {
+	    if ($urValue + 2 == $skyCellValue) {
+	      echo "<script type=\"text/javascript\">changeCell(\"$warpId.00\", \"$cellContent\");</script>";
+	      echo "<script type=\"text/javascript\">changeCell(\"t$warpId.00\", \"$row[23]\");</script>";
+	    } else {
+	      $expected = $urValue + 1;
+	      $actual = $skyCellValue;
+	      echo "<script type=\"text/javascript\">changeCell(\"$warpId.00\", \"Problem in UpperLeft corner: expected $expected but was $actual\");</script>";
+	      echo "<tr><td>Problem in Upper part!</td></tr>";
+	    }
+	  } 
+	}
+      }
+    }
+  }
+}
+
+// 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: /branches/sc_branches/ippMonitorLap/scripts/build_histogram.dvo
===================================================================
--- /branches/sc_branches/ippMonitorLap/scripts/build_histogram.dvo	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/scripts/build_histogram.dvo	(revision 31685)
@@ -0,0 +1,79 @@
+#!/usr/bin/env dvo
+
+$debug = 0
+
+$bins = 100
+$delta = -1
+
+macro build_histogram
+  myecho "Loading data from = $1"
+  data $1
+  read v 1
+  minimum v
+  maximum v
+  myecho "minvalue = $minvalue"
+  myecho "maxvalue = $maxvalue"
+
+  if ($bins >= 2)
+    $delta = ($maxvalue-$minvalue)/$bins
+    myecho "delta = $delta"
+  else
+    if ($delta <= 0)
+      $bins = 100
+      $delta = ($maxvalue-$minvalue)/$bins
+      myecho "delta = $delta"
+    end
+  end
+
+  histo v vhist $minvalue $maxvalue $delta -range dx
+  myecho "bins = dx[]"
+  myecho "  Setting limits"
+  limits dx vhist
+  plot dx vhist -x 1
+  clear
+  myecho "  Showing box"
+  box
+  myecho "  Plotting"
+  plot dx vhist -x 1 -c blue
+  $binsCount = dx[]
+  strsub $3 "_" "\\\\_" -var xLabel
+  myecho "  Labelling"
+  myecho "    -x $xLabel"
+  myecho "    -y Occurrences "
+  myecho "    +x 'Histogram of $xLabel "
+  myecho "           interval = $minvalue : $maxvalue "
+  myecho "	     / $binsCount bins"
+  myecho "           / bin width: $delta)'"
+  labels -x $xLabel
+  labels -y Occurrences
+  labels +x "Histogram of $xLabel / interval = $minvalue : $maxvalue / $binsCount bins / bin width: $delta"
+
+  myecho "Saving graphics to [$2]"
+  png -name $2
+end
+
+if ($SCRIPT)
+  $KAPA = kapa -noX
+  resize 1000 1000
+  if ($argv:n != 5)
+    echo "USAGE: build_histogram (input) (output) (delta) (bins) (x-axis label)"
+    echo "  If (bins) >= 2"
+    echo "     build histogram with (bins) bins ((delta) is ignored)"
+    echo "  Otherwise"
+    echo "     if delta > 0
+    echo "        build histogram with (delta)-wide bins"
+    echo "     otherwise"
+    echo "        build histogram with 100 bins"
+    exit 1
+  end
+
+  echo "Loading dependencies"
+  $helpersFilename = `which helpers.dvo`
+  input $helpersFilename
+  echo "Dependencies loaded"
+
+  $bins = $argv:3 + 1
+  $delta = $argv:2
+  build_histogram $argv:0 $argv:1 $argv:4
+  exit 0
+end
Index: /branches/sc_branches/ippMonitorLap/scripts/czartool_getServerStatus.pl
===================================================================
--- /branches/sc_branches/ippMonitorLap/scripts/czartool_getServerStatus.pl	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/scripts/czartool_getServerStatus.pl	(revision 31685)
@@ -0,0 +1,18 @@
+#!/usr/bin/perl -w
+
+use warnings;
+use strict;
+use Getopt::Long;
+
+my $server = undef;
+GetOptions ("server|s=s" => \$server);
+
+my @cmdOut = `echo "status;quit" | pantasks_client -c ~ipp/$server/ptolemy.rc 2>&1`;
+my $line;
+my $passedHeader=0;
+foreach $line (@cmdOut) {
+
+    chomp($line);
+    if ($line =~ m/.*Task Status.*/) {$passedHeader=1;next;}
+    if ($passedHeader){print "$line<br>";}
+}
Index: /branches/sc_branches/ippMonitorLap/scripts/czartool_revert.pl
===================================================================
--- /branches/sc_branches/ippMonitorLap/scripts/czartool_revert.pl	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/scripts/czartool_revert.pl	(revision 31685)
@@ -0,0 +1,39 @@
+#!/usr/bin/perl -w
+
+use warnings;
+use strict;
+use Getopt::Long;
+
+my $task = undef;
+my $onoff = undef;
+
+GetOptions (
+        "task|t=s" => \$task,
+        "onoff|o=s" => \$onoff);
+
+my $prob = 0;
+if (!$task) {print "ERROR: need to define a task (-t)\n"; $prob=1;}
+if ($prob) {exit;}
+
+if ($task eq "cam") {$task = "camera";}
+
+my $server = undef;
+if ($task eq "destreak" or $task eq "dist") {$server = "distribution";}
+else {$server = "stdscience";}
+
+my $revert = undef;
+if ($onoff) {$revert = "$task.revert.$onoff;";}
+else {$revert="";}
+
+my @cmdOut = `echo "$revert status;quit" | pantasks_client -c ~ipp/$server/ptolemy.rc 2>&1`;
+
+my $line;
+foreach $line (@cmdOut) {
+
+    chomp($line);
+    if ($line =~ m/\s+([+-])[+-]\s+$task\.revert.*/) {
+
+        if ($1 =~ m/-/) {print "off\n";}
+        elsif ($1 =~ m/\+/) {print "on\n";}
+    }
+}
Index: /branches/sc_branches/ippMonitorLap/scripts/czartool_serverstoprun.pl
===================================================================
--- /branches/sc_branches/ippMonitorLap/scripts/czartool_serverstoprun.pl	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/scripts/czartool_serverstoprun.pl	(revision 31685)
@@ -0,0 +1,29 @@
+#!/usr/bin/perl -w
+
+use warnings;
+use strict;
+use Getopt::Long;
+
+my $server = undef;
+my $cmd = undef;
+
+GetOptions (
+        "server|s=s" => \$server,
+        "cmd|c=s" => \$cmd);
+
+if (!$server) {print "ERROR: need to define a server (-s)\n"; exit;}
+if (!$cmd) {print "ERROR: need to define a cmd (-c)\n"; exit;}
+if (($cmd !~ m/^stop$/) && ($cmd !~ m/^run$/)) {print "ERROR: cmd must be 'stop' or 'run'\n"; exit;}
+
+my @cmdOut = `echo "$cmd; status;quit" | pantasks_client -c ~ipp/$server/ptolemy.rc 2>&1`;
+
+my $line;
+foreach $line (@cmdOut) {
+
+    chomp($line);
+    if ($line =~ m/Scheduler is stopped/) {print "stopped\n"; exit;}
+    if ($line =~ m/Scheduler is running/) {print "running\n"; exit;}
+    if ($line =~ m/Task Status/) {last;}
+}
+
+print "dead\n";
Index: /branches/sc_branches/ippMonitorLap/scripts/dbadmin
===================================================================
--- /branches/sc_branches/ippMonitorLap/scripts/dbadmin	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/scripts/dbadmin	(revision 31685)
@@ -0,0 +1,77 @@
+#!/bin/csh -f
+## this script creates the tables needed by ippMonitor for user administration
+
+if ($#argv < 4) goto usage;
+
+if ("$1" == "init") then
+  if ($#argv != 4) goto usage;
+  set dbserver = $2
+  set dbuser = $3
+  set dbpass = $4
+
+  mysql -h $dbserver -u root -p <<EOF
+  create database ippadmin;
+  use ippadmin;
+  create table users (username char(20) not null, password varchar(255));
+  create table cookies (username char(20) not null, cookie varchar(255));
+  create table projects (projname char(20) not null);
+  grant all on *.* to $dbuser@localhost identified by '$dbpass';
+EOF
+    exit 0;
+endif
+
+if ("$1" == "client") then
+  if ($#argv != 5) goto usage;
+  set dbserver = $2
+  set dbuser = $3
+  set dbpass = $4
+  set client = $5
+
+  mysql -h $dbserver -u root -p <<EOF
+   grant all on *.* to $dbuser@"$client" identified by '$dbpass';
+EOF
+    exit 0;
+endif
+
+if ("$1" == "user") then
+  if ($#argv != 5) goto usage;
+  set dbserver = $2
+  set dbuser = $3
+  set user = $4
+  set pass = $5
+
+  mysql -h $dbserver -u $dbuser -p ippadmin <<EOF
+  insert into users (username, password) values ('$user', '$pass');
+EOF
+    exit 0;
+endif
+
+if ("$1" == "project") then
+  if ($#argv != 4) goto usage;
+  set dbserver = $2
+  set dbuser = $3
+  set dbname = $4
+
+  mysql -h $dbserver -u $dbuser -p ippadmin <<EOF
+   insert into projects (projname) values ('$dbname');
+   create database $dbname;
+EOF
+    exit 0;
+endif
+
+usage:
+  echo "USAGE: dbadmin (options)"
+  echo ""
+  echo "  dbadmin init (dbserver) (dbuser) (dbpassword)"
+  echo "      creates admin tables, basic db user -- requires root password"
+  echo ""
+  echo "  dbadmin client (dbserver) (dbuser) (dbpassword) (client)"
+  echo "      add client name or regex"
+  echo ""
+  echo "  dbadmin user (dbserver) (dbuser) (username) (password)"
+  echo "      create a new www user and password"
+  echo ""
+  echo "  dbadmin project (dbserver) (dbuser) (dbname)"
+  echo "      create a new ipp project (database)"
+  echo ""
+  exit 2
Index: /branches/sc_branches/ippMonitorLap/scripts/generate
===================================================================
--- /branches/sc_branches/ippMonitorLap/scripts/generate	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/scripts/generate	(revision 31685)
@@ -0,0 +1,733 @@
+#!/usr/bin/env perl
+
+$VERBOSE = 0;
+
+if ($ARGV[0] eq "-v") { $VERBOSE = 1; shift @ARGV; }
+if (@ARGV != 3) { die "generate (schema) (template) (output)\n"; }
+
+$schema   = $ARGV[0];
+$template = $ARGV[1];
+$output   = $ARGV[2];
+
+# global variables:
+# @key, @value                         : paired list of keys and values
+# @headcode, @tailcode                 : additional HTML or PHP code before or after table
+# @field, @width, @name, @show, @link, @extras : properties of each table column
+# @imagedefs, %image: array of image defines
+
+&parse_schema;
+&parse_template;
+exit 0;
+
+sub parse_schema {
+    open (FILE, "$schema");
+    @list = <FILE>;
+    close (FILE);
+
+    &init_key ("MENU");
+    &init_key ("STYLE");
+    &init_key ("MODE");
+    &init_key ("UNRESTRICTED");
+    &init_key ("TABLE");
+    &init_key ("TITLE");
+    &init_key ("FILE");
+
+    &init_key ("FIELDS");
+    &init_key ("GROUPS");
+    &init_key ("TOPLOT");
+    &init_key ("PLOTTER");
+    &init_key ("PLOTTITLE");
+
+    foreach $line (@list) {
+        chop $line;
+        ($key, $value) = split (" ", $line, 2);
+
+        # strip leading and trailing white space from the following
+        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);
+
+        # list of the table fields
+        if ($key eq "FIELD") {
+            ($field, $width, $format, $name, $show, $link, $extras) = split (/,\s+/, $value, 7);
+            if (! $name) { die "table $ARGV[0] missing required elements: $value\n"; }
+            if ($field =~ m|\S+\s+as\s+\S+|) {
+                ($fieldreal) = $field =~ m|\S+\s+as\s+(\S+)|;
+            } else {
+                $fieldreal = $field;
+            }
+
+            if ($VERBOSE) { printf "%-20s %-20s %-20s %-20s %-20s %-20s\n", $field, $name, $format, $show, $link, $extras; }
+
+            if ($show eq "") {$show = "value";}
+            push @field,     $field;
+            push @fieldreal, $fieldreal;
+            push @width,     $width;
+            push @format,    $format;
+            push @name,      $name;
+            push @show,      $show;
+            push @link,      $link;
+            push @extras,    $extras;
+        }
+
+        if ($key eq "FILE") {
+            $myFile = $value;
+        }
+
+        # list of the table fields
+        if ($key eq "HEAD") {
+            push @headcode, $value;
+        }
+
+        # the IMAGE commands sets up a reference name
+        if ($key eq "IMAGE") {
+            push @imagedefs, $value;
+        }
+
+        # the GROUP entries are used in summary tables as arguments to the GROUP BY sql statement
+        if ($key eq "GROUP") {
+            push @group, $value;
+        }
+
+        # the ARGS commands define arguments to FIELDS commands
+        if ($key eq "ARGS") {
+            push @linkargs, $value;
+        }
+
+        # the OP commands define field operations
+        if ($key eq "OP") {
+            push @opwords, $value;
+        }
+
+        # the TD_CLASS command sets up an alternate TD class
+        if ($key eq "TD_CLASS") {
+            push @tdClasses, $value;
+            # print STDERR "found TD_CLASS\n";
+        }
+
+        # list of the table fields
+        if ($key eq "TAIL") {
+            push @tailcode, $value;
+        }
+
+        # list of the table restrictions
+        # replace this with a flexible where statement?
+        if ($key eq "WHERE") {
+            ($field) = split (/,\s+/, $value, 1);
+            if ($VERBOSE) { printf "%-20s\n", $field; }
+            push @where,   $field;
+        }
+    }
+
+    # check on keys
+    &check_key ("MENU", "ipp.menu.dat");
+    &check_key ("STYLE", "ipp.css");
+    &check_key ("MODE", "basic");
+    &check_key ("UNRESTRICTED", "none");
+    &check_key ("TABLE", "");
+    &check_key ("TITLE", "");
+    &check_key ("FILE", "");
+
+    # these are used internally (not just a replacement)
+    for ($i = 0; $i < @key; $i++) {
+        if ($key[$i] eq "MENU") { $MENU = $value[$i]; }
+        if ($key[$i] eq "MODE") {
+            if ($value[$i] eq "summary") {
+                if (@group == 0) {
+                    print STDERR "a summary table must have at least one group\n";
+                    exit 1;
+                }
+                &define_groups_string (@group);
+            }
+        }
+    }
+
+    &check_key ("GROUPS", "none");
+
+    # define FIELDS and WHERE strings, add to keypairs
+    &define_fields_count;
+    &define_fields_string (@field);
+    &define_where_string (@where);
+
+    foreach $linkarg (@linkargs) {
+        # print STDERR "linkarg: $linkarg\n";
+        &parse_linkarg ($linkarg);
+    }
+
+    foreach $opword (@opwords) {
+        &parse_opwords ($opword);
+    }
+
+    foreach $imagedef (@imagedefs) {
+        &parse_imagedef ($imagedef);
+    }
+
+    if ($VERBOSE) {
+        print STDERR "show: $show[0]\n";
+        ($a, $b, $c) = &parse_label ($show[0]);
+        print STDERR "a: $a, b: $b, c: $c\n";
+
+        print STDERR "extras: $extras[0]\n";
+        ($a, $b, $c) = &parse_label ($extras[0]);
+        print STDERR "a: $a, b: $b, c: $c\n";
+
+        print STDERR "show: $show[1]\n";
+        ($a, $b, $c) = &parse_label ($show[1]);
+        print STDERR "a: $a, b: $b, c: $c\n";
+
+        print STDERR "extras: $extras[1]\n";
+        ($a, $b, $c) = &parse_label ($extras[1]);
+        print STDERR "a: $a, b: $b, c: $c\n";
+    }
+}
+
+sub parse_template {
+    open (FILE, $template);
+    @list = <FILE>;
+    close (FILE);
+
+    open (FILE, ">$output");
+
+    foreach $line (@list) {
+
+        &check_keypairs;
+
+        print FILE $line;
+
+        # fill in table header
+        if ($line =~ m|// \*\* TABLE HEADER \*\*|) {
+            &write_table_header;
+        }
+
+        # fill in TD_CLASS test
+        if ($line =~ m|// \*\* TD CLASS \*\*|) {
+            &write_td_class;
+        }
+
+        # fill in table data
+        if ($line =~ m|// \*\* TABLE DATA \*\*|) {
+            &write_table_data;
+        }
+
+        # fill in table query
+        if ($line =~ m|// \*\* TABLE QUERY \*\*|) {
+            &write_table_query;
+        }
+
+        # fill in table restricts
+        if ($line =~ m|// \*\* TABLE RESTRICTIONS \*\*|) {
+            &write_table_restrict;
+        }
+
+        # fill in GROUP BY
+        if ($line =~ m|// \*\* GROUP RESTRICTIONS \*\*|) {
+            &write_group_by;
+        }
+
+        # fill in table restricts
+        if ($line =~ m|// \*\* BUTTON RESTRICTIONS \*\*|) {
+            &write_button_restrict;
+        }
+
+        # fill in head HTML or PHP code
+        if ($line =~ m|// \*\* HEAD CODE \*\*|) {
+            &write_inline_code (@headcode);
+        }
+
+        # fill in tail HTML or PHP code
+        if ($line =~ m|// \*\* TAIL CODE \*\*|) {
+            &write_inline_code (@tailcode);
+        }
+    }
+    close (FILE);
+}
+
+sub write_inline_code {
+    my (@code) = @_;
+    my ($i, $code, $type);
+
+    for ($i = 0; $i < @code; $i++) {
+        ($type, $line) = split (" ", $code[$i], 2);
+        if ($type eq "PHP") {
+            print FILE "$line\n";
+        }
+        if ($type eq "HTML") {
+            print FILE "?> $line <?\n";
+        }
+    }
+}
+
+# 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";
+    for ($i = 0; $i < @field; $i++) {
+        ($label, $value, $string) = &parse_label ($show[$i]);
+        if ($show[$i] eq "none")  { next; }
+        print FILE "write_header_cell (\"list\", \"$name[$i]\");\n";
+    }
+    print FILE "echo \"</tr>\\n\";\n";
+
+    # print the column sort cells
+    print FILE "echo \"<tr><td></td>\\n\";\n";
+    for ($i = 0; $i < @field; $i++) {
+        ($label, $value, $string) = &parse_label ($show[$i]);
+        if ($show[$i] eq "none")  { next; }
+        if ($field[$i] eq "*") { print FILE "echo \"<td></td>\\n\";\n"; next; } # empty cell (no sort for such fields)
+        if ($label eq "op") {
+            print FILE "write_sort_cell (\"list\", \"$opf{$value}\", \$buttonLink, \$ID, '$myFile');\n";
+        } else {
+            print FILE "write_sort_cell (\"list\", \"$fieldreal[$i]\", \$buttonLink, \$ID, '$myFile');\n";
+        }
+    }
+    print FILE "echo \"</tr>\\n\";\n";
+}
+
+sub write_td_class {
+    my ($field, $testline);
+
+    if (@tdClasses == 0) { return; }
+    foreach $tdClass (@tdClasses) {
+
+        # TD_CLASS class field expression
+        ($class, $testline) = split (" ", $tdClass, 2);
+
+        $testlineFixed = "";
+        @testlineBits = split (" ", $testline);
+        foreach my $bit (@testlineBits) {
+            $newbit = &parse_fieldname ($bit);
+            $testlineFixed = "$testlineFixed $newbit";
+        }
+
+        print FILE "  if ($testlineFixed) {\n";
+        print FILE "    \$class = \"$class\";\n";
+        print FILE "  }\n";
+    }
+}
+
+# generate a WHERE test for each field (field != *)
+sub write_table_restrict {
+
+    if ($WHERE) {
+        print FILE "\$WHERE = \"WHERE $WHERE\";\n";
+    }
+    for ($i = 0; $i < @field; $i++) {
+        $value = $fieldreal[$i];
+        if ($value eq "*") { next; }
+        if ($format[$i] eq "%s") {
+            print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'string', 1.0);\n";
+            next;
+        }
+        if ($format[$i] eq "%C") {
+            # convert the RA & DEC limits to radians for comparison
+            print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'min', 0.017453);\n";
+            print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'max', 0.017453);\n";
+            next;
+        }
+        print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'string', 1.0);\n";
+        print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'min', 1.0);\n";
+        print FILE "\$WHERE = check_restrict ('$value', \$WHERE, 'max', 1.0);\n";
+    }
+    # print FILE "\$WHERE = check_ordering ('$GROUPS', \$WHERE);\n";
+}
+
+# Generate GROUP BY statement if any 
+sub write_group_by {
+    print FILE "\$WHERE = check_ordering ('$GROUPS', \$WHERE);\n";
+}
+
+# generate a button link entry for each field (field != *)
+sub write_button_restrict {
+
+    for ($i = 0; $i < @field; $i++) {
+        $value = $fieldreal[$i];
+        if ($value eq "*") { next; }
+        if ($format[$i] eq "%s") {
+            print FILE "\$buttonLink = button_restrict_string ('$value', \$buttonLink);\n";
+        } else {
+            print FILE "\$buttonLink = button_restrict_string ('$value', \$buttonLink);\n";
+            print FILE "\$buttonLink = button_restrict_min ('$value', \$buttonLink);\n";
+            print FILE "\$buttonLink = button_restrict_max ('$value', \$buttonLink);\n";
+        }
+    }
+}
+
+# there are two query rows: the first is populated for both strings
+# and numbers, the second only for numbers
+sub write_table_query {
+    my ($i);
+
+    print FILE "echo \"<tr><td>&ge;</td>\\n\";\n";
+    for ($i = 0; $i < @field; $i++) {
+        if ($show[$i] eq "none")  { next; }
+        if ($field[$i] eq "*")  {
+            # * fields create an empty cell
+            print FILE "echo \"<td> &nbsp; </td>\\n\";\n";
+        } else {
+            if ($format[$i] eq "%s") {
+                print FILE "write_query_row ('$fieldreal[$i]', $width[$i], 'string');\n";
+            } else {
+                print FILE "write_query_row ('$fieldreal[$i]', $width[$i], 'min');\n";
+            }
+        }
+    }
+    print FILE "echo \"</tr><tr><td>&le;</td>\\n\";\n";
+    for ($i = 0; $i < @field; $i++) {
+        if ($show[$i] eq "none")  { next; }
+        if (($field[$i] eq "*") || ($format[$i] eq "%s")) {
+            # * fields create an empty cell
+            print FILE "echo \"<td> &nbsp; </td>\\n\";\n";
+        } else {
+            print FILE "write_query_row ('$fieldreal[$i]', $width[$i], 'max');\n";
+        }
+    }
+    print FILE "echo \"</tr>\\n\";\n";
+}
+
+sub write_table_data {
+    my ($i, $Nrow);
+    my ($label, $value, $string);
+
+    for ($i = 0; $i < @field; $i++) {
+        ($label, $value, $string) = &parse_label ($show[$i]);
+        $Nrow = $count[$i];
+
+        # create the link variable if this entry should be linked
+        if ($label eq "none")  { next; }
+
+        if ($label eq "value") {
+            # create the basic link variable
+            # print STDERR "value: $link[$i]\n";
+            if ($link[$i]) {
+                print FILE "  \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n";
+                # add extra GET data to target
+                if ($extras[$i]) { &parse_extras ($linkarg{$extras[$i]}); }
+                $myLink = "\$link";
+            } else {
+                $myLink = "\"\"";
+            }
+            # print the actual table cell line with the link...
+            if (! $value && ($field[$i] ne "*")) { $value = "\$row[$Nrow]"; }
+
+            # add special format elements
+            # $realFormat = $format[$i];
+            # if ($format[$i] eq '%T') {
+            #   $realFormat = '%s';
+            # }
+            print FILE "  write_table_cell (\$class, '$format[$i]', $myLink, $value);\n";
+            next;
+        }
+
+        if ($label eq "op") {
+            # create the basic link variable
+            if ($link[$i]) {
+                print FILE "  \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n";
+                # add extra GET data to target
+                if ($extras[$i]) { &parse_extras ($linkarg{$extras[$i]}); }
+                $myLink = "\$link";
+            } else {
+                $myLink = "\"\"";
+            }
+            print FILE "  write_table_cell (\$class, '$format[$i]', $myLink, $ops{$value});\n";
+            next;
+        }
+
+        if (($label eq "image") && !$link[$i]) {
+            # print the actual table cell line with the image...
+            print FILE "  echo \"<td class=\\\"\$class\\\">\n";
+            print FILE "  echo \"              <img src=\\\"$image{$value}\\\"></td>\\n\";\n";
+            next;
+        }
+
+        if (($label eq "image") && $link[$i]) {
+            # create the basic link
+            print FILE "  \$link = \"$link[$i]\" . \"?menu=$MENU&\" . \$ID['link'];\n";
+            # add extra php data to target
+            if ($extras[$i]) { &parse_extras ($linkarg{$extras[$i]}); }
+            # print the actual table cell line with the link...
+            print FILE "  echo \"<td class=\\\"\$class\\\"><a href=\\\"\$link\\\"> <img src=\\\"$image{$value}\\\"> </a></td>\\n\";\n";
+            next;
+        }
+
+    }
+}
+
+sub define_fields_string {
+    my (@array) = @_;
+    my ($i, $FIELDS);
+
+    $FIELDS = "$array[0]";
+    for ($i = 1; $i < @array; $i++) {
+        # skip * fields (not a valid query element
+        if ($array[$i] eq "*") { next; }
+        $FIELDS = "$FIELDS,$array[$i]";
+    }
+    set_keypair ("FIELDS", $FIELDS);
+}
+
+sub define_groups_string {
+    my (@array) = @_;
+    my ($i);
+
+    $GROUPS = "$array[0]";
+    for ($i = 1; $i < @array; $i++) {
+        # skip * fields (not a valid query element
+        if ($array[$i] eq "*") { next; }
+        $GROUPS = "$GROUPS,$array[$i]";
+    }
+    set_keypair ("GROUPS", $GROUPS);
+}
+
+sub define_fields_count {
+    my ($i, $Nrow);
+
+    @count = ();
+
+    $Nrow = 0;
+    for ($i = 0; $i < @field; $i++) {
+        # skip * fields (not a valid query element
+        if ($field[$i] eq "*") {
+            $count[$i] = -1;
+        } else {
+            $count[$i] = $Nrow;
+            $Nrow ++;
+        }
+    }
+}
+
+sub define_where_string {
+    my (@array) = @_;
+    my ($i, $FIELDS);
+
+    if (@array == 0) { return; }
+
+    $WHERE = "$array[0]";
+    for ($i = 1; $i < @array; $i++) {
+        $WHERE = "$WHERE AND $array[$i]";
+    }
+
+    set_keypair ("WHERE", $WHERE);
+}
+
+sub parse_extras {
+    my ($extras) = $_[0];
+    my (@extfields);
+    my ($label, $value, $outline);
+    my ($i);
+
+    # examine the extras and parse the embedded fields (comma-separated)
+
+    @extfields = split (/,/, $extras);
+    for ($i = 0; $i < @extfields; $i++) {
+        ($label, $value, $outline) = &parse_label ($extfields[$i]);
+        print FILE "  \$link = \$link . \"&$outline\";\n";
+    }
+}
+
+# each linkarg is an entry of the form "word name=value"
+# the entries for matching words are concatenated together
+# separated by commas to create the value $linkarg{word}
+sub parse_linkarg {
+    my ($word, $value);
+
+    ($word, $value) = split (" ", $_[0]);
+
+    # print STDERR "0: $_[0], $word, $value\n";
+
+    if ($linkarg{$word}) {
+        $linkarg{$word} = "$linkarg{$word},$value";
+    } else {
+        $linkarg{$word} = $value;
+    }
+    # print STDERR "linkarg($word) : $linkarg{$word}\n";
+}
+
+# parse strings of the form label=value
+# if 'value' is of the form $field, try to match with
+# a supplied DB field, and replace with $row[$n] if found
+sub parse_label {
+    my ($string) = $_[0];
+    my ($label, $value, $outline);
+    my ($Nrow, $i);
+
+    # unless we replace the value with the db row element, return the original string
+    $outline = $string;
+    $label = $string;
+    $value = "";
+
+    # search for embedded table fields and replace with row[N]
+    if ($VERBOSE) { print STDERR "string: $string\n"; }
+    if ($string =~ m|\S+=\S+|) {
+        ($label, $value) = $string =~ m|(\S+)=(\S+)|;
+        if ($value =~ m|^\$|) {
+          MATCH_LABEL:
+            for ($i = 0; $i < @field; $i++) {
+                if ($field[$i] eq "*") { next; }
+                while ($value =~ m|\$$fieldreal[$i]|) {
+                    # print "field: $fieldreal[$i]\n";
+                    # ($part1, $name, $part2) = $value =~ m|\$($fieldreal[$i])\@(\S+)|;
+                    ($part1, $name, $part2) = $value =~ m|(\S*)\$($fieldreal[$i])(\S*)|;
+                    # print "name: $name\n";
+                    # print "part1: $part1\n";
+                    # print "part2: $part2\n";
+                    # print "value: $value\n";
+
+                    $Nrow = $count[$i];
+                    $value = $part1 . "\$row[$Nrow]" . $part2;
+
+                    # if ($part1 || $part2) {
+                    # } else {
+                    #     $value = "\$row[$Nrow]";
+                    # }
+                    # print "outval: $value\n";
+                    # last MATCH_LABEL;
+                }
+            }
+            $outline = "$label=$value";
+        }
+    }
+    return ($label, $value, $outline);
+}
+
+# given a variable of the form $fieldname, return the corresponding
+# row entry in the form $row[N], otherwise return $fieldname
+# globals: field (list of field names), count (list of sequence)
+sub parse_fieldname {
+    my ($variable) = $_[0];
+    my ($i);
+
+    # print STDERR "variable: $variable\n";
+
+    unless ($variable =~ m|^\$|) {
+        return $variable;
+    }
+
+    $fieldname = substr ($variable, 1);
+
+    # print STDERR "fieldname: $fieldname\n";
+
+    for ($i = 0; $i < @field; $i++) {
+        # print STDERR "$i: $fieldreal[$i] : $fieldname\n";
+
+        if ($field[$i] eq "*") { next; }
+        if ($fieldname ne $fieldreal[$i]) { next; }
+
+
+        $Nrow = $count[$i];
+
+        $value = "\$row[$Nrow]";
+
+        # print STDERR "found : $i : $count[$i] : $Nrow : $value\n";
+        return $value;
+    }
+    return $variable;
+}
+
+sub parse_imagedef {
+    my ($value) = $_[0];
+
+    ($var, $name, $rule, $camera, $class) = split (" ", $value);
+    $name   = &parse_fieldname ($name);
+    if (exists $ops{$name}) {
+	#if OPx was defined, replace it by its value
+	$name = $ops{$name};
+	$name =~ s/\s+//g;
+    }
+    $camera = &parse_fieldname ($camera);
+    $class  = &parse_fieldname ($class);
+    $image{$var} = "getimage.php?name=$name&rule=$rule&camera=$camera&class_id=$class";
+    return 1;
+}
+
+sub parse_opwords {
+    my ($value) = $_[0];
+
+    @words = split (" ", $value);
+    $name = shift (@words);
+
+    $opline = "";
+    @outwords = ();
+    @outfields = ();
+    foreach $word (@words) {
+        $fword = &parse_fieldname ($word);
+#         print "field: $word -> $fword\n";
+        push @outwords, $fword;
+        if ($word =~ m|^\$|) {
+            $word = substr ($word, 1);
+        }
+        push @outfields, $word;
+    }
+    $outline = join (" ", @outwords);
+    $ops{$name} = $outline;
+    $outline = join (" ", @outfields);
+    $opf{$name} = $outline;
+
+#     print "ops: $name : $ops{$name}\n";
+#     print "opf: $name : $opf{$name}\n";
+
+    return 1;
+}
+
+sub init_key {
+    my ($key)   = $_[0];
+
+    push @key, $key;
+    push @value, "";
+}
+
+sub set_keypair {
+    my ($i);
+    my ($key)   = $_[0];
+    my ($value) = $_[1];
+
+    for ($i = 0; $i < @key; $i++) {
+        if ($key eq $key[$i]) {
+            if ($value[$i] ne "") { die "key is multiply defined\n"; }
+            $value[$i] = $value;
+            if ($VERBOSE) { print STDERR "setting $key = $value\n"; }
+            return;
+        }
+    }
+}
+
+sub check_key {
+    my ($i);
+    my ($key)     = $_[0];
+    my ($default) = $_[1];
+
+    for ($i = 0; $i < @key; $i++) {
+        if ($key eq $key[$i]) {
+            if ($VERBOSE) { print "found $key: $key[$i]  -- $value[$i] (def: $default)\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;
+        }
+    }
+    die "unknown key $key\n";
+}
+
+sub check_keypairs {
+    my ($i);
+    for ($i = 0; $i < @key; $i++) {
+        if ($VERBOSE) { print "$key[$i]  -- $value[$i]\n"; }
+        if ($line =~ m|\$$key[$i]|) {
+            if ($value[$i] eq "") { die "check_keypairs: missing value for required key $key[$i]\n"; }
+            $line =~ s|\$$key[$i]|$value[$i]|g;
+        }
+    }
+}
+
+# we need to find the structure size, including padding
+# i'm not sure I know the answer to this: it is probably
+# the total number of bytes rounded up to the largest
+# data item in the structure (ie, 8 for a double, etc)
+# if we have the size, then we can double check the structure
+# against the expectation at runtime.  for the moment,
+# calculate by hand and add to def.d file
Index: /branches/sc_branches/ippMonitorLap/scripts/helpers.dvo
===================================================================
--- /branches/sc_branches/ippMonitorLap/scripts/helpers.dvo	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/scripts/helpers.dvo	(revision 31685)
@@ -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: /branches/sc_branches/ippMonitorLap/scripts/plot_x_vs_y.dvo
===================================================================
--- /branches/sc_branches/ippMonitorLap/scripts/plot_x_vs_y.dvo	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/scripts/plot_x_vs_y.dvo	(revision 31685)
@@ -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
Index: /branches/sc_branches/ippMonitorLap/scripts/skyplot.dvo
===================================================================
--- /branches/sc_branches/ippMonitorLap/scripts/skyplot.dvo	(revision 31685)
+++ /branches/sc_branches/ippMonitorLap/scripts/skyplot.dvo	(revision 31685)
@@ -0,0 +1,81 @@
+#!/usr/bin/env dvo
+
+list filters
+ green
+ blue
+ red
+ indigo
+ black
+ gold
+end
+
+list pttype
+ 7
+ 0
+ 1
+ 2
+ 7
+ 3
+end
+
+list ptsize
+ 1.1
+ 0.5
+ 0.8
+ 1.3
+ 0.9
+ 1.3
+end
+
+macro skyplot
+  if ($0 != 3)
+    echo "skyplot (input) (output)"
+    break
+  end
+
+  data $1
+  read r 1 d 2 f 3
+
+  resize 1000 500
+  region +ns -ew 180 0 85 ait; cgrid -ra-by-hour -c grey80
+
+  set R = r * 180/3.14
+  set D = d * 180/3.14
+
+  for i 0 $filters:n
+    subset R1 = R if (f == $i)
+    subset D1 = D if (f == $i)
+    if (R1[]) 
+      cplot R1 D1 -pt $pttype:$i -sz $ptsize:$i -c $filters:$i
+    end
+  end
+
+  style -c red -pt 0 -sz 0.5; ecliptic
+  style -c blue -pt 0 -sz 0.5; galactic
+
+  png -name $2
+end
+
+macro galactic
+ create l 720 -360 0.1
+ set b = l * 0
+ csystem G C l b
+ cplot l b
+end
+
+macro ecliptic
+ create l 720 -360 0.1
+ set b = l * 0
+ csystem E C l b
+ cplot l b
+end
+
+if ($SCRIPT)
+  $KAPA = kapa -noX
+  if ($argv:n != 2)
+    echo "USAGE: skyplot (input) (output)"
+    exit 1
+  end
+  skyplot $argv:0 $argv:1
+  exit 0
+end
