#!/usr/bin/perl
#
# Plots for (bulk) properties of discovered planets
# 
# MWR 9/28/2016

if (0 == 1) {
    
      ####################################################################
      #  planet mass vs. period, 
      #    with colors denoting discovery method
      #
      # get the arguments
      $output_file = "./planets_mass_period_a.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Orbital Period (days) ' \n";
      printf CMDFILE "set ylabel 'Planet Mass (Jupiter units)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";

      printf CMDFILE "set label 1 'Transit' at 80000,0.10 font 'Helvetica-Bold,18' textcolor lt 1 \n";
      printf CMDFILE "set label 2 'Radial Vel' at 80000,0.05 font 'Helvetica-Bold,18' textcolor lt 2 \n";
      printf CMDFILE "set label 3 'Imaging' at 80000,0.025 font 'Helvetica-Bold,18' textcolor lt 3 \n";
      printf CMDFILE "set label 4 'Microlens' at 80000,0.0125 font 'Helvetica-Bold,18' textcolor lt 4 \n";
      printf CMDFILE "set label 5 'Timing' at 80000,0.00625 font 'Helvetica-Bold,18' textcolor lt 9 \n";
      printf CMDFILE "set label 7 'Modulation' at 80000,0.003125 font 'Helvetica-Bold,18' textcolor lt 7 \n";
      printf CMDFILE "set label 8 'Pulsar' at 80000,0.00157 font 'Helvetica-Bold,18' textcolor lt 8 \n";
      printf CMDFILE "set label 9 'Astrometry' at 80000,0.00076 font 'Helvetica-Bold,18' textcolor lt 5 \n";
      
      $cmd = "plot [0.1:1e6][0.0001:40] ";
      $cmd .= " './planet_table.transit.csv' using 6:22 ";
      $cmd .= "    with points pt 6 ps 0.4 lw 6 lt 1 lc 1 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.rv.csv' using 6:22 ";
      $cmd .= "    with points pt 6 ps 0.4 lw 6 lt 1 lc 2 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv' using 6:22 ";
      $cmd .= "    with points pt 6 ps 0.8 lw 5 lt 1 lc 3 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.microlens.csv' using 6:22 ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 4 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.timing.csv' using 6:22 ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 9 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.modulation.csv' using 6:22 ";
      $cmd .= "    with points pt 3 ps 0.8 lw 2 lt 1 lc 7 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsar.csv' using 6:22 ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 8 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.astrometry.csv' using 6:22 ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 5 ";
      $cmd .= "    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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

    
      ####################################################################
      #  planet radius vs. period, 
      #    with colors denoting discovery method
      #
      # get the arguments
      $output_file = "./planets_radius_period_a.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Orbital Period (days) ' \n";
      printf CMDFILE "set ylabel 'Planet Radius (Earth units)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";
      printf CMDFILE "set key bot right \n";

#      printf CMDFILE "set label 1 'Transit' at 80000,0.10e3 font 'Helvetica-Bold,18' textcolor lt 1 \n";
#      printf CMDFILE "set label 2 'Radial Vel' at 80000,0.05e3 font 'Helvetica-Bold,18' textcolor lt 2 \n";
#      printf CMDFILE "set label 3 'Imaging' at 80000,0.025e3 font 'Helvetica-Bold,18' textcolor lt 3 \n";
#      printf CMDFILE "set label 4 'Microlens' at 80000,0.0125e3 font 'Helvetica-Bold,18' textcolor lt 4 \n";
#      printf CMDFILE "set label 5 'Timing' at 80000,0.00625e3 font 'Helvetica-Bold,18' textcolor lt 9 \n";
#      printf CMDFILE "set label 7 'Modulation' at 80000,0.003125e3 font 'Helvetica-Bold,18' textcolor lt 7 \n";
#      printf CMDFILE "set label 8 'Pulsar' at 80000,0.00157e3 font 'Helvetica-Bold,18' textcolor lt 8 \n";
#      printf CMDFILE "set label 9 'Astrometry' at 80000,0.00076e3 font 'Helvetica-Bold,18' textcolor lt 5 \n";
      
      $cmd = "plot [0.1:1e6][0.2:0.4e2] ";
      $cmd .= " './planet_table.transit.csv' using 6:(\$27/0.0911) ";
      $cmd .= "    with points pt 6 ps 0.4 lw 6 lt 1 lc 1 ";
      $cmd .= "    t 'Transit' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.rv.csv' using 6:(\$27/0.0911) ";
      $cmd .= "    with points pt 6 ps 0.8 lw 6 lt 1 lc 2 ";
      $cmd .= "    t 'Radial Vel' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv' using 6:(\$27/0.0911) ";
      $cmd .= "    with points pt 6 ps 0.8 lw 5 lt 1 lc 3 ";
      $cmd .= "    t 'Imaging' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.microlens.csv' using 6:(\$27/0.0911) ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 4 ";
      $cmd .= "    t 'Microlens' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.timing.csv' using 6:(\$27/0.0911) ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 9 ";
      $cmd .= "    t 'Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.modulation.csv' using 6:(\$27/0.0911) ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 7 ";
      $cmd .= "    t 'Modulation' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsar.csv' using 6:(\$27/0.0911) ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 8 ";
      $cmd .= "    t 'Pulsar' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.astrometry.csv' using 6:(\$27/0.0911) ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 5 ";
      $cmd .= "    t 'Astrometry' ";

    
  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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

    
      ####################################################################
      #  planet radius vs. mass, 
      #    with colors denoting discovery method
      #
      # get the arguments
      $output_file = "./planets_radius_mass_a.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Planet Mass (Earth masses) ' \n";
      printf CMDFILE "set ylabel 'Planet Radius (Earth radii)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "unset logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";
      printf CMDFILE "set key top left \n";

#      printf CMDFILE "set label 1 'Transit' at 80000,0.10e3 font 'Helvetica-Bold,18' textcolor lt 1 \n";
#      printf CMDFILE "set label 2 'Radial Vel' at 80000,0.05e3 font 'Helvetica-Bold,18' textcolor lt 2 \n";
#      printf CMDFILE "set label 3 'Imaging' at 80000,0.025e3 font 'Helvetica-Bold,18' textcolor lt 3 \n";
#      printf CMDFILE "set label 4 'Microlens' at 80000,0.0125e3 font 'Helvetica-Bold,18' textcolor lt 4 \n";
#      printf CMDFILE "set label 5 'Timing' at 80000,0.00625e3 font 'Helvetica-Bold,18' textcolor lt 9 \n";
#      printf CMDFILE "set label 7 'Modulation' at 80000,0.003125e3 font 'Helvetica-Bold,18' textcolor lt 7 \n";
#      printf CMDFILE "set label 8 'Pulsar' at 80000,0.00157e3 font 'Helvetica-Bold,18' textcolor lt 8 \n";
#      printf CMDFILE "set label 9 'Astrometry' at 80000,0.00076e3 font 'Helvetica-Bold,18' textcolor lt 5 \n";
      
      $cmd = "plot [0.1:100][0:15] ";
      $cmd .= " './planet_table.transit.csv' using (\$22/0.0032):(\$27/0.0911) ";
      $cmd .= "    with points pt 6 ps 0.4 lw 6 lt 1 lc 1 ";
      $cmd .= "    t 'Transit' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.rv.csv' using (\$22/0.0032):(\$27/0.0911) ";
      $cmd .= "    with points pt 6 ps 0.8 lw 6 lt 1 lc 2 ";
      $cmd .= "    t 'Radial Vel' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv' using (\$22/0.0032):(\$27/0.0911) ";
      $cmd .= "    with points pt 6 ps 0.8 lw 5 lt 1 lc 3 ";
      $cmd .= "    t 'Imaging' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.microlens.csv' using (\$22/0.0032):(\$27/0.0911) ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 4 ";
      $cmd .= "    t 'Microlens' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.timing.csv' using (\$22/0.0032):(\$27/0.0911) ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 9 ";
      $cmd .= "    t 'Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.modulation.csv' using (\$22/0.0032):(\$27/0.0911) ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 7 ";
      $cmd .= "    t 'Modulation' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsar.csv' using (\$22/0.0032):(\$27/0.0911) ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 8 ";
      $cmd .= "    t 'Pulsar' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.astrometry.csv' using (\$22/0.0032):(\$27/0.0911) ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 5 ";
      $cmd .= "    t 'Astrometry' ";
      $cmd .= " , ";
      # and now some models
      #   this is average density = Earth's average density
#      $cmd .= "    (((3.0*x)/(4.0*3.14159*0.2387))**0.3333) ";
#      $cmd .= "         with lines lt 2 lc -1 t 'Earth density' \n";
#      $cmd .= " , ";
      #   this is average density = water
      $cmd .= "    (((3.0*x)/(4.0*3.14159*0.0432))**0.3333) ";
      $cmd .= "         with lines lt 2 lw 2 lc -1 t 'uniform water' ";
      $cmd .= " , ";
      #   this is average density = Earth's average density
      $cmd .= "    (((3.0*x)/(4.0*3.14159*0.3403))**0.3333) ";
      $cmd .= "         with lines lt 1 lw 2 lc 3 t 'uniform iron' ";

    
  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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

    
      ####################################################################
      #  planet eccentricity vs. period, 
      #    with colors denoting discovery method
      #
      # get the arguments
      $output_file = "./planets_eccen_period_a.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Planet orbital period (days) ' \n";
      printf CMDFILE "set ylabel 'Planet orbital eccentricity' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "unset logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";
      printf CMDFILE "set key top left \n";

#      printf CMDFILE "set label 1 'Transit' at 80000,0.10e3 font 'Helvetica-Bold,18' textcolor lt 1 \n";
#      printf CMDFILE "set label 2 'Radial Vel' at 80000,0.05e3 font 'Helvetica-Bold,18' textcolor lt 2 \n";
#      printf CMDFILE "set label 3 'Imaging' at 80000,0.025e3 font 'Helvetica-Bold,18' textcolor lt 3 \n";
#      printf CMDFILE "set label 4 'Microlens' at 80000,0.0125e3 font 'Helvetica-Bold,18' textcolor lt 4 \n";
#      printf CMDFILE "set label 5 'Timing' at 80000,0.00625e3 font 'Helvetica-Bold,18' textcolor lt 9 \n";
#      printf CMDFILE "set label 7 'Modulation' at 80000,0.003125e3 font 'Helvetica-Bold,18' textcolor lt 7 \n";
#      printf CMDFILE "set label 8 'Pulsar' at 80000,0.00157e3 font 'Helvetica-Bold,18' textcolor lt 8 \n";
#      printf CMDFILE "set label 9 'Astrometry' at 80000,0.00076e3 font 'Helvetica-Bold,18' textcolor lt 5 \n";
      
      $cmd = "plot [0.1:1e5][-0.05:1.1] ";
      $cmd .= " './planet_table.transit.csv' using 6:14 ";
      $cmd .= "    with points pt 6 ps 0.4 lw 6 lt 1 lc 1 ";
      $cmd .= "    t 'Transit' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.rv.csv' using 6:14 ";
      $cmd .= "    with points pt 6 ps 0.6 lw 6 lt 1 lc 2 ";
      $cmd .= "    t 'Radial Vel' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv' using 6:14 ";
      $cmd .= "    with points pt 6 ps 0.8 lw 5 lt 1 lc 3 ";
      $cmd .= "    t 'Imaging' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.microlens.csv' using 6:14 ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 4 ";
      $cmd .= "    t 'Microlens' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.timing.csv' using 6:14 ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 9 ";
      $cmd .= "    t 'Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.modulation.csv' using 6:14 ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 7 ";
      $cmd .= "    t 'Modulation' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsar.csv' using 6:14 ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 8 ";
      $cmd .= "    t 'Pulsar' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.astrometry.csv' using 6:14 ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 5 ";
      $cmd .= "    t 'Astrometry' ";

    
  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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

    
      ####################################################################
      #  planet equlib. temp vs. period, 
      #    with colors denoting discovery method
      #
      # get the arguments
      $output_file = "./planets_temp_period_a.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Planet orbital period (days) ' \n";
      printf CMDFILE "set ylabel 'Planet equilib. blackbody temp (K)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";
      printf CMDFILE "set key bot left  \n";

#      printf CMDFILE "set label 1 'Transit' at 80000,0.10e3 font 'Helvetica-Bold,18' textcolor lt 1 \n";
#      printf CMDFILE "set label 2 'Radial Vel' at 80000,0.05e3 font 'Helvetica-Bold,18' textcolor lt 2 \n";
#      printf CMDFILE "set label 3 'Imaging' at 80000,0.025e3 font 'Helvetica-Bold,18' textcolor lt 3 \n";
#      printf CMDFILE "set label 4 'Microlens' at 80000,0.0125e3 font 'Helvetica-Bold,18' textcolor lt 4 \n";
#      printf CMDFILE "set label 5 'Timing' at 80000,0.00625e3 font 'Helvetica-Bold,18' textcolor lt 9 \n";
#      printf CMDFILE "set label 7 'Modulation' at 80000,0.003125e3 font 'Helvetica-Bold,18' textcolor lt 7 \n";
#      printf CMDFILE "set label 8 'Pulsar' at 80000,0.00157e3 font 'Helvetica-Bold,18' textcolor lt 8 \n";
#      printf CMDFILE "set label 9 'Astrometry' at 80000,0.00076e3 font 'Helvetica-Bold,18' textcolor lt 5 \n";
      
      $cmd = "plot [0.1:1e5][40:3000] ";
      $cmd .= " './planet_table.transit.csv' using 6:68 ";
      $cmd .= "    with points pt 6 ps 0.4 lw 6 lt 1 lc 1 ";
      $cmd .= "    t 'Transit' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.rv.csv' using 6:68 ";
      $cmd .= "    with points pt 6 ps 0.6 lw 6 lt 1 lc 2 ";
      $cmd .= "    t 'Radial Vel' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv' using 6:68 ";
      $cmd .= "    with points pt 6 ps 0.8 lw 5 lt 1 lc 3 ";
      $cmd .= "    t 'Imaging' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.microlens.csv' using 6:68 ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 4 ";
      $cmd .= "    t 'Microlens' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.timing.csv' using 6:68 ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 9 ";
      $cmd .= "    t 'Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.modulation.csv' using 6:68 ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 7 ";
      $cmd .= "    t 'Modulation' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsar.csv' using 6:68 ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 8 ";
      $cmd .= "    t 'Pulsar' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.astrometry.csv' using 6:68 ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 5 ";
      $cmd .= "    t 'Astrometry' ";

    
  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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

    
      ####################################################################
      #  planet irradiation. temp vs. period, 
      #    using my attempt to compute irradiation in earth units
      #    with colors denoting discovery method
      #
      # get the arguments
      $output_file = "./planets_temp_period_b.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Planet orbital period (days) ' \n";
      printf CMDFILE "set ylabel 'Planet irradiation (Earth units)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";
      printf CMDFILE "set key bot left  \n";

#      printf CMDFILE "set label 1 'Transit' at 80000,0.10e3 font 'Helvetica-Bold,18' textcolor lt 1 \n";
#      printf CMDFILE "set label 2 'Radial Vel' at 80000,0.05e3 font 'Helvetica-Bold,18' textcolor lt 2 \n";
#      printf CMDFILE "set label 3 'Imaging' at 80000,0.025e3 font 'Helvetica-Bold,18' textcolor lt 3 \n";
#      printf CMDFILE "set label 4 'Microlens' at 80000,0.0125e3 font 'Helvetica-Bold,18' textcolor lt 4 \n";
#      printf CMDFILE "set label 5 'Timing' at 80000,0.00625e3 font 'Helvetica-Bold,18' textcolor lt 9 \n";
#      printf CMDFILE "set label 7 'Modulation' at 80000,0.003125e3 font 'Helvetica-Bold,18' textcolor lt 7 \n";
#      printf CMDFILE "set label 8 'Pulsar' at 80000,0.00157e3 font 'Helvetica-Bold,18' textcolor lt 8 \n";
#      printf CMDFILE "set label 9 'Astrometry' at 80000,0.00076e3 font 'Helvetica-Bold,18' textcolor lt 5 \n";
      
      $cmd = "plot [0.1:1e5][] ";
      $cmd .= " './planet_table.transit.csv' ";
      $cmd .= "    using 6:(((\$62**2.0)*((\$52/5777.0)**4.0))*((1.0/\$10)**2))";
      $cmd .= "    with points pt 6 ps 0.4 lw 6 lt 1 lc 1 ";
      $cmd .= "    t 'Transit' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.rv.csv'  ";
      $cmd .= "    using 6:(((\$62**2.0)*((\$52/5777.0)**4.0))*((1.0/\$10)**2))";
      $cmd .= "    with points pt 6 ps 0.6 lw 6 lt 1 lc 2 ";
      $cmd .= "    t 'Radial Vel' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv'  ";
      $cmd .= "    using 6:(((\$62**2.0)*((\$52/5777.0)**4.0))*((1.0/\$10)**2))";
      $cmd .= "    with points pt 6 ps 0.8 lw 5 lt 1 lc 3 ";
      $cmd .= "    t 'Imaging' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.microlens.csv'  ";
      $cmd .= "    using 6:(((\$62**2.0)*((\$52/5777.0)**4.0))*((1.0/\$10)**2))";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 4 ";
      $cmd .= "    t 'Microlens' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.timing.csv'  ";
      $cmd .= "    using 6:(((\$62**2.0)*((\$52/5777.0)**4.0))*((1.0/\$10)**2))";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 9 ";
      $cmd .= "    t 'Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.modulation.csv'  ";
      $cmd .= "    using 6:(((\$62**2.0)*((\$52/5777.0)**4.0))*((1.0/\$10)**2))";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 7 ";
      $cmd .= "    t 'Modulation' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsar.csv'  ";
      $cmd .= "    using 6:(((\$62**2.0)*((\$52/5777.0)**4.0))*((1.0/\$10)**2))";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 8 ";
      $cmd .= "    t 'Pulsar' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.astrometry.csv'  ";
      $cmd .= "    using 6:(((\$62**2.0)*((\$52/5777.0)**4.0))*((1.0/\$10)**2))";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 5 ";
      $cmd .= "    t 'Astrometry' ";

    
  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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }


    
      ####################################################################
      #  planet radius vs transit depth 
      #    with colors denoting discovery method
      #
      # get the arguments
      $output_file = "./planets_radius_depth.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Planet transit depth (percent) ' \n";
      printf CMDFILE "set ylabel 'Planet radius (Earth units)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";
      printf CMDFILE "set key bot right  \n";

