function wv_out = new_wave_grid(cba, n_pix)
% function new_wave_grid(cba)
%	Produces a wavelength grid generated from the paramters a,b,c
%	(where pixel# = a + b*lambda + c*lambda^2, lambda = wavelength (nm))
%	Handles the linear (c = 0) and quadractic (c > 0) cases.

%	ARGUMENTS:
%		cba		vector containing params a,b,c
%					format: [c b a] (MatLab polynomial format)
%		n_pix		# of pixels on the CCD
%
%	LAST MODIFIED: July 14 / 00

i = 1:1:n_pix;

if cba(1) == 0
   wv_out = (i - cba(3))./cba(2);
elseif cba(1) > 0
   wv_out = (-cba(2) + sqrt(cba(2)^2 - 4*cba(1)*(cba(3) - i)))/(2*cba(1));
else	% if c < 0 (c = cba(1)) then something is wrong
   disp('NEW_WAVE_GRID: Error, c < 0.')
   return
end
