#!/usr/bin/perl
#

  
  my($output_file, $term_options);


  # diagram showing location of the planets, linear scale
  #   this has no line showing temp as function of position
  $output_file = "planet_loc_a.ps";
  $term_options = "postscript color enhanced 'Helvetica,18' ";

  $cmdfile = "gnuplot.in";

  $label_y = 350.0;
  
  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 'Temperature (K)' \n";
  printf CMDFILE "set xlabel 'Semi-major axis (AU) ' \n";
#  printf CMDFILE "set label 1 'Me' at 1.52,$label_y \n"; 
#  printf CMDFILE "set label 2 'V' at 1.52,$label_y \n"; 
#  printf CMDFILE "set label 3 'E' at 1.00,$label_y \n"; 
  printf CMDFILE "set label 4 'Ma' at 1.52,$label_y \n"; 
  printf CMDFILE "set label 5 'J' at 5.20,$label_y \n"; 
  printf CMDFILE "set label 6 'S' at 9.58,$label_y \n"; 
  printf CMDFILE "set label 7 'U' at 19.20,$label_y \n"; 
  printf CMDFILE "set label 8 'N' at 30.05,$label_y \n"; 
  printf CMDFILE "set label 9 'P' at 39.48,$label_y \n"; 
  
  $cmd = "plot [0:35][0:400] 'calc_temp.out' using (\$1):(0.0-\$2)   ";
  $cmd .= "     with lines 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`;
  }



  # diagram showing location of the planets, linear scale
  #   this DOES show line showing temp as function of position
  $output_file = "planet_loc_b.ps";
  $term_options = "postscript color enhanced 'Helvetica,18' ";

  $cmdfile = "gnuplot.in";

  $label_y = 350.0;
  
  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 'Temperature (K)' \n";
  printf CMDFILE "set xlabel 'Semi-major axis (AU) ' \n";
#  printf CMDFILE "set label 1 'Me' at 1.52,$label_y \n"; 
#  printf CMDFILE "set label 2 'V' at 1.52,$label_y \n"; 
#  printf CMDFILE "set label 3 'E' at 1.00,$label_y \n"; 
  printf CMDFILE "set label 4 'Ma' at 1.52,$label_y \n"; 
  printf CMDFILE "set label 5 'J' at 5.20,$label_y \n"; 
  printf CMDFILE "set label 6 'S' at 9.58,$label_y \n"; 
  printf CMDFILE "set label 7 'U' at 19.20,$label_y \n"; 
  printf CMDFILE "set label 8 'N' at 30.05,$label_y \n"; 
  printf CMDFILE "set label 9 'P' at 39.48,$label_y \n"; 
  
  $cmd = "plot [0:35][0:400] 'calc_temp.out' using (\$1):(\$2)   ";
  $cmd .= "     with lines 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`;
  }




  # diagram showing location of the planets, linear scale
  #   this DOES show line showing temp as function of position
  #   and has marks showing snow lines for several materials
  $output_file = "planet_loc_c.ps";
  $term_options = "postscript color enhanced 'Helvetica,18' ";

  $cmdfile = "gnuplot.in";

  $label_y = 350.0;
  
  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 'Temperature (K)' \n";
  printf CMDFILE "set xlabel 'Semi-major axis (AU) ' \n";
#  printf CMDFILE "set label 1 'Me' at 1.52,$label_y \n"; 
#  printf CMDFILE "set label 2 'V' at 1.52,$label_y \n"; 
#  printf CMDFILE "set label 3 'E' at 1.00,$label_y \n"; 
  printf CMDFILE "set label 4 'Ma' at 1.52,$label_y \n"; 
  printf CMDFILE "set label 5 'J' at 5.20,$label_y \n"; 
  printf CMDFILE "set label 6 'S' at 9.58,$label_y \n"; 
  printf CMDFILE "set label 7 'U' at 19.20,$label_y \n"; 
  printf CMDFILE "set label 8 'N' at 30.05,$label_y \n"; 
  printf CMDFILE "set label 9 'P' at 39.48,$label_y \n"; 

  printf CMDFILE "set arrow 1  from 1.04,50 to 1.04,150 \n";
  printf CMDFILE "set arrow 2  from 2.04,100 to 2.04,150 \n";
  printf CMDFILE "set arrow 3  from 6.21,200 to 6.21,150 \n";
  printf CMDFILE "set arrow 4  from 16.8,200 to 16.8,150 \n";

  printf CMDFILE "set label 10 'H20' at 1.0,20 \n";
  printf CMDFILE "set label 11 'NH3' at 1.8,80 \n";
  printf CMDFILE "set label 12 'CO2' at 1.8,60 \n";
  printf CMDFILE "set label 13 'CH4' at 5.5,220 \n";
  printf CMDFILE "set label 14 'CO' at 16.0,220 \n";
  
  $cmd = "plot [0:35][0:400] 'calc_temp.out' using (\$1):(\$2)   ";
  $cmd .= "     with lines 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;
