%BAOPLT300_loop_func % Plot data from GMD 300m BAO data loggers % Dave has split these data into daily files and corrected the PRT and Wind Dir %You are correct on all counts. yes, m/s on the wind speed. %The PRT temperature is (accurate to within 0.1 deg C) is: a0 + %a1*(D3_PRTRES_Avg) + a2*(D3_PRTRES_Avg)^2 + a3*(D3_PRTRES_Avg)^3, %a0 = -246.058 %a1 = 2.36626 %a2 = 0.000923807 %a3 = 2.43906e-007 %The sonic anemometer is on the south boom % The north pole points to 322 degrees. %The the true wind direction should then be (SE2_SONICWD_Avg) - 38 degrees % % 300m %"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","PRT_AVG","SONICWDT_AVG" %"TS","RN","ms","Deg","Deg","ms","mV","","Deg C","Deg C","%","Counts","ms","Volts","DegC","Deg True" %"2007-06-14 14:22:00",0,3.37,230.5,0.502,0.012,13.42,105.8471,14.24,15.09,42.15,0,110.6,13.31,15.0,192.5 %"2007-06-14 14:22:30",1,3.418,231.1,0.269,0.026,13.38,105.8718,14.3,15.11,42.26,0,110.6,13.31,15.1,193.1 function [retval] = BAOPLT300_Profiler_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\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) ); name300 = sprintf('%sBAO_300_%4d%03d.dat', inpath, dv(1), yday ); fprintf(1,'*** Processing 300m daily ***\n'); fid300 = fopen( name300 ); if( fid300 > 0 ) fclose( fid300 ); else fprintf(1,'No 300m: %s\n',name300); continue; end [data300 dt n] = load300( name300, nmax); jdb = fix(dt(1,7)); jde = fix(dt(n,7)) + 1; times = zeros(6,48); nhts = zeros(48,1); delta = zeros(48,1); ht = zeros(40,48); s = zeros(40,48); d = zeros(40,48); fname = sprintf('c:/src/CorrectedWinds/data/W%02d%03d.CNS', dv(1)-2000, yday ); [fid fmess] = fopen(fname, 'r'); line=fgetl(fid); j = 0; while ~feof(fid) j = j + 1; line=fgetl(fid); line=fgetl(fid); line=fgetl(fid); line=fgetl(fid); time = sscanf(line,'%d %d %d %d %d %d'); times(1:6,j) = time(1:6); line=fgetl(fid); nht = sscanf(line,'%d %d %d'); nhts(j) = nht(3); line=fgetl(fid); line=fgetl(fid); rpar = sscanf(line,'%d %d %d %d %d'); delta(j) = rpar(5); line=fgetl(fid); line=fgetl(fid); line=fgetl(fid); for i = 1:nhts(j) line=fgetl(fid); data = sscanf(line,'%f %f %f'); ht(i,j) = data(1); s(i,j) = data(2); d(i,j) = data(3); end % read in the last line '$' line=fgetl(fid); end times(1,1:j)=times(1,1:j)+2000; yd(1:j)=datenum(times(1,1:j),times(2,1:j),times(3,1:j),times(4,1:j),times(5,1:j),times(6,1:j)); if pltflg % do plots if pltflg=1 figure2 = figure('Position',[10 50 650 650]); subplot(2,1,1),plot(dt(1:n,7),data300(1:n,1)) stitle=sprintf('BAO %4d-%02d-%02d 300m vs WP', dv(1),dv(2),dv(3)); title(stitle) ylim([0,max(data300(1:n,1))+5]) xlim([jdb,jde]) ylabel('Spd (m/s)') xlabel('Hour (UTC)') datetick('x','HH','keeplimits'); grid on hold lm = find(delta < 500 ); hm = find(delta > 500 ); subplot(2,1,1),plot(yd(lm),s(3,lm),'r.') subplot(2,1,1),plot(yd(lm),s(4,lm),'g.') subplot(2,1,1),plot(yd(hm),s(2,hm),'y.') subplot(2,1,1),plot(yd(hm),s(3,hm),'k.') subplot(2,1,2),plot(dt(1:n,7),data300(1:n,14),'bx','MarkerSize',4) xlim([jdb,jde]) ylim([0 360]) ylabel('Dir (true)') xlabel('Hour (UTC)') datetick('x','HH','keeplimits'); grid on hold legend('L259','L315','H266','H364','Location','North','Orientation','Horizontal') subplot(2,1,2),plot(dt(1:n,7),data300(1:n,14),'bx','MarkerSize',4) xlim([jdb,jde]) ylim([0 360]) ylabel('Dir (true)') xlabel('Hour (UTC)') datetick('x','HH','keeplimits'); grid on hold subplot(2,1,2),plot(yd(lm),d(3,lm),'r.') subplot(2,1,2),plot(yd(lm),d(4,lm),'g.') subplot(2,1,2),plot(yd(hm),d(2,hm),'y.') subplot(2,1,2),plot(yd(hm),d(3,hm),'k.') 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_300WP_%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 end clear data300 dt close all end % loop though each day retval = 0;