#!/usr/bin/perl
# 


# plot showing changes in filter 8B number 2 
$title = "Changes in magnitudes of stars observed in filter 8B number 2 (center 500 nm)";
$cmdfile = "make_results_plots_8b_a.gnu";
$psfile = "make_results_plots_8b_a.ps";
open(CMDFILE, ">$cmdfile") || die("can't open $cmdfile");
printf CMDFILE "set output '$psfile' \n";
printf CMDFILE "set term postscript color \n";
printf CMDFILE "set grid \n";
printf CMDFILE "set key top left \n";
printf CMDFILE "set xlabel 'Shift in central wavelength (nm)' \n";
printf CMDFILE "set ylabel 'Change in apparent magnitude '  \n";
printf CMDFILE "set title '$title'  \n";
printf CMDFILE "plot [-45:45][-0.4:0.4] ";
printf CMDFILE " 'result_o5v_b8_2.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'O5V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_b0v_b8_2.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'B0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_a0v_b8_2.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'A0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_f0v_b8_2.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'F0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_g0v_b8_2.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'G0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_k0v_b8_2.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'K0V' lt 7 ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_m0v_b8_2.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'M0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_m5v_b8_2.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'M5V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 0 with lines lt -1 t '' ";
printf CMDFILE " \n";

printf CMDFILE "quit \n";
close(CMDFILE);

$cmd = "gnuplot $cmdfile ";
printf "cmd is ..$cmd.. \n";
$ret = `$cmd`;
$giffile = $psfile;
$giffile =~ s/.ps/.gif/;
$cmd = "convert -rotate 90 $psfile $giffile";
printf "cmd is ..$cmd.. \n";
$ret = `$cmd`;


# plot showing changes in filter b6
$title = "Changes in magnitudes of stars observed in filter 8B number 6 (center 1050 nm)";
$cmdfile = "make_results_plots_8b_b.gnu";
$psfile = "make_results_plots_8b_b.ps";
open(CMDFILE, ">$cmdfile") || die("can't open $cmdfile");
printf CMDFILE "set output '$psfile' \n";
printf CMDFILE "set term postscript color \n";
printf CMDFILE "set grid \n";
printf CMDFILE "set key top left \n";
printf CMDFILE "set xlabel 'Shift in central wavelength (nm)' \n";
printf CMDFILE "set ylabel 'Change in apparent magnitude '  \n";
printf CMDFILE "set title '$title'  \n";
printf CMDFILE "plot [-45:45][-0.4:0.4] ";
printf CMDFILE " 'result_o5v_b8_6.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'O5V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_b0v_b8_6.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'B0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_a0v_b8_6.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'A0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_f0v_b8_6.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'F0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_g0v_b8_6.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'G0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_k0v_b8_6.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'K0V' lt 7 ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_m0v_b8_6.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'M0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_m5v_b8_6.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'M5V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 0 with lines lt -1 t '' ";
printf CMDFILE " \n";

printf CMDFILE "quit \n";
close(CMDFILE);

$cmd = "gnuplot $cmdfile ";
printf "cmd is ..$cmd.. \n";
$ret = `$cmd`;
$giffile = $psfile;
$giffile =~ s/.ps/.gif/;
$cmd = "convert -rotate 90 $psfile $giffile";
printf "cmd is ..$cmd.. \n";
$ret = `$cmd`;


# plot showing changes in filter b8
$title = "Changes in magnitudes of stars observed in filter 8B number 8 (center 1400 nm)";
$cmdfile = "make_results_plots_8b_c.gnu";
$psfile = "make_results_plots_8b_c.ps";
open(CMDFILE, ">$cmdfile") || die("can't open $cmdfile");
printf CMDFILE "set output '$psfile' \n";
printf CMDFILE "set term postscript color \n";
printf CMDFILE "set grid \n";
printf CMDFILE "set key top left \n";
printf CMDFILE "set xlabel 'Shift in central wavelength (nm)' \n";
printf CMDFILE "set ylabel 'Change in apparent magnitude '  \n";
printf CMDFILE "set title '$title'  \n";
printf CMDFILE "plot [-45:45][-0.4:0.4] ";
printf CMDFILE " 'result_o5v_b8_8.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'O5V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_b0v_b8_8.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'B0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_a0v_b8_8.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'A0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_f0v_b8_8.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'F0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_g0v_b8_8.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'G0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_k0v_b8_8.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'K0V' lt 7 ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_m0v_b8_8.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'M0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_m5v_b8_8.dat' using ((\$1*0.1)):(\$2) ";
printf CMDFILE "     with points t 'M5V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 0 with lines lt -1 t '' ";
printf CMDFILE " \n";

printf CMDFILE "quit \n";
close(CMDFILE);

$cmd = "gnuplot $cmdfile ";
printf "cmd is ..$cmd.. \n";
$ret = `$cmd`;
$giffile = $psfile;
$giffile =~ s/.ps/.gif/;
$cmd = "convert -rotate 90 $psfile $giffile";
printf "cmd is ..$cmd.. \n";
$ret = `$cmd`;


