% function [retval] = bao10300_month_loop_func( by, bm, bd, ey, em, ed ) % Plot combined wind and temp/Rh monthly data from BAO data loggers function [retval] = bao10300_month_loop_func( by, bm, bd, ey, em, ed ) pltflg = 1; %flag to plot the data: 1=yes, 0=no pngflg = 1; %flag to make a png of the plot: 1=yes, 0=no have_trh = 0; %flag not to plot TRH: 1=yes, 0=no if ispc inpath = 'z:\BAO\Tower\Processed\monthly\'; outpath = 'z:\BAO\Tower\Processed_Images\monthly\'; else inpath = '/archive/BAO/Tower/Processed/monthly/'; outpath = '/archive/BAO/Tower/Processed_Images/monthly/'; 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]); bdv=datevec(bdn); edv=datevec(edn); yr = bdv(1); mo = bdv(2); nloops = edv(2) + (edv(1) - bdv(1)) * 12 - bdv(2) + 1; for i = 1:nloops name10 = sprintf('%sBAO_010_%4d%02d.dat', inpath, yr, mo ); name300 = sprintf('%sBAO_300_%4d%02d.dat', inpath, yr, mo ); fprintf(1,'*** Processing 10m and 300m monthly ***\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 %%%%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 fid300 = fopen( name300 ); if( fid300 > 0 ) fclose( fid300 ); else fprintf(1,'No 300m: %s\n',name300); continue; end data10 = load(name10); nmax = 90000; [data300 dt n] = load300( name300, nmax); hhmm = data10(:,4); hh = fix(hhmm/100); mn = hhmm - (hh*100); data10(:,3)=data10(:,3)+(((mn/60.)+hh)/24)+datenum(data10(:,2)-1,12,31); %Julian day clear hhmm hh mm %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 nr = size(data10,1); jdb = fix(data10(1,3)); jde = fix(data10(nr,3))+1; if pltflg %check for plotting figure1 = figure('Position',[10 50 650 650]); subplot(2,1,1),plot(data10(:,3),data10(:,7)) hold subplot(2,1,1),plot(dt(1:n,7),data300(1:n,1),'r') stitle=sprintf('BAO %4d-%02d 10m and 300m', yr, mo); title(stitle) ylabel('Speed (m/s)') %xlim([jdb,jde]) elim = max(max(data10(:,7)),max(data300(1:n,1)))+2.0; %legend('10m','300m'); xlabel('Day (UTC)') datetick('x','mm/dd','keeplimits','keepticks'); legend('10m','300m','Location','NorthEast','Orientation','horizontal'); legend('boxoff'); axis tight grid on ylim([0 elim]) subplot(2,1,2),plot(data10(:,3),data10(:,12),'bx','MarkerSize',4) hold subplot(2,1,2),plot(dt(1:n,7),data300(1:n,14),'rx','MarkerSize',4) set(gca,'YTick',[0 90 180 270 360]) ylabel('Dir (True)') %xlim([jdb,jde]) xlabel('Day (UTC)') datetick('x','mm/dd','keeplimits','keepticks'); axis tight grid on ylim([0 360]) 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%02d_WS.png',... outpath, yr, mo ); set(gcf,'PaperPositionMode','auto'); print('-dpng', print_buffer); %f=getframe(gcf); %imwrite(f.cdata,print_buffer,'png'); end end % skip plotting if have_trh %check for plotting figure2 = figure('Position',[10 50 650 650]); clf subplot(2,1,1),plot(data10(:,3),data10(:,5)) hold subplot(2,1,1),plot(dt(1:n,7),data300(1:n,13),'r') stitle=sprintf('BAO %4d-%02d 10m and 300m', yr, mo); title(stitle) ylabel('Temp (C)') xlim([jdb,jde]) %gis = find( data10(:,5) > -50. ); gip = find( data300(:,13) > -50. ); blims(1) = min(data300(gip,13))-5; elims(1) = max(data300(gip,13))+5; %blims(2) = min(data10(gis,5))-10; %elims(2) = max(data10(gis,5))+10; xlabel('Day (UTC)') datetick('x','mm/dd','keeplimits','keepticks'); legend('10m','300m','Location','Best','Orientation','horizontal'); legend('boxoff'); axis tight grid on ylim([min(blims) max(elims)]) subplot(2,1,2),plot(data10(:,3),data10(:,6)) hold subplot(2,1,2),plot(dt(1:n,7),data300(1:n,9),'r') ylabel('RH (%)') xlim([jdb,jde]) xlabel('Day (UTC)') datetick('x','mm/dd','keeplimits','keepticks'); axis tight grid on ylim([0 105]) 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_10300_%4d%02d_TRH.png',... outpath, yr, mo ); set(gcf,'PaperPositionMode','auto'); print('-dpng', print_buffer); %f=getframe(gcf); %imwrite(f.cdata,print_buffer,'png'); end end % skip plotting clear data10 data300 dt close all mo = mo + 1; if mo > 12 mo = mo - 12; yr = yr + 1; end end % loop through all files clear all retval = 0;