Index: /trunk/tools/eam/teleff/cammask.pro
===================================================================
--- /trunk/tools/eam/teleff/cammask.pro	(revision 41718)
+++ /trunk/tools/eam/teleff/cammask.pro	(revision 41719)
@@ -2,5 +2,5 @@
 
 $VERBOSE    = 1	       
-$COPYMASKS  = 1
+$COPYMASKS  = 0
 $OUTDIR     = .
 $OUTVERSION = XXX
@@ -65,4 +65,9 @@
  end
 
+  # delete any existing output vectors
+  foreach field $SMF_FIELDS_CAM $REF_FIELDS_CAM $XTR_FIELDS_CAM
+    delete -q $field\_out
+  end
+
  # find matching entries in smf file 
  for i 0 $chipName:n
@@ -70,9 +75,9 @@
    get.chip.mask.stats $camMask:$i
 
-   foreach field SMF_FIELDS_CAM
+   foreach field $SMF_FIELDS_CAM
      concat $field\_found $field\_out
      delete $field\_found
    end
-   foreach field REF_FIELDS_CAM $XTR_FIELDS_CAM
+   foreach field $REF_FIELDS_CAM $XTR_FIELDS_CAM
      concat $field\_onchp $field\_out
      delete $field\_onchp
@@ -81,5 +86,5 @@
 
  $OUT_FIELDS = 
- foreach field $SMP_FIELDS_CAM $REF_FIELDS_CAM $XTR_FIELDS_CAM
+ foreach field $SMF_FIELDS_CAM $REF_FIELDS_CAM $XTR_FIELDS_CAM
    $OUT_FIELDS = $OUT_FIELDS $field\_out
  end
@@ -309,5 +314,6 @@
 
 
-####
+#### this test macro generates the match table without measuring the mask fraction
+#### XXX the output formats are not consistent with the above version
 
 macro get.camera.matches
Index: /trunk/tools/eam/teleff/diffmask.pro
===================================================================
--- /trunk/tools/eam/teleff/diffmask.pro	(revision 41718)
+++ /trunk/tools/eam/teleff/diffmask.pro	(revision 41719)
@@ -2,7 +2,9 @@
 
 $VERBOSE    = 1	       
-$COPYMASKS  = 1
+$COPYMASKS  = 0
 $OUTDIR     = .
-$OUTVERSION = XXX
+if (not($?OUTVERSION))
+  $OUTVERSION = XXX
+end
 
 $DIFF_MODE_WW = 1
@@ -52,4 +54,9 @@
   if ($VERBOSE) echo "loaded Rref[] sources from reference $refsrcs"
 
+  # delete any existing output vectors
+  foreach field $SMF_FIELDS_DIF $REF_FIELDS_DIF $XTR_FIELDS_DIF
+    delete -q $field\_out
+  end
+
   # find matching entries in cmf files and measure mask fraction
   for i 0 $diffMask:n
@@ -67,9 +74,9 @@
     end
 
-   foreach field SMF_FIELDS_DIF
+   foreach field $SMF_FIELDS_DIF
      concat $field\_found $field\_out
      delete $field\_found
    end
-   foreach field REF_FIELDS_DIF $XTR_FIELDS_DIF
+   foreach field $REF_FIELDS_DIF $XTR_FIELDS_DIF
      concat $field\_onchp $field\_out
      delete $field\_onchp
@@ -78,9 +85,9 @@
 
   $OUT_FIELDS = 
-  foreach field $SMP_FIELDS_DIF $REF_FIELDS_DIF $XTR_FIELDS_DIF
+  foreach field $SMF_FIELDS_DIF $REF_FIELDS_DIF $XTR_FIELDS_DIF
     $OUT_FIELDS = $OUT_FIELDS $field\_out
   end
 
-  sprintf output "%s/%s.%s.diff.stf" $OUTDIR $expname $OUTVERSION
+  sprintf output "%s/%s.%s.dif.stf" $OUTDIR $expname $OUTVERSION
   write -fits DATA $output $OUT_FIELDS
 end
