Index: branches/eam_branches/ipp-20211108/ippTests/ippCheck/cammask.pro
===================================================================
--- branches/eam_branches/ipp-20211108/ippTests/ippCheck/cammask.pro	(revision 42030)
+++ branches/eam_branches/ipp-20211108/ippTests/ippCheck/cammask.pro	(revision 42031)
@@ -6,10 +6,10 @@
 
 # this module provides the following functions
-# get.camera.eff (camera) (expname) (camLabel) (refsrcs.fits) : 
+# get.camera.eff (camera) (expname) (camDgroup) (refsrcs.fits) : 
 # get.chip.detect.stats (chipname) (chipnseq)
 # get.chip.mask.stats (cammask)
 # get.chip.mask.files (camPath)
 # get.chip.metadata (camera) (chipID)
-# get.camera.metadata (camera) (expname) (camLabel)
+# get.camera.metadata (camera) (expname) (camDgroup)
 
 # init.radec.range
@@ -29,13 +29,13 @@
 macro get.camera.eff
  if ($0 != 5)
-  echo "USAGE: get.camera.eff (camera) (expname) (camLabel) (refsrcs.fits)"
+  echo "USAGE: get.camera.eff (camera) (expname) (camDgroup) (refsrcs.fits)"
   echo "EX:    get.camera.eff gpc1 o9322g0253o EU.nightlyscience filename.fits"
   break
  end
 
- local i dbname expname camlabel output
+ local i dbname expname camdgrp output
  $dbname   = $1
  $expname  = $2
- $camlabel = $3
+ $camdgrp  = $3
  $refsrcs  = $4
 
@@ -48,5 +48,5 @@
 
  # get the name of the smf file:
- get.camera.metadata $dbname $expname $camlabel
+ get.camera.metadata $dbname $expname $camdgrp
  $smffile = $camPath.smf     
  $smfreal = `neb-locate -p $smffile`
@@ -298,5 +298,5 @@
 macro get.camera.metadata
  if ($0 != 4)
-  echo "USAGE: get.camera.metadata (camera) (expname) (camLabel)"
+  echo "USAGE: get.camera.metadata (camera) (expname) (camDgroup)"
   echo "EX:    get.camera.metadata gpc1 o9322g0253o EU.nightlyscience"
   echo "  sets camPath, chipID"
@@ -304,8 +304,8 @@
  end
 
- local dbname expname camlabel
- $dbname   = $1
- $expname  = $2
- $camlabel = $3
+ local dbname expname camdgrp
+ $dbname  = $1
+ $expname = $2
+ $camdgrp = $3
 
 # need to generically handle the question of which version / label
@@ -313,5 +313,5 @@
 # instead of label, we could specify the cam_id (which we might know)
 
- $command = camtool -dbname $dbname -processedexp -exp_name $expname -label $camlabel
+ $command = camtool -dbname $dbname -processedexp -exp_name $expname -data_group $camdgrp
 #$command = camtool -dbname $dbname -processedexp -exp_name $expname
  
Index: branches/eam_branches/ipp-20211108/ippTests/ippCheck/ippCheck
===================================================================
--- branches/eam_branches/ipp-20211108/ippTests/ippCheck/ippCheck	(revision 42030)
+++ branches/eam_branches/ipp-20211108/ippTests/ippCheck/ippCheck	(revision 42031)
@@ -28,5 +28,5 @@
 
   if ($0 != 3)
-    echo "USAGE: check.exposure.dvo (expname) (label)"
+    echo "USAGE: check.exposure.dvo (expname) (dgroup)"
     echo " -no-cam, -no-warp, -no-diff, -no-plots"
     echo " [-camera gpc2]"
@@ -34,7 +34,7 @@
   end
 
-  local expname camlabel
+  local expname camdgrp
   $expname = $1
-  $camlabel = $2
+  $camdgrp = $2
  
   $OUTVERSION = DVO; # used to define output names
