
clear all;
close all;

clear all;
read_parameters_rhb
fclose('all');
%%%%%%%%%
tit = cruise;
lt = length(cruise);
tit(lt+1) = '-';
tit((lt+2):lt+5) = year;

days =input('Input YYMMDD to evaluate (071001, 071002, 071003....): ','s');
fname = '070517*.csv';
fname(1:6) = days;
s1=[way_raw_data_aerosol fname];
s=way_raw_data_aerosol;

a=dir(s1);
%%%%%%%%

day=days;

time=[];chnl0=[];chnl1=[];chnl2=[];chnl3=[];chnl4=[];chnl5=[];flow_rate=[];
ict = 0;
for i=1:length(a)  %loop though hourly csv files
	a(i).name
	%temp=importdata([w.path a(i).name],',');
    temp=importdata([way_raw_data_aerosol a(i).name],',');

	hr=str2num(a(i).name(7:8));
	time1=[];
	
	for j=2:length(temp.textdata)
ict = ict + 1;
		dummy=temp.textdata(j,2);

		dummy=dummy{1};

        hour=str2num(dummy(2:3));

		minute=str2num(dummy(5:6));

		sec=str2num(dummy(8:9));
		
        tt(ict) = hour + ((minute +(sec/60))/60); %DEW 10182006
		%time1=[time1 hour*3600+minute*60+sec];
		clear minute sec dummy;
	end
		
	time=vertcat(time,time1');
	flow_rate=vertcat(flow_rate,temp.data(:,1));
	chnl0=vertcat(chnl0,temp.data(:,4));
	chnl1=vertcat(chnl1,temp.data(:,6));
	chnl2=vertcat(chnl2,temp.data(:,8));
	chnl3=vertcat(chnl3,temp.data(:,10));
	chnl4=vertcat(chnl4,temp.data(:,12));
	chnl5=vertcat(chnl5,temp.data(:,14));

	clear temp hour time1;

end


figure()
set(gcf,'defaultaxesfonts',12)
set(gca,'fontname','time','fontsize',10);
subplot(2,1,1)
%semilogy((time-time(1))/3600,chnl0,'b.')
%hold on
%semilogy((time-time(1))/3600,chnl1,'r.')
%semilogy((time-time(1))/3600,chnl2,'g.')
%semilogy((time-time(1))/3600,chnl3,'y.')
%semilogy((time-time(1))/3600,chnl4,'c.')
%semilogy((time-time(1))/3600,chnl5,'k.')
% DEW Oct 18,2006
semilogy(tt,chnl0,'b.')
hold on
semilogy(tt,chnl1,'r.')
semilogy(tt,chnl2,'g.')
semilogy(tt,chnl3,'y.')
semilogy(tt,chnl4,'c.')
semilogy(tt,chnl5,'k.')
%h=legend('0.1 \mum','0.2 \mum','0.3 \mum','0.5 \mum','1 \mum','5 \mum','location','best')
h=legend('0.1 \mum','0.2 \mum','0.3 \mum','0.5 \mum','1 \mum','5 \mum','orientation','horizontal','location','bestoutside');
set(h,'fontsize',8)
ylabel('Particles (m^{-3})');
ylim([10^0 10^6])
title([tit ' ' num2str(day)])
xlim([0 24])
subplot(2,1,2)
semilogy(tt,chnl0+chnl1+chnl2+chnl3+chnl4+chnl5,'k.');
%semilogy((time-time(1))/3600,chnl0+chnl1+chnl2+chnl3+chnl4+chnl5,'k.');
ylabel('No. of Particles (m^{-3})');
xlabel('UTC Time (Hour)')
title(['Total No. of particles'])
xlim([0 24]);ylim([1000 1000000])

print_buffer = [way_images_aerosol cruise '_' year '_pms_' days,'.jpg'];
print('-djpeg90 ', print_buffer);


figure
subplot(2,1,1)
semilogy(tt,chnl0,'b.')
ylabel('No of Particles 0.3 \mum')
title([tit ' ' num2str(day)])
%%%flow=2.829e4
subplot(2,1,2)
semilogy(tt,flow_rate,'r')

xlabel('UTC Time (Hour)')
ylabel('Flow Rate (cc/min)')

print_buffer = [way_images_aerosol cruise '_' year '_pms_flowrate_' days,'.jpg'];
print('-djpeg90 ', print_buffer);

 
