Index: /trunk/Ohana/src/shell/src/getfocus
===================================================================
--- /trunk/Ohana/src/shell/src/getfocus	(revision 48)
+++ /trunk/Ohana/src/shell/src/getfocus	(revision 49)
@@ -14,5 +14,5 @@
    breaksw;
   case -*: 
-   goto escape
+   goto usage
    breaksw;
   default:
@@ -23,5 +23,5 @@
 end
 
-if ($#args != 3) goto escape
+if ($#args != 3) goto usage
 
 # kill off other processes with this name, and their children
@@ -45,4 +45,6 @@
 set datdir  = `gconfig DATDIR`
 set confdir = `gconfig CONFDIR`
+set ccds    = `gconfig FOCUS-CCDS-LIST`
+set ccdn    = `gconfig FOCUS-CCDN-LIST`
 
 # sextractor needs full paths to:
@@ -76,6 +78,5 @@
 if ("$mode" == "on") goto mef
 if ("$mode" == "off") goto split
-echo "invalid mode $mode in getfocus"
-exit 1;
+goto usage
 
 ### SPLIT mode
@@ -83,9 +84,10 @@
 
 # make sure all four files exist
-foreach ccd (01 04 07 10)
+foreach ccd ($ccdn)
  block $fdir/$name/$name$ccd.fits -t 60 || goto failure;
 end
 
-foreach ccd (01 04 07 10)
+# run sextractor on each chip
+foreach ccd ($ccdn)
  sex $fdir/$name/$name$ccd.fits \
     -c $sexconf \
@@ -96,15 +98,16 @@
     mv $temp.$ccd $temp.sdat.$ccd &
 end
-# sextract writes output to catalog while processing;
-# mv to real file *after* sextract is done
 
-foreach ccd (01 04 07 10)
+# wait for results, extract stellar objects
+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
  rm -f $temp.sdat.$ccd
 end
+# result i in $temp.$ccd.sdat ($ccd from $ccdn)
 
+# create mana script & run it
 rm -f $temp.pro
-set ccd=00
+set ccd = $ccdn[1]
 echo "plotfocus $temp $temp.ppm $name $fdir/$name/$name$ccd.fits" >> $temp.pro
 mana --norc --only $script $temp.pro
@@ -115,7 +118,8 @@
 cp $output1 $output2
 
+# cleanup temp files
 rm -f $temp $temp.sdat $temp.pro $temp.ppm
-foreach ccd (01 04 07 10)
- rm -f $temp.$ccd.sdat 
+foreach ccd ($ccdn)
+ rm -f $temp.$ccd.sdat $temp.$ccd.fits
 end
 exit 0;
@@ -124,14 +128,19 @@
 mef:
  
+# wait for file to appear
 block $fdir/$name.fits -t 60 || goto failure;
 
+# extract section of each image to $temp.$ccd.fits ($ccd in $ccdn)
 rm -f $temp.pro
-foreach ccd (01 04 07 10)
- echo "split $fdir/$name.fits $ccd $temp.$ccd.fits" >> $temp.pro
+set i = 1
+while ($i <= $#ccds)
+ $ccdnum = $ccdn[$i]
+ $ccdnam = $ccns[$i]
+ echo "split $fdir/$name.fits $ccdnam $temp.$ccdnum.fits" >> $temp.pro
 end
-
 mana --norc --only $script $temp.pro
 
-foreach ccd (01 04 07 10)
+# run sextractor on each chip
+foreach ccd ($ccdn)
  sex $temp.$ccd.fits \
     -c $sexconf \
@@ -142,15 +151,15 @@
     mv $temp.$ccd $temp.sdat.$ccd &
 end
-# sextract writes output to catalog while processing;
-# mv to real file *after* sextract is done
 
-foreach ccd (01 04 07 10)
- block $temp.sdat.$ccd -t 30 || goto failure;
+# wait for results, extract stellar objects
+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
  rm -f $temp.sdat.$ccd
 end
 
+# create mana script & run it
 rm -f $temp.pro
-set ccd=01
+set ccd = $ccdn[1]
 echo "plotfocus $temp $temp.ppm $name $temp.$ccd.fits" >> $temp.pro
 mana --norc --only $script $temp.pro
@@ -161,6 +170,7 @@
 cp $output1 $output2
 
+# cleanup temp files
 rm -f $temp $temp.sdat $temp.pro $temp.ppm
-foreach ccd (01 04 07 10)
+foreach ccd ($ccdn)
  rm -f $temp.$ccd.sdat $temp.$ccd.fits
 end
@@ -168,24 +178,13 @@
 
 failure: 
- echo "****** error with focus"
+ echo "****** error with focus ******"
  rm -f $temp $temp.sdat $temp.pro
- foreach ccd (01 04 07 10)
+ foreach ccd ($ccdn)
   rm -f $temp.$ccd.sdat $temp.$ccd.fits
  end
  exit 1;
 
-escape:
+usage:
  echo "USAGE: getfocus (fdir) (file) (mode)"
  echo "(mode) may be 'on' for mef, 'off' for split"
  exit 2;
-
-
- sex $temp.$ccd.fits -c $config -CATALOG_NAME $temp.sdat
- sort -k 2n $temp.sdat | head -300 > $temp.$ccd.sdat
-
-rm -f $temp.pro
-rm -f $temp.ppm
-echo "plotfocus $temp $temp.ppm $name $fdir/$name.fits" >> $temp.pro
-mana --norc --only $script $temp.pro
-if ($status) goto failure
-
Index: /trunk/Ohana/src/shell/src/getseeing
===================================================================
--- /trunk/Ohana/src/shell/src/getseeing	(revision 48)
+++ /trunk/Ohana/src/shell/src/getseeing	(revision 49)
@@ -35,8 +35,8 @@
 set mode=$3
 
-set ccd=03
-
-set datdir  = `gconfig DATDIR`
-set confdir = `gconfig CONFDIR`
+set pixscale = `gconfig ASEC_PIX`
+set ccd      = `gconfig SEEING_REF_CCD`
+set datdir   = `gconfig DATDIR`
+set confdir  = `gconfig CONFDIR`
 
 # sextractor needs full paths to:
@@ -65,4 +65,6 @@
 rm -f $temp $temp.fits $temp.stats $temp.pro $temp.cat
 if ($mef) then
+ set Nextend = `echo $file | fields NEXTEND | awk '{print $2}'` 
+ if ($Nextend > 50) set ccd = amp26
  echo "subraster.mef   $file $ccd $temp.fits $temp.stats" > $temp.pro
 else
@@ -80,6 +82,7 @@
     -STARNNW_NAME    $sexnnw \
     -CATALOG_NAME    $temp.cat
-set fwhm=`seeingstats $temp.cat | awk '{print $1*0.2}'`
-set filter=`echo $temp.fits | fields FILTER`
+
+set fwhm   = `seeingstats $temp.cat | awk -v scale=$pixscale '{print $1*scale}'`
+set filter = `echo $temp.fits | fields FILTER`
 
 # send output (screen || $output & QSO)
