%BAOPLT10_month_loop_func % Plot data from BAO data loggers % Systems turned back on April 2007 % Not calibrated old sensors % 10m %ID,year,YearDay,ddmm,T,RH,WS,WSvec,DIR,Dsig,VDC,P,Precip,Corrected Dir %10,2007,099,1413,7.35,87.654,.305,.305,292.84,2.03,13.981,826.61,0,111.234 function [retval] = BAOPLTSFC_month_loop_func( by, bm, bd, ey, em, ed ) %clear 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 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); year = 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, year, mo ); fprintf(1,'*** Processing 10m monthly ***\n'); fidsfc = fopen( name10 ); if( fidsfc > 0 ) fclose( fidsfc ); else fprintf(1,'No 10m: %s\n',name10); continue; end datasfc = load(name10); %load 1 month of PSD mean logger data ddmm = datasfc(:,4); dd = fix(ddmm/100); mm = ddmm - (dd*100); yday = datasfc(1,3); datasfc(:,3)=datasfc(:,3)+(((mm/60.)+dd)/24)+datenum(datasfc(:,2)-1,12,31); %year day clear ddmm dd mm jdb = fix(datasfc(1,3)); jde = fix(datasfc(size(datasfc,1),3))+1; if pltflg % do plots if pltflg=1 figure1 = figure('Position',[10 50 650 650]); subplot(2,1,1),plot(datasfc(:,3),datasfc(:,5)) stitle=sprintf('BAO %4d-%02d 10m', year, mo); title(stitle) gi = find( datasfc(:,5) > -50.0 ); blim = min(datasfc(gi,5))-5; elim = max(datasfc(gi,5))+5; %xlim([jdb,jde]) ylabel('T (C)') xlabel('Day (UTC)') datetick('x','mm/dd','keeplimits','keepticks'); axis tight grid on ylim([blim elim]) subplot(2,1,2),plot(datasfc(:,3),datasfc(:,6)) ylabel('Rh (%)') %xlim([jdb,jde]) xlabel('Day (UTC)') datetick('x','mm/dd','keeplimits','keepticks'); axis tight grid on ylim([0,109]) 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_010_%4d%02d_TRH.png',... outpath, year, mo ); set(gcf,'PaperPositionMode','auto'); print('-dpng', print_buffer); %f=getframe(gcf); %imwrite(f.cdata,print_buffer,'png'); end figure2 = figure('Position',[10 50 650 650]); subplot(2,1,1),plot(datasfc(:,3),datasfc(:,7)) title(stitle) ylabel('Spd (m/s)') %xlim([jdb,jde]) xlabel('Day (UTC)') datetick('x','mm/dd','keeplimits','keepticks'); axis tight grid on subplot(2,1,2),plot(datasfc(:,3),datasfc(:,14),'bx','MarkerSize',4) xlabel('Year Day (UTC)') ylabel('Dir (true)') %xlim([jdb,jde]) xlabel('Day (UTC)') datetick('x','mm/dd','keeplimits','keepticks'); axis tight grid on ylim([0 360]) 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_010_%4d%02d_WS.png',... outpath, year, mo ); set(gcf,'PaperPositionMode','auto'); print('-dpng', print_buffer); %f=getframe(gcf); %imwrite(f.cdata,print_buffer,'png'); end %Total precip Before 2007 year-day 270 precip in mm after inches tp = cumsum(datasfc(:,13)); if yday < 270 && year < 2008 totpmm = tp; else totpmm = tp*25.4; end tpmm = totpmm(length(totpmm)); tpin = tpmm / 25.4; figure3 = figure('Position',[10 50 650 650]); subplot(2,1,1),plot(datasfc(:,3),datasfc(:,12)) stitle=sprintf('BAO %4d-%02d Surface', year, mo); title(stitle) %xlim([jdb,jde]) ylabel('Pressure (mb)') xlabel('Day (UTC)') datetick('x','mm/dd','keeplimits','keepticks'); axis tight grid on ylim([800 880]) subplot(2,1,2),plot(datasfc(:,3),totpmm,'r.') ctp = sprintf('Total precipitation %.2f mm (%.2f in)',tpmm,tpin); title(ctp) ylabel('Precip (mm)') xlabel('Day (UTC)') datetick('x','mm/dd','keeplimits','keepticks'); axis tight grid on ylim([0 max(tpmm)+1.0]) annotation(figure3,'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_SFC_%4d%02d_PP.png',... outpath, year, mo ); set(gcf,'PaperPositionMode','auto'); print('-dpng', print_buffer); end end % if doing plots clear datasfc yday tp totpmm tpmm tpin close all mo = mo + 1; if mo > 12 mo = mo - 12; year = year + 1; end end % loop through all files retval = 0;