0001 function [btl_struct]=read_sbebtl(btl_file,varargin);
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
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063 if nargin == 2
0064 time_offset = varargin{1};
0065 else
0066 time_offset = 0;
0067 end
0068
0069
0070
0071 fid=fopen(btl_file,'rt');
0072 if fid < 0
0073 disp(['WARNING: read_sbebtl could not open ',btl_file]);
0074 btl=[];
0075 return
0076 end
0077
0078
0079
0080
0081
0082
0083
0084
0085 str='*START*';
0086
0087
0088
0089
0090
0091 choose_nmea = 0;
0092
0093 while (strncmp(str,'#',1) | strncmp(str,'*',1));
0094 str=remove233(fgetl(fid));
0095
0096
0097
0098
0099 if (strncmp(str,'* NMEA Lat',10))
0100 choose_nmea = 1;
0101 is=findstr(str,'=');
0102 isub=is+1:length(str);
0103 dm=sscanf(str(isub),'%f',2);
0104 if(findstr(str(isub),'N'));
0105 lat=dm(1)+dm(2)/60;
0106 else
0107 lat=-(dm(1)+dm(2)/60);
0108 end
0109
0110
0111
0112
0113 elseif (strncmp(str,'* NMEA Lon',10))
0114 choose_nmea = 1;
0115 is=findstr(str,'=');
0116 isub=is+1:length(str);
0117 dm=sscanf(str(isub),'%f',2);
0118 if(findstr(str(isub),'E'));
0119 lon=dm(1)+dm(2)/60;
0120 else
0121 lon=-(dm(1)+dm(2)/60);
0122 end
0123
0124
0125
0126
0127 elseif (strncmp(str,'** Lat',6))
0128 if choose_nmea == 0
0129 is=findstr(str,':');
0130 isub=is+1:length(str);
0131 dm=sscanf(str(isub),'%f',2);
0132 if(findstr(str(isub),'N'));
0133 if length(dm) == 2
0134 lat=dm(1)+dm(2)/60;
0135 else
0136 lat = dm(1);
0137 end
0138 else
0139 if length(dm) == 2
0140 lat=-(dm(1)+dm(2)/60);
0141 else
0142 lat = -(dm(1));
0143 end
0144
0145 end
0146 end
0147
0148
0149
0150
0151 elseif (strncmp(str,'** Lon',6))
0152 if choose_nmea == 0
0153 is=findstr(str,':');
0154 isub=is+1:length(str);
0155 dm=sscanf(str(isub),'%f',2);
0156 if(findstr(str(isub),'E'));
0157 if length(dm) == 2
0158 lon =dm(1)+dm(2)/60;
0159 else
0160 lon = dm(1);
0161 end
0162 else
0163 if length(dm) == 2
0164 lon=-(dm(1)+dm(2)/60);
0165 else
0166 lon = -(dm(1));
0167 end
0168
0169 end
0170 end
0171
0172
0173
0174
0175
0176
0177 elseif (strncmp(str,'* System UpLoad',15))
0178 is=findstr(str,'=');
0179
0180 datstr=[str(is+6:is+7) '-' str(is+2:is+4) '-' str(is+9:is+12)];
0181 datstr=[datstr ' ' str(is+14:is+21)];
0182
0183 n=datenum(datstr)+time_offset/24;
0184 gtime=datevec(n);
0185
0186
0187
0188
0189
0190 elseif (strncmp(str,'* NMEA UTC',10))
0191 is=findstr(str,':');
0192 isub=is(1)-2:length(str);
0193 gtime([4:6])=sscanf(str(isub),'%2d:%2d:%2d');
0194
0195
0196
0197
0198 elseif (strncmp(str,'# name',6))
0199 var=sscanf(str(7:10),'%d',1);
0200 var=var+1;
0201
0202 names{var}=str;
0203
0204
0205
0206
0207 elseif (strncmp(str,'# sensor',8))
0208 sens=sscanf(str(10:11),'%d',1);
0209 sens=sens+1;
0210
0211 sensors{sens}=str;
0212
0213
0214 elseif (strncmp(str,'# bad_flag',10))
0215 isub=13:length(str);
0216 bad_flag=sscanf(str(isub),'%g',1);
0217 end
0218 end
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230 col_headings = str;
0231 column_names1 = strread(col_headings,'%s','delimiter',' ');
0232 col_headings = remove233(fgetl(fid));
0233 column_names2 = strread(col_headings,'%s','delimiter',' ');
0234
0235 Nbf_flag=strmatch('Nbf',column_names1)|strmatch('Nbf',column_names2);
0236
0237
0238 if isempty(Nbf_flag)
0239 msg = sprintf('\n');
0240 msg = [msg sprintf([' WARNING read_sbebtl: There is no Nbf column in file: ',btl_file,' \n'])];
0241 msg = [msg sprintf([' Rerun rossum and configure to print number of bottles fired.\n'])];
0242 msg = [msg sprintf([' Trying to continue anyway...\n'])];
0243 msg = [msg sprintf('\n')];
0244 disp(msg);
0245 end
0246
0247
0248
0249
0250 count = 1;
0251 while ~feof(fid)
0252 str = remove233(fgetl(fid));
0253 avgcell{count} = strread(str,'%s' ,'delimiter',' ');
0254
0255 tmp = avgcell{count};
0256 tmp{end} = [];
0257 avgcell{count} = tmp;
0258 str = remove233(fgetl(fid));
0259 stdcell{count} = strread(str,'%s' ,'delimiter',' ');
0260
0261 tmp = stdcell{count};
0262 tmp{end} = [];
0263 stdcell{count} = tmp;
0264 count = count+1;
0265 end
0266
0267
0268
0269
0270 offset = 0;
0271 column_count = 0;
0272 for i = 1:length(column_names1)
0273 if strncmp('Bottle',column_names1{i},6);
0274 column_count = column_count + 1;
0275 btl_pos_idx = column_count + offset;
0276 end;
0277 if strncmp('Date',column_names1{i},4);
0278 column_count = column_count + 1;
0279 date_idx = column_count;
0280 offset = 2;
0281 end;
0282 if strncmp('Density00',column_names1{i},9);
0283 column_count = column_count + 1;
0284 pri_pri_dens_idx = column_count + offset;
0285 end;
0286 if strncmp('Density11',column_names1{i},9);
0287 column_count = column_count + 1;
0288 sec_sec_dens_idx = column_count + offset;
0289 end;
0290 if strncmp('Density01',column_names1{i},9);
0291 column_count = column_count + 1;
0292 pri_sec_dens_idx = column_count + offset;
0293 end;
0294 if strncmp('Density10',column_names1{i},9);
0295 column_count = column_count + 1;
0296 sec_pri_dens_idx = column_count + offset;
0297 end;
0298 if strncmp('Sigma-',column_names1{i},6);
0299
0300
0301
0302 sig = column_names1{i};
0303 if strncmp('00',sig(end-1:end),2)
0304 column_count = column_count + 1;
0305 pri_pri_sig_idx = column_count + offset;
0306 elseif strncmp('11',sig(end-1:end),2)
0307 column_count = column_count + 1;
0308 sec_sec_sig_idx = column_count + offset;
0309 elseif strncmp('10',sig(end-1:end),2)
0310 column_count = column_count + 1;
0311 sec_pri_sig_idx = column_count + offset;
0312 elseif strncmp('01',sig(end-1:end),2)
0313 column_count = column_count + 1;
0314 pri_sec_sig_idx = column_count + offset;
0315 end
0316 end;
0317
0318 if strncmp('pr',lower(column_names1{i}),2);
0319 column_count = column_count + 1;
0320 pr_idx = column_count + offset;
0321 end;
0322 if strncmp('T068',column_names1{i},4);
0323 column_count = column_count + 1;
0324 pri_t68_idx = column_count + offset;
0325 end;
0326 if strncmp('T168',column_names1{i},4);
0327 column_count = column_count + 1;
0328 sec_t68_idx = column_count + offset;
0329 end;
0330 if strncmp('T090',column_names1{i},4);
0331 column_count = column_count + 1;
0332 pri_t90_idx = column_count + offset;
0333 end;
0334 if strncmp('T190',column_names1{i},4);
0335 column_count = column_count + 1;
0336 sec_t90_idx = column_count + offset;
0337 end;
0338 if strncmp('Sal00',column_names1{i},5);
0339 column_count = column_count + 1;
0340 pri_pri_sal_idx = column_count + offset;
0341 end;
0342 if strncmp('Sal11',column_names1{i},5);
0343 column_count = column_count + 1;
0344 sec_sec_sal_idx = column_count + offset;
0345 end;
0346 if strncmp('Sal01',column_names1{i},5);
0347 column_count = column_count + 1;
0348 pri_sec_sal_idx = column_count + offset;
0349 end;
0350 if strncmp('Sal10',column_names1{i},5);
0351 column_count = column_count + 1;
0352 sec_pri_sal_idx = column_count + offset;
0353 end;
0354 if strncmp('C0S/m',column_names1{i},5);
0355 column_count = column_count + 1;
0356 pri_con_idx = column_count + offset;
0357 end;
0358 if strncmp('C1S/m',column_names1{i},5);
0359 column_count = column_count + 1;
0360 sec_con_idx = column_count + offset;
0361 end;
0362 if strncmp('C0mS/cm',column_names1{i},5);
0363 column_count = column_count + 1;
0364 pri_con_idx = column_count + offset;
0365 end;
0366 if strncmp('C1mS/cm',column_names1{i},5);
0367 column_count = column_count + 1;
0368 sec_con_idx = column_count + offset;
0369 end;
0370 if strncmp('OxC',column_names1{i},3);
0371 column_count = column_count + 1;
0372 pri_oxc_idx = column_count + offset;
0373 end;
0374 if strncmp('OxsC',column_names1{i},4);
0375 column_count = column_count + 1;
0376 sec_oxc_idx = column_count + offset;
0377 end;
0378 if strncmp('OxT',column_names1{i},3);
0379 column_count = column_count + 1;
0380 pri_oxt_idx = column_count + offset;
0381 end;
0382 if strncmp('OxsT',column_names1{i},4);
0383 column_count = column_count + 1;
0384 sec_oxt_idx = column_count + offset;
0385 end;
0386 if strncmp('OxMm/Kg',column_names1{i},7);
0387 column_count = column_count + 1;
0388 pri_do2_mmkg_idx = column_count + offset;
0389 end;
0390 if strncmp('OxsMm/Kg',column_names1{i},8);
0391 column_count = column_count + 1;
0392 sec_do2_mmkg_idx = column_count + offset;
0393 end;
0394 if strncmp('Sbeox0Mm/Kg',column_names1{i},11);
0395 column_count = column_count + 1;
0396 pri_sbedo2_mmkg_idx = column_count + offset;
0397 end;
0398 if strncmp('Sbeox1Mm/Kg',column_names1{i},11);
0399 column_count = column_count + 1;
0400 sec_sbedo2_mmkg_idx = column_count + offset;
0401 end;
0402 if strncmp('OxdOC/dT',column_names1{i},8);
0403 column_count = column_count + 1;
0404 pri_odocdt_idx = column_count + offset;
0405 end;
0406 if strncmp('OxsdOC/dT',column_names1{i},9);
0407 column_count = column_count + 1;
0408 sec_odocdt_idx = column_count + offset;
0409 end;
0410 if strncmp('Sbeox0ML/L',column_names1{i},10);
0411 column_count = column_count + 1;
0412 pri_sbedo2_mll_idx = column_count + offset;
0413 end;
0414 if strncmp('Sbeox1ML/L',column_names1{i},10);
0415 column_count = column_count + 1;
0416 sec_sbedo2_mll_idx = column_count + offset;
0417 end;
0418 if strncmp('OxML/L',column_names1{i},6);
0419 column_count = column_count + 1;
0420 pri_do2_mll_idx = column_count + offset;
0421 end;
0422 if strncmp('OxsML/L',column_names1{i},7);
0423 column_count = column_count + 1;
0424 sec_do2_mll_idx = column_count + offset;
0425 end;
0426 if strncmp('Nbf',column_names1{i},3);
0427 column_count = column_count + 1;
0428 btl_fired_idx = column_count + offset;
0429 end;
0430
0431 if strncmp('Potemp090C',column_names1{i},10);
0432 column_count = column_count + 1;
0433 pot_temp_pri_idx = column_count + offset;
0434 end;
0435 if strncmp('Potemp190C',column_names1{i},10);
0436 column_count = column_count + 1;
0437 pot_temp_sec_idx = column_count + offset;
0438 end;
0439 if strncmp('Sbeox0PS',column_names1{i},8);
0440 column_count = column_count + 1;
0441 sbeox_pct_sat_pri_idx = column_count + offset;
0442 end;
0443 if strncmp('Sbeox1PS',column_names1{i},8);
0444 column_count = column_count + 1;
0445 sbeox_pct_sat_sec_idx = column_count + offset;
0446 end;
0447 if strncmp('Sbeox0dOC/dT',column_names1{i},12);
0448 column_count = column_count + 1;
0449 pri_sbedOC_dt_idx = column_count + offset;
0450 end;
0451 if strncmp('Sbeox1dOC/dT',column_names1{i},12);
0452 column_count = column_count + 1;
0453 sec_sbedOC_dt_idx = column_count + offset;
0454 end;
0455 if strncmp('Sbeox0V',column_names1{i},7);
0456 column_count = column_count + 1;
0457 pri_sbeox_volt_idx = column_count + offset;
0458 end;
0459 if strncmp('Sbeox1V',column_names1{i},7);
0460 column_count = column_count + 1;
0461 sec_sbeox_volt_idx = column_count + offset;
0462 end;
0463 if strncmp('Scan',column_names1{i},4);
0464 column_count = column_count + 1;
0465 scan_idx = column_count + offset;
0466 end;
0467 if strncmp('OxPS',column_names1{i},4);
0468 column_count = column_count + 1;
0469 pct_sat_idx = column_count + offset;
0470 end;
0471 if strncmp('OxsPS',column_names1{i},4);
0472 column_count = column_count + 1;
0473 pct_sat_sec_idx = column_count + offset;
0474 end;
0475
0476
0477 end
0478 column_count2 = 0;
0479 for i = 1:length(column_names2);
0480 if strncmp('Position',column_names2{i},8)
0481
0482 elseif strncmp('Time',column_names2{i},4)
0483 column_count2 = column_count2 + 1;
0484 time_idx = column_count2;
0485 end
0486 end
0487
0488
0489 num_rows = length(avgcell);
0490 if ~isempty(date_idx)
0491
0492 offset = 2;
0493 else
0494 offset = 0;
0495 end
0496 data = NaN.* ones(num_rows,(column_count-offset));
0497 for i = 1:num_rows
0498 if exist('btl_pos_idx','var') == 1
0499 data(i,btl_pos_idx) = str2num(avgcell{i}{btl_pos_idx});
0500 names{btl_pos_idx} = 'bottle_ros_position';
0501 end
0502 if exist('date_idx','var') == 1
0503 mnth = avgcell{i}{date_idx};
0504 day = avgcell{i}{date_idx + 1};
0505 yr = avgcell{i}{date_idx+2};
0506 if exist('time_idx','var') == 1
0507 timestr = stdcell{i}{time_idx};
0508
0509 datestr = sprintf('%s',[day,'-',mnth,'-',yr,' ',timestr]);
0510 else
0511 datestr = sprintf('%s',[day,'-',mnth,'-',yr]);
0512 end
0513 data(i,date_idx) = datenum(datestr);
0514 names{date_idx} = 'date';
0515 end;
0516 if exist('pri_pri_dens_idx','var') == 1
0517 data(i,pri_pri_dens_idx) = str2num(avgcell{i}{pri_pri_dens_idx});
0518 names{pri_pri_dens_idx} = 'density_pri_pri';
0519 end;
0520 if exist('sec_sec_dens_idx','var') == 1
0521 data(i,sec_sec_dens_idx) = str2num(avgcell{i}{sec_sec_dens_idx});
0522 names{sec_sec_dens_idx} = 'density_sec_sec';
0523 end;
0524 if exist('pri_sec_dens_idx','var') == 1
0525 data(i,pri_sec_dens_idx) = str2num(avgcell{i}{pri_sec_dens_idx});
0526 names{pri_sec_dens_idx} = 'density_pri_sec';
0527 end;
0528 if exist('sec_pri_dens_idx','var') == 1
0529 data(i,sec_pri_dens_idx) = str2num(avgcell{i}{sec_pri_dens_idx});
0530 names{sec_pri_dens_idx} = 'density_sec_pri';
0531 end;
0532 if exist('pri_pri_sig_idx','var') == 1
0533 data(i,pri_pri_sig_idx) = str2num(avgcell{i}{pri_pri_sig_idx});
0534 names{pri_pri_sig_idx} = 'sigma_pri_pri';
0535 end;
0536 if exist('sec_sec_sig_idx','var') == 1
0537 data(i,sec_sec_sig_idx) = str2num(avgcell{i}{sec_sec_sig_idx});
0538 names{sec_sec_sig_idx} = 'sigma_sec_sec';
0539 end;
0540 if exist('pri_sec_sig_idx','var') == 1
0541 data(i,pri_sec_sig_idx) = str2num(avgcell{i}{pri_sec_sig_idx});
0542 names{pri_sec_sig_idx} = 'sigma_pri_sec';
0543 end;
0544 if exist('sec_pri_sig_idx','var') == 1
0545 data(i,sec_pri_sig_idx) = str2num(avgcell{i}{sec_pri_sig_idx});
0546 names{sec_pri_sig_idx} = 'sigma_sec_pri';
0547 end;
0548 if exist('pr_idx','var') == 1
0549 data(i,pr_idx) = str2num(avgcell{i}{pr_idx});
0550 names{pr_idx}='pressure';
0551 end;
0552 if exist('pri_t68_idx','var') == 1
0553 data(i,pri_t68_idx) = str2num(avgcell{i}{pri_t68_idx});
0554 names{pri_t68_idx} = 't68_pri';
0555 end;
0556 if exist('sec_t68_idx','var') == 1
0557 data(i,sec_t68_idx) = str2num(avgcell{i}{sec_t68_idx});
0558 names{sec_t68_idx} = 't68_sec';
0559 end;
0560 if exist('pri_t90_idx','var') == 1
0561 data(i,pri_t90_idx) = str2num(avgcell{i}{pri_t90_idx});
0562 names{pri_t90_idx} = 't90_pri';
0563 end;
0564 if exist('sec_t90_idx','var') == 1
0565 data(i,sec_t90_idx) = str2num(avgcell{i}{sec_t90_idx});
0566 names{sec_t90_idx} = 't90_sec' ;
0567 end;
0568 if exist('pri_pri_sal_idx','var') == 1
0569 data(i,pri_pri_sal_idx) = str2num(avgcell{i}{pri_pri_sal_idx});
0570 names{pri_pri_sal_idx} = 'sal_pri_pri';
0571 end;
0572 if exist('sec_sec_sal_idx','var') == 1
0573 data(i,sec_sec_sal_idx) = str2num(avgcell{i}{sec_sec_sal_idx});
0574 names{sec_sec_sal_idx} = 'sal_sec_sec';
0575 end;
0576 if exist('pri_sec_sal_idx','var') == 1
0577 data(i,pri_sec_sal_idx) = str2num(avgcell{i}{pri_sec_sal_idx});
0578 names{pri_sec_sal_idx} = 'sal_pri_sec';
0579 end;
0580 if exist('sec_pri_sal_idx','var') == 1
0581 data(i,sec_pri_sal_idx) = str2num(avgcell{i}{sec_pri_sal_idx});
0582 names{sec_pri_sal_idx} = 'sal_sec_pri';
0583 end;
0584 if exist('pri_con_idx','var') == 1
0585 data(i,pri_con_idx) = str2num(avgcell{i}{pri_con_idx});
0586 names{pri_con_idx} = 'con_pri';
0587 end;
0588 if exist('sec_con_idx','var') == 1
0589 data(i,sec_con_idx) = str2num(avgcell{i}{sec_con_idx});
0590 names{sec_con_idx} = 'con_sec';
0591 end;
0592 if exist('pri_oxc_idx','var') == 1
0593 data(i,pri_oxc_idx) = str2num(avgcell{i}{pri_oxc_idx});
0594 names{pri_oxc_idx} = 'oxc_pri';
0595 end;
0596 if exist('sec_oxc_idx','var') == 1
0597 data(i,sec_oxc_idx) = str2num(avgcell{i}{sec_oxc_idx});
0598 names{sec_oxc_idx} = 'oxc_sec';
0599 end;
0600 if exist('pri_oxt_idx','var') == 1
0601 data(i,pri_oxt_idx) = str2num(avgcell{i}{pri_oxt_idx});
0602 names{pri_oxt_idx} = 'oxt_pri';
0603 end;
0604 if exist('sec_oxt_idx','var') == 1
0605 data(i,sec_oxt_idx) = str2num(avgcell{i}{sec_oxt_idx});
0606 names{sec_oxt_idx} = 'oxt_sec';
0607 end;
0608 if exist('pri_do2_mmkg_idx','var') == 1
0609 data(i,pri_do2_mmkg_idx) = str2num(avgcell{i}{pri_do2_mmkg_idx});
0610 names{pri_do2_mmkg_idx} = 'do2_pri';
0611 end;
0612 if exist('sec_do2_mmkg_idx','var') == 1
0613 data(i,sec_do2_mmkg_idx) = str2num(avgcell{i}{sec_do2_mmkg_idx});
0614 names{sec_do2_mmkg_idx} = 'do2_sec';
0615 end;
0616 if exist('pri_do2_mll_idx','var') == 1
0617 data(i,pri_do2_mll_idx) = str2num(avgcell{i}{pri_do2_mll_idx});
0618 names{pri_do2_mll_idx} = 'do2_pri';
0619 end;
0620 if exist('sec_do2_mll_idx','var') == 1
0621 data(i,sec_do2_mll_idx) = str2num(avgcell{i}{sec_do2_mll_idx});
0622 names{sec_do2_mll_idx} = 'do2_sec';
0623 end;
0624 if exist('btl_fired_idx','var') == 1
0625 data(i,btl_fired_idx) = str2num(avgcell{i}{btl_fired_idx});
0626 names{btl_fired_idx} = 'bottle_fired_count';
0627 end;
0628 if exist('scan_idx','var') == 1
0629 data(i,scan_idx) = str2num(avgcell{i}{scan_idx});
0630 names{scan_idx} = 'scan';
0631 end;
0632 if exist('pri_odocdt_idx','var') == 1
0633 data(i,pri_odocdt_idx) = str2num(avgcell{i}{pri_odocdt_idx});
0634 names{pri_odocdt_idx} = 'odocdt_pri';
0635 end;
0636 if exist('sec_odocdt_idx','var') == 1
0637 data(i,sec_odocdt_idx) = str2num(avgcell{i}{sec_odocdt_idx});
0638 names{sec_odocdt_idx} = 'odocdt_sec';
0639 end;
0640 if exist('pri_sbedo2_mll_idx','var') == 1
0641 data(i,pri_sbedo2_mll_idx) = str2num(avgcell{i}{pri_sbedo2_mll_idx});
0642 names{pri_sbedo2_mll_idx} = 'sbedo2_mll_pri';
0643 end;
0644 if exist('sec_sbedo2_mll_idx','var') == 1
0645 data(i,sec_sbedo2_mll_idx) = str2num(avgcell{i}{sec_sbedo2_mll_idx});
0646 names{sec_sbedo2_mll_idx} = 'sbedo2_mll_sec';
0647 end;
0648 if exist('pri_sbedo2_mmkg_idx','var') == 1
0649 data(i,pri_sbedo2_mmkg_idx) = str2num(avgcell{i}{pri_sbedo2_mmkg_idx});
0650 names{pri_sbedo2_mmkg_idx} = 'sbedo2_mmkg_pri';
0651 end;
0652 if exist('sec_sbedo2_mmkg_idx','var') == 1
0653 data(i,sec_sbedo2_mmkg_idx) = str2num(avgcell{i}{sec_sbedo2_mmkg_idx});
0654 names{sec_sbedo2_mmkg_idx} = 'sbedo2_mmkg_sec';
0655 end;
0656
0657 if exist('pot_temp_pri_idx','var') == 1
0658 data(i,pot_temp_pri_idx) = str2num(avgcell{i}{pot_temp_pri_idx});
0659 names{pot_temp_pri_idx} = 'pot_temp_pri';
0660 end;
0661 if exist('pot_temp_sec_idx','var') == 1
0662 data(i,pot_temp_sec_idx) = str2num(avgcell{i}{pot_temp_sec_idx});
0663 names{pot_temp_sec_idx} = 'pot_temp_sec';
0664 end;
0665 if exist('sbeox_pct_sat_pri_idx','var') == 1
0666 data(i,sbeox_pct_sat_pri_idx) = str2num(avgcell{i}{sbeox_pct_sat_pri_idx});
0667 names{sbeox_pct_sat_pri_idx} = 'sbeox_pct_sat_pri';
0668 end;
0669 if exist('sbeox_pct_sat_sec_idx','var') == 1
0670 data(i,sbeox_pct_sat_sec_idx) = str2num(avgcell{i}{sbeox_pct_sat_sec_idx});
0671 names{sbeox_pct_sat_sec_idx} = 'sbeox_pct_sat_sec';
0672 end;
0673 if exist('pri_sbedOC_dt_idx','var') == 1
0674 data(i,pri_sbedOC_dt_idx) = str2num(avgcell{i}{pri_sbedOC_dt_idx});
0675 names{pri_sbedOC_dt_idx} = 'sbeox_dOCdt_pri';
0676 end;
0677 if exist('sec_sbedOC_dt_idx','var') == 1
0678 data(i,sec_sbedOC_dt_idx) = str2num(avgcell{i}{sec_sbedOC_dt_idx});
0679 names{sec_sbedOC_dt_idx} = 'sbeox_dOCdt_sec';
0680 end;
0681 if exist('pri_sbeox_volt_idx','var') == 1
0682 data(i,pri_sbeox_volt_idx) = str2num(avgcell{i}{pri_sbeox_volt_idx});
0683 names{pri_sbeox_volt_idx} = 'sbeox_volt_pri';
0684 end;
0685 if exist('sec_sbeox_volt_idx','var') == 1
0686 data(i,sec_sbeox_volt_idx) = str2num(avgcell{i}{sec_sbeox_volt_idx});
0687 names{sec_sbeox_volt_idx} = 'sbeox_volt_sec';
0688 end;
0689 if exist('pct_sat_idx','var') == 1
0690 data(i,pct_sat_idx) = str2num(avgcell{i}{pct_sat_idx});
0691 names{pct_sat_idx} = 'pct_sat';
0692 end;
0693 if exist('pct_sat_sec_idx','var') == 1
0694 data(i,pct_sat_sec_idx) = str2num(avgcell{i}{pct_sat_sec_idx});
0695 names{pct_sat_sec_idx} = 'pct_sat_sec';
0696 end;
0697
0698
0699 end
0700
0701
0702
0703 offset = 0;
0704 if exist('date_idx','var') == 1
0705 data(:,[date_idx+1:date_idx+2]) = [];
0706 count = 1;
0707 for i = 1:(length(names))
0708 if ~isempty(names{i})
0709 tmp{count} = names{i};
0710 count = count + 1;
0711 end
0712 end
0713 names = tmp;
0714 end
0715
0716
0717
0718
0719
0720
0721 if exist('bad_flag','var') == 1
0722 ind=find(data==bad_flag);
0723 data(ind)=data(ind)*nan;
0724 end
0725
0726
0727 btl_struct.lat = lat;
0728 btl_struct.lon = lon;
0729 btl_struct.gtime = gtime;
0730 btl_struct.sensors = char(sensors');
0731
0732 for i = 1:length(names)
0733 str = names{i};
0734 idxspc = isspace(str);
0735 str(idxspc) = [];
0736 names{i} = str;
0737 end
0738 btl_struct.names = names;
0739 btl_struct.data = data;
0740 disp([btl_file,' loaded'])
0741
0742 return
0743
0744
0745 function outStr = remove233(inStr);
0746
0747
0748
0749
0750 strDbl = double(inStr);
0751 idxStr = find(strDbl==233);
0752 if ~isempty(idxStr)
0753 strDbl(idxStr) = 32;
0754 outStr = char(strDbl);
0755 else
0756 outStr = inStr;
0757 end
0758
0759 return
0760