
macro test.measure.basic
  
  $PASS = 1

  catdir catdir.test
  skyregion 9 11 19 21

  mextract ra, dec, xccd, yccd, mag:inst, mag, mag:err, time, photcode

  if (ra[] != 242) 
    $PASS = 0
    echo "found the wrong number of measurements in db"
  end

  avextract ra, dec

  if (ra[] != 242) 
    $PASS = 0
    echo "found the wrong number of stars in db"
  end

  ### XXX write down some tests of things we know about the input data values
  ### XXX probably need to add options to mkcmf to eliminate poisson error
end

# create a populated catdir with a couple of cmf files
macro mkcatdir

  exec rm -rf catdir.test

  mkinput
  exec mkcmf test.in.txt test.1.cmf -date 2008/1/1 -time 01:00:00 -radec 10.0 20.0
  exec mkcmf test.in.txt test.2.cmf -date 2008/1/1 -time 02:00:00 -radec 10.0 20.0

  exec addstar -D CATDIR catdir.test -D CAMERA simtest test.1.cmf
  exec addstar -D CATDIR catdir.test -D CAMERA simtest test.2.cmf
end

# make a simple input file for mkcmf
macro mkinput
  exec rm -f test.in.txt

  output test.in.txt
  for i 10 1024 100
    for j 10 1024 100
      fprintf " %4d %4d  %6.2f" $i $j {-15.0 + 2.5*($i + $j)/1000.0}
    end
  end
  output stdout
end

macro showinput
   data test.in.txt 
   read x 1 y 2 m 3
   lim x y; clear; box; zplot -pt 7 x y m -10 -15
end

