#!/usr/bin/perl
#
# Make a nice picture showing the (artificial) light curve of
#   RR Lyr, or the real light curve
#
# MWR 10/17/2006

$cmdfile = "make_rrlyr_plot.gnu";


# plot of artificial light curve

$output_file = "rrlyr_art_prof.eps";

  
  open (CMDFILE, ">$cmdfile") || die("can't open $cmdfile for writing");
  printf CMDFILE "set output '$output_file' \n";
  printf CMDFILE "set term postscript eps mono \n";
  printf CMDFILE "set grid \n";
  printf CMDFILE "set key top left \n";
  printf CMDFILE "set xlabel 'Time (days)' \n";
  printf CMDFILE "set ylabel 'V-band magnitude' \n";
  printf CMDFILE "set title 'Apparent V-band light curve of RR Lyr' \n";
  
  $cmd = "plot [-0.2:3.2][8.3:6.9] 'rrlyr_art.dat' using 1:2 ";
  $cmd .= "  pt 7 ps 0.5 t '' ";

  printf CMDFILE "$cmd \n";
  printf CMDFILE "set output \n";
  printf CMDFILE "quit \n";
  close(CMDFILE) ;
  
  $retval = `gnuplot < $cmdfile`;
  printf "retval is ..%s..\n", $retval;

  # create a GIF copy of any Postscript file
    $gif_file = $output_file;
    $gif_file =~ s/.eps/.gif/;
    $cmd = "convert -rotate 90 $output_file $gif_file ";
    printf "cmd is ..$cmd.. \n";
    $retval = `$cmd`;




exit 0;