@@ -42,7 +42,7 @@
 
   make.truth.sources $CAMERA $expname $PV3_CATDIR DVO
-  if (not($SKIP_CAM))  get.camera.eff $CAMERA $expname $camlabel       $REFSOURCE
-  if (not($SKIP_WARP)) get.warp.eff   $CAMERA $expname $camID          $REFSOURCE
-  if (not($SKIP_DIFF)) get.diff.eff   $CAMERA $expname $warpID         $REFSOURCE
+  if (not($SKIP_CAM))  get.camera.eff $CAMERA $expname $camdgrp $REFSOURCE
+  if (not($SKIP_WARP)) get.warp.eff   $CAMERA $expname $camID   $REFSOURCE
+  if (not($SKIP_DIFF)) get.diff.eff   $CAMERA $expname $warpID  $REFSOURCE
 
   if (not($SKIP_PLOTS)) plot.exposure.real $expname
@@ -64,11 +64,11 @@
 
   if ($0 != 4)
-    echo "USAGE: check.exposure.mpc (expname) (label) (mpcfile)"
-    break
-  end
-
-  local expname camlabel mpcfile
+    echo "USAGE: check.exposure.mpc (expname) (dgroup) (mpcfile)"
+    break
+  end
+
+  local expname camdgrp mpcfile
   $expname = $1
-  $camlabel = $2
+  $camdgrp = $2
   $mpcfile = $3
  
@@ -81,5 +81,5 @@
   make.truth.sources $CAMERA $expname $mpcfile MPC; # sets the value of REFSOURCE 
 
-  if (not($SKIP_CAM)) get.camera.eff     $CAMERA $expname $camlabel $REFSOURCE
+  if (not($SKIP_CAM)) get.camera.eff     $CAMERA $expname $camdgrp $REFSOURCE
 
   # CAMSOURCE lists all REFSOURCE entries which actually fall on a chip, while REFSOURCE includes
@@ -226,6 +226,6 @@
 macro show.usage
   echo "USAGE: ippCheck (mode) ..."
-  echo "   EG: ippCheck mpc  (expname) (label) [mpcfile]"
-  echo "   EG: ippCheck dvo  (expname) (label)"
+  echo "   EG: ippCheck mpc  (expname) (dgroup) [mpcfile]"
+  echo "   EG: ippCheck dvo  (expname) (dgroup)"
   echo "   EG: ippCheck smf  (outroot) (smf1) (smf2) [+plot]"
   echo "   EG: ippCheck smf.dgrp (outroot) (smf1) (smf2) [+plot]"
Index: branches/eam_branches/ipp-20211108/ippTests/ippCheck/smfcheck.pro
===================================================================
--- branches/eam_branches/ipp-20211108/ippTests/ippCheck/smfcheck.pro	(revision 42030)
+++ branches/eam_branches/ipp-20211108/ippTests/ippCheck/smfcheck.pro	(revision 42031)
@@ -17,5 +17,5 @@
   end
 
-  local output expname dgrp1 dgrp2 
+  local output expname dgrp1 dgrp2 saveplot
   $output  = $1
   $expname = $2
@@ -31,12 +31,17 @@
   $smf2    = `neb-locate -p $smffile`
 
+  $saveplot =
+  if ($SAVEPLOT) 
+    $saveplot = +plot
+  end
   smf.compare.all.extensions $output $smf1 $smf2
 end
 
 macro smf.compare.all.extensions
-  getargs +plot   BOOL  -var SAVEPLOT
+  # defaults to 'false' if +plot is not provided
+  getargs +plot     BOOL  -var SAVEPLOT
 
   if ($0 != 4)
-    echo "USAGE: smf.compare.all.extensions (output) (smf1) (smf2) [-plot]"
+    echo "USAGE: smf.compare.all.extensions (output) (smf1) (smf2)"
     break
   end
