#!/usr/bin/perl
#
  
  ###############################################################
  #  Make a graph showing luminosity distance as a function of
  #     redshift on linear graph
  #     Here, we vary the Hubble constant value
  #
  $output_file = "lumdist_nearby_a.ps";
  $term_options = "postscript enhanced color 'Helvetica,18' ";
  $cmdfile = "gnuplot.in";
  
  open (CMDFILE, ">$cmdfile") || die("can't open $cmdfile for writing");
  printf CMDFILE "set output '$output_file' \n";
  printf CMDFILE "set term $term_options \n";
  printf CMDFILE "set grid \n";
  printf CMDFILE "set key top left \n";
  #printf CMDFILE "set logscale x \n";
  #printf CMDFILE "set logscale y \n";
  #printf CMDFILE "set xtics (2000,4000,6000) \n";
  #printf CMDFILE "set ytics (0.4,0.8,1.0,4.0) \n";
  printf CMDFILE "set xlabel 'Redshift z ' \n";
  printf CMDFILE "set ylabel 'Distance (Mpc) ' \n";
  printf CMDFILE "set title 'Luminosity distance for {/Symbol W}_M = 1.0, {/Symbol W}_{/Symbol L} = 0' \n";

  
  $cmd = "plot [0.0001:0.01][] './lumdist_01.00_00.00_0030.0.dat' using 1:6 ";
  $cmd .= "  with lines   lt 1 lc 1 lw 3 ";
  $cmd .= "      t 'H_0 = 30 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_01.00_00.00_0050.0.dat' using 1:6 ";
  $cmd .= "  with lines   lt 1 lc 2 lw 3 ";
  $cmd .= "      t 'H_0 = 50 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_01.00_00.00_0070.0.dat' using 1:6 ";
  $cmd .= "  with lines   lt 1 lc 3 lw 3 ";
  $cmd .= "      t 'H_0 = 70 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_01.00_00.00_0090.0.dat' using 1:6 ";
  $cmd .= "  with lines   lt 1 lc 4 lw 3 ";
  $cmd .= "      t 'H_0 = 90 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_01.00_00.00_0110.0.dat' using 1:6 ";
  $cmd .= "  with lines   lt 1 lc 5 lw 3 ";
  $cmd .= "      t 'H_0 = 110'  ";


  

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


  ###############################################################
  #  Make a graph showing luminosity distance as a function of
  #     redshift on linear graph
  #     Here, we present a puzzle for the student:
  #          estimate the Hubble parameter from the data
  #
  $output_file = "lumdist_nearby_a2.ps";
  $term_options = "postscript enhanced color 'Helvetica,18' ";
  $cmdfile = "gnuplot.in";
  
  open (CMDFILE, ">$cmdfile") || die("can't open $cmdfile for writing");
  printf CMDFILE "set output '$output_file' \n";
  printf CMDFILE "set term $term_options \n";
  printf CMDFILE "set grid \n";
  printf CMDFILE "set key top left \n";
  #printf CMDFILE "set logscale x \n";
  #printf CMDFILE "set logscale y \n";
  #printf CMDFILE "set xtics (2000,4000,6000) \n";
  #printf CMDFILE "set ytics (0.4,0.8,1.0,4.0) \n";
  printf CMDFILE "set xlabel 'Redshift z ' \n";
  printf CMDFILE "set ylabel 'Distance (Mpc) ' \n";
  printf CMDFILE "set title 'Luminosity distance for {/Symbol W}_{/Symbol L} = 0' \n";

  
  $cmd = "plot [0.0001:0.01][] './lumdist_01.00_00.00_0090.0.dat' using 1:6 ";
  $cmd .= "  with lines   lt 1 lc 1 lw 3 ";
  $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/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }


  ###############################################################
  #  Make a graph showing luminosity distance as a function of
  #     redshift on linear graph
  #     Here, we vary the Omega_m value
  #
  $output_file = "lumdist_nearby_b.ps";
  $term_options = "postscript enhanced color 'Helvetica,18' ";
  $cmdfile = "gnuplot.in";
  
  open (CMDFILE, ">$cmdfile") || die("can't open $cmdfile for writing");
  printf CMDFILE "set output '$output_file' \n";
  printf CMDFILE "set term $term_options \n";
  printf CMDFILE "set grid \n";
  printf CMDFILE "set key top left \n";
  #printf CMDFILE "set logscale x \n";
  #printf CMDFILE "set logscale y \n";
  #printf CMDFILE "set xtics (2000,4000,6000) \n";
  #printf CMDFILE "set ytics (0.4,0.8,1.0,4.0) \n";
  printf CMDFILE "set xlabel 'Redshift z ' \n";
  printf CMDFILE "set ylabel 'Distance (Mpc) ' \n";
  printf CMDFILE "set title 'Luminosity distance for H_0 = 70 km/s/Mpc, {/Symbol W}_{/Symbol L} = 0' \n";

  
  $cmd = "plot [0.0001:0.01][] './lumdist_00.20_00.00_0070.0.dat' using 1:6 ";
  $cmd .= "  with lines   lt 1 lc 1 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 0.20 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_00.50_00.00_0070.0.dat' using 1:6 ";
  $cmd .= "  with lines   lt 1 lc 2 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 0.50 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_01.00_00.00_0070.0.dat' using 1:6 ";
  $cmd .= "  with lines   lt 1 lc 3 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 1.00 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_02.00_00.00_0070.0.dat' using 1:6 ";
  $cmd .= "  with lines   lt 1 lc 4 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 2.00 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_10.00_00.00_0070.0.dat' using 1:6 ";
  $cmd .= "  with lines   lt 1 lc 5 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 10.00 '  ";


  

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


  ###############################################################
  #  Make a graph showing luminosity distance as a function of
  #     redshift on linear graph
  #     Here, we vary the Omega_m value
  #
  $output_file = "lumdist_distant_a.ps";
  $term_options = "postscript enhanced color 'Helvetica,18' ";
  $cmdfile = "gnuplot.in";
  
  open (CMDFILE, ">$cmdfile") || die("can't open $cmdfile for writing");
  printf CMDFILE "set output '$output_file' \n";
  printf CMDFILE "set term $term_options \n";
  printf CMDFILE "set grid \n";
  printf CMDFILE "set key bot right \n";
  #printf CMDFILE "set logscale x \n";
  #printf CMDFILE "set logscale y \n";
  #printf CMDFILE "set xtics (2000,4000,6000) \n";
  #printf CMDFILE "set ytics (0.4,0.8,1.0,4.0) \n";
  printf CMDFILE "set xlabel 'Redshift z ' \n";
  printf CMDFILE "set ylabel 'Distance modulus ' \n";
  printf CMDFILE "set title 'Luminosity distance for H_0 = 70 km/s/Mpc, {/Symbol W}_{/Symbol L} = 0' \n";

  
  $cmd = "plot [0.0001:1.0][] './lumdist_00.20_00.00_0070.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 1 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 0.20 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_00.50_00.00_0070.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 2 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 0.50 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_01.00_00.00_0070.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 3 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 1.00 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_02.00_00.00_0070.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 4 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 2.00 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_10.00_00.00_0070.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 5 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 10.00 '  ";


  

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



  ###############################################################
  #  Make a graph showing luminosity distance as a function of
  #     redshift on LOGARITHMIC graph
  #     Here, we vary the Omega_m value
  #
  $output_file = "lumdist_distant_b.ps";
  $term_options = "postscript enhanced color 'Helvetica,18' ";
  $cmdfile = "gnuplot.in";
  
  open (CMDFILE, ">$cmdfile") || die("can't open $cmdfile for writing");
  printf CMDFILE "set output '$output_file' \n";
  printf CMDFILE "set term $term_options \n";
  printf CMDFILE "set grid \n";
  printf CMDFILE "set key bot right \n";
  printf CMDFILE "set logscale x \n";
  #printf CMDFILE "set logscale y \n";
  #printf CMDFILE "set xtics (2000,4000,6000) \n";
  #printf CMDFILE "set ytics (0.4,0.8,1.0,4.0) \n";
  printf CMDFILE "set xlabel 'Redshift z ' \n";
  printf CMDFILE "set ylabel 'Distance modulus ' \n";
  printf CMDFILE "set title 'Luminosity distance for H_0 = 70 km/s/Mpc, {/Symbol W}_{/Symbol L} = 0' \n";

  
  $cmd = "plot [0.0008:1.0][] './lumdist_00.20_00.00_0070.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 1 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 0.20 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_00.50_00.00_0070.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 2 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 0.50 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_01.00_00.00_0070.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 3 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 1.00 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_02.00_00.00_0070.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 4 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 2.00 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_10.00_00.00_0070.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 5 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 10.00 '  ";


  

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


  ###############################################################
  #  Make a graph showing luminosity distance as a function of
  #     redshift on linear graph
  #     Here, we vary the Omega_m value, 
  #     and zoom in on region of interest: 0.3 < z < 1.5, say
  #
  $output_file = "lumdist_distant_c.ps";
  $term_options = "postscript enhanced color 'Helvetica,18' ";
  $cmdfile = "gnuplot.in";
  
  open (CMDFILE, ">$cmdfile") || die("can't open $cmdfile for writing");
  printf CMDFILE "set output '$output_file' \n";
  printf CMDFILE "set term $term_options \n";
  printf CMDFILE "set grid \n";
  printf CMDFILE "set key bot right \n";
  #printf CMDFILE "set logscale x \n";
  #printf CMDFILE "set logscale y \n";
  #printf CMDFILE "set xtics (2000,4000,6000) \n";
  #printf CMDFILE "set ytics (0.4,0.8,1.0,4.0) \n";
  printf CMDFILE "set xlabel 'Redshift z ' \n";
  printf CMDFILE "set ylabel 'Distance modulus ' \n";
  printf CMDFILE "set title 'Luminosity distance for H_0 = 70 km/s/Mpc, {/Symbol W}_{/Symbol L} = 0' \n";

  
  $cmd = "plot [0.3:1.5][40:43.2] './lumdist_00.20_00.00_0070.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 1 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 0.20 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_00.50_00.00_0070.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 2 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 0.50 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_01.00_00.00_0070.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 3 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 1.00 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_02.00_00.00_0070.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 4 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 2.00 '  ";