#      printf CMDFILE "set label 1 'Transit' at 80000,0.10e3 font 'Helvetica-Bold,18' textcolor lt 1 \n";
#      printf CMDFILE "set label 2 'Radial Vel' at 80000,0.05e3 font 'Helvetica-Bold,18' textcolor lt 2 \n";
#      printf CMDFILE "set label 3 'Imaging' at 80000,0.025e3 font 'Helvetica-Bold,18' textcolor lt 3 \n";
#      printf CMDFILE "set label 4 'Microlens' at 80000,0.0125e3 font 'Helvetica-Bold,18' textcolor lt 4 \n";
#      printf CMDFILE "set label 5 'Timing' at 80000,0.00625e3 font 'Helvetica-Bold,18' textcolor lt 9 \n";
#      printf CMDFILE "set label 7 'Modulation' at 80000,0.003125e3 font 'Helvetica-Bold,18' textcolor lt 7 \n";
#      printf CMDFILE "set label 8 'Pulsar' at 80000,0.00157e3 font 'Helvetica-Bold,18' textcolor lt 8 \n";
#      printf CMDFILE "set label 9 'Astrometry' at 80000,0.00076e3 font 'Helvetica-Bold,18' textcolor lt 5 \n";
      
      $cmd = "plot [][] ";
      $cmd .= " './planet_table.transit.csv' ";
      $cmd .= "    using 76:(\$27/0.0911) ";
      $cmd .= "    with points pt 6 ps 0.4 lw 6 lt 1 lc 1 ";
      $cmd .= "    t 'Transit' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.rv.csv'  ";
      $cmd .= "    using 76:(\$27/0.0911) ";
      $cmd .= "    with points pt 6 ps 0.6 lw 6 lt 1 lc 2 ";
      $cmd .= "    t 'Radial Vel' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv'  ";
      $cmd .= "    using 76:(\$27/0.0911) ";
      $cmd .= "    with points pt 6 ps 0.8 lw 5 lt 1 lc 3 ";
      $cmd .= "    t 'Imaging' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.microlens.csv'  ";
      $cmd .= "    using 76:(\$27/0.0911) ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 4 ";
      $cmd .= "    t 'Microlens' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.timing.csv'  ";
      $cmd .= "    using 76:(\$27/0.0911) ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 9 ";
      $cmd .= "    t 'Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.modulation.csv'  ";
      $cmd .= "    using 76:(\$27/0.0911) ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 7 ";
      $cmd .= "    t 'Modulation' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsar.csv'  ";
      $cmd .= "    using 76:(\$27/0.0911) ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 8 ";
      $cmd .= "    t 'Pulsar' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.astrometry.csv'  ";
      $cmd .= "    using 76:(\$27/0.0911) ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 5 ";
      $cmd .= "    t 'Astrometry' ";

    
  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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }


    
      ####################################################################
      #  planet semi-major axis vs orbital period
      #    with colors denoting discovery method
      #
      # get the arguments
      $output_file = "./planets_semia_period.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Planet orbital period (days) ' \n";
      printf CMDFILE "set ylabel 'Planet orbital radius (AU)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "unset logscale y  \n";
      printf CMDFILE "unset logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";
      printf CMDFILE "set key top left \n";

