NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/adcp/trunk/adcp/diwasp_1_1GD/subplotspec.m

Revision 168 (checked in by cbc, 16 years ago)

Adding diwasp customizations.

Line 
1 function plotspec(SM,ptype);
2
3 %DIWASP V1.1 function
4 %plotspec: plots the spectral matrix in 3D or polar form
5 %
6 %plotspec(SM,ptype)
7 %
8 %Inputs:
9 % SM            A spectral matrix structure
10 % ptype         plot type:
11 %   1   3D surface plot
12 %   2   polar type plot
13 %   3   3D surface plot (compass bearing angles)
14 %   4   polar type plot   (compass bearing angles)
15 %
16 %The 3D surface plot type is a MATLAB surface plot with SM.freqs on the x axis, SM.dirs on the y axis and the spectral density, SM.S as the z value.
17 %The polar type plot is a MATLAB polar plot with the direction showing values in SM.dirs, the radius showing values in SM.freqs
18 %and contours representing the spectral density, SM.S. An example of the polar type plot is shown on the front cover of the manual.
19 %For both plot types, the direction is the direction of propagation (see also The DIWASP spectrum file format). 
20 %For options 3 and 4 the direction is the compass bearing. This is calculated from the SM.xaxisdir input that defines the orientation of the axes.
21 %Note that if SM.xaxisdir is 90 the appearance of the polar plot is unchanged.
22 %
23 %"help data_structures" for information on the DIWASP data structures
24
25 %Copyright (C) 2002 Coastal Oceanography Group, CWR, UWA, Perth
26
27
28
29 SM=check_data(SM,2);if isempty(SM) return;end;
30 dirs=SM.dirs;ffreqs=SM.freqs;S=real(SM.S);
31
32 if (ptype==3|ptype==4)
33       xaxisdir=SM.xaxisdir;
34       if ~(xaxisdir >=0 & xaxisdir <=360)
35          warning('xaxisdir must be between 0 and 360 -set to default value of 90');
36          xaxisdir=90;
37       end   
38 end
39
40 if(ptype==1|ptype==3)
41       if(ptype==3)
42         dirs=xaxisdir*ones(size(dirs))-dirs;
43          dirs=dirs+360*(dirs<0);
44          dirs=dirs-360*(dirs>360);
45         [dirs,order]=sort(dirs);
46         else
47          order=([1:max(size(dirs))]);
48       end
49    [ddir,df]=meshgrid(dirs,ffreqs);
50    surf(df,ddir,real(S(:,order)));
51    
52    shading interp;
53    xlabel('frequency [Hz]');
54    if(ptype==1)
55       ylabel('direction [degrees]');
56       axis([0 (max(ffreqs)) -180 180 0 (max(max(S)))]);
57
58    else
59       ylabel('direction [bearing]');
60       axis([0 (max(ffreqs)) 0 360 0 (max(max(S)))]);
61    end
62    zlabel('m^2s / deg');
63    
64 elseif(ptype==2|ptype==4)
65    if(ptype==4)
66       dirs=(90-xaxisdir)*ones(size(dirs))+dirs;
67    end
68    h = polar([0 2*pi], [0 0.4]); %[0 0.8*max(ffreqs)]);  Changed on 5/25/07
69    delete(h);
70    
71    [df,ddir]=meshgrid(ffreqs,dirs);
72    
73 %uses the existing polar figure function and replaces numbering of angles for compass directions. Will probably be changed in future versions.
74         if(ptype==4)
75    set(0,'ShowHiddenHandles','on')
76    chhs=get(gca,'Children');
77    for i=1:size(chhs,1);
78       obj=chhs(i);
79       if strcmp(get(obj,'Type'),'text')
80          num=str2num(get(obj,'String'));
81          if~(isempty(num))
82          if mod(num,30)==0
83             num=90-num;
84             num=(num<0)*360+num;
85             set(obj,'String',num2str(num));
86          end
87          end
88       end
89    end
90    set(0,'ShowHiddenHandles','off')
91    end
92          
93    hold on;
94    
95         [px,py]=pol2cart(ddir*pi/180,df);
96         contour(px,py,real(S'),20);
97    
98    
99    
100     caxis([0 max(max(S))]); %caxis([0 0.02]);
101     cb=colorbar('vert');
102     %set(cb,'CLim',[0 0.02]);
103    
104    if(ptype==2)
105       ylabel('direction [degrees] / frequency [Hz]');
106    else
107       ylabel('direction [bearing] / frequency [Hz]');
108    end
109         xlabel('m^2s / deg');
110     hold off;
111 end
112
113 set(gca,'Color','none');
114
115
Note: See TracBrowser for help on using the browser.