#  $cmd .= " , ";
#  $cmd .= " './lumdist_10.00_00.00_0070.0.dat' using 1:5 ";
#  $cmd .= "  with lines   lt 1 lc 5 lw 3 ";
#  $cmd .= "      t '{/Symbol W}_M = 10.00 '  ";


  

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



  ###############################################################
  #  Make a graph showing luminosity distance as a function of
  #     redshift on linear graph
  #     Here, we vary the Hubble constant value
  #     This shows H0 not interesting for large z
  #
  $output_file = "lumdist_distant_d.ps";
  $term_options = "postscript enhanced color 'Helvetica,18' ";
  $cmdfile = "gnuplot.in";
  
  open (CMDFILE, ">$cmdfile") || die("can't open $cmdfile for writing");
  printf CMDFILE "set output '$output_file' \n";
  printf CMDFILE "set term $term_options \n";
  printf CMDFILE "set grid \n";
  printf CMDFILE "set key bot right \n";
  #printf CMDFILE "set logscale x \n";
  printf CMDFILE "set logscale y \n";
  #printf CMDFILE "set xtics (2000,4000,6000) \n";
  #printf CMDFILE "set ytics (0.4,0.8,1.0,4.0) \n";
  printf CMDFILE "set xlabel 'Redshift z ' \n";
  printf CMDFILE "set ylabel 'Distance (Mpc) ' \n";
  printf CMDFILE "set title 'Luminosity distance for {/Symbol W}_M = 1.0, {/Symbol W}_{/Symbol L} = 0' \n";

  
  $cmd = "plot [0.0001:10][500:20000] './lumdist_01.00_00.00_0030.0.dat' using 1:6 ";
  $cmd .= "  with lines   lt 1 lc 1 lw 3 ";
  $cmd .= "      t 'H_0 = 30 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_01.00_00.00_0050.0.dat' using 1:6 ";
  $cmd .= "  with lines   lt 1 lc 2 lw 3 ";
  $cmd .= "      t 'H_0 = 50 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_01.00_00.00_0070.0.dat' using 1:6 ";
  $cmd .= "  with lines   lt 1 lc 3 lw 3 ";
  $cmd .= "      t 'H_0 = 70 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_01.00_00.00_0090.0.dat' using 1:6 ";
  $cmd .= "  with lines   lt 1 lc 4 lw 3 ";
  $cmd .= "      t 'H_0 = 90 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_01.00_00.00_0110.0.dat' using 1:6 ";
  $cmd .= "  with lines   lt 1 lc 5 lw 3 ";
  $cmd .= "      t 'H_0 = 110'  ";


  

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


  ###############################################################
  #  Make a graph showing distance modulus as a function of
  #     redshift on linear graph
  #     Here, we vary the Hubble constant value
  #     This shows H0 not interesting for large z
  #
  $output_file = "lumdist_distant_e.ps";
  $term_options = "postscript enhanced color 'Helvetica,18' ";
  $cmdfile = "gnuplot.in";
  
  open (CMDFILE, ">$cmdfile") || die("can't open $cmdfile for writing");
  printf CMDFILE "set output '$output_file' \n";
  printf CMDFILE "set term $term_options \n";
  printf CMDFILE "set grid \n";
  printf CMDFILE "set key bot right \n";
  #printf CMDFILE "set logscale x \n";
  #printf CMDFILE "set logscale y \n";
  #printf CMDFILE "set xtics (2000,4000,6000) \n";
  #printf CMDFILE "set ytics (0.4,0.8,1.0,4.0) \n";
  printf CMDFILE "set xlabel 'Redshift z ' \n";
  printf CMDFILE "set ylabel 'Distance modulus (m - M)' \n";
  printf CMDFILE "set title 'Luminosity distance for {/Symbol W}_M = 1.0, {/Symbol W}_{/Symbol L} = 0' \n";

  
  $cmd = "plot [0.0001:10][35:47] './lumdist_01.00_00.00_0030.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 1 lw 3 ";
  $cmd .= "      t 'H_0 = 30 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_01.00_00.00_0050.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 2 lw 3 ";
  $cmd .= "      t 'H_0 = 50 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_01.00_00.00_0070.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 3 lw 3 ";
  $cmd .= "      t 'H_0 = 70 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_01.00_00.00_0090.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 4 lw 3 ";
  $cmd .= "      t 'H_0 = 90 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_01.00_00.00_0110.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 5 lw 3 ";
  $cmd .= "      t 'H_0 = 110'  ";


  

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


  ###############################################################
  #  Make a graph showing luminosity distance as a function of
  #     redshift on linear graph
  #     Here, we vary the Omega_m value, 
  #     and zoom in on region of interest: 0.3 < z < 1.5, say
  #
  $output_file = "lumdist_distant_f.ps";
  $term_options = "postscript enhanced color 'Helvetica,18' ";
  $cmdfile = "gnuplot.in";
  
  open (CMDFILE, ">$cmdfile") || die("can't open $cmdfile for writing");
  printf CMDFILE "set output '$output_file' \n";
  printf CMDFILE "set term $term_options \n";
  printf CMDFILE "set grid \n";
  printf CMDFILE "set key bot right \n";
  #printf CMDFILE "set logscale x \n";
  #printf CMDFILE "set logscale y \n";
  #printf CMDFILE "set xtics (2000,4000,6000) \n";
  #printf CMDFILE "set ytics (0.4,0.8,1.0,4.0) \n";
  printf CMDFILE "set xlabel 'Redshift z ' \n";
  printf CMDFILE "set ylabel 'Distance modulus ' \n";
  printf CMDFILE "set title 'Luminosity distance for H_0 = 70 km/s/Mpc, {/Symbol W}_{/Symbol L} = 0' \n";

  
  $cmd = "plot [0.0001:10][35:47] './lumdist_00.20_00.00_0070.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 1 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 0.20 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_00.50_00.00_0070.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 2 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 0.50 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_01.00_00.00_0070.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 3 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 1.00 '  ";
  $cmd .= " , ";
  $cmd .= " './lumdist_02.00_00.00_0070.0.dat' using 1:5 ";
  $cmd .= "  with lines   lt 1 lc 4 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 2.00 '  ";