#      printf CMDFILE "set label 1 'Transit' at 80000,0.10e3 font 'Helvetica-Bold,18' textcolor lt 1 \n";
#      printf CMDFILE "set label 2 'Radial Vel' at 80000,0.05e3 font 'Helvetica-Bold,18' textcolor lt 2 \n";
#      printf CMDFILE "set label 3 'Imaging' at 80000,0.025e3 font 'Helvetica-Bold,18' textcolor lt 3 \n";
#      printf CMDFILE "set label 4 'Microlens' at 80000,0.0125e3 font 'Helvetica-Bold,18' textcolor lt 4 \n";
#      printf CMDFILE "set label 5 'Timing' at 80000,0.00625e3 font 'Helvetica-Bold,18' textcolor lt 9 \n";
#      printf CMDFILE "set label 7 'Modulation' at 80000,0.003125e3 font 'Helvetica-Bold,18' textcolor lt 7 \n";
#      printf CMDFILE "set label 8 'Pulsar' at 80000,0.00157e3 font 'Helvetica-Bold,18' textcolor lt 8 \n";
#      printf CMDFILE "set label 9 'Astrometry' at 80000,0.00076e3 font 'Helvetica-Bold,18' textcolor lt 5 \n";
      
      $cmd = "plot [0:4000][0:6.5] ";
      $cmd .= " './planet_table.transit.csv' ";
      $cmd .= "    using 6:10 ";
      $cmd .= "    with points pt 6 ps 0.4 lw 6 lt 1 lc 1 ";
      $cmd .= "    t 'Transit' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.rv.csv'  ";
      $cmd .= "    using 6:10 ";
      $cmd .= "    with points pt 6 ps 0.6 lw 6 lt 1 lc 2 ";
      $cmd .= "    t 'Radial Vel' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv'  ";
      $cmd .= "    using 6:10 ";
      $cmd .= "    with points pt 6 ps 0.8 lw 5 lt 1 lc 3 ";
      $cmd .= "    t 'Imaging' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.microlens.csv'  ";
      $cmd .= "    using 6:10 ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 4 ";
      $cmd .= "    t 'Microlens' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.timing.csv'  ";
      $cmd .= "    using 6:10 ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 9 ";
      $cmd .= "    t 'Timing' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.modulation.csv'  ";
      $cmd .= "    using 6:10 ";
      $cmd .= "    with points pt 3 ps 1.0 lw 3 lt 1 lc 7 ";
      $cmd .= "    t 'Modulation' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.pulsar.csv'  ";
      $cmd .= "    using 6:10 ";
      $cmd .= "    with points pt 4 ps 1.0 lw 4 lt 1 lc 8 ";
      $cmd .= "    t 'Pulsar' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.astrometry.csv'  ";
      $cmd .= "    using 6:10 ";
      $cmd .= "    with points pt 4 ps 0.8 lw 5 lt 1 lc 5 ";
      $cmd .= "    t 'Astrometry' ";
      #  and now some models, for stars of different masses
      $cmd .= " , ";
      $cmd .= "    (((x/365.25)**0.6666)*(3**0.3333)) with lines ";
      $cmd .= "        lt 2 lw 2 lc 3 t '3 M_{{/=12 O}&{/*-.49 O}{/=12 \\267}}' ";
      $cmd .= " , ";
      $cmd .= "    (((x/365.25))**0.6666) with lines ";
      $cmd .= "        lt 1 lw 2 lc -1 t '1 M_{{/=12 O}&{/*-.49 O}{/=12 \\267}}' ";
      $cmd .= " , ";
      $cmd .= "    (((x/365.25)**0.6666)*((0.33)**0.3333)) with lines ";
      $cmd .= "        lt 3 lw 4 lc 4 t '0.33 M_{{/=12 O}&{/*-.49 O}{/=12 \\267}}' ";


    
  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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }


}


