%vertical_focusing.m


Bydst = idst(Bm(:,3));
%  iBydst = idst(Bm(:,3));

Dk = 0.5 / dz;
dk = 0.5 / Dz;
ks = (0.:dk:Dk+dk)';

kfilt = exp(-0.5*(1./ks - 0.55).^2 / (0.1)^2);
Bydstfilt = Bydst .* kfilt;
Bmfilt = dst(Bydstfilt);

figure
plot(1./ks,Bydst); hold on
plot(1./ks, kfilt * max(abs(Bydst)),'color','green'); 
plot(1./ks, Bydstfilt,'color','red'); hold off

Bmreconstr = 0.*Bm(:,3);
%  for i = 1:numel(ks)
%      Bmreconstr = Bmreconstr + Bydst(i) .* sin(pi*ks(i) * Bm(:,1));
%  end
N = numel(ks);
for ik = 1:N
%  for ik = 1:1000
%  for ik = [17]
%      Bmreconstr = Bmreconstr + Bydst(ik) .* sin(pi*ik/N * ((1:N)' + 1/2) );% gb
%      Bmreconstr = Bmreconstr + Bydst(ik) .* sin(pi*ik/N/dz * dz*((1:N)' + 1/2) );% gb
    Bmreconstr = Bmreconstr + Bydst(ik) .* sin(pi*ik/N * ((1:N)' + 1/2) ) .* cosh(pi*ik/N/dz * y );% gb
end

figure
plot(Bm(:,1),Bm(:,3)); hold on
plot(Bm(:,1), Bmreconstr,'color','green'); 
plot(Bm(:,1), Bmfilt,'color','red'); hold off


%  % try dst 
%  v=0:0.001:4;
%  u=cos(2.*pi*v)+1;
%  figure;
%  plot(v,u);
%  
%  udst = dst(u);
%  dk = 1./(v(end)-v(1))/2.;
%  Dk = 1./(v(2)-v(1))/2.;
%  ks = 0.:dk:Dk;
%  
%  figure;
%  plot(ks,udst);
%  figure;
%  plot(1./ks,udst);

