%BAOPLT010_loop_func % Plot data from BAO data loggers % Systems turned back on April 2007 % Not calibrated old sensors % 10m %ID,YR,YearDay,hhmm,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] = BAOPLTsodar_loop_func_new( 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 if ispc inpath = 'z:\bao\Tower\Sodar\Raw\'; outpath = 'z:\bao\Tower\Sodar\Images\'; else inpath = '/archive/BAO/Tower/Sodar/Raw/'; outpath = '/archive/BAO/Tower/Sodar/Processed_Images/'; end %cd(inpath); if( nargin == 0 ) bys = input('Input the beginning year to process (2007) ','s'); bms = input('Input the beginning the month to process (1-12) ','s'); bds = input('Input the beginning day to process (1-31) ','s'); eys = input('Input the endding year to process (2007) ','s'); ems = input('Input the endding the month to process (1-12) ','s'); eds = input('Input the endding 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]); for idn = bdn:edn dv=datevec(idn); yday = md2yd( dv(1), dv(2), dv(3) ); fname = sprintf('%s%02d%03d_sodarpc.nc', inpath, dv(1)-2000, yday ); fprintf(1,'*** Processing Sodar daily %d-%02d-%02d yd %03d***\n',... dv(1),dv(2),dv(3),yday); fid = fopen( fname ); if( fid > 0 ) fclose( fid ); else fprintf(1,'No sodar file: %s\n',fname); continue; end ncid = netcdf.open(fname,'NC_NOWRITE'); [tname,tlen]=netcdf.inqDim(ncid,3); tid = netcdf.inqVarID(ncid,'Time'); rid = netcdf.inqVarID(ncid,'ReflectivityData'); time = netcdf.getVar(ncid,tid,'double'); ref = netcdf.getVar(ncid,rid,'double'); netcdf.close(ncid); dt=datenum(1970,1,1,0,0,time); hts=1.:1.:500; deltahr=.5; bh=0; eh=bh+deltahr; nplots = 24 / (4 * deltahr); if pltflg % do plots if pltflg=1 for ip=1:nplots figure1 = figure('Position',[100 50 650 650]); bhp = bh; ehp = bhp + deltahr * 4; stitle=sprintf('BAO %4d-%02d-%02d %02d-%02d Sodar backscatter',... dv(1),dv(2),dv(3),bhp,ehp); if ip == 1 cms=256; colormap(gray(cms)) cm=colormap(); cm1=cm; cm(cms:-1:1,:)=cm1(1:cms,:); end for i=1:4 bt=datenum(dv(1),dv(2),dv(3),bh,0,0); et=datenum(dv(1),dv(2),dv(3),eh,0,0); dtindx=find(dt>=bt & dt<=et); if ~isempty(dtindx) dta6=dt(dtindx); refa = ref(:,dtindx); zindx=refa < 10.0; refa(zindx) = 10.0; lra6=log10(refa(1:500,:)); dm2i=lra6 > 5.; lra6(dm2i)= 4.0; dmax=max(max(max(lra6)),4.0); dmed=min(median(refa(400:500,:))); dmin=log10(dmed); %dmin=min(min(lra6)); %if dmin < 1.0 % dmin = 1.0; %else % dmin = 1.7845; %end else lra6=ones(500,360); deltat=60.0/86400.; dta6=bt:deltat:et-deltat; dmax=4.4; dmin=1.0; end subplot(4,1,i),imagesc(dta6,hts,lra6,[dmin dmax]); if i == 1 title(stitle) end if i == 4 xlabel('Time (UTC)') end ylabel('Ht (m)') xlim([bt et]) axis xy colormap(cm) set(gca,'XTick',bt:(et-bt)/6.:et) datetick('x','HH:MM','keeplimits','keepticks'); bh = bh + deltahr; eh = eh + deltahr; end 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_SFC_%4d%03d_%02d-%02d_Sodar.png',... outpath, dv(1), yday, bhp, ehp ); set(gcf,'PaperPositionMode','auto'); print('-dpng', print_buffer); end close all end %for number of plots end %if pltflg end % loop through all files clear all retval = 0;