files=dir(['C:\Documents and Settings\sylvie lorsolo\My Documents\research\frances\data\wavelength analysis\filtered\1500\x_section_filtered\*.mat']);

% total=[];
%  for fil=5%:2%length(files)
%      load(['C:\Documents and Settings\sylvie lorsolo\My Documents\research\frances\data\wavelength analysis\filtered\1500\',files(fil).name]);
%      for ii=1:length(lambda)
% %         peaks=lambda(ii).peaks(:,:);
% %         [m,n]=size(peaks);
% %         peaks=reshape(peaks,(m*n),1);
% %         u_zeros=find(peaks >0);
% %         peaks=peaks(u_zeros);
% %         total=[total;peaks];
%           
%      end
%  end
% 
% edges=[0 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 Inf];%[0 150 300 450 600 750 900 1050 1200 1350];%
% n=histc(total,edges);
% bar(n);
% set(gca,'XTick',1:16);
% set(gca,'XTickLabel','');
% x_axis=[50 150 250 350 450 550 650 750 850 950 1050 1150 1250 1350 1450 1550];%[75 225 375 525 675 825 975 1125 1275 1425 1575];%
% set(gca,'XTicklabel',x_axis);


% for each trans at all heights and for all files
% for ii=1%:2:13%length(lambda)
%     total=[];
% for fil=1:12%length(files)
%     load(['C:\Documents and Settings\sylvie lorsolo\My Documents\research\frances\data\wavelength analysis\filtered\10000\',files(fil).name]);
%     
%         peaks=lambda(ii).peaks(:,1:21);
%         [m,n]=size(peaks);
%         peaks=reshape(peaks,(m*n),1);
%         u_zeros=find(peaks ==0);
%         peaks(u_zeros)=NaN;
%         total=[total;peaks];
%      
%     end
%        edges=[0 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000 3100 3200 3300 Inf];%[0 150 300 450 600 750 900 1050 1200 1350];%
% n=histc(total,edges);
% figure
% bar(n);
% set(gca,'XTick',1:2:32);
% set(gca,'XTickLabel','');
% x_axis=[50  250  450  650  850  1050  1250  1450  1650  1850  2050  2250  2450 2650 2850 3050 3250 3450 3650 3850];%[75 225 375 525 675 825 975 1125 1275 1425 1575];%
% set(gca,'XTicklabel',x_axis);
% title(['all all height ',num2str(lambda(ii).trans),' up to 500m']);
% end


%For all trans at each height
total=[];
for fil=1:12%:length(files)
    load(['C:\Documents and Settings\sylvie lorsolo\My Documents\research\frances\data\wavelength analysis\filtered\1500\x_section_filtered\',files(fil).name]);
    for ii=1:13%length(lambda)
        
        [lignes,colonnes]=size(lambda(ii).peaks);
            peaks=lambda(ii).peaks;
            total=[total;peaks];
            
    end
end
u_zeros=find(total ==0);
total(u_zeros)=NaN;
edges=0:100:5000;
n=histc(total,edges);
x_axis=50:100:5000;
n=n(1:length(x_axis),:);
n1=n;
for i=1:colonnes
    u_nzeros=find(n1(:,i) ~=0);
    sigma=sum(n1(u_nzeros,i));
    n1(u_nzeros,i)=n1(u_nzeros,i)./sigma;
end
figure
z=lambda(1).zd2(1:colonnes,1);
contourf(x_axis,z,n')
colorbar
title(['# of occurrences (filt:5000)']);
figure
contourf(x_axis,z,100*n1')
colorbar
title(['Percentage (filt:5000)']);
% % set(gca,'XTicklabel',x_axis);





% For each trans at each height
% total=[];
% for fil=1:12%:length(files)
%     load(['C:\Documents and Settings\sylvie lorsolo\My Documents\research\frances\data\wavelength analysis\filtered\1500\',files(fil).name]);
%     for ii=1%:13%length(lambda)
%         
%         [lignes,colonnes]=size(lambda(ii).peaks);
%             peaks=lambda(ii).peaks;
%             total=[total;peaks];
%             
%     end
%     
% end
% u_zeros=find(total ==0);
% total(u_zeros)=NaN;
% edges=0:100:5000;
% n=histc(total,edges);
% x_axis=50:100:5000;
% n=n(1:length(x_axis),:);
% n1=n;
% for i=1:colonnes
%     u_nzeros=find(n1(:,i) ~=0);
%     sigma=sum(n1(u_nzeros,i));
%     n1(u_nzeros,i)=n1(u_nzeros,i)./sigma;
% end
% figure
% z=lambda(1).zd2(1:colonnes,1);
% contourf(x_axis,z,n')
% colorbar
% title(['# of occurrences (filt:5000)']);
% figure
% contourf(x_axis,z,100*n1')
% colorbar
% title(['Percentage (filt:5000)']);