%BAOPLT10100300 % Plot daily combined data for levels 10, 100 and 300 meters. clear close all outpath = 'Z:\bao\Tower\Processed_Images\daily\'; doplot = 1; % do the plot 1=yes 0=no pngflg = 1; % save data to png's flag 1= yes 0 = no name10 = 'Z:\bao\Tower\Processed\daily\BAO_010_2007165.dat'; name100 = 'Z:\bao\Tower\Processed\daily\BAO_100_2007165.dat'; name300 = 'Z:\bao\Tower\Processed\daily\BAO_300_2007165.dat'; bds = input('Input the beginning day to process (165) ','s'); eds = input('Input end day to process (168) ','s'); ym = input('Input year to process (2007) ','s'); year = str2double( ym ); name10(38:41) = ym; name100(38:41) = ym; name300(38:41) = ym; bd = str2double(bds); ed = str2double(eds); for i = bd:ed is = sprintf('%03d', i); fprintf(1,'*** Processing %s %s ***\n', ym, is); name10(42:44) = is; name100(42:44) = is; name300(42:44) = is; %%%%%%%10m data %1 2 3 4 5 6 7 8 9 10 11 12 13 14 %ID YR YD hhmm T RH WSv WSs Dir WDt Bat press precip WDT %10,2007,165,1405,15.095,50.858,1.810,-999.000,238.61,-999.0000,13.515,843.01,0.000,212.610 %10,2007,165,1406,15.115,50.448,1.692,-999.000,245.47,-999.0000,13.514,842.98,0.000,219.470 %%%%%%%100m data %1 2 3 4 5 6 7 8 9 10 11 12 13 14 %ID YR YD hhmm T RH WSv WSs Dir WDt Bat press precip WDT %100,2007,244,5,29.848,19.414,0,0,0,0,13.132 %100,2007,244,6,29.849,19.333,0,0,0,0,13.132 %%%%300m data %"TOA5","CR1000","CR1000","2846","CR1000.Std.11","CPU:060516b_Met.CR1","10044","wkt30m" %"TIMESTAMP","RECORD","SE1_SONICWS_Avg","SE2_SONICWD_Avg","SE2_SONICWD_Std","SE1_SONICWS_Std","SE3_SONICTEMP_Avg","D3_PRTRES_Avg","D3_PRTTEMPAPPROX_Avg","SE4_HMPTEMP_Avg","SE9_HMPRH_Avg","P1_AIRFLOW_Avg","SE10_ACPOWER","BT_BATVOLT_Min" %"TS","RN","mV","Deg","Deg","mV","mV","","Deg C","Deg C","%","Counts","mV","Volts" %"","","WVc","WVc","WVc","Std","Avg","Avg","Avg","Avg","Avg","Avg","Smp","Min" %"2007-10-01 00:00:00",312159,5.06,201.1,8.43,0.523,15.68,106.923,17,17.91,23.68,0,110.7,13.26,17.8,163.1 %"2007-10-01 00:00:30",312160,5.008,183.5,3.734,0.294,15.49,106.9227,17,17.9,25.13,0,110.7,13.26,17.8,145.5 fid10 = fopen( name10 ); if( fid10 > 0 ) fclose( fid10 ); else fprintf(1,'No 10m: %s\n',name10); continue; end fid100 = fopen( name100 ); if( fid100 > 0 ) have100 = 1; fclose( fid100 ); else have100 = 0; fprintf(1,'No 100m: %s\n',name100); end fid300 = fopen( name300 ); if( fid300 > 0 ) fclose( fid300 ); else fprintf(1,'No 300m: %s\n',name300); continue; end data10 = load(name10); if have100 data100 = load(name100); end fprintf(1,' 10m: %s\n',name10); if have100 fprintf(1,'100m: %s\n',name100); end fprintf(1,'300m: %s\n',name300); nmax = 2880; year = zeros(1,nmax); month = zeros(1,nmax); day = zeros(1,nmax); hour = zeros(1,nmax); minute = zeros(1,nmax); sec = zeros(1,nmax); yday = zeros(1,nmax); bao300 = zeros( nmax, 15); f300 = fopen(name300,'r'); %load f:\BAO_CR10\data\bao10.dat %read in 4 header lines tmp=fgetl(f300); tmp=fgetl(f300); tmp=fgetl(f300); tmp=fgetl(f300); n = 0; while ~feof(f300) %for x = 1:10000 n = n + 1; temp=fgetl(f300); year(n)= str2double(temp(2:5)); month(n)= str2double(temp(7:8)); day(n)= str2double(temp(10:11)); hour(n)= str2double(temp(13:14)); minute(n)= str2double(temp(16:17)); sec(n)= str2double(temp(19:20)); lt= length(temp); % strip off date/time info from first part of each line s1 = temp(23:lt); % convert each , to a blank space s1 = strrep( s1, ',', ' ' ); [data]=sscanf(s1,'%f') ; bao300(n,1) = data(2,1); % WS ms Sonic bao300(n,2) = data(3,1); % WD deg Sonic bao300(n,3) = data(4,1); % WD std deg Sonic bao300(n,4) = data(5,1); % WS STD Sonic bao300(n,5) = data(6,1); % Temp deg C Sonic bao300(n,6) = data(7,1); % PRT temp resistance bao300(n,7) = data(8,1); % PRT temp deg C bao300(n,8) = data(9,1); % HMT Temp Deg C bao300(n,9) = data(10,1); % RH bao300(n,10) = data(11,1); % airflow bao300(n,11) = data(12,1); % VAC bao300(n,12) = data(13,1); % Bat VDC bao300(n,13) = data(14,1); % PRT corrected deg C bao300(n,14) = data(15,1); % Dir true end yd300 = datenum(year,month,day,hour,minute,sec)-datenum(year-1,12,31); hhmm = data10(:,4); hh = fix(hhmm/100); mn = hhmm - (hh*100); data10(:,3) = data10(:,3) + (((mn/60.) + hh)/24); %Julian day clear hhmm hh mm if have100 hhmm = data100(:,4); hh = fix(hhmm/100); mn = hhmm - (hh*100); data100(:,3) = data100(:,3) + (((mn/60.) + hh)/24); %Julian day clear hhmm hh mm end %10m prop vane was on the north boom until Aug 3 ~1600 UTC when it was moved to %the south boom % N is 154 to correct we add 206 and correct for > 360 ld = length(data10); jdb = fix(data10(1,3)); jde = fix(data10(ld,3))+1; % if have100 % ld2 = length(data100); % jdb2 = fix(data100(1,3)); % jde2 = fix(data100(ld2,3))+1; % end %CSD experiment %jdb = 208; %jde = 222; if doplot %skip plotting figure(1) clf subplot(2,1,1),plot(data10(:,3),data10(:,7)) hold %subplot(2,1,1),plot(data100(:,3),data100(:,7),'k') subplot(2,1,1),plot(yd300(1:n),bao300(1:n,1),'r') title(name10(38:44)) ylabel('Speed (m/s)') xlim([jdb,jde]) elim = max(bao300(1:n,1))+5; ylim([0 elim]) legend('10m','300m','Location','Best','Orientation','horizontal'); %legend('boxoff'); %axis([110,116,820,850]) subplot(2,1,2),plot(data10(:,3),data10(:,14)) hold %subplot(2,1,1),plot(data100(:,3),data100(:,14),'k') subplot(2,1,2),plot(yd300(1:n),bao300(1:n,14),'r') xlabel('Year Day') ylabel('Dir (True)') xlim([jdb,jde]) ylim([0 360]) %axis([110,116,0,.5]) if pngflg print_buffer = [outpath 'BAO_10300_WS_' ym is '.png']; print('-dpng ', print_buffer); end if have100 figure(2) clf subplot(2,1,1),plot(data10(:,3),data10(:,5)) hold subplot(2,1,1),plot(data100(:,3),data100(:,5),'k') subplot(2,1,1),plot(yd300(1:n),bao300(1:n,13),'r') title(name10(38:44)) ylabel('Temp (C)') xlim([jdb,jde]) blim = min(data10(:,5))-10; elim = max(data10(:,5))+10; ylim([blim elim]) legend('10m','100m','300m','Location','Best','Orientation','horizontal'); %legend('boxoff'); %legend('10m','100m','300m','Location','SouthEast'); subplot(2,1,2),plot(data10(:,3),data10(:,6)) hold subplot(2,1,2),plot(data100(:,3),data100(:,6),'k') subplot(2,1,2),plot(yd300(1:n),bao300(1:n,9),'r') xlabel('Year Day') ylabel('RH (%)') xlim([jdb,jde]) ylim([0 105]) if pngflg print_buffer = [outpath 'BAO_10100300_TRH_' ym is '.png']; print('-dpng ', print_buffer); end end % if have100 data end % skip plotting clear bao300 data10 data100 end %loop through days