if (0 == 1) {

      ####################################################################
      #  planet mass vs. separation, 
      #    highlighting microlensing discoveries
      #
      # get the arguments
      $output_file = "./planets_microlensing_a.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Semi-major axis or separation (AU) ' \n";
      printf CMDFILE "set ylabel 'Planet Mass (Jupiter units)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";

      
      $cmd = "plot [0.01:5e2][0.001:40] ";
      $cmd .= " './planet_table.csv' using 10:22 ";
      $cmd .= "    with points pt 6 ps 0.2 lw 6 lt 1 lc -1 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.microlens.csv' using 10:22 ";
      $cmd .= "    with points pt 6 ps 1.5 lw 6 lt 1 lc 1 ";
      $cmd .= "    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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }


      ####################################################################
      #  planet mass vs. separation, 
      #    highlighting imaging discoveries
      #
      # get the arguments
      $output_file = "./planets_imaging_a.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Semi-major axis or separation (AU) ' \n";
      printf CMDFILE "set ylabel 'Planet Mass (Jupiter units)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";

      
      $cmd = "plot [0.01:1e3][0.001:50] ";
      $cmd .= " './planet_table.csv' using 10:22 ";
      $cmd .= "    with points pt 6 ps 0.2 lw 6 lt 1 lc -1 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv' using 10:22 ";
      $cmd .= "    with points pt 4 ps 1.5 lw 6 lt 1 lc 2 ";
      $cmd .= "    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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }


      ####################################################################
      #  planet mass vs. ANGULAR separation, 
      #    highlighting (or only?) imaging discoveries
      #
      # get the arguments
      $output_file = "./planets_imaging_b.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Angular separation (arcsec) ' \n";
      printf CMDFILE "set ylabel 'Planet Mass (Jupiter units)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";

      
      $cmd = "plot [][0.001:50] ";
      $cmd .= " './planet_table.csv' using (\$10/\$43):22 ";
      $cmd .= "    with points pt 6 ps 0.2 lw 6 lt 1 lc -1 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv' using (\$10/\$43):22 ";
      $cmd .= "    with points pt 4 ps 1.5 lw 6 lt 1 lc 2 ";
      $cmd .= "    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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }



      ####################################################################
      #  planet mass vs. ANGULAR separation, 
      #    highlighting (or only?) imaging discoveries
      #    This time in linear units, focus on interesting region
      #
      # get the arguments
      $output_file = "./planets_imaging_c.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Angular separation (arcsec) ' \n";
      printf CMDFILE "set ylabel 'Planet Mass (Jupiter units)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";

      
      $cmd = "plot [0.02:10][0.001:50] ";
      $cmd .= " './planet_table.csv' using (\$10/\$43):22 ";
      $cmd .= "    with points pt 6 ps 0.2 lw 6 lt 1 lc -1 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv' using (\$10/\$43):22 ";
      $cmd .= "    with points pt 4 ps 1.5 lw 6 lt 1 lc 2 ";
      $cmd .= "    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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

}



      ####################################################################
      #  planet radius vs. orbital radius for Kepler planets
      #    before and after 2013
      #
      # get the arguments
      $output_file = "./planets_kepler_a.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' size 15,10";
    
      $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 size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Orbital period (years) ' \n";
      printf CMDFILE "set ylabel 'Planet Radius (Jupiter units)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set logscale y  \n";
      printf CMDFILE "set logscale x  \n";
      printf CMDFILE "set datafile separator ',' \n";

      
      $cmd = "plot [0.02:10][0.001:50] ";
      $cmd .= " './planet_table.csv' using (\$10/\$43):22 ";
      $cmd .= "    with points pt 6 ps 0.2 lw 6 lt 1 lc -1 ";
      $cmd .= "    t '' ";
      $cmd .= " , ";
      $cmd .= " './planet_table.imaging.csv' using (\$10/\$43):22 ";
      $cmd .= "    with points pt 4 ps 1.5 lw 6 lt 1 lc 2 ";
      $cmd .= "    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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }










