function [P,ext,SSA]=MieOptics(lambda,ref,rm,sigm,Teta_s)
%rm=0.231e-5;
%sigm=2.03;
%ref=1.245e-9i;
lambda=lambda/1000;
nrec=75;
nang=100;

TETA=linspace(0,pi,nang*2-1);
r=logspace(log10(rm)-2,log10(50),nrec);
N=lognormal(r,rm,sigm);
X=2*pi*r./lambda;
for i=1:nrec
   [SS1(i,:),SS2(i,:),Qe(i),Qs(i)]=mie(X(i),ref,nang); 
end
k=2*pi/lambda;
if nrec==1
    ext=pi*r*Qe;
    sca=pi*r*Qs;
    TERM=0.5*(abs(SS1).^2+abs(SS2).^2);
    P11=1/(k^2*sca)*r.^2.*TERM*4*pi;
else    
 ext=trapz(r,pi.*N.*r.^2.*Qe);
 sca=trapz(r,pi.*N.*r.^2.*Qs);
 for j=1:2*nang-1
  TERM=0.5*(abs(SS1(:,j)).^2+abs(SS2(:,j)).^2);  %P11
  clear i 
  P11(j)=1/(k^2*sca)*trapz(r,N.*TERM')*4*pi;
 end
end
SSA=sca/ext;
%trapz(cos(TETA),P11)
P=interp1(TETA,P11,Teta_s);
