#!/usr/bin/perl
#



############################################################################
# plot of a single gaussian, no noise
#
  
  my($output_file, $term_options);

  # get the arguments
  $output_file = "one_gauss_a.ps";
  $term_options = "postscript color '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 xlabel 'Time (sec)' \n";
  printf CMDFILE "set ylabel 'Voltage (volts)' \n";
  printf CMDFILE "set title ''\n", $aper;
  
  $cmd = "plot [5:12][-0.1:5.2] 'make_one_gauss.a.out' using 1:2 ";
  $cmd .= "     with linespoints ps 1.5 pt 3 lc 1 lw 3 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 -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }


exit 0;


############################################################################
# closeup plot of perfect instrument and simple square wave
#
  
  my($output_file, $term_options);

  # get the arguments
  $output_file = "simple_closeup.ps";
  $term_options = "postscript color '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 xlabel 'Time (sec)' \n";
  printf CMDFILE "set ylabel 'Voltage (volts)' \n";
  printf CMDFILE "set title ''\n", $aper;
  
  $cmd = "plot [36:39][-0.1:1.2] 'simple_square.out' using 1:2 ";
  $cmd .= "     with linespoints ps 1.5 pt 3 lc 1 lw 3 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 -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }


############################################################################
# closeup plot of perfect instrument and gaussian at t = 12.0
#
  
  my($output_file, $term_options);

  # get the arguments
  $output_file = "gaussian_a.ps";
  $term_options = "postscript color '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 xlabel 'Time (sec)' \n";
  printf CMDFILE "set ylabel 'Voltage (volts)' \n";
  printf CMDFILE "set title ''\n", $aper;
  
  $cmd = "plot [10:14][-0.1:1.2] 'make_one_gauss.a.out' using 1:2 ";
  $cmd .= "     with linespoints ps 0.7 pt 3 lc 1 lw 3 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 -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }


############################################################################
# closeup plot of perfect instrument and gaussian at t = 12.333333
#
  
  my($output_file, $term_options);

  # get the arguments
  $output_file = "gaussian_b.ps";
  $term_options = "postscript color '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 xlabel 'Time (sec)' \n";
  printf CMDFILE "set ylabel 'Voltage (volts)' \n";
  printf CMDFILE "set title ''\n", $aper;
  
  $cmd = "plot [10:14][-0.1:1.2] 'make_one_gauss.b.out' using 1:2 ";
  $cmd .= "     with linespoints ps 0.7 pt 3 lc 1 lw 3 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 -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }


############################################################################
# MORE closeup plot of perfect instrument and gaussian at t = 12.333333
#
  
  my($output_file, $term_options);

  # get the arguments
  $output_file = "gaussian_b_closer.ps";
  $term_options = "postscript color '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 xlabel 'Time (sec)' \n";
  printf CMDFILE "set ylabel 'Voltage (volts)' \n";
  printf CMDFILE "set title ''\n", $aper;
  
  $cmd = "plot [12.0:12.7][0.6:1.1] 'make_one_gauss.b.out' using 1:2 ";
  $cmd .= "     with linespoints ps 1.0 pt 3 lc 1 lw 3 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 -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