if (0 == 1) {

      ####################################################################
      #  "typical" stellar spectrum, closeup near H-beta visible range
      #
      # get the arguments
      $output_file = "./pickles_small_range.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' ";
    
      $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 size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Wavelength (Angstroms) ' \n";
      printf CMDFILE "set ylabel 'Flam (arbitrary units)' \n";
      printf CMDFILE "set title '' \n";
      
      $cmd = "plot [4800:5000][] ";
      $cmd .= " './ukg2v_dat' index 0 ";
      $cmd .= "    t '' ";
      $cmd .= "    with linespoints ps 1.0 pt 5 lw 2 lt 1 lc 1 ";
    
  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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }


if (0 == 1) {

      ####################################################################
      #  HARPS spectrum of BD 184914
      #
      # get the arguments
      $output_file = "./bd184914_a.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' ";
    
      $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 size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Wavelength (Angstroms) ' \n";
      printf CMDFILE "set ylabel 'Flux (arbitrary units)' \n";
      printf CMDFILE "set title '' \n";
      
      $cmd = "plot [5000:5020][] ";
      $cmd .= " './excerpt.txt' index 0 ";
      $cmd .= "    t '' ";
      $cmd .= "    with lines lw 2 lt 1 lc 1 ";
    
  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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

    

      ####################################################################
      #  HARPS spectrum of BD 184914 -- closeup around 5010 Angstroms
      #
      # get the arguments
      $output_file = "./bd184914_b.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' ";
    
      $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 size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Wavelength (Angstroms) ' \n";
      printf CMDFILE "set ylabel 'Flux (arbitrary units)' \n";
      printf CMDFILE "set title '' \n";
      
      $cmd = "plot [5010.5:5011.5][] ";
      $cmd .= " './excerpt.txt' index 0 ";
      $cmd .= "    t '' ";
      $cmd .= "    with linespoints lw 2 pt 5 ps 0.5 lt 1 lc 1 ";
    
  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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

    

      ####################################################################
      #  HARPS spectrum of BD 184914 -- very closeup around 5010.8 Angstroms
      #
      # get the arguments
      $output_file = "./bd184914_c.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";
      printf CMDFILE "set size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Wavelength (Angstroms) ' \n";
      printf CMDFILE "set ylabel 'Flux (arbitrary units)' \n";
      printf CMDFILE "set title '' \n";
      
      $cmd = "plot [5010.6:5011.0][] ";
      $cmd .= " './excerpt.txt' index 0 ";
      $cmd .= "    t '' ";
      $cmd .= "    with linespoints lw 2 pt 5 ps 0.8 lt 1 lc 1 ";
    
  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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

    

      ####################################################################
      #  HARPS spectrum of BD 184914 -- entire spectrum
      #
      # get the arguments
      $output_file = "./bd184914_d.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";
      printf CMDFILE "set size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Wavelength (Angstroms) ' \n";
      printf CMDFILE "set ylabel 'Flux (arbitrary units)' \n";
      printf CMDFILE "set title '' \n";
      
      $cmd = "plot [3700:7000][-2:105] ";
      $cmd .= " './BD184914_20100702_0949_full.txt' index 0 ";
      $cmd .= "    t '' ";
      $cmd .= "    with lines lw 1 lt 1 lc 1 ";
    
  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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

    

      ####################################################################
      #  HARPS spectrum of BD 184914 -- 4800 to 5000 Angstroms
      #    compared to Pickles spectrum of another star over same interval
      #
      # get the arguments
      $output_file = "./bd184914_e.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";
      printf CMDFILE "set size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Wavelength (Angstroms) ' \n";
      printf CMDFILE "set ylabel 'Flux (arbitrary units)' \n";
      printf CMDFILE "set title '' \n";
      
      $cmd = "plot [4800:5000][] ";
      $cmd .= " './BD184914_20100702_0949_full.txt' index 0 ";
      $cmd .= "    t '' ";
      $cmd .= "    with lines lw 2 lt 1 lc 1 ";
      $cmd .= " , ";
      $cmd .= " './ukg2v_dat' ";    
      $cmd .= "    using 1:(\$2*90) ";
      $cmd .= "    t '' ";
      $cmd .= "    with linespoints ps 0.8 pt 5 lw 2 lt 1 lc -1 ";

  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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

    
}
    
    

      ####################################################################
      #  radial velocity due to earth spin only, over three days
      #
      # get the arguments
      $output_file = "./rv_spin_only.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";
      printf CMDFILE "set size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Time (days) ' \n";
      printf CMDFILE "set ylabel 'Apparent radial velocity (m/s)' \n";
      printf CMDFILE "set title 'Observatory at lat=40, star at ecl. lat=30 ' \n";
      
      $cmd = "plot [-0.1:3.1][-600:600] ";
      $cmd .= " './compute_rv.out' index 0 ";
      $cmd .= "    t 'spin only' ";
      $cmd .= "    with lines lw 3 lt 1 lc 1 ";

  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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

    

      ####################################################################
      #  radial velocity due to earth spin and orbit, over three days
      #
      # get the arguments
      $output_file = "./rv_both_short.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";
      printf CMDFILE "set size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key top left Left reverse \n";
      printf CMDFILE "set xlabel 'Time (days) ' \n";
      printf CMDFILE "set ylabel 'Apparent radial velocity (m/s)' \n";
      printf CMDFILE "set title 'Observatory at lat=40, star at ecl. lat=30 ' \n";
      
      $cmd = "plot [-0.1:3.1][-600:2000] ";
      $cmd .= " './compute_rv.out' index 0 using 1:2 ";
      $cmd .= "    t 'spin only' ";
      $cmd .= "    with lines lw 3 lt 1 lc 1 ";
      $cmd .= " , ";
      $cmd .= " './compute_rv.out' index 0 using 1:3 ";
      $cmd .= "    t 'orbit only' ";
      $cmd .= "    with lines lw 3 lt 1 lc 3 ";
      $cmd .= " , ";
      $cmd .= " './compute_rv.out' index 0 using 1:4 ";
      $cmd .= "    t 'combined' ";
      $cmd .= "    with lines lw 3 lt 1 lc -1 ";


  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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

    

      ####################################################################
      #  radial velocity due to earth spin and orbit, over ninety days
      #
      # get the arguments
      $output_file = "./rv_both_long.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";
      printf CMDFILE "set size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key top left Left reverse \n";
      printf CMDFILE "set xlabel 'Time (days) ' \n";
      printf CMDFILE "set ylabel 'Apparent radial velocity (m/s)' \n";
      printf CMDFILE "set title 'Observatory at lat=40, star at ecl. lat=30 ' \n";
      
      $cmd = "plot [-0.1:90.1][-600:] ";
      $cmd .= " './compute_rv.out' index 0 using 1:2 ";
      $cmd .= "    t 'spin only' ";
      $cmd .= "    with lines lw 3 lt 1 lc 1 ";
      $cmd .= " , ";
      $cmd .= " './compute_rv.out' index 0 using 1:3 ";
      $cmd .= "    t 'orbit only' ";
      $cmd .= "    with lines lw 3 lt 1 lc 3 ";
      $cmd .= " , ";
      $cmd .= " './compute_rv.out' index 0 using 1:4 ";
      $cmd .= "    t 'combined' ";
      $cmd .= "    with lines lw 3 lt 1 lc -1 ";


  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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

    
}
    