#  now plots showing changes as function of FRACTIONAL shift in central wavelength
#
# plot showing changes in filter 8B number 2 
$center_lam = 5027.0;
$title = "Changes in magnitudes of stars observed in filter 8B number 2 (center 503 nm)";
$cmdfile = "make_results_plots_8b_d.gnu";
$psfile = "make_results_plots_8b_d.ps";
open(CMDFILE, ">$cmdfile") || die("can't open $cmdfile");
printf CMDFILE "set output '$psfile' \n";
printf CMDFILE "set term postscript color \n";
printf CMDFILE "set grid \n";
printf CMDFILE "set key top left \n";
printf CMDFILE "set xlabel 'Fractional shift in central wavelength (percent)' \n";
printf CMDFILE "set ylabel 'Change in apparent magnitude '  \n";
printf CMDFILE "set title '$title'  \n";
printf CMDFILE "plot [-3:3][-0.3:0.3] ";
printf CMDFILE " 'result_o5v_b8_2.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'O5V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_b0v_b8_2.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'B0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_a0v_b8_2.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'A0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_f0v_b8_2.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'F0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_g0v_b8_2.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'G0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_k0v_b8_2.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'K0V' lt 7 ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_m0v_b8_2.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'M0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_m5v_b8_2.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'M5V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 0 with lines lt -1 t '' ";
printf CMDFILE " \n";

printf CMDFILE "quit \n";
close(CMDFILE);

$cmd = "gnuplot $cmdfile ";
printf "cmd is ..$cmd.. \n";
$ret = `$cmd`;
$giffile = $psfile;
$giffile =~ s/.ps/.gif/;
$cmd = "convert -rotate 90 $psfile $giffile";
printf "cmd is ..$cmd.. \n";
$ret = `$cmd`;



#
# plot showing changes in filter 8B number 6 
$center_lam = 10459.0;
$title = "Changes in magnitudes of stars observed in filter 8B number 6 (center 1046 nm)";
$cmdfile = "make_results_plots_8b_e.gnu";
$psfile = "make_results_plots_8b_e.ps";
open(CMDFILE, ">$cmdfile") || die("can't open $cmdfile");
printf CMDFILE "set output '$psfile' \n";
printf CMDFILE "set term postscript color \n";
printf CMDFILE "set grid \n";
printf CMDFILE "set key top left \n";
printf CMDFILE "set xlabel 'Fractional shift in central wavelength (percent)' \n";
printf CMDFILE "set ylabel 'Change in apparent magnitude '  \n";
printf CMDFILE "set title '$title'  \n";
printf CMDFILE "plot [-3:3][-0.3:0.3] ";
printf CMDFILE " 'result_o5v_b8_6.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'O5V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_b0v_b8_6.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'B0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_a0v_b8_6.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'A0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_f0v_b8_6.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'F0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_g0v_b8_6.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'G0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_k0v_b8_6.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'K0V' lt 7 ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_m0v_b8_6.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'M0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_m5v_b8_6.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'M5V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 0 with lines lt -1 t '' ";
printf CMDFILE " \n";

printf CMDFILE "quit \n";
close(CMDFILE);

$cmd = "gnuplot $cmdfile ";
printf "cmd is ..$cmd.. \n";
$ret = `$cmd`;
$giffile = $psfile;
$giffile =~ s/.ps/.gif/;
$cmd = "convert -rotate 90 $psfile $giffile";
printf "cmd is ..$cmd.. \n";
$ret = `$cmd`;



#
# plot showing changes in filter 8B number 8 
$center_lam = 15086.0;
$title = "Changes in magnitudes of stars observed in filter 8B number 8 (center 1509 nm)";
$cmdfile = "make_results_plots_8b_f.gnu";
$psfile = "make_results_plots_8b_f.ps";
open(CMDFILE, ">$cmdfile") || die("can't open $cmdfile");
printf CMDFILE "set output '$psfile' \n";
printf CMDFILE "set term postscript color \n";
printf CMDFILE "set grid \n";
printf CMDFILE "set key top left \n";
printf CMDFILE "set xlabel 'Fractional shift in central wavelength (percent)' \n";
printf CMDFILE "set ylabel 'Change in apparent magnitude '  \n";
printf CMDFILE "set title '$title'  \n";
printf CMDFILE "plot [-3:3][-0.3:0.3] ";
printf CMDFILE " 'result_o5v_b8_8.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'O5V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_b0v_b8_8.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'B0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_a0v_b8_8.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'A0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_f0v_b8_8.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'F0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_g0v_b8_8.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'G0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_k0v_b8_8.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'K0V' lt 7 ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_m0v_b8_8.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'M0V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 'result_m5v_b8_8.dat' using ((\$1/$center_lam)*100):(\$2) ";
printf CMDFILE "     with points t 'M5V' ps 1.5 lw 3  ";
printf CMDFILE " , ";
printf CMDFILE " 0 with lines lt -1 t '' ";
printf CMDFILE " \n";

printf CMDFILE "quit \n";
close(CMDFILE);

$cmd = "gnuplot $cmdfile ";
printf "cmd is ..$cmd.. \n";
$ret = `$cmd`;
$giffile = $psfile;
$giffile =~ s/.ps/.gif/;
$cmd = "convert -rotate 90 $psfile $giffile";
printf "cmd is ..$cmd.. \n";
$ret = `$cmd`;





exit 0;
