% -- % Jeff Sevadjian % Research Technician % Monterey Bay Aquarium Research Institute % 7700 Sandholdt Rd % Moss Landing, CA 95039, USA % ph: +1 831-775-1888 % Parses CTD.txt capture file from Sea-Term (internally-logged data). % Extra data here, not logged by cntl due to failed charging system % (3 solar panels busted out by end of depl). % QC's [T, S] in a manner consisent w/ 'OA2_201505_convQC_datalog.m'. % SBE-logged data [T, S] are slightly different, presumably due to OASIS AtoD? %define buoy, deployment, data directory buoy = 'OA2'; dep = '201505'; mydir = ['//atlas.shore.mbari.org/OA_Moorings/deployment_data/' ... buoy '/' dep '/']; myfile = 'CTD'; %read-in SBE internally-logged data data = []; time = []; fid = fopen([mydir 'raw/ctd/' myfile '.txt']); while ~feof(fid) fline = fgetl(fid); f = strfind(fline,','); if length(f)==5 & length(fline)==60 s = str2num(fline(1:f(4)-1)); if length(s)==4 data = [data; s]; time = [time; fline(f(4)+2:end)]; end end end fclose(fid); clear fid ans fline f s; %form to matrix CTD = [datenum(time), data(:,[1,4])]; %I looked at press, don't need anymore clear data time; %save raw .mat file save([mydir 'raw/CTD/' myfile '.mat'],'CTD'); %load un-QC'd CTD data from cntl load([mydir 'raw/cntl/DATALOG.mat']); clear AANDERAA_O2 AIRMAR_PB200 EXT_ANALOG* PCO2 SPECIAL*; figure; hold on; plot(MICROCAT(:,1),MICROCAT(:,5),'r.-'); plot(CTD(:,1),CTD(:,3),'b.'); figure; hold on; plot(MICROCAT(:,1),MICROCAT(:,2),'r.-'); plot(CTD(:,1),CTD(:,2),'b.'); %tBeg, tEnd tBeg = datenum([2015 5 13 20 36 0]); %slightly diff, one extra data pt tEnd = datenum([2016 9 27 16 4 0]); %QC f = find(CTD(:,1)tEnd); CTD(f,:) = []; clear f; %QC salinity %pump failed f = find( CTD(:,1) > datenum([2016 3 6 2 6 0]) ); CTD(f,3) = NaN; clear f; %variance filter win = 100; %window nst = 5; %number of stdev's above median sm = slidingmed(CTD(:,3), win); ss = slidingstdev(CTD(:,3), win); fs = find(abs(CTD(:,3) - sm) > nst*ss); CTD(fs,3) = NaN; clear win nst sm ss fs; %manual outliers f = find( CTD(:,1) > datenum([2015 9 30 16 6 0]) & ... CTD(:,1) < datenum([2015 10 16 4 5 0]) ); %prolonged dip in S; T vs S out-of-whack CTD(f,3) = NaN; clear f; %save save([mydir 'QC/' myfile '_QC.mat'],'CTD');