Difference between revisions of "Ac9tosb E.m"
Jump to navigation
Jump to search
| Line 1: | Line 1: | ||
| + | Modified by ES 5-31-2016 | ||
| + | |||
<pre> | <pre> | ||
function ac9tosb_E(cruise) | function ac9tosb_E(cruise) | ||
| Line 5: | Line 7: | ||
% This file loads up the mat file produced in the ac9 processing and | % 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 | % produces a flat ascii file needed for producing SEABASS files for the | ||
| − | % ac9. | + | % ac9. .sbin files are written to a folder in the "final" folder location |
| − | + | % of the ac9 files. | |
| − | % | ||
| − | ac9_path=strcat('/home/data65/pb/ | + | %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 =[]; | ac9matfiles =[]; | ||
| − | matfiles=what(ac9_path) | + | matfiles=what(ac9_path) |
for i=1:size(matfiles.mat,1), | for i=1:size(matfiles.mat,1), | ||
isdowncast=findstr(char(matfiles.mat(i)),'.lcd.1.'); | isdowncast=findstr(char(matfiles.mat(i)),'.lcd.1.'); | ||
| Line 20: | Line 25: | ||
for i=1:size(ac9matfiles,1), | for i=1:size(ac9matfiles,1), | ||
| − | eval(['load ',strcat(ac9_path,ac9matfiles(i,:))]); | + | eval(['load ',strcat(ac9_path,'/',ac9matfiles(i,:))]); |
use_ac9struct(ac9,ac9matfiles(i,:),cruise); | use_ac9struct(ac9,ac9matfiles(i,:),cruise); | ||
| Line 41: | Line 46: | ||
dy=filename(10:11); | dy=filename(10:11); | ||
st=filename(12:12); | st=filename(12:12); | ||
| − | + | mkdir([pwd,'/sbin']); | |
| + | outpath = [pwd,'/sbin/']; | ||
outname=strcat('ac9_',yr,mon,dy,st,'_',cruise,'.sbin'); | outname=strcat('ac9_',yr,mon,dy,st,'_',cruise,'.sbin'); | ||
| − | outpath='/home/data65/pb/ | + | %outpath='/home/data65/pb/SEABASS/ac9/sbin/'; |
| − | fid=fopen(strcat(outpath,outname),'w'); | + | %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); | fprintf(fid,'#%s\n',filename); | ||
for i=1:size(fields,2) | for i=1:size(fields,2) | ||
| Line 57: | Line 66: | ||
display(['Printing to file ',strcat(outpath,outname)]); | display(['Printing to file ',strcat(outpath,outname)]); | ||
fclose(fid); | fclose(fid); | ||
| + | |||
</pre> | </pre> | ||
[[ac9tosb_E]] | [[ac9tosb_E]] | ||
Latest revision as of 10:41, 31 May 2016
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);