#!/usr/bin/perl
#

$ensemble_dir = "/home/richmond/tomoe/ensemble/";

$target = "iyuma";
$filter = "clear";
$filter_lc = lc($filter);
$filter_uc = uc($filter);
$aper = "3";

#$globstr = sprintf "%s*%s*pht", $target, $filter_lc;
#$globstr = sprintf "%s*%s.pht", $target, $filter_lc;
$globstr = sprintf "%s*.pht", $target;
@files = glob($globstr);

$cmd  = "$ensemble_dir/multipht ";
if ($aper eq "2") {
  $cmd .= " x=1 y=2 mag=5 err=6 jd=12 ";
}
elsif ($aper eq "3") {
  $cmd .= " x=1 y=2 mag=7 err=8 jd=12 ";
}
elsif ($aper eq "4") {
  $cmd .= " x=1 y=2 mag=9 err=10 jd=12 ";
}
else {
  printf " invalid aper $aper \n";
  exit(1);
}
#$cmd .= " template=maxi_clear-0192.pht";
#$cmd .= " outfile=multi3_" . $filter_lc . ".out ";
$cmd .= " outfile=multi_" . $target . $aper . "_" . $filter_lc . ".out ";
$cmd .= " matchrad=8 ";
#$cmd .= " min_match=5 ";
foreach $file (@files) {
  $cmd .= " $file ";
}

printf "cmd is ..$cmd.. \n";

exec($cmd);
#printf "ret is ..$ret.. \n";


exit 0;
