#!/usr/bin/perl
#
  
  my($output_file, $term_options);

  # plot of blackbody flux per unit wavelength
  $output_file = "./vband_a.ps";
  $term_options = "postscript color enhanced 'Helvetica,18' ";


  $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 top right \n";
  printf CMDFILE "set ylabel 'Transmission ' \n";
  printf CMDFILE "set xlabel 'Wavelength (Angstroms) ' \n";
  printf CMDFILE "set title 'Johnson-Cousins V-band filter ' \n";
  
  $cmd = "plot [4500:7000][0.0:1.1]  ";
  $cmd .= "   './bess_v_pass.dat'  ";
  $cmd .= "   using 1:2  with lines lt 1 lc 1 lw 3 t 'Bessell V' ";
  $cmd .= " , ";
  $cmd .= "  './equiv_v_pass.dat' ";
  $cmd .= "   using 1:2  with lines lt 2 lc -1 lw 3 t 'equiv rect'  ";

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




exit 0;
