function [ws,wd,Rsel,fracsel,winds,windd,rain,namb,ambsel,frac,wfr,qaflag,mle] = loadL2RBYU(filename)
%
%[fs,fd,is,id,winds,windd,inits,initd,consflag,init_ambsel,final_ambsel] = loadL2RBYU(filename) 
%
% load BYU L2R ultra high resolution simultaneous wind/rain file
%

% load entire L2R file
[winds,windd,rain,namb,ambsel,mle,qaflag,percent_rain,wvc_row,...
      rain_conf,wvcsel_opt,setsel_opt,regime,winds1,windd1,namb1] = ... 
    read_sds(filename,'wind_speed','wind_dir','rain_rate','num_ambigs', ... 
    'wvc_selection','max_likelihood_est','wvc_quality_flag','percent_rain',...
    'wvc_row','rain_confidence_flag','wvc_selection_opt','set_selection_opt',...
    'regime','wind_speed1','wind_dir1','num_ambigs1');

Z = zeros(size(rain));
M = size(namb,1);
N = size(namb,2);

[ws,wd] = find_pw_amb_sel(ambsel,winds,windd,M,N);
[Rsel,temp] = find_pw_amb_sel(ambsel,rain,rain,M,N);
[fracsel,mlesel] = find_pw_amb_sel(ambsel,percent_rain,mle,M,N);
fracsel = fracsel/100;

% if no output variables specified, create output arrays
if nargout == 0
  assignin('caller','ws',ws);
  assignin('caller','wd',wd);
  assignin('caller','Rsel',Rsel);
  assignin('caller','winds',winds);
  assignin('caller','windd',windd);
  assignin('caller','rain',rain);
  assignin('caller','namb',namb);
  assignin('caller','ambsel',ambsel);
  assignin('caller','frac',percent_rain/100);
  assignin('caller','fracsel',fracsel);  
  assignin('caller','qaflag',qaflag)
  assignin('caller','mle',mle)
end


disp(['Swath loaded']);


