Commit 80752ef4 authored by PStar User Account's avatar PStar User Account
Browse files

mcoxyhyst_reverse that handles missing data

parent ae63b40b
function [oxygen_rev]=mcoxyhyst_reverse(oxygen_sbe,time,press,H1,H2,H3) function [oxygen_rev]=mcoxyhyst_reverse(oxygen_sbe,time,press,H1,H2,H3)
% function [oxygen_rev]=mcoxyhyst_reverse(oxygen_sbe,time,press,H1,H2,H3) % function [oxygen_rev]=mcoxyhyst_reverse(oxygen_sbe,time,press,H1,H2,H3)
% %
% gdm on di346 % gdm on di346
% function to reverse the adjustment for hysteresis in the oxygen sensor % function to reverse the adjustment for hysteresis in the oxygen sensor
% applied by SeaBird % applied by SeaBird
% %
% the default values and ranges or the constants are: % the default values and ranges or the constants are:
% H1 -0.033 [-0.02 to -0.05] % H1 -0.033 [-0.02 to -0.05]
% H2 5000 % H2 5000
% H3 1450 [1200 to 2000] % H3 1450 [1200 to 2000]
oxygen_rev=oxygen_sbe; % DAS chnaged to deal with absent data but note this could give slightly different results from original data as
% the sbe software may deal with absent data differently
for k=2:length(time)
D=1+H1*(exp(press(k)/H2)-1); oxygen_rev=oxygen_sbe;
C=exp(-1*(time(k)-time(k-1))/H3);
kfirst = min(find(isfinite(oxygen_sbe)));
oxygen_rev(k)=D*(oxygen_sbe(k)-C*oxygen_sbe(k-1))+C*oxygen_rev(k-1); klastgood = kfirst; % keep track of most recent good cycle
for k=2:length(time)
D=1+H1*(exp(press(k)/H2)-1);
C=exp(-1*(time(k)-time(k-1))/H3);
oxygen_rev(k)=D*(oxygen_sbe(k)-C*oxygen_sbe(k-1))+C*oxygen_rev(k-1);
if isnan(oxygen_sbe(k)+press(k))
oxygen_rev(k) = nan; %already the case because of initialisation of oxygen_out
else
if press(k) < 0; press(k) = 0; end
D=1+H1*(exp(press(k)/H2)-1);
C=exp(-1*(time(k)-time(klastgood))/H3);
oxygen_rev(k)=D*(oxygen_sbe(k)-C*oxygen_sbe(klastgood))+C*oxygen_rev(klastgood);
klastgood = k;
end
end; end;
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment