% Matlab Script: Make spectral function map and plot it
decim=10; % decimation of the x-axis (to make lighter images)
P=40; % number of the grid points per letter in numerical calculation
let_len=0.5; %2.7/2; % letter length (mkm)
energy_resolution=0.04; % energy smearing scale to simulate polariton life-time


ff_tmp=ff(1:280,[1:decim:end]); % cut off the unnecessary energies
mn=size(ff_tmp);
% artifially extend the length to have higher FT resolution
ff_tmp=[zeros(mn(1),mn(2)) ff_tmp zeros(mn(1),mn(2))];

% for jj=1:400;ff_nl_ft(jj,:)=fftshift(fft(ff_nl(jj,:)));end
ff_ft=fftshift(fft(ff_tmp,[],2),2);

[map_ft,ens] = eigmode_map(ff_ft,idos(1,2:2:560),energy_resolution);
figure
xxxx=size(map_ft,2);
imagesc([-xxxx/2:(xxxx/2-1)]*2*(P/decim)*pi/xxxx/let_len,ens,map_ft); axis xy
xlabel('k [\mum^{-1}]','Interpreter','Tex')
ylabel('$E [meV]$','Interpreter','LaTex')
clear xxxx ff_tmp mn