input_dir = '/home/eleanor/data/WOD/wod05/'; filename1 = 'ocldb1169076334.845.'; % FAROES SMALL rep = [4 1 4 1 3]; filename1 = 'ocldb1170103337.8037.'; % FAROES BIG rep = [25 1 19 2 12]; inst = ['CTD';'DRB';'OSD';'PFL';'XBT']; filename1 = 'ocldb1170866160.12282.'; % LABRADOR SEA input_dir = '/home/eleanor/data/WOD/wod05/labsea/'; output_dir = '/home/eleanor/matlab/bin/glider/WOD/wod05/mat/'; % CTD, CTD2, CTD3, CTD4, DRB, OSD, OSD2, OSD3, OSD4,PFL, XBT, XBT2, XBT3 inst = ['DRB';'OSD';'PFL';'XBT';'MBT';'CTD']; inst = ['DRB';'PFL';'OSD';'XBT';'MBT';'CTD'] rep = [1 11 12 16 34 56]; % DRB, PFL, OSD, XBT,MBT, CTD for Lab sea rep = [1 11 12 16 34 56]; % CRASHED ON OSD7, data(:,11) L 99, depth= %rep = [4 1 4 1 3]; ext4 = '.csv'; %% Make sure all the data files exist first for ff = 1:length(inst) for rr = 1:rep(ff) if rr==1 filename2 = inst(ff,:); else filename2 = [inst(ff,:),num2str(rr)]; end filename = [filename1,filename2]; longfile = [input_dir,filename,ext4]; fid=fopen(longfile); if fid==-1 disp(['Missing file ',longfile]); end fclose(fid); end end disp('All data files exist.'); disp('Type any key to continue...'); pause %% Clean files disp('Cleaning...') qdo=0; for ff = 1:length(inst) for rr = 1:rep(ff) if rr==1 filename2 = inst(ff,:); else filename2 = [inst(ff,:),num2str(rr)]; end filename = [filename1,filename2]; ext4 = '.csv'; replace_str =' '; find_str = '---.---'; tic file_clean = clean_files(input_dir,filename,ext4,find_str,replace_str,input_dir); qdo=qdo+1; time1(qdo)=toc; avetime = mean(time1); disp(['Cleaned ',filename,' in ',num2str(time1(qdo)),'. Ave time = ',num2str(avetime)]); end end disp('All data files are cleaned of ---.---'); disp('Type any key to continue...'); pause %% Read cleaned .csv files and write to .mat for ff = 1:length(inst) for rr = 1:rep(ff) if rr==1 filename2 = inst(ff,:); else filename2 = [inst(ff,:),num2str(rr)]; end file_clean = [filename1,filename2,'C']; % if ~exist([output_dir,file_clean,'.mat']) disp(['Parsing ',file_clean]); read_ocldb_write_mat(input_dir,file_clean,output_dir,inst(ff,:)); % end end end disp('All data files have been parsed to .mat'); disp('Type any key to continue...'); pause %% Create huge array structure, all_cast zdo=0; for ff = 1:length(inst) for rr = 1:rep(ff) if rr==1 filename2 = inst(ff,:); else filename2 = [inst(ff,:),num2str(rr)]; end file_clean = [filename1,filename2,'C']; eval(['load ',output_dir,file_clean,'.mat']); % cast1=cast; % eval(['save ',output_dir,file_clean,'.mat cast1']); CC = length(cast1); all_cast(zdo+1:zdo+CC) = cast1(1:CC); zdo=zdo+CC end end disp('All casts have been loaded into variable all_cast') disp('Type "save allcast_long.mat all_cast to save the variable');