#!/usr/bin/perl
#
# Rotate images by 180 degrees, to account for flip past meridian
#
# MWR 6/24/2009

$debug = 1;

$start = 348;
$end = 521;

for ($i = $start; $i <= $end; $i++) {
  $file = sprintf "rxj-%03dV.fit", $i;
  $cmd = sprintf "rotate %s pa=180", $file;
  exec_cmd($cmd);
  $datestr = `date`;
  $cmd = "comment $file 'rotated by 180 deg on $datestr ' ";
  exec_cmd($cmd);
}






##############################################################################
# PROCEDURE: exec_cmd
#
# DESCRIPTION: Execute the given shell command line.  If the $debug flag
#              is set, we print to stdout the command line, and
#              also print out the result string.
#
# RETURNS:
#              the result of the command
#
#
sub exec_cmd {

  my($cmd, $ret);

  $cmd = $_[0];

  if ($debug > 0) {
    printf "cmd is ..$cmd.. \n";
  }
  $ret = `$cmd`;
  if ($debug > 0) {
    printf "ret is ..$ret.. \n";
  }

  return($ret);
}


