#!/usr/bin/perl
#

# length of exposure in seconds
$length = "1";

$cmd = "median ";
$first = 1;
$last = 20;
$outfile = sprintf "dark%s.fts", $length;
#$outfile = sprintf "latedark%s.fts", $length;

$n = $first;
while ($n <= $last) {
  $number = sprintf("dark%s-%03d.fit", $length, $n);
  $cmd = $cmd . " $number ";
  $n = $n + 1;
}

$cmd = $cmd . " outfile=$outfile iqm nomean verbose ";

printf "cmd is $cmd\n";
$result = `$cmd`;
printf "result of median is ..$result..\n";

$nframes = ($last - $first) + 1;
$datestr = `date`;
$comment = "median of $nframes dark frame, created $datestr";
$result  = `comment $outfile $comment`;
printf "result of comment is ..$result..\n";


exit 0;
  
