Index: /trunk/Ohana/src/perl/src/ckastrom
===================================================================
--- /trunk/Ohana/src/perl/src/ckastrom	(revision 2443)
+++ /trunk/Ohana/src/perl/src/ckastrom	(revision 2444)
@@ -38,5 +38,5 @@
     exit 0;
 } 
-if ($Nbad < 5) {
+if ($Nbad < 0.4*$Nccd) {
     print STDOUT "pass $Nbad bad\n";
     exit 0;
Index: /trunk/Ohana/src/perl/src/elixir.photreport
===================================================================
--- /trunk/Ohana/src/perl/src/elixir.photreport	(revision 2443)
+++ /trunk/Ohana/src/perl/src/elixir.photreport	(revision 2444)
@@ -29,6 +29,9 @@
 print STAT "macro go\n";
 foreach $filter (@filter) {
-    print STAT "echo $filter\n";
-    print STAT "photreport $filter $name\n";
+    @word = split (" ", `filtnames $filter -cal`);
+    if (@word[1] == 0) { next; }
+    $target = $word[2];
+    print STAT "echo $filter -> $target\n";
+    print STAT "photreport $target $name\n";
 }
 print STAT "exit 0\n";
Index: /trunk/Ohana/src/perl/src/fr.mkhtml
===================================================================
--- /trunk/Ohana/src/perl/src/fr.mkhtml	(revision 2443)
+++ /trunk/Ohana/src/perl/src/fr.mkhtml	(revision 2444)
@@ -47,5 +47,5 @@
 	if (-e $line) { $Nfound ++; }
     }
-    if ($Nfound == 0) { 
+    if ($Nfound < @list) { 
 	print STDERR "NOTE: no files from $list: assuming initial state\n";
 	open (FILE, ">$outlist");
@@ -53,5 +53,4 @@
 	&goodbye; 
     }
-    if ($Nfound != @list) { &escape ("missing some files from $list"); }
 
     open (FILE, ">$outlist");
Index: /trunk/Ohana/src/perl/src/fr.modestats
===================================================================
--- /trunk/Ohana/src/perl/src/fr.modestats	(revision 2443)
+++ /trunk/Ohana/src/perl/src/fr.modestats	(revision 2444)
@@ -4,5 +4,5 @@
 if ($ARGV[0] eq "-h") { &usage (); }
 if ($ARGV[0] eq "-help") { &usage (); }
-if (@ARGV != 5) { &usage (); }
+if (@ARGV != 6) { &usage (); }
 
 # assign the command line arguments
@@ -12,4 +12,5 @@
 $modejpg   = $ARGV[3]; # root of jpg images
 $residjpg  = $ARGV[4]; # root of jpg images
+$inmapjpg  = $ARGV[5]; # root of jpg images
 
 # find the appropriate script file
@@ -20,5 +21,5 @@
 $xhost=`gconfig -q XHOST`; chop ($xhost);
 $xdisp=`gconfig -q XDISP`; chop ($xdisp);
-if (vsystem ("xdpyinfo -display $xdisp")) {
+if (vsystem ("xdpyinfo -display $xdisp >& /dev/null")) {
     print STDERR "X server is not running. start it now on $xhost\n";
     exit 1;
@@ -44,9 +45,11 @@
 open (MANA, "|mana --norc");
 print MANA "input $script\n";
-
 print MANA "macro go\n";
 
 # we'll use the default 8 to generate the jpgs of the modes
 print MANA "jpgmodes $modefits $modejpg\n";
+
+system ("rm -f $residjpg");
+system ("rm -f $inmapjpg");
 
 # reset $Nmode for the actual number desired
@@ -56,5 +59,8 @@
     ($name, $status) = split (" ", $imlist[$i]);
     $jpgname = sprintf "%s.%03d.jpg", $residjpg, $i;
-    print MANA "jpgresid $name $jpgname\n";
+    system ("basename $jpgname >> $residjpg");
+    $srcname = sprintf "%s.%03d.jpg", $inmapjpg, $i;
+    system ("basename $srcname >> $inmapjpg");
+    print MANA "jpgresid $name $jpgname $srcname\n";
 }
 print MANA "exit 0\n";
@@ -83,5 +89,5 @@
 
 sub usage {
-    print "USAGE: fr.modestats (map.list) (mode.fits) (mode.list) (modes[.NNN.jpg]) (resid[.NNN.jpg])\n";
+    print "USAGE: fr.modestats (map.list) (mode.fits) (mode.list) (modes[.NNN.jpg]) (resid[.NNN.jpg]) (source[.NNN.jpg])\n";
     exit 1;
 }
Index: /trunk/Ohana/src/perl/src/fr.select
===================================================================
--- /trunk/Ohana/src/perl/src/fr.select	(revision 2443)
+++ /trunk/Ohana/src/perl/src/fr.select	(revision 2444)
@@ -49,4 +49,14 @@
 @marginal = ();
 
+# special list to skip specific chips
+$CHIPSKIP     = `gconfig CHIP_SKIP_LIST`; chop $CHIPSKIP;
+@chipskip = ();
+if (-e $CHIPSKIP) { 
+    open (FILE, $CHIPSKIP);
+    @chipskip = <FILE>;
+    close (FILE);
+    foreach $chip (@chipskip) { chop $chip; }
+}
+
 $criteria = "-type object -mode $mode -trange $start $stop -filter $filter";
 
@@ -71,5 +81,5 @@
 print STDERR "found $Nlist images\n";
 
-IMLIST:
+FRAME:
     foreach $image (@list) {
     @words = split (" ",$image);
@@ -80,5 +90,5 @@
 	# in a subdirectory of their own, .fits extension assumed
 	@answer = <$words[4]/*.fits>;
-	if (@answer != $Nccd) { print STDERR "$words[5] rejected: missing images\n"; next IMLIST; }
+	if (@answer != $Nccd) { print STDERR "$words[5] rejected: missing images\n"; next FRAME; }
     }
 
@@ -90,5 +100,5 @@
     }
     ($tmp, $Nx, $Ny) = split (" ", $answer);
-    if (($Nx != $Naxis1) || ($Ny != $Naxis2)) { print STDERR "$words[5] rejected: wrong dimensions\n"; next IMLIST; }
+    if (($Nx != $Naxis1) || ($Ny != $Naxis2)) { print STDERR "$words[5] rejected: wrong dimensions\n"; next FRAME; }
 
     # $match is a word unique to the full mosaic image (the rootdir for split, the image for mef) 
@@ -101,15 +111,18 @@
     @list2 = `imsearch -name $match`;
     
-  MOSLIST:
+  CCD:
     foreach $ccd (@list2) {
 	@words2 = split (" ", $ccd);
+	foreach $chipskip (@chipskip) { 
+	    if ($words2[3] eq $chipskip) { next CCD; }
+	}
 	
 	$cnts = $words2[11];
 	$flux = $words2[11] / $words2[7];
 	# test for acceptable flux range
-	if ($cnts < $MIN_CNTS) { print STDERR "$words[5] rejected: cnts too low:  $cnts vs $MIN_CNTS\n"; next IMLIST; }
-	if ($cnts > $MAX_CNTS) { print STDERR "$words[5] rejected: cnts too high: $cnts vs $MAX_CNTS\n"; next IMLIST; }
-	if ($flux < $MIN_FLUX) { print STDERR "$words[5] rejected: flux too low:  $flux vs $MIN_FLUX\n"; next IMLIST; }
-	if ($flux > $MAX_FLUX) { print STDERR "$words[5] rejected: flux too high: $flux vs $MAX_FLUX\n"; next IMLIST; }
+	if ($cnts < $MIN_CNTS) { print STDERR "$words[5] rejected: cnts too low:  $cnts vs $MIN_CNTS\n"; next FRAME; }
+	if ($cnts > $MAX_CNTS) { print STDERR "$words[5] rejected: cnts too high: $cnts vs $MAX_CNTS\n"; next FRAME; }
+	if ($flux < $MIN_FLUX) { print STDERR "$words[5] rejected: flux too low:  $flux vs $MIN_FLUX\n"; next FRAME; }
+	if ($flux > $MAX_FLUX) { print STDERR "$words[5] rejected: flux too high: $flux vs $MAX_FLUX\n"; next FRAME; }
     }
 
@@ -122,8 +135,8 @@
 open (LIST, ">$output");
 # write output to Nccd list files 
-# keep a random sample of roughly 40 images:
+# keep a random sample of roughly 60 images:
 $Nselect = @good;
 for ($i = 0; $i < $Nselect; $i++) {
-    if (rand ($Nselect) < 40) {
+    if (rand ($Nselect) < 60) {
 	print LIST "$good[$i]\n";
     }
Index: /trunk/Ohana/src/perl/src/grab.keywords
===================================================================
--- /trunk/Ohana/src/perl/src/grab.keywords	(revision 2443)
+++ /trunk/Ohana/src/perl/src/grab.keywords	(revision 2444)
@@ -135,13 +135,14 @@
     # parse the photometry data line
     @words = split (" ", $photlist[$Nphot-1]);
-    $line = sprintf "PHOT_C  = %20.4F / Nightly zero point - actual                   \n", $words[2];  @photom = (@photom, $line);
-    $line = sprintf "PHOT_C0 = %20.4F / Nightly zero point - nominal                  \n", $words[3];  @photom = (@photom, $line);
-    $line = sprintf "PHOT_CS = %20.4F / Nightly zero point - scatter                  \n", $words[4];  @photom = (@photom, $line);
-    $line = sprintf "PHOT_NS = %20d / Nightly zero point - N stars                  \n", $words[5];  @photom = (@photom, $line);
-    $line = sprintf "PHOT_NM = %20d / Nightly zero point - N images                 \n", $words[6];  @photom = (@photom, $line);
-    $line = sprintf "PHOT_X  = %20.4F / Nightly zero point - color term             \n", $words[7];  @photom = (@photom, $line);
-    $line = sprintf "PHOT_K  = %20.4F / Nightly zero point - airmass term             \n", $words[8];  @photom = (@photom, $line);
-    $line = sprintf "PHOT_C1 = '%-18s' / Nightly zero point - color 1               \n", $words[9];  @photom = (@photom, $line);
-    $line = sprintf "PHOT_C2 = '%-18s' / Nightly zero point - color 2               \n", $words[10]; @photom = (@photom, $line);
+#   we conclude that the nightly zero point contains insufficient information 
+    $line = sprintf "PHOT_C  = %20.4F / Elixir zero point - measured for camera run \n", $words[2];  @photom = (@photom, $line);
+    $line = sprintf "PHOT_CS = %20.4F / Elixir zero point - scatter                \n", $words[4];  @photom = (@photom, $line);
+    $line = sprintf "PHOT_NS = %20d / Elixir zero point - N stars                  \n", $words[5];  @photom = (@photom, $line);
+    $line = sprintf "PHOT_NM = %20d / Elixir zero point - N images                 \n", $words[6];  @photom = (@photom, $line);
+    $line = sprintf "PHOT_C0 = %20.4F / Elixir zero point - nominal                \n", $words[3];  @photom = (@photom, $line);
+    $line = sprintf "PHOT_X  = %20.4F / Elixir zero point - color term             \n", $words[7];  @photom = (@photom, $line);
+    $line = sprintf "PHOT_K  = %20.4F / Elixir zero point - airmass term           \n", $words[8];  @photom = (@photom, $line);
+    $line = sprintf "PHOT_C1 = '%-18s' / Elixir zero point - color 1               \n", $words[9];  @photom = (@photom, $line);
+    $line = sprintf "PHOT_C2 = '%-18s' / Elixir zero point - color 2               \n", $words[10]; @photom = (@photom, $line);
     
     if ($cmproot ne "phu") {
Index: /trunk/Ohana/src/perl/src/mktrans
===================================================================
--- /trunk/Ohana/src/perl/src/mktrans	(revision 2443)
+++ /trunk/Ohana/src/perl/src/mktrans	(revision 2444)
@@ -12,4 +12,5 @@
     print STDERR "filter: $code\n";
     @list = `photsearch -trange $start $stop -photcode $code`;
+    if (! @list) { next; }
 
     # the lines from photsearch look like this:
@@ -17,41 +18,67 @@
     # V 2001/02/03,15:38:53  26.249  0.017 3 1 elixir
 
-    @dates = ();
+    if (1) {
 
-    # use date hashes to extract stats for each date:
-    foreach $line (@list) {
+	# first pass, get list of zp, sort, find median 
+	@zp = ();
+	$sumN = $sumM = $sum1 = $sum2 = $n = 0;
+	foreach $line (@list) {
+	    @words = split (" ", $line);
+	    push @zp, $words[2];
+	    $sumN ++;
+	    $sumM += $words[5];
+	}
+	@zp = sort {$a <=> $b} @zp;
+
+	$N = @zp;
+	for ($i = 0.2*$N; $i < 0.8*$N; $i++) {
+	    $sum1 += $zp[$i];
+	    $sum2 += $zp[$i]*$zp[$i];
+	    $n ++;
+	}
 	
-	# parse the line for the date
-	@words = split (" ", $line);
-	($date) = $words[1] =~ /(\d\d\d\d\/\d\d\/\d\d),/;
-	
-	# if this is a new date, save it in the list
-	unless ($sum1{$date}) { @dates = (@dates, $date); }
+	$zp = $sum1 / $n;
+	$dzp = sqrt (abs($sum2 / $n - $zp*$zp));
 
-	# add to the stats 
-	$sumN{$date} ++;
-	$sumM{$date} += $words[5];
-	$sum1{$date} += $words[2];
-	$sum2{$date} += $words[2]*$words[2];
+	printf STDOUT "photreg -trans -photcode $code -zp %6.3f -dzp %6.4f -trange $start $stop -Nmeas $sumM -Ntime $sumN\n", $zp, $dzp;
+
+    } else {
+	# use date hashes to extract stats for each date:
+	@dates = ();
+	foreach $line (@list) {
+	    
+	    # parse the line for the date
+	    @words = split (" ", $line);
+	    ($date) = $words[1] =~ /(\d\d\d\d\/\d\d\/\d\d),/;
+	    
+	    # if this is a new date, save it in the list
+	    unless ($sum1{$date}) { @dates = (@dates, $date); }
+
+	    # add to the stats 
+	    $sumN{$date} ++;
+	    $sumM{$date} += $words[5];
+	    $sum1{$date} += $words[2];
+	    $sum2{$date} += $words[2]*$words[2];
+	}
+
+	@sdates = sort by_date @dates;
+
+	# calculate mean and stdev for each date
+	foreach $date (@sdates) {
+	    
+	    $Nm  = $sumM{$date};
+	    $Np  = $sumN{$date};
+	    $zp  = $sum1{$date} / $Np;
+	    $dzp = sqrt (abs($sum2{$date} / $Np - $zp*$zp));
+
+	    printf STDOUT "photreg -trans -photcode $code -zp %6.3f -dzp %6.4f -trange $start $stop -Nmeas $Nm -Ntime $Np\n", $zp, $dzp;
+	}
+
+	%sumM = ();
+	%sumN = ();
+	%sum1 = ();
+	%sum2 = ();
+	print STDOUT "\n";
     }
-
-    @sdates = sort by_date @dates;
-
-    # calculate mean and stdev for each date
-    foreach $date (@sdates) {
-	
-	$Nm  = $sumM{$date};
-	$Np  = $sumN{$date};
-	$zp  = $sum1{$date} / $Np;
-	$dzp = sqrt (abs($sum2{$date} / $Np - $zp*$zp));
-
-	printf STDOUT "photreg -trans -photcode $code -zp %6.3f -dzp %6.4f -trange $date 1d -Nmeas $Nm -Ntime $Np\n", $zp, $dzp;
-    }
-
-    %sumM = ();
-    %sumN = ();
-    %sum1 = ();
-    %sum2 = ();
-    print STDOUT "\n";
     
 }
Index: /trunk/Ohana/src/shell/src/dads.cleanup
===================================================================
--- /trunk/Ohana/src/shell/src/dads.cleanup	(revision 2443)
+++ /trunk/Ohana/src/shell/src/dads.cleanup	(revision 2444)
@@ -10,5 +10,8 @@
 rm -f $outdir/*.raw
 rm -f $outdir/*.det
-rm -f $outdir/*.dem
+rm -f $outdir/*.def
+
+# generate binned-by-12 image
+mosmc $outdir/*.fits $outdir.B12.fits 12
 
 echo "SUCCESS"
Index: /trunk/Ohana/src/shell/src/el_plots
===================================================================
--- /trunk/Ohana/src/shell/src/el_plots	(revision 2443)
+++ /trunk/Ohana/src/shell/src/el_plots	(revision 2444)
@@ -11,4 +11,5 @@
 if ($camera == "cfhtir") goto valid;
 if ($camera == "megacam") goto valid;
+if ($camera == "meganorth") goto valid;
 
 if ("$1" == "init") then
Index: /trunk/Ohana/src/shell/src/elixir.launch
===================================================================
--- /trunk/Ohana/src/shell/src/elixir.launch	(revision 2443)
+++ /trunk/Ohana/src/shell/src/elixir.launch	(revision 2444)
@@ -56,8 +56,8 @@
      case meganorth:
       echo "checking for existing imstatreg -daemon"
-      imstatreg -D CAMERA $camera -daemon -status
+      imstatreg -D CAMERA $camera -D RUNID $run -daemon -status
       if ($status) then
 	echo "no imstatreg -daemon, starting..."
-	imstatreg -D CAMERA $camera -daemon -v
+	imstatreg -D CAMERA $camera -D RUNID $run -daemon -v
 	if ($status) then
 	    echo "error starting imstatreg -daemon"
@@ -79,11 +79,20 @@
      case meganorth:
       set date = `date -u +%Y%m%d+%H:%M:%S`
-      imsearch -D CAMERA $camera -trange now -1d -cadctable $datdir/cadc/mcmd.raw.$date.fits
-      cp $datdir/cadc/mcmd.raw.$date.fits /h/ftp/pub/fits_hdrs/
+
+      # extract CADC table, using all undistributed, object images from the past few days
+      imsearch -D CAMERA $camera -D RUNID $run -type object -dist f -trange now -4d -cadctable $datdir/cadc/mcmd.raw.$date.fits
       if ($status) then
 	echo "error extracting cadc table"
 	exit 1;
       endif
-      imsearch -D CAMERA $camera -trange now -1d -dist f -modify dist t
+      # mark the images above distributed
+      imsearch -D CAMERA $camera -D RUNID $run -type object -dist f -trange now -4d -modify dist t
+
+      # send the file to the CADC ftp location
+      cp $datdir/cadc/mcmd.raw.$date.fits /h/ftp/pub/fits_hdrs/
+
+      # update the values to the QSO database
+      cadc2qso $datdir/cadc/mcmd.raw.$date.fits
+
       breaksw;
 
Index: /trunk/Ohana/src/shell/src/getfocus
===================================================================
--- /trunk/Ohana/src/shell/src/getfocus	(revision 2443)
+++ /trunk/Ohana/src/shell/src/getfocus	(revision 2444)
@@ -102,5 +102,5 @@
 foreach ccd ($ccdn)
  block $temp.sdat.$ccd -t 60 || goto failure;
- awk '($6 > -14) && ($6 < -8){print $0}' $temp.sdat.$ccd | sort -k 6n | head -300 | sort -k 2n > $temp.$ccd.sdat
+ awk '($6 > -14) && ($6 < -8) && ($4== 0){print $0}' $temp.sdat.$ccd | sort -k 6n | head -500 | sort -k 2n > $temp.$ccd.sdat
  rm -f $temp.sdat.$ccd
 end
@@ -157,5 +157,5 @@
 foreach ccd ($ccdn)
  block $temp.sdat.$ccd -t 60 || goto failure;
- awk '($6 > -14) && ($6 < -8){print $0}' $temp.sdat.$ccd | sort -k 6n | head -300 | sort -k 2n > $temp.$ccd.sdat
+ awk '($6 > -14) && ($6 < -8) && ($4 == 0){print $0}' $temp.sdat.$ccd | sort -k 6n | head -500 | sort -k 2n > $temp.$ccd.sdat
  rm -f $temp.sdat.$ccd
 end
Index: /trunk/Ohana/src/shell/src/getseeing
===================================================================
--- /trunk/Ohana/src/shell/src/getseeing	(revision 2443)
+++ /trunk/Ohana/src/shell/src/getseeing	(revision 2444)
@@ -37,4 +37,5 @@
 set pixscale = `gconfig ASEC_PIX`
 set ccd      = `gconfig SEEING_REF_CCD`
+set amp      = `gconfig SEEING_REF_AMP`
 set datdir   = `gconfig DATDIR`
 set confdir  = `gconfig CONFDIR`
@@ -66,6 +67,8 @@
 if ($mef) then
  set Nextend = `echo $file | fields NEXTEND | awk '{print $2}'` 
+ set Nccds   = `echo $file | fields NCCDS | awk '{print $2}'` 
  set tccd = $ccd
- if ($Nextend > 50) set tccd = amp26
+ if ($Nextend != $Nccds) set tccd = $amp
+ # use amp for un-spliced data, ccd for spliced
  echo "subraster.mef   $file $tccd $temp.fits $temp.stats" > $temp.pro
 else
Index: /trunk/Ohana/src/shell/src/sp_command
===================================================================
--- /trunk/Ohana/src/shell/src/sp_command	(revision 2443)
+++ /trunk/Ohana/src/shell/src/sp_command	(revision 2444)
@@ -4,6 +4,6 @@
 set template  = "/h/skyprobe/data/Refs/template.fits"
 set dummyfits = "/h/skyprobe/data/Refs/dummy.fits"
-set dlogfile  = "/h/skyprobe/sp_expose.log"
-set photlog   = "/h/skyprobe/sp_phot.log"
+set dlogfile  = "/h/skyprobe/log/sp_expose.log"
+set photlog   = "/h/skyprobe/log/sp_phot.log"
 set process   = 1
 
@@ -29,5 +29,5 @@
 end
 
-if ($#args == 0) goto usage;
+if ($args[1] == "") goto usage;
 if ($args[1] == "init")   goto init;
 if ($args[1] == "cool")   goto cool;
@@ -45,4 +45,6 @@
   mkdir -p $args[2]
  endif
+ echo "" > $dlogfile
+ echo "" > $photlog
  exit 0;
 
@@ -65,4 +67,5 @@
 
 test:
+
  echo ""
  echo "starting skyprobe test suite"
@@ -93,14 +96,14 @@
 
  # take a dark frame
- echo "taking 1 sec dark frame test.dark.fits"
+ echo "taking 1 sec dark frame sample.dark.fits"
  set exptime = 1.0
- set output  = test.dark.fits
+ set output  = sample.dark.fits
  ssh -n $IOPENER sp_ccdcontrol expose -etime $exptime -shuttermode 2 > $output
  echo ""
 
  # is DETTEMP in range?
- set temps = `echo test.dark.fits | fields DETTEM CAMTEM`
+ set temps = `echo sample.dark.fits | fields DETTEM CAMTEM`
  if ($status) then
-   echo "header information incorrect for test.dark.fits"
+   echo "header information incorrect for sample.dark.fits"
    exit 1
  endif
@@ -117,7 +120,7 @@
  mana --norc << EOF >& /dev/null
   macro go
-   rd a test.dark.fits
+   rd a sample.dark.fits
    stats a - - - -
-   exec echo \$MEAN \$MEDIAN \$SIGMA > test.dark.dat
+   exec echo \$MEAN \$MEDIAN \$SIGMA > sample.dark.dat
    exit 0
   end
@@ -131,5 +134,5 @@
 
  # check dark frame stats
- set flux = `cat test.dark.dat`
+ set flux = `cat sample.dark.dat`
  echo "dark flux: $flux[2]"
  set t = `echo $flux[2] | awk '($1 > 10000){print 1}'`
@@ -140,7 +143,7 @@
  
  # take a light frame
- echo "taking 0.1 sec light frame test.light.fits"
+ echo "taking 0.1 sec light frame sample.light.fits"
  set exptime = 0.1
- set output  = test.light.fits
+ set output  = sample.light.fits
  ssh -n $IOPENER sp_ccdcontrol expose -etime $exptime -shuttermode 1 > $output
  echo ""
@@ -158,21 +161,21 @@
  endif
  setenv DISPLAY $xdisp
+ echo $xdisp
 
  # delete old PS file
  date +%Y.%m.%d | awk '{printf "TEXT 10 20 date:%s\n", $1}' > date.reg
 
- # measure light frame stats
  mana --norc << EOF >& /dev/null
   macro go
-   rd a test.light.fits
+   rd a sample.light.fits
    stats a - - - -
-   exec echo \$MEAN \$MEDIAN \$SIGMA > test.light.dat
+   exec echo \$MEAN \$MEDIAN \$SIGMA > sample.light.dat
    keyword a NAXIS1 nx
    keyword a NAXIS2 ny
-   echo "nx, ny: \$nx, \$ny"
+   tv a {\$MEDIAN*1.1} {-0.2*\$MEDIAN}
    resize \$nx \$ny
-   tv a {\$MEDIAN*1.1} {-0.2*\$MEDIAN}
    load red date.reg
-   ps -name skyprobe.ps
+   exec sleep 2
+   ps -name sample.light.ps
    exit 0
   end
@@ -186,5 +189,5 @@
 
  # check light frame stats
- set flux = `cat test.light.dat`
+ set flux = `cat sample.light.dat`
  echo "light flux: $flux[2]"
  echo "approx. expected counts: "
@@ -194,16 +197,20 @@
  echo ""
 
- if (! -e skyprobe.ps) then 
-   echo "skyprobe.ps not created, cannot print out image"
- else
-   lpr -Psps skyprobe.ps
+ if (! -e sample.light.ps) then 
+   echo "sample.light.ps not created, cannot print out image"
+ else
+   lpr -Psps sample.light.ps
    echo "image is being printed on SPS"
  endif
 
+ rm -f date.reg
+ rm -r sample.dark.dat
+ rm -r sample.light.dat
+
  # test tcsh & loggerh
-# cp -f $template $dummyfits
-# setenv FFTEMPLATE $dummyfits
-# /cfht/bin/tcsh -B >>& $logfile
-# /cfht/bin/loggerh -E >>& $logfile
+ # cp -f $template $dummyfits
+ # setenv FFTEMPLATE $dummyfits
+ # /cfht/bin/tcsh -B >>& $logfile
+ # /cfht/bin/loggerh -E >>& $logfile
 
  exit 0; 
Index: /trunk/Ohana/src/shell/src/sp_phot
===================================================================
--- /trunk/Ohana/src/shell/src/sp_phot	(revision 2443)
+++ /trunk/Ohana/src/shell/src/sp_phot	(revision 2444)
@@ -19,5 +19,6 @@
 set args=""
 set setdate=1
-while ("$1" != "") 
+set testrun=0
+while ($#argv)
  switch ($1)
   case -date: 
@@ -33,8 +34,11 @@
 end
 
-if ($#args != 1) then
+if ("$args[1]" == "") then
   echo "USAGE: sp_phot (filename.fits) [-date YYYYMMDD]";
+  echo "USAGE: sp_phot (test)";
   exit 2;
 endif
+
+if ($args[1] == "test") set testrun = 1
 
 # kill off other processes with this name, and their children
@@ -53,12 +57,11 @@
 end
 
-# setenv PATH {$PATH}:/apps/elixir/bin
-
 if ($setdate) then
   set DATE=`date -u +%Y%m%d`
 endif
+
 set spdir = `gconfig SKYPROBE_DIR`
 if ($?) then 
-  echo "problem with config system"
+  echo "problem with config system: missing SKYPROBE_DIR"
   exit 1;
 endif
@@ -84,4 +87,8 @@
 
 set raw=$args[1]
+if ($testrun) then
+ set raw = /h/skyprobe/data/Refs/sample.fits
+endif
+
 set root=`echo $raw | awk -F/ '{print $NF}' | sed s/.fits//`
 
@@ -104,9 +111,31 @@
 
 # use the tycho data only to do astrometry
-rsh -n $DBMACHINE gastro -D CATDIR $TYCHO $SMPDIR/$root.smp
+# rsh -n $DBMACHINE gastro -D CATDIR $TYCHO $SMPDIR/$root.smp
+echo gastro -D CATDIR $TYCHO $SMPDIR/$root.smp
+gastro -D CATDIR $TYCHO $SMPDIR/$root.smp
 # if ($status) goto cleanup;
 
-rsh -n $DBMACHINE addspphot -image -cal TYCHO_V TYCHO_B $SMPDIR/$root.smp 
+# rsh -n $DBMACHINE addspphot -image -cal TYCHO_V TYCHO_B $SMPDIR/$root.smp 
+addspphot -image -cal TYCHO_V TYCHO_B $SMPDIR/$root.smp 
 # if ($status) goto cleanup;
+
+if ($testrun) then
+ set N = `imphotsearch -name sample | wc -l`
+ imphotsearch -name sample
+ if ($status) then
+   echo "failure to find image in db"
+   exit 2;
+ endif
+ if ($N == 0) then
+   echo "failure to write image to db"
+   exit 1;
+ endif
+ echo delstar $SMPDIR/$root.smp 
+ delstar $SMPDIR/$root.smp 
+ if ($status) then
+   echo "failure to remove test image from db"
+   exit 2;
+ endif
+endif
 
 rm -f $SMPDIR/$root.flt 
Index: /trunk/Ohana/src/shell/src/sp_plots
===================================================================
--- /trunk/Ohana/src/shell/src/sp_plots	(revision 2443)
+++ /trunk/Ohana/src/shell/src/sp_plots	(revision 2444)
@@ -9,6 +9,6 @@
 set datdir=`gconfig DATDIR`
 set script="$confdir/mana/skyprobe"
-set xhost=`gconfig XHOST`
-set xdisp=`gconfig XDISP`
+set xhost=`gconfig XHOST.SUMMIT`
+set xdisp=`gconfig XDISP.SUMMIT`
 setenv DISPLAY $xdisp
 