#  $cmd .= " , ";
#  $cmd .= " './lumdist_10.00_00.00_0070.0.dat' using 1:5 ";
#  $cmd .= "  with lines   lt 1 lc 5 lw 3 ";
#  $cmd .= "      t '{/Symbol W}_M = 10.00 '  ";


  

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



  ###############################################################
  #  Make a graph showing difference in distance modulus
  #     as a function of redshift on linear graph
  #     Here, we vary the Omega_m value, 
  #
  $output_file = "lumdist_delta_a.ps";
  $term_options = "postscript enhanced color 'Helvetica,18' ";
  $cmdfile = "gnuplot.in";
  
  open (CMDFILE, ">$cmdfile") || die("can't open $cmdfile for writing");
  printf CMDFILE "set output '$output_file' \n";
  printf CMDFILE "set term $term_options \n";
  printf CMDFILE "set grid \n";
  printf CMDFILE "set key top left \n";
  #printf CMDFILE "set logscale x \n";
  #printf CMDFILE "set logscale y \n";
  #printf CMDFILE "set xtics (2000,4000,6000) \n";
  #printf CMDFILE "set ytics (0.4,0.8,1.0,4.0) \n";
  printf CMDFILE "set xlabel 'Redshift z ' \n";
  printf CMDFILE "set ylabel 'Difference in distance modulus from {/Symbol W}_M = 1' \n";
  printf CMDFILE "set title 'Luminosity distance for H_0 = 70 km/s/Mpc, {/Symbol W}_{/Symbol L} = 0' \n";

  
  $cmd = "plot [0.0:1.5][] './delta_lumdist_00.20_01.00.dat' using 1:(\$5-\$11) ";
  $cmd .= "  with lines   lt 1 lc 1 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 0.20 '  ";
  $cmd .= " , ";
  $cmd .= " './delta_lumdist_00.50_01.00.dat' using 1:(\$5-\$11) ";
  $cmd .= "  with lines   lt 1 lc 2 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 0.50 '  ";
  $cmd .= " , ";
  $cmd .= " './delta_lumdist_01.00_01.00.dat' using 1:(\$5-\$11) ";
  $cmd .= "  with lines   lt 1 lc 3 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 1.00 '  ";
  $cmd .= " , ";
  $cmd .= " './delta_lumdist_02.00_01.00.dat' using 1:(\$5-\$11) ";
  $cmd .= "  with lines   lt 1 lc 4 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 2.00 '  ";


  

  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;

  
  ###############################################################
  #  Make a graph showing angular distance as function 
  #     of distance for ordinary Euclidean space
  #     This time, use logarithmic axes
  #
  $output_file = "angdist_euclid_log.ps";
  $term_options = "postscript enhanced color 'Helvetica,18' ";
  $cmdfile = "gnuplot.in";
  
  open (CMDFILE, ">$cmdfile") || die("can't open $cmdfile for writing");
  printf CMDFILE "set output '$output_file' \n";
  printf CMDFILE "set term $term_options \n";
  printf CMDFILE "set grid \n";
  printf CMDFILE "set key top right \n";
  printf CMDFILE "set logscale x \n";
  printf CMDFILE "set logscale y \n";
  #printf CMDFILE "set xtics (2000,4000,6000) \n";
  #printf CMDFILE "set ytics (0.4,0.8,1.0,4.0) \n";
  printf CMDFILE "set xlabel 'Distance from Joe to meterstick (m) ' \n";
  printf CMDFILE "set ylabel 'Angular diameter of stick (radians) ' \n";
  printf CMDFILE "set title 'Alice carries a meterstick on a soccer pitch' \n";

  
  $cmd = "plot [ 8:120][0.008:0.15] './make_angdist_soccer.out' using 1:2 ";
  $cmd .= "  with points  pt 4 ps 1.5 lt 1 lc 1 lw 3 ";
  $cmd .= "      t ''  ";
  $cmd .= " , ";
  $cmd .= "  (1.0/x) with lines lt 2 lc -1 t '1 / distance' ";


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


  ###############################################################
  #  Make a graph showing angular distance as function 
  #     of redshift for limiting cases of small and large z
  #
  $output_file = "angdist_limit_cases.ps";
  $term_options = "postscript enhanced color 'Helvetica,18' ";
  $cmdfile = "gnuplot.in";
  
  open (CMDFILE, ">$cmdfile") || die("can't open $cmdfile for writing");
  printf CMDFILE "set output '$output_file' \n";
  printf CMDFILE "set term $term_options \n";
  printf CMDFILE "set grid \n";
  printf CMDFILE "set key top right \n";
  printf CMDFILE "set logscale x \n";
  printf CMDFILE "set logscale y \n";
  #printf CMDFILE "set xtics (2000,4000,6000) \n";
  #printf CMDFILE "set ytics (0.4,0.8,1.0,4.0) \n";
  printf CMDFILE "set xlabel 'redshift z ' \n";
  printf CMDFILE "set ylabel 'Angular diameter of object (radians) ' \n";
  printf CMDFILE "set title 'Limiting cases for an object of fixed size' \n";
  printf CMDFILE "set label 1 at 0.02,0.5 '{/Symbol q \\265} z^{-1}' \n";
  printf CMDFILE "set label 2 at 3.0,0.05 '{/Symbol q \\265} z^{0.5}' \n";

  
  $cmd = "plot [0.005:20][] './make_angdist_limits.out' index 0 using 1:2 ";
  $cmd .= "  with points  pt 4 ps 1.5 lt 1 lc 1 lw 3 ";
  $cmd .= "      t ''  ";
  $cmd .= " , ";
  $cmd .= "  './make_angdist_limits.out' index 1 using 1:2 ";
  $cmd .= "  with points  pt 6 ps 1.5 lt 1 lc 3 lw 3 ";
  $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/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }



  ###############################################################
  #  Make a graph showing angular distance as function 
  #     of redshift for various values of Omega
  #
  $output_file = "angdist_for_omega.ps";
  $term_options = "postscript enhanced color 'Helvetica,18' ";
  $cmdfile = "gnuplot.in";
  
  open (CMDFILE, ">$cmdfile") || die("can't open $cmdfile for writing");
  printf CMDFILE "set output '$output_file' \n";
  printf CMDFILE "set term $term_options \n";
  printf CMDFILE "set grid \n";
  printf CMDFILE "set key bot left \n";
  printf CMDFILE "set logscale x \n";
  printf CMDFILE "set logscale y \n";
  #printf CMDFILE "set xtics (2000,4000,6000) \n";
  #printf CMDFILE "set ytics (0.4,0.8,1.0,4.0) \n";
  printf CMDFILE "set xlabel 'redshift z ' \n";
  printf CMDFILE "set ylabel 'Angular diameter of object (arbitrary units) ' \n";
  printf CMDFILE "set title 'The angular diameter test (assuming {/Symbol W}_{/Symbol L} = 0) ' \n";
  #printf CMDFILE "set label 1 at 0.02,0.5 '{/Symbol q \\265} z^{-1}' \n";
  #printf CMDFILE "set label 2 at 3.0,0.05 '{/Symbol q \\265} z^{0.5}' \n";

  
  $cmd = "plot [0.005:50][1.5:110] './generate_angdist.out' index 0 using 1:2 ";
  $cmd .= "  with lines  lt 1 lc 1 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 0.1'  ";
  $cmd .= " , ";
  $cmd .= "                  './generate_angdist.out' index 0 using 1:3 ";
  $cmd .= "  with lines  lt 1 lc 2 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 0.5'  ";
  $cmd .= " , ";
  $cmd .= "                  './generate_angdist.out' index 0 using 1:4 ";
  $cmd .= "  with lines  lt 1 lc 3 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 1.0'  ";
  $cmd .= " , ";
  $cmd .= "                  './generate_angdist.out' index 0 using 1:5 ";
  $cmd .= "  with lines  lt 1 lc 4 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 2.0'  ";
  $cmd .= " , ";
  $cmd .= "                  './generate_angdist.out' index 0 using 1:6 ";
  $cmd .= "  with lines  lt 1 lc 5 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 10.0'  ";
  $cmd .= " , ";
  $cmd .= "                  './generate_angdist.out' index 1 using 1:2 ";
  $cmd .= "  with points  pt 5 ps 1.0 lt 1 lc 1 lw 3 ";
  $cmd .= "      t ''  ";
  $cmd .= " , ";
  $cmd .= "                  './generate_angdist.out' index 2 using 1:3 ";
  $cmd .= "  with points  pt 5 ps 1.0 lt 1 lc 2 lw 3 ";
  $cmd .= "      t ''  ";
  $cmd .= " , ";
  $cmd .= "                  './generate_angdist.out' index 3 using 1:4 ";
  $cmd .= "  with points  pt 5 ps 1.0 lt 1 lc 3 lw 3 ";
  $cmd .= "      t ''  ";
  $cmd .= " , ";
  $cmd .= "                  './generate_angdist.out' index 4 using 1:5 ";
  $cmd .= "  with points  pt 5 ps 1.0 lt 1 lc 4 lw 3 ";
  $cmd .= "      t ''  ";
  $cmd .= " , ";
  $cmd .= "                  './generate_angdist.out' index 5 using 1:6 ";
  $cmd .= "  with points  pt 5 ps 1.0 lt 1 lc 5 lw 3 ";
  $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/.ps/.png/;
    $cmd = "convert -rotate 90 $psfile $giffile";
    printf "cmd is ..$cmd.. \n";
    $ret = `$cmd`;
  }






exit 0;

  
  ###############################################################
  #  Make a graph showing scale factor as function of time
  #     for open, critical, closed values of Omega_M
  #     Zoom in on time near present
  #
  $output_file = "scale_omegam_b.ps";
  $term_options = "postscript enhanced color 'Helvetica,18' ";
  $cmdfile = "gnuplot.in";
  
  open (CMDFILE, ">$cmdfile") || die("can't open $cmdfile for writing");
  printf CMDFILE "set output '$output_file' \n";
  printf CMDFILE "set term $term_options \n";
  printf CMDFILE "set grid \n";
  printf CMDFILE "set key top left \n";
  #printf CMDFILE "set logscale x \n";
  #printf CMDFILE "set logscale y \n";
  #printf CMDFILE "set xtics (2000,4000,6000) \n";
  #printf CMDFILE "set ytics (0.4,0.8,1.0,4.0) \n";
  printf CMDFILE "set xlabel 'Time (Hubble times from present) ' \n";
  printf CMDFILE "set ylabel 'Scale factor a' \n";
  printf CMDFILE "set title 'Newtonian universe with matter only ' \n";

  
  $cmd = "plot [-0.5:0.5][] './scale_3.50.dat' using 1:9 ";
  $cmd .= "  with points  pt 4 ps 0.3 lt 1 lc 1 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 3.5'  ";
  $cmd .= " , ";
  $cmd .= "                 './scale_1.00.dat' using 1:9 ";
  $cmd .= "  with points  pt 4 ps 0.3 lt 1 lc -1 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 1.0'  ";
  $cmd .= " , ";
  $cmd .= "                 './scale_0.20.dat' using 1:9 ";
  $cmd .= "  with points  pt 4 ps 0.3 lt 1 lc 3 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 0.2'  ";

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

  
  ###############################################################
  #  Make a graph showing redshift as function of time
  #     for open, critical, closed values of Omega_M
  #
  $output_file = "redshift_time.ps";
  $term_options = "postscript enhanced color 'Helvetica,18' ";
  $cmdfile = "gnuplot.in";
  
  open (CMDFILE, ">$cmdfile") || die("can't open $cmdfile for writing");
  printf CMDFILE "set output '$output_file' \n";
  printf CMDFILE "set term $term_options \n";
  printf CMDFILE "set grid \n";
  printf CMDFILE "set key bot left \n";
  #printf CMDFILE "set logscale x \n";
  #printf CMDFILE "set logscale y \n";
  #printf CMDFILE "set xtics (2000,4000,6000) \n";
  #printf CMDFILE "set ytics (0.4,0.8,1.0,4.0) \n";
  printf CMDFILE "set xlabel 'Time (Hubble times from present) ' \n";
  printf CMDFILE "set ylabel 'redshift z' \n";
  printf CMDFILE "set title 'Newtonian universe with matter only ' \n";

  
  $cmd = "plot [-1.0:-0.001][0.0:9.9] './scale_3.50.dat' using 1:11 ";
  $cmd .= "  with points  pt 4 ps 0.5 lt 1 lc 1 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 3.5'  ";
  $cmd .= " , ";
  $cmd .= "                 './scale_1.00.dat' using 1:11 ";
  $cmd .= "  with points  pt 4 ps 0.5 lt 1 lc -1 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 1.0'  ";
  $cmd .= " , ";
  $cmd .= "                 './scale_0.20.dat' using 1:11 ";
  $cmd .= "  with points  pt 4 ps 0.5 lt 1 lc 3 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 0.2'  ";

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

  
  ###############################################################
  #  Make a graph showing proper distance as function of redshift
  #     for open, critical, closed values of Omega_M
  #
  $output_file = "propdist_z.ps";
  $term_options = "postscript enhanced color 'Helvetica,18' ";
  $cmdfile = "gnuplot.in";
  
  open (CMDFILE, ">$cmdfile") || die("can't open $cmdfile for writing");
  printf CMDFILE "set output '$output_file' \n";
  printf CMDFILE "set term $term_options \n";
  printf CMDFILE "set grid \n";
  printf CMDFILE "set key top left \n";
  #printf CMDFILE "set logscale x \n";
  #printf CMDFILE "set logscale y \n";
  #printf CMDFILE "set xtics (2000,4000,6000) \n";
  #printf CMDFILE "set ytics (0.4,0.8,1.0,4.0) \n";
  printf CMDFILE "set xlabel 'redshift z' \n";
  printf CMDFILE "set ylabel 'proper distance (Mpc)' \n";
  printf CMDFILE "set title 'Newtonian universe with matter only, H_0 = 70 ' \n";

  
  $cmd = "plot [-0.03:0.6][] './calc_omega.out' using 2:8 ";
  $cmd .= "  with linespoints  pt 4 ps 0.5 lt 1 lc 1 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 3.5'  ";
  $cmd .= " , ";
  $cmd .= "                 './calc_omega.out' using 2:6 ";
  $cmd .= "  with linespoints  pt 4 ps 0.5 lt 1 lc -1 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 1.0'  ";
  $cmd .= " , ";
  $cmd .= "                 './calc_omega.out' using 2:4 ";
  $cmd .= "  with linespoints  pt 4 ps 0.5 lt 1 lc 3 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 0.2'  ";

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


  
  ###############################################################
  #  Make a graph showing proper distance as function of redshift
  #     for open, critical, closed values of Omega_M
  #     Closeup on very small distances.
  #
  $output_file = "propdist_z_2.ps";
  $term_options = "postscript enhanced color 'Helvetica,18' ";
  $cmdfile = "gnuplot.in";
  
  open (CMDFILE, ">$cmdfile") || die("can't open $cmdfile for writing");
  printf CMDFILE "set output '$output_file' \n";
  printf CMDFILE "set term $term_options \n";
  printf CMDFILE "set grid \n";
  printf CMDFILE "set key top left \n";
  #printf CMDFILE "set logscale x \n";
  #printf CMDFILE "set logscale y \n";
  #printf CMDFILE "set xtics (2000,4000,6000) \n";
  #printf CMDFILE "set ytics (0.4,0.8,1.0,4.0) \n";
  printf CMDFILE "set xlabel 'redshift z' \n";
  printf CMDFILE "set ylabel 'proper distance (Mpc)' \n";
  printf CMDFILE "set title 'Newtonian universe with matter only, H_0 = 70 ' \n";

  
  $cmd = "plot [-0.003:0.06][] './calc_omega.out' using 2:8 ";
  $cmd .= "  with linespoints  pt 4 ps 0.5 lt 1 lc 1 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 3.5'  ";
  $cmd .= " , ";
  $cmd .= "                 './calc_omega.out' using 2:6 ";
  $cmd .= "  with linespoints  pt 4 ps 0.5 lt 1 lc -1 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 1.0'  ";
  $cmd .= " , ";
  $cmd .= "                 './calc_omega.out' using 2:4 ";
  $cmd .= "  with linespoints  pt 4 ps 0.5 lt 1 lc 3 lw 3 ";
  $cmd .= "      t '{/Symbol W}_M = 0.2'  ";

  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;
