Met Visibility MATLAB Implementation

function [visibility, status] = compute_visibility ( raw_counts, cals )
% COMPUTE_VISIBILITY:  computes visibility product from raw instrument counts
%
% USAGE:  [visibility, status] = compute_visibility ( raw_counts, cals );
%
% PARAMETERS:
% Input:
%    raw_counts:  
%       in raw engineering units as produced in met buffer 
%    cals:
%       calibration coefficients
% Output:
%    visibility: 
%       units are meters, maximum value of 3000
%    status:
%       -1 for failure
%            

status = -1;

visibility = cals(1) ...
           + cals(2)*raw_counts  ...
		   + cals(3)*raw_counts.^2  ...
		   + cals(4)*raw_counts.^3;

status = 1;
return