0001 function varargout = load_bl(cruiseid)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 error(nargchk(1,1,nargin))
0034
0035
0036 group = group_name(cruiseid);
0037
0038
0039 if ispref(group,'cal_bl_dir')
0040 bl_dir=getpref(group,'cal_bl_dir');
0041 else
0042 error(['The cal_bl_dir preference was not set for cruise: ' cruiseid '. Run register_cruise.m']);
0043 end
0044
0045
0046 if ispref(group,'cal_data_dir')
0047 cruise_dir=getpref(group,'cal_data_dir');
0048 else
0049 error(['The cal_data_dir preference was not set for cruise: ' cruiseid '. Run register_cruise.m']);
0050 end
0051
0052
0053
0054 lc_bl = dir(fullfile(bl_dir,'*.bl'));
0055 uc_bl = dir(fullfile(bl_dir,'*.BL'));
0056
0057 if isempty(lc_bl) & isempty(uc_bl)
0058 error(['No *.bl or *.BL files were found in ', bl_dir]);
0059 end
0060 if isequal(lc_bl,uc_bl)
0061 bl_names = lc_bl;
0062 else
0063 if ~isempty(lc_bl) & ~isempty(uc_bl)
0064 error(['The *.bl files in ', bl_dir...
0065 ,' are named in both upper and lower case. Pick one and rename before running ',mfilename]);
0066 elseif isempty(lc_bl) & ~isempty(uc_bl)
0067 bl_names = uc_bl;
0068 elseif ~isempty(lc_bl) & isempty(uc_bl)
0069 bl_names = lc_bl;
0070 else
0071 error(['No *.bl or *.BL files were found in ', bl_dir]);
0072 end
0073 end
0074
0075
0076 for i=1:length(bl_names)
0077 tmp = read_sbebl(fullfile(bl_dir,bl_names(i).name));
0078 if ~isempty(tmp)
0079 bl(i)=tmp;
0080 else
0081
0082 end
0083 end
0084
0085
0086 if ~exist('bl','var') | isempty(bl)
0087 error('The bl output structure does not exist or is empty.')
0088 end
0089
0090
0091 db_file = fullfile(cruise_dir,[cruiseid '_db.mat']);
0092 if exist(db_file)==2
0093 save(db_file,'bl','-append');
0094 else
0095 save(db_file,'bl');
0096 end
0097 if nargout==0
0098 assignin('caller','ans',bl);
0099 return
0100 else
0101 varargout{1}=bl;
0102 return
0103 end
0104
0105
0106