#!/usr/bin/perl
#

  my($output_file, $term_options);

  ########################################################################3
  #  Plot the spectrum of the Sun around 5023 Angstroms, 
  #      showing several unsaturated, isolated lines.
  #      FWHM = approx 0.10 Angstrom
  #

  $output_file = "./sun_a.ps";
  $term_options = "postscript color 'Helvectica,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 3  \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 "set style line 6 lt rgb 'orange' lw 3  \n"; 
  printf CMDFILE "set style line 7 lt rgb 'black' lw 3  \n"; 


  printf CMDFILE "set grid \n";
  printf CMDFILE "set key top right \n";
  printf CMDFILE "set ylabel 'Intensity (arb units)' \n";
  printf CMDFILE "set xlabel 'Wavelength (Angstroms) ' \n";
  
  $cmd = "plot [5022.5:5023.8][] 'bass_solar_5000.dat' using 1:2   ";
  $cmd .= "   with lines  ls 1  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`;
  }



  ########################################################################3
  #  Plot the spectrum of the Sun around 4957 Angstroms, 
  #

  $output_file = "./sun_4957_a.ps";
  $term_options = "postscript color 'Helvectica,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 3  \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 "set style line 6 lt rgb 'orange' lw 3  \n"; 
  printf CMDFILE "set style line 7 lt rgb 'black' lw 3  \n"; 


  printf CMDFILE "set grid \n";
  printf CMDFILE "set key top right \n";
  printf CMDFILE "set ylabel 'Intensity (arb units)' \n";
  printf CMDFILE "set xlabel 'Wavelength (Angstroms) ' \n";
  
  $cmd = "plot [4952:4960][0:50000] 'bass_solar_4957.dat' using 1:(\$2*2.5)   ";
  $cmd .= "   with lines  ls 1  t 'Sun' ";
  $cmd .= "  , ";
  $cmd .= "  'hd112313_spec.dat' using 1:2 ";
  $cmd .= "    with lines ls 3 t 'HD 112313' ";
   

  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`;
  }



  ########################################################################3
  #  Plot the spectrum of the Sun around H-alpha,
  #

  $output_file = "./sun_halpha_a.ps";
  $term_options = "postscript color 'Helvectica,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 3  \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 "set style line 6 lt rgb 'orange' lw 3  \n"; 
  printf CMDFILE "set style line 7 lt rgb 'black' lw 3  \n"; 


  printf CMDFILE "set grid \n";
  printf CMDFILE "set key top right \n";
  printf CMDFILE "set ylabel 'Intensity (arb units)' \n";
  printf CMDFILE "set xlabel 'Wavelength (Angstroms) ' \n";
  
  $cmd = "plot [6542.0:6582.0][] 'bass_solar_6562.dat' using 1:2   ";
  $cmd .= "   with lines  ls 1  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`;
  }



  ########################################################################3
  #  Plot the spectrum of the 40 Eri B around H-beta,
  #     showing pressure broadening
  #

  $output_file = "./40erib_hbeta_a.ps";
  $term_options = "postscript color 'Helvectica,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 3  \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 "set style line 6 lt rgb 'orange' lw 3  \n"; 
  printf CMDFILE "set style line 7 lt rgb 'black' lw 3  \n"; 


  printf CMDFILE "set grid \n";
  printf CMDFILE "set key top right \n";
  printf CMDFILE "set ylabel 'Intensity (arb units)' \n";
  printf CMDFILE "set xlabel 'Wavelength (Angstroms) ' \n";
  
  $cmd = "plot [4650:5050][] 'elodie_40erib.dat' using 1:2   ";
  $cmd .= "   with lines  ls 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`;
  }



  ########################################################################3
  #  Plot the spectrum of the HD 112313
  #     showing rotational broadening
  #

  $output_file = "./hd112313_spec_a.ps";
  $term_options = "postscript color 'Helvectica,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 3  \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 "set style line 6 lt rgb 'orange' lw 3  \n"; 
  printf CMDFILE "set style line 7 lt rgb 'black' lw 3  \n"; 


  printf CMDFILE "set grid \n";
  printf CMDFILE "set key top right \n";
  printf CMDFILE "set ylabel 'Intensity (arb units)' \n";
  printf CMDFILE "set xlabel 'Wavelength (Angstroms) ' \n";
  
  $cmd = "plot [4954:4960][] 'hd112313_spec.dat' using 1:2   ";
  $cmd .= "   with lines  ls 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`;
  }



  ########################################################################3
  #  Plot the spectrum of the HD 112313
  #     for equiv width picture
  #

  $output_file = "./hd112313_spec_b.ps";
  $term_options = "postscript color 'Helvectica,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 3  \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 "set style line 6 lt rgb 'orange' lw 3  \n"; 
  printf CMDFILE "set style line 7 lt rgb 'black' lw 3  \n"; 


  printf CMDFILE "set grid \n";
  printf CMDFILE "set key top right \n";
  printf CMDFILE "set ylabel 'Intensity (arb units)' \n";
  printf CMDFILE "set xlabel 'Wavelength (Angstroms) ' \n";
  
  $cmd = "plot [4954:4960][0:45000] 'hd112313_spec.dat' using 1:2   ";
  $cmd .= "   with lines  ls 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;

