#!/usr/bin/perl
# 
# subtract master darks from a set of raw images
#

# if set to 0, will not actually do work, just print commands
$do_it = 1;

#$dark="dark03.fts";
#$dark="dark1.fts";
$dark="dark45.fts";
#$dark="foo_dark30.fts";
#$dark="dark120.fts";

#@files1 = glob("flatclear-*.fit");
#@files1 = glob("domeflat[ri]*.fit");
#@files1 = glob("domeflatclear*.fit");
#@files1 = glob("flat*.fit");
#@files1 = glob("twiflat_clear*.fit");
#@files1 = glob("flatclear*.fit");
#@files1 = glob("HATP3clear*.fit");
@files1 = glob("asas14cv*.fit");
#@files1 = glob("dqher*.fit");
#@files1 = glob("ugc*.fit");
#@files1 = glob("jup_v*.fit");
foreach $file (@files1, @files2, @files3) {

if ($file eq "ngc7790_r-005.fit") {
  printf "skipping $file \n";
  next;
}

  $img = $file;
  $cmd = "sub $img $dark";
  printf "cmd is $cmd\n";
  if ($do_it == 1) {
    $result = `$cmd`;
  }
  printf "result of sub is ..$result..\n";

  $datestr = `date`;
  $comment = "subtracted dark $dark on $datestr";
  #  $comment = "subtracted bogus const=175 on $datestr";
  $cmd = "comment $img $comment";
  printf "cmd is $cmd\n";
  if ($do_it == 1) {
    $result  = `$cmd`;
  }
  printf "result of comment is ..$result..\n";

}


exit 0;
  
