Ac9tosb E.m

From Pnb
Revision as of 12:52, 17 March 2011 by Eriks (talk | contribs) (Created page with '<pre> function ac9tosb_E(cruise) % useage: ac9tosb('pb##'); %latest % This file loads up the mat file produced in the ac9 processing and % produces a flat ascii file needed for …')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
function ac9tosb_E(cruise)
% useage: ac9tosb('pb##');
%latest
% This file loads up the mat file produced in the ac9 processing and 
% produces a flat ascii file needed for producing SEABASS files for the
% ac9.  The flat ascii files are stored in /home/data65/pb/SEABASS/ac9/sbin_tiho.
%Modified by T. Kostadinov to read in the calibarted, TS and scatter
%correted AC9 data from downcasts. 

ac9_path=strcat('/home/data65/pb/REPROCESS_2010/AC9/',cruise,'/final/');
ac9matfiles =[];
matfiles=what(ac9_path);
for i=1:size(matfiles.mat,1),
    isdowncast=findstr(char(matfiles.mat(i)),'.lcd.1.');
    if isempty(isdowncast)==0
        ac9matfiles=[ac9matfiles; char(matfiles.mat(i))];
    end
end

for i=1:size(ac9matfiles,1),
    eval(['load ',strcat(ac9_path,ac9matfiles(i,:))]);
    use_ac9struct(ac9,ac9matfiles(i,:),cruise); 
    
end

function use_ac9struct(str,filename,cruise)
wv_hdr=str.debug.par.wavelength;
other_fields=cellstr('depth');
for i=1:size(wv_hdr,2),
    a_fields(i)=cellstr(strcat('a',num2str(wv_hdr(i))));
    c_fields(i)=cellstr(strcat('c',num2str(wv_hdr(i))));
end
fields=[other_fields a_fields c_fields cellstr('bin_depth')];
%matrix_out=[str.ac9data.rac9depth str.out.a_cal, str.out.c_cal ...
        %str.ac9data.intdepth]; %This line chnaged by Tiho
matrix_out=[str.ac9data.rac9depth str.out.a_scorr1, str.out.c_corr ...
        str.ac9data.intdepth];
yr=filename(6:7);
mon=filename(8:9);
dy=filename(10:11);
st=filename(12:12);

outname=strcat('ac9_',yr,mon,dy,st,'_',cruise,'.sbin');
outpath='/home/data65/pb/REPROCESS_2010/SEABASS/ac9/sbin/';
fid=fopen(strcat(outpath,outname),'w');
fprintf(fid,'#%s\n',filename);
for i=1:size(fields,2)
    fprintf(fid,'#%s\n',char(fields(i)));
end
for i=1:size(matrix_out,1),
    for j=1:size(matrix_out,2),
        fprintf(fid,'%e ',matrix_out(i,j));
    end
    fprintf(fid,'\n','');
end
display(['Printing to file ',strcat(outpath,outname)]);
fclose(fid);

ac9tosb