% script for testing levenberg-marquardt method using the resid function.
% Steps:
%	-	read in data from daily reference and absolute reference files
%	-	shift/stretch - ie use lsqnonlin with marq method and resid function

global file_nms std_name lowest

% Globals from INIT.M:
global n_abs n_pix abs_gas

% Read in absolute reference spectrum:
fid = fopen(strcat(dir.ip, std_name), 'r');
tic
for i = 1:1:3
   fgetl(fid);
end
% Initialize array:
ref = zeros(1,n_pix);
continue = 1;
i = 0;
while ~feof(fid)
   i = i + 1;
   ref(i) = fscanf(fid,'%8f',1);
   fgetl(fid);
   %if feof(fid)
   %   continue = 0;
   %end
end
toc
tic
frewind(fid);
for i = 1:1:3
   fgetl(fid);
end
for i = 1:1:n_pix
   ref(i) = fscanf(fid,'%8f',1);
   fgetl(fid);
end
toc
i
fclose(fid);

