function twodviewing(mychoice) %A callback function that is called from cmgadcpview.m, % cannot be run on its own. global yhand adcp; if nargin<1 help(mfilename);return;end; colordepth=100; delt=24*mean(diff(adcp.time)); %hours plotlength=ceil(adcp.wl/delt); % only ploting 72 hrs of data at a time midpoint=ceil(plotlength/2); [m,n]=size(adcp.data{1,1}); set(yhand.ensambleslide,'sliderstep',[1/m,1/plotlength]); start=1+floor(m*get(yhand.ensambleslide,'value')); if start>=m-midpoint, start=m-midpoint; end; stop=start+plotlength-1; if stop>m, stop=m; end; switch mychoice case {1,2} set(yhand.prenxt,'enable','on'); pens=start+midpoint-1; axes(yhand.spdimage); thedata=adcp.data{mychoice,1}(start:stop,:)' + adcp.offset(mychoice,1); thedata=thedata/((adcp.offset(mychoice,1) + adcp.max(mychoice,1))/colordepth); image(start:stop,1:n,thedata,'buttondownfcn','twodviewing(3)'); axis xy; ylabel(adcp.ylab); hold on; adcp.spdmarker=plot([pens pens],[1 n],'w:','linewidth',2); hold off; hh=colorbar; set(hh,'ytick',[25:25:100],'yticklabel',... (adcp.offset(mychoice,1) + adcp.max(mychoice,1))/colordepth*(adcp.scale{mychoice})); hhh=get(hh,'title'); set(hhh,'string',adcp.cbar{mychoice,1},'rotation',90,'pos',[-1 50 10]); axes(yhand.dirimage); thedata=adcp.data{mychoice,2}(start:stop,:)' + adcp.offset(mychoice,2); thedata=thedata/((adcp.offset(mychoice,2) + adcp.max(mychoice,2))/colordepth); image(start:stop,1:n,thedata,'buttondownfcn','twodviewing(3)'); axis xy; ylabel(adcp.ylab); pgreg=gregorian(adcp.time(start)); pdate0=[num2str(pgreg(1)),'-',num2str(pgreg(2)),'-',num2str(pgreg(3))]; pgreg=gregorian(adcp.time(stop)); pdate1=[num2str(pgreg(1)),'-',num2str(pgreg(2)),'-',num2str(pgreg(3))]; halfway=(start+stop)/2; halfwaystr='Click image to see a profile'; set(gca,'xtick',[start halfway stop],'xticklabel',{pdate0 halfwaystr pdate1}); hold on; adcp.dirmarker=plot([pens pens],[1 n],'w:','linewidth',2); hold off; hh=colorbar; set(hh,'ytick',[25:25:100],'yticklabel',... (adcp.offset(mychoice,2) + adcp.max(mychoice,2))/colordepth*(adcp.scale{mychoice})); hhh=get(hh,'title'); set(hhh,'string',adcp.cbar{mychoice,2},'rotation',90,'pos',[-1 50 10]); if mychoice==1 myticks=[0 1/4 1/2 3/4 1]; else myticks=[-1 -1/2 0 1/2 1]; end; if pens>=m, pens=m-1;end; axes(yhand.spdprofile); adcp.hps=plot(adcp.data{mychoice,1}(pens,:),1:n,'bs','erasemode','xor'); axis([[myticks(1) myticks(5)]*adcp.max(mychoice,1) 1 n]); set(gca,'xtick',myticks*adcp.max(mychoice,1),... 'xgrid','on',... 'xticklabel',myticks*adcp.max(mychoice,1)); xlabel(adcp.cbar{mychoice,1}); axes(yhand.dirprofile); adcp.hpd=plot(adcp.data{mychoice,2}(pens,:),1:n,'rs','erasemode','xor'); axis([[myticks(1) myticks(5)]*adcp.max(mychoice,2) 1 n]); set(gca,'xtick',myticks*adcp.max(mychoice,2),... 'xgrid','on',... 'xticklabel',myticks*adcp.max(mychoice,2)); xlabel(adcp.cbar{mychoice,2}); pgreg=gregorian(adcp.time(pens)); pdate=[num2str(pgreg(1)),'-',num2str(pgreg(2)),'-',num2str(pgreg(3))]; ptime=[num2str(pgreg(4)),':',num2str(pgreg(5)),':',num2str(pgreg(6))]; pens=num2str(pens); set(yhand.adcptxt,'string',{['Ensamble: ' pens],['Date: ' pdate],['Time: ' ptime]}); case 3 thechoice=2 - get(yhand.uvsdradio(2),'value'); pens=get(gca,'currentpoint'); pens=ceil(pens(1)); set(yhand.prenxt,'enable','on'); refresh(thechoice,pens); case 4 thechoice=2 - get(yhand.uvsdradio(2),'value'); pens=get(adcp.spdmarker,'xdata'); pens=pens(1); if gco==yhand.prenxt(1) pens=pens-1; if pens<1, pens=1;end; if pens=stop, set(yhand.prenxt(2),'enable','off'); end; if pens>start, set(yhand.prenxt(1),'enable','on'); end; end; refresh(thechoice,pens); case 10 if get(gco,'value')==1 set(get(gco,'UserData'),'value',0); else set(gco,'value',1); end; if strcmpi(get(gco,'string'),'[spd,dir]') set(yhand.ensambleslide,'callback','twodviewing(1)'); twodviewing(1); adcp.choice=1; else set(yhand.ensambleslide,'callback','twodviewing(2)'); adcpviewing(2); adcp.choice=2; end; case 11 wl=24*[3 1 7 30 floor(max(adcp.time)-min(adcp.time))]; adcp.wl=wl(get(yhand.windl,'value')); adcpviewing(adcp.choice); end; function refresh(thechoice,pens) % redrawing plots after new time is elected global adcp yhand set(adcp.spdmarker,'xdata',[pens pens]); set(adcp.dirmarker,'xdata',[pens pens]); set(adcp.hps,'xdata',adcp.data{thechoice,1}(pens,:)); set(adcp.hpd,'xdata',adcp.data{thechoice,2}(pens,:)); pgreg=gregorian(adcp.time(pens)); pdate=[num2str(pgreg(1)),'-',num2str(pgreg(2)),'-',num2str(pgreg(3))]; ptime=[num2str(pgreg(4)),':',num2str(pgreg(5)),':',num2str(pgreg(6))]; pens=num2str(pens); set(yhand.adcptxt,'string',{['Ensamble: ' pens],['Date: ' pdate],['Time: ' ptime]}); return;