#!/usr/bin/perl
# Make a nice graph showing nova magnitudes over the past two centuries
#
# MWR 10/21/2007

  
  $output_file = "./nova_mag_by_year.ps";
  $term_options = "postscript color";

  $cmdfile = "gnuplot.in";
  
  open (CMDFILE, ">$cmdfile") || die("can't open $cmdfile for writing");
  printf CMDFILE "set output '$output_file' \n";
  printf CMDFILE "set term $term_options \n";
  printf CMDFILE "set grid \n";
  printf CMDFILE "set key bot left \n";
  printf CMDFILE "set xlabel 'Year' \n";
  printf CMDFILE "set ylabel 'Magnitude' \n";
  printf CMDFILE "set title 'Novae in the Milky Way '\n", $aper;
  
  $cmd =   "plot [1840:2020][20:-2] 'get_nova_mags.out' using 2:3 ";
  $cmd .=  "    lt -1 pt 6 ps 0.5 lw 2 t 'discovery mag' ";
  $cmd .=  " , ";
  $cmd .=  "  'get_nova_mags.out' using 2:4 ";
  $cmd .=  "    lt 1 pt 3 ps 1.0 lw 2 t 'mag at max light' ";

  printf CMDFILE "$cmd \n";
  printf CMDFILE "set output \n";
  printf CMDFILE "quit \n";
  close(CMDFILE) ;
  
  $retval = `gnuplot < $cmdfile`;
  printf "retval is ..%s..\n", $retval;
  
    $psfile = $output_file;
    $giffile = $psfile;
    $giffile =~ s/.ps/.gif/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;

