%%%addpath where the files are!%%%%


%%%%%% COMPOSITE OF CEILOMETER BACKSCATTER %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



pathdata = 'C:\NEAQS_2004\ETLceilometer\results\';

eval(['cd ', pathdata]);

a = dir('*.txt');

k = length(a);


[num] = num2str(k);
disp('Number of ceilometer *.txt files : '); disp( [num]); 

st=1%%%%%%%%%%%%%%%%%%%%%%%by changing st you can plot they dates separetely

for w = st:k;

[numf] = num2str(w);


disp('# of *.txt file in process :'); disp ( [numf]); 

%%%%%%% k is the # of *.cdf files need to be processed. %%%%%%%%

data = [a(w).name]
scatter_data = ['backscatter_' a(w).name(1:12)];
load(scatter_data);
ceil_series = load(data);

ceil_time = str2num(data(1:3))+(ceil_hr+ceil_mn/60+ceil_sc/3600)/24;

if w == st 

sf = length(ceil_time);
time_all = ceil_time;
height_all = height;
backscatter = ceil_b;
base        = ceil_series(:,2);
else
    
    gf = length(time_all);
    sf = length(ceil_time);
    time_all(gf+1:gf+sf)=ceil_time;
    backscatter(1:256,gf+1:gf+sf)=ceil_b;
    base(gf+1:gf+sf)=ceil_series(:,2);
end


end

figure(6)
set(gcf,'DefaultAxesFonts',12);
imagesc(time_all(1:3:length(time_all)),height(1:100)*.303,log10(abs(backscatter(1:100,1:3:length(time_all)))),[1 3.5]);
axis xy; colorbar;
%ylim([0 3000]);
xlabel('Day','FontName','times','FontSize',12);
ylabel('Height (m)','FontName','times','FontSize',12);
title('NEAQS 2004 Ceilometer Backscatter','FontName','times','FontSize',12);
print_buffer = ['C:\NEAQS_2004\ETLceilometer\results\NEAQS2004_ceilometer_alldays_backscatter_b.jpg'];
print('-djpeg90 ', print_buffer);

pause(5);
figure(5)
set(gcf,'DefaultAxesFonts',12);
plot(time_all(1:3:length(time_all)),base(1:3:length(time_all)),'b.');
xlim([min(time_all) max(time_all)]);
%ylim([0 4000]);
xlabel('Day','FontName','times','FontSize',16);
ylabel('Height (m)','FontName','times','FontSize',12);
title('NEAQS 2004, Ceilometer Cloud Base','FontName','times','FontSize',12);
print_buffer = ['C:\NEAQS_2004\ETLceilometer\results\NEAQS2004_ceilometer_alldays_base_b.jpg'];
print('-djpeg90 ', print_buffer);
pause(5);
