Index: trunk/ippToPsps/test/testscripts/force.sh
===================================================================
--- trunk/ippToPsps/test/testscripts/force.sh	(revision 39180)
+++ trunk/ippToPsps/test/testscripts/force.sh	(revision 39180)
@@ -0,0 +1,26 @@
+#!/bin/csh
+
+set catdir = catdir.test
+
+mkcmf -forcedwarp -photcode SIMTEST.g.ForcedWarp testdata/test.01.txt testdata/warp.01.cmf -extroot SkyChip -date 2010/01/01 -time 01:00:00 -mjd 55197.0416667 -radec 10.0 20.0 -type PS1_V5_Lensing -imageID 1 -sourceID 2 -tess_id RINGS.V3 -skycell skycell.1133.081 -bad-psfqf-frac 0.2
+mkcmf -forcedwarp -photcode SIMTEST.g.ForcedWarp testdata/test.02.txt testdata/warp.02.cmf -extroot SkyChip -date 2010/01/01 -time 02:00:00 -mjd 55197.0833333 -radec 10.0 20.0 -type PS1_V5_Lensing -imageID 2 -sourceID 2 -tess_id RINGS.V3 -skycell skycell.1133.081 -bad-psfqf-frac 0.2
+mkcmf -forcedwarp -photcode SIMTEST.g.ForcedWarp testdata/test.03.txt testdata/warp.03.cmf -extroot SkyChip -date 2010/01/01 -time 03:00:00 -mjd 55197.125 -radec 10.0 20.0 -type PS1_V5_Lensing -imageID 3 -sourceID 2 -tess_id RINGS.V3 -skycell skycell.1133.081 -bad-psfqf-frac 0.2
+mkcmf -forcedwarp -photcode SIMTEST.g.ForcedWarp testdata/test.04.txt testdata/warp.04.cmf -extroot SkyChip -date 2010/01/01 -time 04:00:00 -mjd 55197.1666667 -radec 10.0 20.0 -type PS1_V5_Lensing -imageID 4 -sourceID 2 -tess_id RINGS.V3 -skycell skycell.1133.081 -bad-psfqf-frac 0.2
+mkcmf -forcedwarp -photcode SIMTEST.r.ForcedWarp testdata/test.13.txt testdata/warp.13.cmf -extroot SkyChip -date 2010/01/02 -time 01:00:00 -mjd 55198.0416667 -radec 10.0 20.0 -type PS1_V5_Lensing -imageID 13 -sourceID 2 -tess_id RINGS.V3 -skycell skycell.1133.081 -bad-psfqf-frac 0.2
+mkcmf -forcedwarp -photcode SIMTEST.r.ForcedWarp testdata/test.14.txt testdata/warp.14.cmf -extroot SkyChip -date 2010/01/02 -time 02:00:00 -mjd 55198.0833333 -radec 10.0 20.0 -type PS1_V5_Lensing -imageID 14 -sourceID 2 -tess_id RINGS.V3 -skycell skycell.1133.081 -bad-psfqf-frac 0.2
+mkcmf -forcedwarp -photcode SIMTEST.r.ForcedWarp testdata/test.15.txt testdata/warp.15.cmf -extroot SkyChip -date 2010/01/02 -time 03:00:00 -mjd 55198.125 -radec 10.0 20.0 -type PS1_V5_Lensing -imageID 15 -sourceID 2 -tess_id RINGS.V3 -skycell skycell.1133.081 -bad-psfqf-frac 0.2
+mkcmf -forcedwarp -photcode SIMTEST.r.ForcedWarp testdata/test.16.txt testdata/warp.16.cmf -extroot SkyChip -date 2010/01/02 -time 04:00:00 -mjd 55198.1666667 -radec 10.0 20.0 -type PS1_V5_Lensing -imageID 16 -sourceID 2 -tess_id RINGS.V3 -skycell skycell.1133.081 -bad-psfqf-frac 0.2
+mkcmf -forcedgalaxy -photcode SIMTEST.g.ForcedWarp testdata/test.01.txt testdata/fgal.01.cmf -extroot SkyChip -date 2008/1/1 -time 0:00:00 -mjd 54466.0 -radec 10.0 20.0 -type PS1_V5_Lensing -imageID 1 -sourceID 1 -tess_id RINGS.V3 -skycell skycell.1133.081
+mkcmf -forcedgalaxy -photcode SIMTEST.r.ForcedWarp testdata/test.04.txt testdata/fgal.04.cmf -extroot SkyChip -date 2008/1/1 -time 3:00:00 -mjd 54466.0 -radec 10.0 20.0 -type PS1_V5_Lensing -imageID 4 -sourceID 1 -tess_id RINGS.V3 -skycell skycell.1133.081
+
+addstar -D SKY_DEPTH 4 -D CATDIR $catdir -D CAMERA simtest testdata/warp.01.cmf -D CATFORMAT PS1_V5 -quick-airmass -xrad
+addstar -D SKY_DEPTH 4 -D CATDIR $catdir -D CAMERA simtest testdata/warp.02.cmf -D CATFORMAT PS1_V5 -quick-airmass -xrad
+addstar -D SKY_DEPTH 4 -D CATDIR $catdir -D CAMERA simtest testdata/warp.03.cmf -D CATFORMAT PS1_V5 -quick-airmass -xrad
+addstar -D SKY_DEPTH 4 -D CATDIR $catdir -D CAMERA simtest testdata/warp.04.cmf -D CATFORMAT PS1_V5 -quick-airmass -xrad
+addstar -D SKY_DEPTH 4 -D CATDIR $catdir -D CAMERA simtest testdata/warp.13.cmf -D CATFORMAT PS1_V5 -quick-airmass -xrad
+addstar -D SKY_DEPTH 4 -D CATDIR $catdir -D CAMERA simtest testdata/warp.14.cmf -D CATFORMAT PS1_V5 -quick-airmass -xrad
+addstar -D SKY_DEPTH 4 -D CATDIR $catdir -D CAMERA simtest testdata/warp.15.cmf -D CATFORMAT PS1_V5 -quick-airmass -xrad
+addstar -D SKY_DEPTH 4 -D CATDIR $catdir -D CAMERA simtest testdata/warp.16.cmf -D CATFORMAT PS1_V5 -quick-airmass -xrad
+
+loadgalphot -D CATDIR $catdir testdata/fgal.01.cmf
+loadgalphot -D CATDIR $catdir testdata/fgal.04.cmf
Index: trunk/ippToPsps/test/testscripts/input.gdb
===================================================================
--- trunk/ippToPsps/test/testscripts/input.gdb	(revision 39180)
+++ trunk/ippToPsps/test/testscripts/input.gdb	(revision 39180)
@@ -0,0 +1,77 @@
+
+define showdata
+  set $i = 0
+  while $i < Npts
+    printf "%6.3f %6.3f   %10.6f  %d\n", Xpt[$i], Ypt[$i], chisq[$i], mask[$i]
+    set $i = $i + 1
+  end
+end
+
+define showlg
+  set $ix = 0
+  while $ix < fit->mterm
+    set $iy = 0
+    while $iy < fit->mterm
+      printf "%6.3f \n", fit->s[$ix][$iy]
+      set $iy = $iy + 1
+    end
+    set $ix = $ix + 1
+    printf "\n"
+  end
+end
+
+define showmn
+  set $ix = 0
+  while $ix < mterm
+    set $iy = 0
+    while $iy < mterm
+      printf "%6.3f \n", s[$ix][$iy]
+      set $iy = $iy + 1
+    end
+    set $ix = $ix + 1
+    printf "\n"
+  end
+end
+
+define showlB
+  set $iy = 0
+  while $iy < fit->wterm
+    printf "%6.3f \n", fit->b[$iy][0]
+    set $iy = $iy + 1
+  end
+end
+
+define showmB
+  set $iy = 0
+  while $iy < wterm
+    printf "%6.3f \n", b[$iy][0]
+    set $iy = $iy + 1 
+  end
+end
+
+define showlc
+  set $ix = 0
+  while $ix < fit->wterm
+    set $iy = 0
+    while $iy < fit->wterm
+      printf "%6.3f ", fit->c[$ix][$iy]
+      set $iy = $iy + 1
+    end
+    set $ix = $ix + 1
+    printf "\n"
+  end
+end
+
+define showmc
+  set $ix = 0
+  while $ix < wterm
+    set $iy = 0
+    while $iy < wterm
+      printf "%6.3f ", c[$ix][$iy]
+      set $iy = $iy + 1
+    end
+    set $ix = $ix + 1
+    printf "\n"
+  end
+end
+
Index: trunk/ippToPsps/test/testscripts/mana.sh
===================================================================
--- trunk/ippToPsps/test/testscripts/mana.sh	(revision 39180)
+++ trunk/ippToPsps/test/testscripts/mana.sh	(revision 39180)
@@ -0,0 +1,87 @@
+
+if (not($?VERBOSE)) set VERBOSE = 0
+if (not($?SHOW_PLOTS)) set SHOW_PLOTS = 1
+
+macro checkfit
+  if ($0 != 3)
+    echo "USAGE: checkfit (file) (number)"
+    break
+  end
+
+  data $1
+  read -fits SkyChip.xgal FR_MINOR_MIN FR_MINOR_MAX FR_MINOR_DEL FR_MAJOR_MIN FR_MAJOR_MAX FR_MAJOR_DEL GAL_CHISQ GAL_FLUX NPIX
+
+  delete -q Xi Yi Xv Yv Zv
+
+  local ix iy
+
+  $N = 0
+  for ix 0 5
+    for iy 0 5
+      $Vx = FR_MAJOR_MIN[$2] + FR_MAJOR_DEL[$2]*$ix
+      $Vy = FR_MINOR_MIN[$2] + FR_MINOR_DEL[$2]*$iy
+
+      concat $ix Xi
+      concat $iy Yi
+      concat $Vx Xv
+      concat $Vy Yv
+ 
+      # echo concat GAL_CHISQ:$N[0] Zv
+      concat GAL_CHISQ:$N[$2] Zv
+      if ($VERBOSE)
+        fprintf "%1d %1d %5.3f %5.3f %7.3f" Xi[$N] Yi[$N] Xv[$N] Yv[$N] Zv[$N]
+      end
+      $N ++
+    end
+  end
+
+  vstat -q Zv
+  set Zv = Zv * NPIX[$2] / $MIN
+
+  if ($VERBOSE)
+    fit2d Xv Yv Zv 2 -clip 5 3
+  else
+    fit2d Xv Yv Zv 2 -clip 5 3  -q
+  end
+
+  $DET = 1 / (4*$CX0Y2*$CX2Y0 - $CX1Y1^2)
+  $Xm = ($CX1Y1*$CX0Y1 - 2*$CX0Y2*$CX1Y0) * $DET
+  $Ym = ($CX1Y1*$CX1Y0 - 2*$CX2Y0*$CX0Y1) * $DET
+  # echo $Xm $Ym
+
+  applyfit2d Xv Yv Zvf
+  set dZ = Zv - Zvf
+
+  if ($SHOW_PLOTS)
+    lim -n 0 Xv Yv; clear; box -ticks 1111
+    vstat -q Zv
+    $Range = $MAX - $MIN
+    $Midpt = 0.5*($MAX + $MIN)
+    zplot -pt  2 Xv Yv Zv  {$Midpt - 0.55*$Range} {$Midpt - 0.3*$Range} -c blue
+    zplot -pt  7 Xv Yv Zvf {$Midpt - 0.55*$Range} {$Midpt - 0.3*$Range} -c red
+    
+    dot $Xm $Ym -pt 7 -sz 3 -c red
+
+    lim -n 1 Xv Yv; clear; box -ticks 1111
+    vstat -q dZ
+    $Range = $MAX - $MIN
+    $Midpt = 0.5*($MAX + $MIN)
+    zplot -pt 10 Xv Yv dZ {$Midpt - 0.8*$Range} {$Midpt + 0.6*$Range}
+    
+    dot $Xm $Ym -pt 7 -sz 3 -c red
+  end
+
+  $A = $CX2Y0
+  $B = $CX1Y0 + 2*$CX2Y0*$Xm + $CX1Y1*$Ym
+  $C = -1
+
+  $dXm = (sqrt($B^2 - 4*$A*$C) - $B) / (2*$A)
+
+  $A = $CX0Y2
+  $B = $CX0Y1 + 2*$CX0Y2*$Ym + $CX1Y1*$Xm
+  $C = -1
+
+  $dYm = (sqrt($B^2 - 4*$A*$C) - $B) / (2*$A)
+
+  echo ($Xm, $Ym) +/- ($dXm, $dYm)
+end