if (0 == 1) {

      ####################################################################
      #  Spectra of several stars from Elodie
      #
      # get the arguments
      $output_file = "./elodie_a.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' ";
    
      $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 size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Wavelength (Angstroms) ' \n";
      printf CMDFILE "set ylabel 'Flam (arbitrary units)' \n";
      printf CMDFILE "set title '' \n";
      
      $cmd = "plot [5000:5020][50000:380000] ";
      $cmd .= " './elodie_hd113139.dat' index 0 ";
      $cmd .= "    using (\$1):(\$2*4.0) ";
      $cmd .= "    t 'HD 113139' ";
      $cmd .= "    with lines lw 2 lt 1 lc 1 ";
      $cmd .= " , ";
      $cmd .= " './elodie_hd27808.dat' index 0 ";
      $cmd .= "    t 'HD 27808' ";
      $cmd .= "    with lines lw 2 lt 1 lc 3 ";
    
  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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

    
      ####################################################################
      #  Spectra of several stars from Elodie
      #     (now label the rotation speed)
      #
      # get the arguments
      $output_file = "./elodie_b.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' ";
    
      $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 size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Wavelength (Angstroms) ' \n";
      printf CMDFILE "set ylabel 'Flam (arbitrary units)' \n";
      printf CMDFILE "set title '' \n";
      
      $cmd = "plot [5000:5020][50000:380000] ";
      $cmd .= " './elodie_hd113139.dat' index 0 ";
      $cmd .= "    using (\$1):(\$2*4.0) ";
      $cmd .= "    t 'HD 113139: F2V  vrot = 100 km/s' ";
      $cmd .= "    with lines lw 2 lt 1 lc 1 ";
      $cmd .= " , ";
      $cmd .= " './elodie_hd27808.dat' index 0 ";
      $cmd .= "    t 'HD 27808:   F8V  vrot =     6 km/s' ";
      $cmd .= "    with lines lw 2 lt 1 lc 3 ";
    
  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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

    
    
      ####################################################################
      #  Spectra of several stars of different spectral class from Elodie
      #
      # get the arguments
      $output_file = "./elodie_c.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' ";
    
      $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 size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
#      printf CMDFILE "set key top right Left \n";
      printf CMDFILE "set nokey \n";
      printf CMDFILE "set xlabel 'Wavelength (Angstroms) ' \n";
      printf CMDFILE "set ylabel 'Flam (arbitrary units)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set label 1 at 5001,20000 'BD+44 4548' \n";
      printf CMDFILE "set label 2 at 5001,160000 '51 Peg' \n";
      printf CMDFILE "set label 3 at 5001,440000 'HD 27808' \n";
      printf CMDFILE "set label 4 at 5001,560000 'eps Aur' \n";

      
      $cmd = "plot [5000:5020][] ";
      $cmd .= " './elodie_epsaur.dat' index 0 ";
      $cmd .= "    using (\$1):(100000+\$2*1.0) ";
      $cmd .= "    t 'eps Aug' ";
      $cmd .= "    with lines lw 2 lt 1 lc 1 ";
      $cmd .= " , ";
      $cmd .= " './elodie_hd27808.dat' index 0 ";
      $cmd .= "    using (\$1):(100000+\$2*1.5) ";
      $cmd .= "    t 'HD 27808' ";
      $cmd .= "    with lines lw 2 lt 1 lc 3 ";
      $cmd .= " , ";
      $cmd .= " './elodie_51peg.dat' index 0 ";
      $cmd .= "    using (\$1):(100000+\$2*8.0) ";
      $cmd .= "    t '51 Peg' ";
      $cmd .= "    with lines lw 2 lt 1 lc 4 ";
      $cmd .= " , ";
      $cmd .= " './elodie_bd444548.dat' index 0 ";
      $cmd .= "    using (\$1):(\$2*24.0) ";
      $cmd .= "    t 'BD+44 4548' ";
      $cmd .= "    with lines lw 2 lt 1 lc -1 ";
    
  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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

    
      ####################################################################
      #  Spectra of several stars of different spectral class from Elodie
      #      with labels for spectral class
      #
      # get the arguments
      $output_file = "./elodie_d.ps";
      $term_options = "postscript color enhanced 'Helvetica,22' ";
    
      $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 size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
#      printf CMDFILE "set key top right Left \n";
      printf CMDFILE "set nokey \n";
      printf CMDFILE "set xlabel 'Wavelength (Angstroms) ' \n";
      printf CMDFILE "set ylabel 'Flam (arbitrary units)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set label 1 at 5001,20000 'BD+44 4548  (M2V)' \n";
      printf CMDFILE "set label 2 at 5001,160000 '51 Peg   (G2.5V) ' \n";
      printf CMDFILE "set label 3 at 5001,440000 'HD 27808   (F8V) ' \n";
      printf CMDFILE "set label 4 at 5001,560000 'eps Aur  (O8Iab) ' \n";

      
      $cmd = "plot [5000:5020][] ";
      $cmd .= " './elodie_epsaur.dat' index 0 ";
      $cmd .= "    using (\$1):(100000+\$2*1.0) ";
      $cmd .= "    t 'eps Aug' ";
      $cmd .= "    with lines lw 2 lt 1 lc 1 ";
      $cmd .= " , ";
      $cmd .= " './elodie_hd27808.dat' index 0 ";
      $cmd .= "    using (\$1):(100000+\$2*1.5) ";
      $cmd .= "    t 'HD 27808' ";
      $cmd .= "    with lines lw 2 lt 1 lc 3 ";
      $cmd .= " , ";
      $cmd .= " './elodie_51peg.dat' index 0 ";
      $cmd .= "    using (\$1):(100000+\$2*8.0) ";
      $cmd .= "    t '51 Peg' ";
      $cmd .= "    with lines lw 2 lt 1 lc 4 ";
      $cmd .= " , ";
      $cmd .= " './elodie_bd444548.dat' index 0 ";
      $cmd .= "    using (\$1):(\$2*24.0) ";
      $cmd .= "    t 'BD+44 4548' ";
      $cmd .= "    with lines lw 2 lt 1 lc -1 ";
    
  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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

    
    
}
    
    
if (0 == 1) {

      ####################################################################
      #  HARPS spectrum of BD 184914 -- very closeup around 5010.8 Angstroms
      #    with a pseudo-fitted absorption line
      #
      # get the arguments
      $output_file = "./bd184914_f.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";
      printf CMDFILE "set size 1.0,1.0 \n";
      printf CMDFILE "set grid \n";
      printf CMDFILE "set key bot left Left reverse \n";
      printf CMDFILE "set xlabel 'Wavelength (Angstroms) ' \n";
      printf CMDFILE "set ylabel 'Flux (arbitrary units)' \n";
      printf CMDFILE "set title '' \n";
      printf CMDFILE "set arrow 1 from 5010.745,60 to 5010.745,63.5 \n";

      # this is only an approximate model, fit by eye
      printf CMDFILE "A = 1.5 \n";
      printf CMDFILE "c = 5010.745 \n";
      printf CMDFILE "s = 0.02 \n";
      printf CMDFILE "f(x) = 65.5-A*exp(-(x-c)*(x-c)/(s*s)) \n";
      
      $cmd = "plot [5010.6:5011.0][] ";
      $cmd .= " './excerpt.txt' index 0 ";
      $cmd .= "    t '' ";
      $cmd .= "    with linespoints lw 2 pt 5 ps 0.8 lt 1 lc 1 ";
      $cmd .= " , ";
      $cmd .= " f(x) with lines lc 3 lw 2  t '' \n";

    
  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/.eps/.png/;
    $giffile =~ s/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }

}

    
    




exit 0;
