% function [F,r_buz]=TubingAttenuationBuzorius(Fm,u,tau_c)
function [r]=TubingAttenuation(rm,samplerate,tau_c)

%this function has been created to correct O3 apparent mixing ratio to real
%mixing ratio.  To do that, we use Lenschow and Lee equations and have
%O3real=(1+6.85r)*O3measured. The problem is that r has been measured at
%the inlet and has not been attenuated by the tubing. To do that we use
%Buzorius model to create a time series of attenuated water vapor r.
%here fm is the measured water vapor mixing ratio, and f is the attenuated
%r
%% 10/10/08 this function is valid only for fluxes and VD...not for mixing
%% ratio  --> LP to be used!

% % % % Buzorius model 
% % % nm=0.085;
% % % alpha=7/8;
% % % % tau_c=0.4;
% % % % u=8;
% % % z=18;
% % % 
% % % % u=[0:20];
% % % r_buz=1./(1+(2.*pi.*nm.*tau_c.*u./z).^alpha);
% % % 
% % % % figure;plot(u,r_buz,'--');
% % % 
% % % F=Fm.*r_buz;

tau_c=0.4;
bc=tau_c/5;[bf af]=butter(1,bc,'low');
% freqz(bf,af,36000,10);
r=filter(bf,af,rm);
% r=filtfilt(bf,af,rm);   -->filtfilt crates problem on this computation.
% The ratio of 2 spectra should be 1/2 at tauc (1/sqrt(2) for Cospectra/Sx)
% use filter!

