#!/usr/bin/perl
#

$JDBASE = 2455000;

  my($output_file, $term_options);



###################################################################
#  Graph of student values

  # get the arguments
  $output_file = "./simple_diffs.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 grid \n";
  # printf CMDFILE "set key 1563.84,0.60 \n";
  printf CMDFILE "set ylabel 'Differential magnitude' \n";
  printf CMDFILE "set xlabel 'image number ' \n";
  printf CMDFILE "set title 'Field of IY UMa, simple differential photometry '\n";
  
  $cmd = "plot [0:100][3.5:-1] ";
  $cmd .=  "   './simple_diffs.dat' using (\$1+10):2 lt 1 lc 1 lw 3 t 'A-A' ";
  $cmd .= " , ";
  $cmd .=  "   './simple_diffs.dat' using (\$1+10):3 lt 1 lc 2 lw 3 t 'B-A' ";
  $cmd .= " , ";
  $cmd .=  "   './simple_diffs.dat' using (\$1+10):4 lt 1 lc 3 lw 3 t 'IY-A' ";

  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;

