#!/usr/bin/perl
#
# find and measure stars in each frame, generating .coo and .pht files

# set to 1 to see pictures, one frame at a time
$interactive = 0;

# first, we generate the list of files to be reduced
@files1 = glob("wz_[a-z].0??");
#@files2 = glob("be87_?.???");
#@files2 = glob("be87_?.???");
$nframes = 0;
foreach $file (@files1) {
  $frame_array[$nframes] = $file;
  $nframes++;
}

# now process each frame in turn
foreach $file (@frame_array) {
  $base = $file;
  $base =~ s/\./_/;
  printf "now working on $file = $base\n";

  `sky $file`;
  if ($interactive == 1) {
    system("tv $file zoom=2 z=sky-100 l=1000; sleep 2");
    `stars $file minsig=5 minfwhm=1.2 minsharp=-0.5 maxsharp=1.1 movemax=3 outfile=$base.coo show`;
  } else {
    `stars $file minsig=5 minfwhm=1.2 minsharp=-0.5 maxsharp=1.1 movemax=3 outfile=$base.coo`;
  }
  `phot $file infile=$base.coo outfile=$base.pht aper=4 aper=8`;
  if ($interactive == 1) {
    printf "\nhit return to continue: \n";
    $a = <STDIN>;
    `killall -1 tv`;
  }
  
}


exit 0;
  
