% -- % Jeff Sevadjian % Monterey Bay Aquarium Research Institute % 7700 Sandholdt Rd % Moss Landing, CA 95039, USA % ph: +1 831-775-1888 % Loads real-time .csv files output from makeOAwebQC_oa1.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 = 'oa1'; dep = '201607'; 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); %get rid of non-unique time stamps (?) [~,i] = unique(CTD(:,1)); CTD = CTD(i,:); clear i; %QC temp figure; hold on; plot(CTD(:,1),CTD(:,2),'.-'); %no manual outliers %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; %manual outliers f = find( CTD(:,1)>datenum([2017 3 22 16 55 0]) & ... CTD(:,1)datenum([2017 3 22 16 55 0]) & ... O2(:,1)datenum([2017 3 22 16 55 0]) & ... Fluor(:,1)datenum([2017 3 18 0 37 0]) & ... pH(:,1)datenum([2016 8 29 18 55 0]) & ... pCO2(:,1)datenum([2016 11 20 19 0 0]) & ... pCO2(:,1)1040 ); 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),'.-'); %fixed floor f = find( MET(:,3)<7 ); 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 % somehow have more values for METw than MET (?) MET = [MET NaN(size(MET,1),1) MET(:,3) ... interp1(METw(:,1),METw(:,2),MET(:,1),'nearest') ... interp1(METw(:,1),METw(:,3),MET(:,1),'nearest')]; %--% %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 %fixed ceiling f = find( VR2C(:,2) > 2e5 ); VR2C(f,2) = NaN; clear f; %--% %save to interns directory save([atlas 'jsevadjian/interns/Diego/mat/OA1_201607_QC.mat'],... 'CTD', 'Fluor', 'MET', 'O2', 'pCO2', 'pH', 'VR2C');