#!/usr/bin/perl
#

  my($output_file, $term_options);

################################################################
#  Graph showing a wave starting at left end of string,
#     heading to the right
  $output_file = "journey_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";


  #  revert to some oldish default colors 
  printf CMDFILE "set style line 1 lt rgb 'red' lw 1  \n"; 
  printf CMDFILE "set style line 2 lt rgb 'sea-green' lw 3  \n"; 
  printf CMDFILE "set style line 3 lt rgb 'blue' lw 3  \n"; 
  printf CMDFILE "set style line 4 lt rgb 'cyan' lw 3  \n"; 
  printf CMDFILE "set style line 5 lt rgb 'violet' lw 3  \n"; 


  printf CMDFILE "unset grid \n";
  printf CMDFILE "unset key\n";
  printf CMDFILE "set ylabel '' \n";
  printf CMDFILE "set xlabel '' \n";
  printf CMDFILE "set title 'A wave starts its journey'\n"; 
  
  $cmd = "plot [-1:6][-2.5:2.5] 'calc_wave_pic.out' using (\$1):(\$2) ";
  $cmd .= "    with points ls 1 pt 3 ps 0.2  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;
  
  if ($term_options =~ /postscript/) {
    $psfile = $output_file;
    $giffile = $psfile;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -flatten -background white -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }



################################################################
#  Graph showing a wave starting at left end of string,
#     heading to the right
#
#  Same as before, but blue, not red
#
  $output_file = "journey_a_blue.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";


  #  revert to some oldish default colors 
  printf CMDFILE "set style line 1 lt rgb 'red' lw 1  \n"; 
  printf CMDFILE "set style line 2 lt rgb 'sea-green' lw 3  \n"; 
  printf CMDFILE "set style line 3 lt rgb 'blue' lw 3  \n"; 
  printf CMDFILE "set style line 4 lt rgb 'cyan' lw 3  \n"; 
  printf CMDFILE "set style line 5 lt rgb 'violet' lw 3  \n"; 


  printf CMDFILE "unset grid \n";
  printf CMDFILE "unset key\n";
  printf CMDFILE "set ylabel '' \n";
  printf CMDFILE "set xlabel '' \n";
  printf CMDFILE "set title 'A wave starts its journey'\n"; 
  
  $cmd = "plot [-1:6][-2.5:2.5] 'calc_wave_pic.out' using (\$1):(\$2) ";
  $cmd .= "    with points ls 3 pt 3 ps 0.2  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;
  
  if ($term_options =~ /postscript/) {
    $psfile = $output_file;
    $giffile = $psfile;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -flatten -background white -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }



exit 0;
