function [ratio] = OP(t,X_CH4,X_C2H2,X_C2H4,X_H2,X_C2H6,X_CO,tau,out,k)
[tspol1,CH4spol1,C2H2spol1,C2H4spol1,H2spol1,C2H6spol1,COspol1,l]=vyhazet_radky6(t,X_CH4,X_C2H2,X_C2H4,X_H2,X_C2H6,X_CO);
n=length(tspol1);
for i=1:n
    soucet(i)=CH4spol1(i)+C2H2spol1(i)+C2H4spol1(i)+H2spol1(i)+C2H6spol1(i)+COspol1(i);
end


if out==1;
    [Q,I]=outliers([tspol1 soucet],1.5);
    t=Q(:,1);
    X=Q(:,2);
else
    t=tspol1;
    X=soucet;
end;
    
if k==1;
    b_lin=robustfit(t,X);
    y=b_lin(1)+b_lin(2)*tau;
end;    
if k==2;
    b_moc=robustfit(log(t),log(X));
    y=exp(b_moc(1))*(tau^b_moc(2));
end; 
if k==3;
    f1=fit(t,X,'poly1');
    b5=coeffvalues(f1);
    y=b5(2)+b5(1)*tau;
end;
if k==4;
    f2=fit(t,X,'exp1');
    b2=coeffvalues(f2);
    y=b2(1)*exp(b2(2)*tau);
end;
if k==5;
    r=ksr(t,X);
    f3=fit(t,r.f','poly2');
    b3=coeffvalues(f3);
    y=b3(1)*tau^2+b3(2)*tau+b3(3);
end;
if k==6;
    klp=smooth(X,3);
    f4=fit(t,klp,'poly2');
    b4=coeffvalues(f4);
    y=b4(1)*tau^2+b4(2)*tau+b4(3);
end;

dny=tau-tspol1(n);
rozdil=y-soucet(n);
ratio=rozdil-dny;

if ratio < 10
OProcessC1='OP1';
IntervalC1=Annually;
end;
if 10 >= ratio <= 30
OProcessC1='OP1';
IntervalC1=Quarterly;
end;
if ratio > 30
OProcessC1='OP2';
IntervalC1=Monthly;
end;

if ratio < 10
OProcessC2='OP3';
IntervalC2=Quarterly;
end;
if 10 >= ratio <= 30
OProcessC2='OP3';
IntervalC2=Monthly;
end;
if ratio > 30
OProcessC2='OP3';
IntervalC2=Monthly;
end;

if ratio < 10
OProcessC3='OP4';
IntervalC3=Monthly;
end;
if 10 >= ratio <= 30
OProcessC3='OP4';
IntervalC3=Weekly;
end;
if ratio > 30
OProcessC3='OP4';
IntervalC3=Weekly;
end;

if ratio < 10
OProcessC4='OP4';
IntervalC4=Monthly;
end;
if 10 >= ratio <= 30
OProcessC4='OP4';
IntervalC4=Weekly;
end;
if ratio > 30
OProcessC4='OP4';
IntervalC4=Weekly;
end;




end

