% -- % Jeff Sevadjian % Monterey Bay Aquarium Research Institute % 7700 Sandholdt Rd % Moss Landing, CA 95039, USA % ph: +1 831-775-1888 % Copied from OA1_201607_QC_fromWeb.m % Loads real-time .csv files output from makeOAwebQC_oa2.py, % does a fairly thorough manual removal of bad data, % saves as a .mat file for Diego to extend the analyses. % This script was run during the 'middle' of the deployment and is not % intended as a 'final' QC'd .mat file. % Output matrices are same as the older QC'd OA1, OA2, M1 data, e.g.: % CTD: Time [Matlab serial datenum], Temperature [C], Salinity % Fluor: Time, fluorescence [ug/l] % MET: Time, barometric pressure [bar], raw (uncorrected) air temp [C], % relative humidity [%], corrected air temp [C], wind direction [T], % wind speed [m/s] % O2: Time, oxygen [umol/kg] % pCO2: Time, pCO2 in water, pCO2 in air [ppm] % pH: total scale % VR2C: Time, tag ID atlas = '//atlas.shore.mbari.org/'; buoy = 'oa2'; dep = '201609'; mydir = [atlas 'OA_Moorings/deployment_data/' buoy '/' dep '/realTime/']; dn = datenum([1970 1 1]); %--% %CTD CTD = csvread([mydir 'CTD.csv'],1,0); CTD(:,1) = dn + (CTD(:,1)/86400/1000); %all unique time stamps %QC temp figure; hold on; plot(CTD(:,1),CTD(:,2),'.-'); %fixed floor f = find(CTD(:,2) < 5); plot(CTD(f,1),CTD(f,2),'m.'); CTD(f,2) = NaN; clear f; %QC salinity figure; hold on; plot(CTD(:,1),CTD(:,3),'.-'); %fixed floor f = find(CTD(:,3) < 15); plot(CTD(f,1),CTD(f,3),'m.'); 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); plot(CTD(fs,1),CTD(fs,3),'r.'); CTD(fs,3) = NaN; clear win nst sm ss fs; %no manual outliers %get rid of 4th column (pressure) CTD(:,4) = []; %--% %O2 O2 = csvread([mydir 'Oxygen.csv'],1,0); O2(:,1) = dn + (O2(:,1)/86400/1000); %get rid of non-unique time stamps (?) [~,i] = unique(O2(:,1)); O2 = O2(i,:); clear i; %QC O2 figure; hold on; plot(O2(:,1),O2(:,2),'.-'); %missing values f = find(O2(:,2) == 0); plot(O2(f,1),O2(f,2),'m.'); O2(f,2) = NaN; clear f; %manual outliers f = find( O2(:,1)>datenum([2016 10 30 2 29 0]) & ... O2(:,1)datenum([2017 2 7 3 20 0]) & ... pCO2(:,1)datenum([2017 1 22 5 20 0]) & ... pCO2(:,1)1080 ); plot(MET(f,1),MET(f,2),'k.'); MET(f,2) = NaN; clear f; %QC air temp figure; hold on; plot(MET(:,1),MET(:,3),'.-'); %missing values f = find(MET(:,3) == 0); MET(f,3) = NaN; clear f; %manual outliers f = find( MET(:,1)>datenum([2017 5 14 0 40 0]) ); plot(MET(f,1),MET(f,3),'k.'); MET(f,3) = NaN; clear f; %--% %METwind METw = csvread([mydir 'METwind.csv'],1,0); METw(:,1) = dn + (METw(:,1)/86400/1000); %get rid of non-unique time stamps (?) [~,i] = unique(METw(:,1)); METw = METw(i,:); clear i; %QC wind speed figure; hold on; plot(METw(:,1),METw(:,3),'.-'); %missing values f = find(METw(:,3) == 0); plot(METw(f,1),METw(f,3),'r.'); METw(f,2:3) = NaN; clear f; %fixed ceiling f = find( METw(:,3)>30 ); plot(METw(f,1),METw(f,3),'k.'); METw(f,2:3) = NaN; clear f; %combine MET and METwind into same fmt as older QC'd data sets % time stamps are identical, yay MET = [MET NaN(size(MET,1),1) MET(:,3) METw(:,2:3)]; %--% %VR2C VR2C = csvread([mydir 'tagID.csv'],1,0); VR2C(:,1) = dn + (VR2C(:,1)/86400/1000); %leave duplicate time stamps (multiple tags at same time) %QC VR2C %missing values f = find(VR2C(:,2) == 0); VR2C(f,:) = []; clear f; %--% %save to interns directory save([atlas 'jsevadjian/interns/Diego/mat/OA2_201609_QC.mat'],... 'CTD', 'Fluor', 'MET', 'O2', 'pCO2', 'pH', 'VR2C');