%BAOPLT10100300 % Plot daily combined data for levels 10, 100 and 300 meters. function [retval] = bao10100300_daily_func( by, bm, bd, ey, em, ed ) %clear pltflg = 1; % do the plot 1=yes 0=no pngflg = 1; % save data to png's flag 1= yes 0 = no if ispc inpath = 'z:\bao\Tower\Processed\daily\'; outpath = 'z:\bao\Tower\Processed_Images\daily\'; else inpath = '/archive/BAO/Tower/Processed/daily/'; outpath = '/archive/BAO/Tower/Processed_Images/daily/'; end %cd(inpath); if( nargin == 0 ) bys = input('Input year to process (2007) ','s'); bms = input('Input the month to process (1-12) ','s'); bds = input('Input the beginning day to process (1-31) ','s'); eys = input('Input year to process (2007) ','s'); ems = input('Input the month to process (1-12) ','s'); eds = input('Input end day to process (1-31) ','s'); by = str2double( bys ); bm = str2double( bms ); bd = str2double( bds ); ey = str2double( eys ); em = str2double( ems ); ed = str2double( eds ); end bdn = datenum([by bm bd 0 0 0]); edn = datenum([ey em ed 0 0 0]); nmax = 3000; for i = bdn:edn dv=datevec(i); if i == bdn && dv(4) > 0 continue end yday = md2yd( dv(1), dv(2), dv(3) ); name10 = sprintf('%sBAO_010_%4d%03d.dat', inpath, dv(1), yday ); name100 = sprintf('%sBAO_100_%4d%03d.dat', inpath, dv(1), yday ); name300 = sprintf('%sBAO_300_%4d%03d.dat', inpath, dv(1), yday ); fprintf(1,'*** Processing 10m, 100m, 300m daily ***\n'); %%%%%%%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 [data300 dt n] = load300( name300, nmax); hhmm = data10(:,4); hh = fix(hhmm/100); mm = hhmm - (hh*100); data10(:,3)=data10(:,3)+(((mm/60.)+hh)/24)+datenum(data10(:,2)-1,12,31); %Julian day clear hhmm hh mm if have100 hhmm = data100(:,4); hh = fix(hhmm/100); mm = hhmm - (hh*100); data100(:,3)=data100(:,3)+(((mm/60.)+hh)/24)+datenum(data100(:,2)-1,12,31); %Julian day clear hhmm hh mm end if pltflg %skip plotting figure1 = figure('Position',[10 50 650 650]); 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(dt(1:n,7),data300(1:n,1),'r') stitle=sprintf('BAO %4d-%02d-%02d 10m, 100m and 300m', dv(1),dv(2),dv(3)); title(stitle) elim = max(data300(1:n,1))+5; ylim([0 elim]) xlim([data10(1,3),data10(1,3)+1]) ylabel('Speed (m/s)') xlabel('Hour (UTC)') datetick('x','HH','keeplimits'); legend('10m','100m','300m','Location','Best','Orientation','horizontal'); legend('boxoff'); grid on subplot(2,1,2),plot(data10(:,3),data10(:,12),'bx','MarkerSize',4) hold subplot(2,1,2),plot(data100(:,3),data100(:,12),'kx','MarkerSize',4) subplot(2,1,2),plot(dt(1:n,7),data300(1:n,14),'rx','MarkerSize',4) set(gca,'YTick',[0 90 180 270 360]) xlabel('Year Day (UTC)') ylim([0 360]) xlim([data10(1,3),data10(1,3)+1]) ylabel('Dir (True)') xlabel('Hour (UTC)') datetick('x','HH','keeplimits'); grid on annotation(figure1,'textbox',[0.007154 0.01077 0.4498 0.02462],... 'String',{'NOAA/ESRL/PSD/Weather & Climate Physics'},... 'FontSize',8,'FitBoxToText','off','LineStyle','none'); if pngflg print_buffer = sprintf('%sBAO_10300_%4d%03d_WS.png',... outpath, dv(1), yday ); set(gcf,'PaperPositionMode','auto'); print('-dpng', print_buffer); %f=getframe(gcf); %imwrite(f.cdata,print_buffer,'png'); end if have100 figure2 = figure('Position',[10 50 650 650]); 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(dt(1:n,7),data300(1:n,13),'r') stitle=sprintf('BAO %4d-%02d-%02d 10m, 100m and 300m', dv(1),dv(2),dv(3)); title(stitle) ylabel('Temp (C)') %gis = find( data10(:,5) > -50. ); gih = find( data100(:,5) > -50. ); gip = find( data300(:,13) > -50. ); blims(1) = min(data300(gip,13))-5; elims(1) = max(data300(gip,13))+5; blims(2) = min(data100(gih,5))-5; elims(2) = max(data100(gih,5))+5; %blims(3) = min(data10(gis,5))-5; %elims(3) = max(data10(gis,5))+5; ylim([min(blims) max(elims)]) xlim([data10(1,3),data10(1,3)+1]) stitle=sprintf('BAO %4d-%02d-%02d 10m, 100m and 300m', dv(1),dv(2),dv(3)); title(stitle) ylabel('Temp (C)') xlabel('Hour (UTC)') datetick('x','HH','keeplimits'); legend('10m','100m','300m','Location','Best','Orientation','horizontal'); legend('boxoff'); grid on 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(dt(1:n,7),data300(1:n,9),'r') ylabel('RH (%)') ylim([0 105]) xlim([data10(1,3),data10(1,3)+1]) xlabel('Hour (UTC)') datetick('x','HH','keeplimits'); grid on annotation(figure2,'textbox',[0.007154 0.01077 0.4498 0.02462],... 'String',{'NOAA/ESRL/PSD/Weather & Climate Physics'},... 'FontSize',8,'FitBoxToText','off','LineStyle','none'); if pngflg print_buffer = sprintf('%sBAO_10100300_%4d%03d_TRH.png',... outpath, dv(1), yday ); set(gcf,'PaperPositionMode','auto'); print('-dpng', print_buffer); %f=getframe(gcf); %imwrite(f.cdata,print_buffer,'png'); end end % if have100 data end % skip plotting clear data300 dt data10 data100 close all end %loop through days clear all retval = 0;