% Plot the target function and its convolution. 
%
% Samuli Siltanen, January 2011

% Plot parameters
fsize  = 20;
lwidth = 1.5;

% Parameter that specifies the width of the PSF, must satisfy 0<a<1/2. 
% The support of the building block of the PSF is [-a,a], and this 
% building block is replicated at each integer to produce a periodic
% function.
a = 0.02;


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% First plot: the building block only

% Create plot points
Nxx = 512;
xx  = linspace(-.5,.5,Nxx);
Dxx = xx(2)-xx(1);

% Evaluate point spread function
psf = zeros(size(xx));
ind = abs(xx)<a;
psf(ind) = DC_PSF(xx(ind),a);
Ca  = 1/(Dxx*sum(abs(psf))); % Normalization constant
psf = Ca*psf;

% Create plot window
figure(1)
clf

% Plot the psf
plot(xx,psf,'k','linewidth',lwidth)
xlim([-1/2 1/2])
box off
%set(gca,'ytick',[0,10,20,23.4],'fontsize',fsize)
%set(gca,'xtick',[-.1,-a,0,a,.1],'fontsize',fsize)
%set(gca,'xticklabel',{'-0.1','-a','0','a','0.1'},'fontsize',fsize)
set(gca,'PlotBoxAspectRatio' , [2 1 1])

break

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Second plot: the periodic psf

% Create plot points
Nxx2 = 2048;
xx2  = linspace(-pi/2,2.5*pi,Nxx2);
Dxx2 = xx2(2)-xx2(1);

% Evaluate point spread function
psf2 = zeros(size(xx2));
ind2 = (abs(xx2)<a);
ind3 = (abs(xx2-1)<a);
ind4 = (abs(xx2+1)<a);
psf2(ind2) = DC_PSF(xx2(ind2),a);
psf2(ind3) = DC_PSF(xx2(ind3)-1,a);
psf2(ind4) = DC_PSF(xx2(ind4)+1,a);
psf2 = Ca*psf2;

% Create plot window
figure(2)
clf

% Plot the psf
plot(xx2,psf2,'k','linewidth',lwidth)
axis([-1.5 1.5 0 25])
box off
set(gca,'ytick',[0,10,20,23.4],'fontsize',fsize)
%set(gca,'yticklabel',{},'fontsize',fsize)
set(gca,'xtick',[-1,0,1],'fontsize',fsize)
set(gca,'PlotBoxAspectRatio' , [2 1 1])


