Ac9tosb E.m
Jump to navigation
Jump to search
Modified by ES 5-31-2016
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. .sbin files are written to a folder in the "final" folder location % of the ac9 files. %ac9_path=strcat('/home/data65/pb/AC9/',cruise,'/final/'); disp('Run this script in the AC9 "final" folder that contains .mat files') pause(3); %ac9_path = strcat('/home/eriks/OCEANCOLOR_PNB/Plumes_and_Blooms/AC9/',cruise,'/final/'); ac9_path = pwd; 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); mkdir([pwd,'/sbin']); outpath = [pwd,'/sbin/']; outname=strcat('ac9_',yr,mon,dy,st,'_',cruise,'.sbin'); %outpath='/home/data65/pb/SEABASS/ac9/sbin/'; %outpath='/home/eriks/OCEANCOLOR_PNB/Plumes_and_Blooms/SEABASS/AC9/sbin/' %mkdir('../','sbin'); %fid=fopen(strcat(outpath,outname),'w'); 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);