# / / / / / / / / / / / / / / /
#   make_standard_file.pl
# / / / / / / / / / / / / / / /
#
# This program will open up an ESO magnitudes file with just two columns,
# the wavelength and AB magnitudes, and it will produce a file which can
# be used to run the IRAF task standard.
#
# It is run like this:
#    % perl make_standard_file.pl standard_file_input > standard_file_output
# 


# First, let's get the input ESO file:
$eso_input_file = "$ARGV[0]";

open(INF, "$eso_input_file") || die("ESO input file $eso_input_file not found");
	$k=0;
	while ($aline=<INF>) {
		chop $aline;
		($wavelength[$k], $magnitude[$k])=split(' ',$aline);
		$k++;
	}
	$anum=$k;
close (INF);

$n_lines = scalar(@wavelength);

for($w = 0; $w < $n_lines-1; $w++){

	$bandwidth[$w] = $wavelength[$w+1]-$wavelength[$w];

	printf "$wavelength[$w] $magnitude[$w] %.3f \n", $bandwidth[$w];

}