@@ -61,14 +66,20 @@
 
   # does the smf have the right number of extensions?
-  list ext0 -x "ftable -list $smf1"
-  list ext1 -x "ftable -list $smf2"
-
-  ok ($ext0:n == $ext1:n) "same number of extensions"
-  if ($ext0:n != $ext1:n) 
-    echo "impossible to continue with mismatched extensions"
-    echo "smf1 : $smf1"
-    echo "smf2 : $smf2"
-    exit 3
-  end
+  # generate a list of just the extension names:
+  list tablelines -x "ftable -list $smf1"
+  smf.compare.extract.extnames ext0 tablelines
+
+  list tablelines -x "ftable -list $smf2"
+  smf.compare.extract.extnames ext1 tablelines
+
+  smf.compare.match.extlists ext0 ext1
+
+  ## ok ($ext0:n == $ext1:n) "same number of extensions"
+  ## if ($ext0:n != $ext1:n) 
+  ##   echo "impossible to continue with mismatched extensions"
+  ##   echo "smf1 : $smf1"
+  ##   echo "smf2 : $smf2"
+  ##   exit 3
+  ## end
 
   # track the number of chips for which the XYnn.hdr keys failed
@@ -77,18 +88,25 @@
 
   # XXX how to do the next steps if the numbers do not match?
-  # NOTE: ext0:0 is the title line
-  for i 1 $ext0:n
-    list w0 -split $ext0:$i
-    list w1 -split $ext1:$i
-    ok ($w0:0 == $w1:0) "matching ext names"
-
-    $extname = $w0:0
+  for Next1 0 $ext0:n
+    $Next2 = $match1:$Next1
+    if ($Next2 == -1) 
+      echo "not ok : missing extenion $ext0:$Next1"
+      next
+    end
+
+    ok ($ext0:$Next1 == $ext1:$Next2) "matching ext names"
+    $extname = $ext0:$Next1
+    # NOTE: analysis below uses ext sequence number (i,j)
+    # extname is only used to name output products
+
+    # ippCheckKeys uses 0 == PHU, 1 = 1st extension
+    # smf.compare.onechip uses 0 = 1st extension 
 
     # if extname is XYnn.hdr, compare the headers
     strstr -q $extname .hdr -start s1
     if ($s1 == 4)
-      $Next = $i - 1
-      echo "# check keys for $extname == FITS entry number $Next"
-      exec ippCheckKeys $smf1 $Next $smf2 $Next >& $outroot.$extname.keys
+      echo "##### check keys for $extname == FITS entry number $Next1,$Next2 #####"
+      echo "##### comparison results in $outroot.$extname.keys               #####"
+      exec ippCheckKeys $smf1 $Next1 $smf2 $Next2 >& $outroot.$extname.keys
       smf.compare.keys $outroot.$extname.keys hdrKeys
       if ($NfailKeys) set NfailHdr = $NfailHdr + 1
@@ -98,12 +116,13 @@
     strstr -q $extname .psf -start s1
     if ($s1 == 4)
-      $Next = $i - 1
-      echo "# check keys for $extname == FITS entry number $Next"
-      exec ippCheckKeys $smf1 $Next $smf2 $Next >& $outroot.$extname.keys 
+      echo "##### check keys for $extname == FITS entry number $Next1,$Next2 #####"
+      echo "##### comparison results in $outroot.$extname.keys               #####"
+      exec ippCheckKeys $smf1 $Next1 $smf2 $Next2 >& $outroot.$extname.keys 
       smf.compare.keys $outroot.$extname.keys psfKeys
       if ($NfailKeys) set NfailPsf = $NfailPsf + 1
 