@@ -128,5 +135,5 @@
 
   # generate a subset of sources which are within the boundaries of the skycell
-  set keep = (XrefS >= 0) && (XrefS <= $NAXIS1) && (YrefS >= 0) && (YrefS <= $NAXIS2)
+  set keep = (Xref_tmp >= 0) && (Xref_tmp <= $NAXIS1) && (Yref_tmp >= 0) && (Yref_tmp <= $NAXIS2)
   foreach field $REF_FIELDS_DIF Nref Xref Yref
     subset $field\_onchp = $field\_tmp if keep
@@ -201,6 +208,12 @@
  for i 0 $diffPath:n
    sprintf filename "%s.mask.fits" $diffPath:$i
+   break -auto off   
    $diffMask:$i = `neb-locate -p $filename`
-   if ($COPYMASKS) exec neb-copy $filename $OUTDIR
+   break -auto on
+   if ("$diffMask:$i" == "")
+     echo "skipping $filename"
+   else 
+     if ($COPYMASKS) exec neb-copy $filename $OUTDIR
+   end
 
    sprintf filename "%s.cmf" $diffPath:$i
@@ -274,7 +287,19 @@
  
  if ($npages < 1) 
-  echo "ERROR: missing exposure : $command"
+  # try the template versoin
   book delete mybook
-  next
+ 
+  $command = difftool -dbname $dbname -listrun -exp_name $expname -warp_id $warpID -diff_mode $diffMode -template
+  
+  queueload  myqueue -x "$command"
+  queue2book myqueue mybook
+  
+  book npages mybook -var npages
+  
+  if ($npages < 1) 
+   echo "ERROR: missing exposure : $command"
+   book delete mybook
+   return
+  end
  end
  
@@ -282,5 +307,5 @@
   echo "ERROR: too many exposures : $command"
   book delete mybook
-  next
+  return
  end
  
