% program to read WOD01 files exported from OCV software
% OUTPUTS
    % date (mo,da,yr,hr,mm)
    % dat (lon,lat,bdep,dep,depqf,temp,tempqf,sal,salqf,o2,o2qf,chl,chlqf,biomass,biomassqf)
    % qf = qualifier flags: 0=good, 4=questionable, 8=bad
    % missing data assigned -9999
    % saves to all-chl-ctd
%
% written by Lisa Taylor, UMaine, 2006
% rewritten 06/06/06 to add wod01_ctd at end of variable names for integrating with other files
%
% Cruise,Station,Type,mon/day/yr,hh:mm,Lon(°E),Lat(°N),Bot. Depth[m],Depth[m],QF,Temperature[°C],QF,Salinity[psu],QF,Oxygen[ml/l],QF,Chlorophyll[~$m~#g/l],QF,Plankton/Biomass[],QF
% WOD01_18009161,9297136,B,4/26/1990,17:46,303.677,40.443,0,2,0,18.907,0,36.544,4,6.8875,0,0.606,0,-9999,8
% format: s,s,s,u/u/u,u:u,f,f,f,f,d,f,d,f,d,f,d,f,d,f,d
%
close all
clear all
[cruise_wod01_ctd,sta_wod01_ctd,type_wod01_ctd,mo_wod01_ctd,da_wod01_ctd,yr_wod01_ctd,hr_wod01_ctd,min_wod01_ctd,lon_wod01_ctd,lat_wod01_ctd,bdep_wod01_ctd,dep_wod01_ctd,depqf_wod01_ctd,temp_wod01_ctd,tempqf_wod01_ctd,sal_wod01_ctd,salqf_wod01_ctd,o2_wod01_ctd,o2qf_wod01_ctd,chl_wod01_ctd,chlqf_wod01_ctd,biomass_wod01_ctd,biomassqf_wod01_ctd] = textread( ...
    'C:\Documents and Settings\Lisa Taylor\My Documents\Data\WOD01\ctd\data\all-chl-ctd.txt', ...
    '%s %s %s %u/%u/%u %u:%u %f %f %f %f %d %f %d %f %d %f %d %f %d %f %d', ...
    'headerlines',1, 'delimiter','\t');
%
lon_wod01_ctd(lon_wod01_ctd==-9999)=NaN;
lat_wod01_ctd(lat_wod01_ctd==-9999)=NaN;
bdep_wod01_ctd(bdep_wod01_ctd==-9999)=NaN;
dep_wod01_ctd(dep_wod01_ctd==-9999)=NaN;
depqf_wod01_ctd(depqf_wod01_ctd==-9999)=NaN;
temp_wod01_ctd(temp_wod01_ctd==-9999)=NaN;
tempqf_wod01_ctd(tempqf_wod01_ctd==-9999)=NaN;
sal_wod01_ctd(sal_wod01_ctd==-9999)=NaN;
salqf_wod01_ctd(salqf_wod01_ctd==-9999)=NaN;
o2_wod01_ctd(o2_wod01_ctd==-9999)=NaN;
o2qf_wod01_ctd(o2qf_wod01_ctd==-9999)=NaN;
chl_wod01_ctd(chl_wod01_ctd==-9999)=NaN;
chlqf_wod01_ctd(chlqf_wod01_ctd==-9999)=NaN;
biomass_wod01_ctd(biomass_wod01_ctd==-9999)=NaN;
biomassqf_wod01_ctd(biomassqf_wod01_ctd==-9999)=NaN;
date_wod01_ctd = datenum(yr_wod01_ctd,mo_wod01_ctd,da_wod01_ctd,hr_wod01_ctd,min_wod01_ctd,0);
%allData=[date_wod01_ctd lon_wod01_ctd lat_wod01_ctd dep_wod01_ctd depqf_wod01_ctd temp_wod01_ctd tempqf_wod01_ctd sal_wod01_ctd salqf_wod01_ctd o2_wod01_ctd o2qf_wod01_ctd chl_wod01_ctd chlqf_wod01_ctd biomass_wod01_ctd biomassqf_wod01_ctd];
Wod01Ctd=[date_wod01_ctd lon_wod01_ctd lat_wod01_ctd dep_wod01_ctd depqf_wod01_ctd temp_wod01_ctd tempqf_wod01_ctd sal_wod01_ctd salqf_wod01_ctd o2_wod01_ctd o2qf_wod01_ctd chl_wod01_ctd chlqf_wod01_ctd biomass_wod01_ctd biomassqf_wod01_ctd];
% save  all-chl-ctd -v6
save wod01-ctd -v6