-      echo "# check fields for $extname == FITS entry number $Next"
-      smf.compare.onechip $outroot.$extname $smf1 $smf2 {$Next - 1}; # Note smf.compare.onechip counts from 0 = first extension
+      echo "##### check fields for $extname == FITS entry number $Next1,$Next2 #####"
+      echo "##### comparison results in $outroot.$extname.txt                  #####"
+      smf.compare.onechip $outroot.$extname $smf1 {$Next1-1} $smf2 {$Next2-1}; # Note smf.compare.onechip counts from 0 = first extension
     end
   end
@@ -116,14 +135,15 @@
 # generate plot and comparison txt file for one chip (extension)
 macro smf.compare.onechip
-  if ($0 != 5)
-    echo "USAGE: smf.compare.onechip (output) (smf1) (smf2) (extension)"
-    break
-  end
-
-  local output smf1 smf2 extnum
+  if ($0 != 6)
+    echo "USAGE: smf.compare.onechip (output) (smf1) (ext1) (smf2) (ext2)"
+    break
+  end
+
+  local output smf1 smf2 ext1 ext2
   $output = $1
   $smf1 = $2
-  $smf2 = $3
-  $extnum = $4
+  $ext1 = $3
+  $smf2 = $4
+  $ext2 = $5
 
   dirname $output -var mydir
@@ -135,6 +155,6 @@
   # load in the full set of data for this extension
   # NOTE : t0 and t1 are used to label the sets of vectors
-  smf.load.fields $smf1 $extnum t1
-  smf.load.fields $smf2 $extnum t2
+  smf.load.fields $smf1 $ext1 t1
+  smf.load.fields $smf2 $ext2 t2
 
   # generate the matched lists (index1, index2)
@@ -211,7 +231,7 @@
   # add a test here?
   vstat -q dX
-  ok ($SIGMA < 0.1) "X position stdev < 0.1"
+  ok ($SIGMA < 0.1) "X position stdev $SIGMA < 0.1"
   vstat -q dY
-  ok ($SIGMA < 0.1) "Y position stdev < 0.1"
+  ok ($SIGMA < 0.1) "Y position stdev $SIGMA < 0.1"
 end
 
@@ -607,4 +627,72 @@
  book getword mybook $pagename cam_id    -var camID
  book delete mybook
+end
+
+######## generate a list of the entries in list2 which correspond to the entries in list 1
+macro smf.compare.match.extlists
+ if ($0 != 3)
+  echo "USAGE: smf.compare.match.extlists (list1) (list2)"
+  break
+ end
+
+ # if I can assume the two lists have the same order (with just inserts or deletions in one or the other)
+ # then I can step through the list only once
+ # otherwise, I need to do N^2 comparisons?
+
+ $list1 = $1
+ $list2 = $2
+
+ $N1 = $$list1:n  
+ $N2 = $$list2:n  
+ 
+ for i 0 $N1
+   $match1:$i = -1
+ end
+ $match1:n = $N1
+
+ for i 0 $N2
+   $match2:$i = -1
+ end
+ $match2:n = $N2
+
+ for i 0 $N1
+   for j 0 $N2
+     if ($match2:$j != -1) continue
+     if ($$list1:$i == $$list2:$j)
+       $match1:$i = $j
+       $match2:$j = $i
+       last
+     end
+   end
+   if ($match1:$i == -1)
+     echo "ERROR: missing extension $$list1:$i in file 2"
+   end
+ end
+
+ for j 0 $N2
+   if ($match2:$j == -1)
+     echo "WARNING: unexpected extension $$list2:$j in file 2"
+   end
+ end
+end
+
+#######
+macro smf.compare.extract.extnames
+  if ($0 != 3)
+    echo "USAGE: smf.compare.extract.extnames (outlist) (inlist)"
+    break
+  end
+
+  local i j inlist outlist
+  $outlist = $1
+  $inlist = $2
+
+  # NOTE: inlist:0 is the title line
+  for i 1 $$inlist:n
+    $j = $i - 1
+    list words -split $$inlist:$i
+    $$outlist:$j = $words:0
+  end
+  $$outlist:n = $tablelines:n - 1
 end
 