Index: /trunk/tools/eam/teleff/run.teleff.pro
===================================================================
--- /trunk/tools/eam/teleff/run.teleff.pro	(revision 41719)
+++ /trunk/tools/eam/teleff/run.teleff.pro	(revision 41719)
@@ -0,0 +1,64 @@
+#!/bin/csh
+
+set hostlist = 
+set hostlist = "$hostlist ippc130"
+set hostlist = "$hostlist ippc131"
+set hostlist = "$hostlist ippc132"
+set hostlist = "$hostlist ippc133"
+set hostlist = "$hostlist ippc134"
+set hostlist = "$hostlist ippc136"
+set hostlist = "$hostlist ippc137"
+set hostlist = "$hostlist ippc138"
+set hostlist = "$hostlist ippc139"
+set hostlist = "$hostlist ippc140"
+set hostlist = "$hostlist ippc141"
+set hostlist = "$hostlist ippc142"
+set hostlist = "$hostlist ippc143"
+set hostlist = "$hostlist ippc144"
+
+## run on this machine
+if ($#argv == 0) then
+
+  # only run 10 exposures per machine
+  set dN = 10
+  set Ns = 0
+  set Nt = 60
+  
+  foreach f ($hostlist)
+    if (`hostname` == "$f") set Ns = $Nt
+    @ Nt += $dN
+  end
+
+  if ($Ns == 0) then
+   echo "must run on valid host"
+   exit 2
+  endif
+  
+  set i = $Ns
+  set Ne = $Ns
+  @ Ne += $dN
+  
+  while ($i < $Ne)
+    set expname = `echo $i | awk '{printf "o9375g0%03do", $1}'`
+    set outdir = $expname.stats
+    echo "$expname"
+    mkdir -p $outdir
+    ./teleff.pro dvo $expname                   >& $outdir/$expname.DVO.log
+    ./teleff.pro mpc $expname trange.59375.fits >& $outdir/$expname.MPC.log
+    @ i++
+  end
+  exit 0
+endif
+
+if ("$1" == "launch") then
+  
+  foreach f ($hostlist)
+    echo "launch on $f"
+    ssh -f $f "cd `pwd` && ./run.teleff.pro >& log.teleff.$f.v0"
+  end
+  exit 0
+endif
+
+echo "USAGE: run.teleff.pro launch "
+echo "   OR: run.teleff.pro"
+exit 2
Index: /trunk/tools/eam/teleff/teleff.pro
===================================================================
--- /trunk/tools/eam/teleff/teleff.pro	(revision 41718)
+++ /trunk/tools/eam/teleff/teleff.pro	(revision 41719)
@@ -33,5 +33,5 @@
   get.diff.eff       gpc1 $expname $warpID           $REFSOURCE
 
-  break
+  return
 
   $KAPA = kapa -noX
@@ -66,4 +66,7 @@
   # this sample has ~1900 known asteroids covering 375 sq deg. we should expect ~ 35 asteroids per exposure
 
+  # mpcorb_predict trange mpc/mpcorb_extended.59396.dat 59375.2 59375.8 190 250 -10 20 trange.59375.fits
+  # this area covers exposures o9375g0060o - o9375g0341o (visit 1) and later visits
+
   # use a larger match radius for the asteroids
   $MATCH_RADIUS = 3.0
@@ -76,5 +79,5 @@
   get.diff.eff       gpc1 $expname $warpID           $REFSOURCE
 
-  break
+  return
 
   $KAPA = kapa -noX
Index: /trunk/tools/eam/teleff/truth.pro
===================================================================
--- /trunk/tools/eam/teleff/truth.pro	(revision 41718)
+++ /trunk/tools/eam/teleff/truth.pro	(revision 41719)
@@ -76,5 +76,5 @@
 
  # the DVO truth file is specific to the exposure
- sprintf REFSOURCE "%s/%s.dvo.fits" $OUTDIR $expname 
+ sprintf REFSOURCE "%s/%s.DVO.fits" $OUTDIR $expname 
  write -fits DATA $REFSOURCE Rref Dref Mref
 end
@@ -120,5 +120,5 @@
  
  # mpcorb_predict generates a FITS table specific to the exposure with fields (Rref, Dref, Mref)
- sprintf REFSOURCE "%s/%s.mpc.fits" $OUTDIR $expname 
+ sprintf REFSOURCE "%s/%s.MPC.fits" $OUTDIR $expname 
  echo mpcorb_predict moment $mpcfile $MJD $Rmin $Rmax $Dmin $Dmax $REFSOURCE
  exec mpcorb_predict moment $mpcfile $MJD $Rmin $Rmax $Dmin $Dmax $REFSOURCE
Index: /trunk/tools/eam/teleff/warpmask.pro
===================================================================
--- /trunk/tools/eam/teleff/warpmask.pro	(revision 41718)
+++ /trunk/tools/eam/teleff/warpmask.pro	(revision 41719)
@@ -2,5 +2,5 @@
 
 $VERBOSE    = 1	       
-$COPYMASKS  = 1
+$COPYMASKS  = 0
 $OUTDIR     = .
 $OUTVERSION = XXX
@@ -46,9 +46,14 @@
   if ($VERBOSE) echo "loaded Rref[] sources from reference $refsrcs"
 
+  # delete any existing output vectors
+  foreach field $REF_FIELDS_WRP $XTR_FIELDS_WRP
+    delete -q $field\_out
+  end
+
   # find matching entries in smf file 
   for i 0 $warpMask:n
     get.warp.mask.stats $warpMask:$i
 
-    foreach field REF_FIELDS_WRP $XTR_FIELDS_WRP
+    foreach field $REF_FIELDS_WRP $XTR_FIELDS_WRP
       concat $field\_onchp $field\_out
       delete $field\_onchp
@@ -61,5 +66,5 @@
   end
 
-  sprintf output "%s/%s.%s.%s.warp.stf" $OUTDIR $expname $skycell:$i $OUTVERSION
+  sprintf output "%s/%s.%s.wrp.stf" $OUTDIR $expname $OUTVERSION
   write -fits DATA $output $OUT_FIELDS
 end
