#!/usr/bin/perl
#

  my($output_file, $term_options);

  ########################################################################3
  #  Plot temperature as a function of radius for a GOOD solar model
  #     using data generated by STATSTAR
  #     from http://www.phys.unm.edu/~gbtaylor/astr421/statstar.f
  #     thanks to Greg Taylor
  #

  $output_file = "./radius_temp_solar_a.ps";
  $term_options = "postscript color enhanced '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 'Temperature (K) ' \n";
  printf CMDFILE "set xlabel 'Radius (m)' \n";
  printf CMDFILE "set title 'A sun-like star computed via STATSTAR (starting T = 5500.2 K)' \n";
  
  $cmd = "plot [][] 'statstar_solar.dat' using (\$1*0.01):(\$4*1.0)   ";
  $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 temperature as a function of radius for a BAD solar model
  #     using data generated by STATSTAR
  #     from http://www.phys.unm.edu/~gbtaylor/astr421/statstar.f
  #     thanks to Greg Taylor
  #

  $output_file = "./radius_temp_bad_a.ps";
  $term_options = "postscript color enhanced '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 'Temperature (K) ' \n";
  printf CMDFILE "set xlabel 'Radius (m)' \n";
  printf CMDFILE "set title 'A bogus sun-like star computed via STATSTAR (starting T = 2000 K)' \n";
  
  $cmd = "plot [][] 'statstar_2000.dat' using (\$1*0.01):(\$4*1.0)   ";
  $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 temperature as a function of radius for a BAD solar model
  #     using data generated by STATSTAR
  #     from http://www.phys.unm.edu/~gbtaylor/astr421/statstar.f
  #     thanks to Greg Taylor
  #
  #  plot both good (5500.2 K) and bad (2000 K) together
  #

  $output_file = "./radius_temp_bad_b.ps";
  $term_options = "postscript color enhanced '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 'Temperature (K) ' \n";
  printf CMDFILE "set xlabel 'Radius (m)' \n";
  printf CMDFILE "set title 'Good and bad Sun-like stars computed via STATSTAR ' \n";
  
  $cmd = "plot [][] 'statstar_solar.dat' using (\$1*0.01):(\$4*1.0)   ";
  $cmd .= "   with lines ls 1 t 'T = 5500 K' ";
  $cmd .= " , ";
  $cmd .= "          'statstar_2000.dat' using (\$1*0.01):(\$4*1.0)   ";
  $cmd .= "   with lines ls 3 t 'T = 2000 K' ";


  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 temperature as a function of radius for a BAD solar model
  #     using data generated by STATSTAR
  #     from http://www.phys.unm.edu/~gbtaylor/astr421/statstar.f
  #     thanks to Greg Taylor
  #

  $output_file = "./radius_temp_bad_c.ps";
  $term_options = "postscript color enhanced '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 'Temperature (K) ' \n";
  printf CMDFILE "set xlabel 'Radius (m)' \n";
  printf CMDFILE "set title 'A bogus sun-like star computed via STATSTAR (starting T = 10000 K)' \n";
  
  $cmd = "plot [][] 'statstar_10000.dat' using (\$1*0.01):(\$4*1.0)   ";
  $cmd .= "   with lines ls 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 -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }



  ########################################################################3
  #  Plot temperature as a function of radius for a BAD solar model
  #     using data generated by STATSTAR
  #     from http://www.phys.unm.edu/~gbtaylor/astr421/statstar.f
  #     thanks to Greg Taylor
  #
  #  plot both good (5500.2 K) and bad (2000 K, 10000 K) together
  #

  $output_file = "./radius_temp_bad_d.ps";
  $term_options = "postscript color enhanced '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 'Temperature (K) ' \n";
  printf CMDFILE "set xlabel 'Radius (m)' \n";
  printf CMDFILE "set title 'Good and bad Sun-like stars computed via STATSTAR ' \n";
  
  $cmd = "plot [0:8.0e8][] 'statstar_solar.dat' using (\$1*0.01):(\$4*1.0)   ";
  $cmd .= "   with lines ls 1 t 'T = 5500 K' ";
  $cmd .= " , ";
  $cmd .= "          'statstar_2000.dat' using (\$1*0.01):(\$4*1.0)   ";
  $cmd .= "   with lines ls 3 t 'T = 2000 K' ";
  $cmd .= " , ";
  $cmd .= "          'statstar_10000.dat' using (\$1*0.01):(\$4*1.0)   ";
  $cmd .= "   with lines ls 2 t 'T = 10000 K' ";


  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 temperature as a function of radius for two sort-of BAD solar models
  #     using data generated by STATSTAR
  #     from http://www.phys.unm.edu/~gbtaylor/astr421/statstar.f
  #     thanks to Greg Taylor
  #
  #  plot both good (5500.2 K) and bad (5000 K, 6000 K) together
  #     All are given the same target luminosity = 0.860710 solar
  #

  $output_file = "./radius_temp_bad_e.ps";
  $term_options = "postscript color enhanced '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 'Temperature (K) ' \n";
  printf CMDFILE "set xlabel 'Radius (m)' \n";
  printf CMDFILE "set title 'Good and bad Sun-like stars computed via STATSTAR ' \n";
  
  $cmd = "plot [0:1.0e9][0.0:3.0e7] 'statstar_solar.dat' using (\$1*0.01):(\$4*1.0)   ";
  $cmd .= "   with lines ls 1 t 'T = 5500 K' ";
  $cmd .= " , ";
  $cmd .= "          'statstar_5000.dat' using (\$1*0.01):(\$4*1.0)   ";
  $cmd .= "   with lines ls 3 t 'T = 5000 K' ";
  $cmd .= " , ";
  $cmd .= "          'statstar_6000.dat' using (\$1*0.01):(\$4*1.0)   ";
  $cmd .= "   with lines ls 2 t 'T = 6000 K' ";


  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 temperature as a function of radius for two sort-of BAD solar models
  #     using data generated by STATSTAR
  #     from http://www.phys.unm.edu/~gbtaylor/astr421/statstar.f
  #     thanks to Greg Taylor
  #
  #  plot both good (5500.2 K) and bad (5000 K, 6000 K) together
  #     All are given the same target luminosity = 0.860710 solar
  #     This on a logarithmic temp axis to show bogus central temps
  #

  $output_file = "./radius_temp_bad_f.ps";
  $term_options = "postscript color enhanced '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 'Temperature (K) ' \n";
  printf CMDFILE "set xlabel 'Radius (m)' \n";
  printf CMDFILE "set logscale y  \n";
  printf CMDFILE "set title 'Good and bad Sun-like stars computed via STATSTAR ' \n";
  
  $cmd = "plot [1.0:1.0e9][1.0:3.0e18] 'statstar_solar.dat' using (\$1*0.01):(\$4*1.0)   ";
  $cmd .= "   with lines ls 1 t 'T = 5500 K' ";
  $cmd .= " , ";
  $cmd .= "          'statstar_5000.dat' using (\$1*0.01):(\$4*1.0)   ";
  $cmd .= "   with lines ls 3 t 'T = 5000 K' ";
  $cmd .= " , ";
  $cmd .= "          'statstar_6000.dat' using (\$1*0.01):(\$4*1.0)   ";
  $cmd .= "   with lines ls 2 t 'T = 6000 K' ";


  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;

