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

root/adcp/trunk/adcp/nortek/nortek_waveplot.m

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

Adding diwasp customizations.

Line 
1 function [E_WI,I_WI,nortek_WI,fig1,fig2]=nortek_waveplot(EMEP,IMLM,sysinfo,nortekspec)
2
3 %make sure to load the EMEP, IMLM and wavesmon samples
4 %EMEP=load('emep'), IMLM=load('imlm'), spec=load('wavesmon')
5 %rangeE=load('EMEP_range'), rangeI=load('IMLM_range')
6
7 %set up the wavesmon data in a structure
8
9 %what is the magnetic variation to nearest degree
10 magvar=10;
11
12 %what is the frequency and dir resolution for those generated in DIWASP
13 freqres=0.01;
14 freqs=[0.01:0.01:.4];
15 dirres=2;
16 dirs=[-180:2:180];
17
18 %what is the frequency and dir resolution for those created by nortek
19 %freqres is the same
20 nortekfreqs=[0.01:0.01:.4];
21 nortekdirres=4;
22 nortekdirs=[270:-4:-86];
23 nortek.S=nortekspec;
24 nortek.dirs=nortekdirs;
25 nortek.freqs=nortekfreqs;
26 nortek.xaxisdir=90;
27
28 % plot the spectrum generated through DIWASP
29
30 scrsz = get(0,'ScreenSize');
31 fig1=figure('Position',[scrsz]);
32 subplot(2,2,1);
33 subplotspec(EMEP,4);
34 title('EMEP AST beam and radial velocities');
35
36 subplot(2,2,2);
37 subplotspec(IMLM,4);
38 title('IMLM AST beam and radial velocities');
39
40 subplot(2,2,3);
41 subplotspec(nortek,4);
42 title('nortek quick wave spectrum');
43
44
45 %calculate just the dir energy spectrum on a single graph
46
47 EMEPdir=sum(EMEP.S)*freqres;
48 IMLMdir=sum(real(IMLM.S))*freqres;
49 nortekdir=sum(nortek.S)*freqres;
50
51
52 %calculate just the frequency energy spectrum
53 EMEPfreq=sum(EMEP.S')*dirres;
54 IMLMfreq=sum(real(IMLM.S)')*dirres;
55 nortekfreq=sum(nortek.S')*nortekdirres;
56
57 %Find the maximum for the directional spectrum so we can set up the proper
58 %x-axis
59 [maxvalue,maxindex] = max(EMEPdir);
60 maxdir=dirs(maxindex);
61 % set up the x-axis for all of the spectra depending on the max
62 if ((100 < maxdir) | (maxdir < -100));
63     %for diwasp spectra
64     index1=find(dirs < 0);
65     index2=find(dirs > -1);
66     dirs(index1)=dirs(index1) +360;
67     %for nortek
68     Aindex=find(nortek.dirs < 0);               
69     Bindex=find((-1 < nortek.dirs) & (nortek.dirs < 361));
70     Bindex2=find(nortek.dirs > 360);
71     nortek.dirs(Bindex2)=nortek.dirs(Bindex2)-360;
72     nortek.dirs(Aindex)=nortek.dirs(Aindex)+360;
73
74     %plot the directional energy spectrum
75     fig2=figure('Position',[scrsz]);
76     subplot(1,2,1);
77     h1 = plot(dirs(index2),EMEPdir(index2),'b');
78     hold on
79     h1a= plot(dirs(index1),EMEPdir(index1),'b');
80     h2 = plot(dirs(index2),IMLMdir(index2),'r');
81     h2a= plot(dirs(index1),IMLMdir(index1),'r');
82     %plot the nortek data
83     h3 = plot(nortek.dirs(Bindex2),nortekdir(Bindex2),'k');
84     h3a = plot(nortek.dirs(Bindex),nortekdir(Bindex),'k');
85     h3b= plot(nortek.dirs(Aindex),nortekdir(Aindex),'k');
86 else
87     %for diwasp spectra do nothing
88    
89     %for nortek
90     Aindex=find(nortek.dirs > 180);
91     Bindex=find(nortek.dirs < 181);
92     nortek.dirs(Aindex)=nortek.dirs(Aindex)-360;
93     %plot the directional energy spectrum
94     fig2=figure('Position',[scrsz]);
95     subplot(1,2,1);
96     h1 = plot(dirs,EMEPdir,'b');
97     hold on
98     h2 = plot(dirs,IMLMdir,'r');
99     %plot the nortek data
100     h3a = plot(nortek.dirs(Bindex),nortekdir(Bindex),'k');
101     h3b = plot(nortek.dirs(Aindex),nortekdir(Aindex),'k');
102    
103 end
104
105 legend([h1, h2, h3a],'EMEP','IMLM','nortek quickwave','location','best');
106 title('directional wave spectrum integrated over frequency');
107 xlabel('axis angle (degrees true)');
108 ylabel('m^2 / deg');
109
110 %plot the frequency energy spectrum
111 subplot(1,2,2);
112 plot(freqs,EMEPfreq,'b');
113 hold on
114 plot(freqs,IMLMfreq,'r');
115 plot(nortekfreqs,nortekfreq,'k');
116 legend('EMEP','IMLM','nortek quickwave','location','best');
117 title('directional wave spectrum integrated over direction');
118 xlabel('frequency in Hz');
119 ylabel('m^2 / hz');
120
121 % ______Calculate and display the wave parameters SigH, Tp, Dp,DTp_______
122
123 %For EMEP AST and radial velocities
124
125 %calculate the 0,1,2 moments
126 m0=sum(EMEPfreq*freqres);                             
127 m1=sum(freqs.*EMEPfreq*freqres);
128 m2=sum((freqs.^2).*EMEPfreq*freqres);
129 % Calculate the Sig wave height
130 EMEP_Hsig=4*sqrt(m0);
131
132 % Calculate the peak period Tp
133 [P,I]=max(EMEPfreq);
134 EMEP_Tp=1/(freqs(I));
135
136 %Calculate the Direction of the peak period DTp
137 [P,I]=max(real(EMEP.S(I,:)));
138 EMEP_DTp=dirs(I);
139
140 %Calculate the Dominant Direction Dp
141 [P,I]=max(EMEPdir);
142 EMEP_Dp=dirs(I);
143
144 %Display on the screen the SigH,Tp,Dp,DTp
145 disp(['EMEP']);
146 disp(['SigH (meters): ' num2str(EMEP_Hsig)]);
147 disp(['peak period (seconds): ' num2str(EMEP_Tp)]);
148 disp(['Dir of peak period: ' num2str(compangle(EMEP_DTp, EMEP.xaxisdir))]);
149 disp(['Dominant Direction: ' num2str(compangle(EMEP_Dp, EMEP.xaxisdir))]);
150 disp(['  ']);
151
152 E_WI.hsig=EMEP_Hsig;
153 E_WI.tp=EMEP_Tp;
154 E_WI.dtp=compangle(EMEP_DTp, EMEP.xaxisdir);
155 E_WI.dp=compangle(EMEP_Dp, EMEP.xaxisdir);
156
157
158 % For IMLM AST and radial velocities
159
160 %calculate the 0,1,2 moments
161 m0=sum(IMLMfreq*freqres);                             
162 m1=sum(freqs.*IMLMfreq*freqres);
163 m2=sum((freqs.^2).*IMLMfreq*freqres);
164 % Calculate the Sig wave height
165 IMLM_Hsig=4*sqrt(m0);
166
167 % Calculate the peak period Tp
168 [P,I]=max(IMLMfreq);
169 IMLM_Tp=1/(freqs(I));
170
171 %Calculate the Direction of the peak period DTp
172 [P,I]=max(real(IMLM.S(I,:)));
173 IMLM_DTp=dirs(I);
174
175 %Calculate the Dominant Direction Dp
176 [P,I]=max(IMLMdir);
177 IMLM_Dp=dirs(I);
178
179 %Display on the screen the SigH,Tp,Dp,DTp
180 disp(['IMLM']);
181 disp(['SigH (meters): ' num2str(IMLM_Hsig)]);
182 disp(['peak period (seconds): ' num2str(IMLM_Tp)]);
183 disp(['Dir of peak period: ' num2str(compangle(IMLM_DTp, IMLM.xaxisdir))]);
184 disp(['Dominant Direction: ' num2str(compangle(IMLM_Dp, IMLM.xaxisdir))]);
185 disp(['  ']);
186
187 I_WI.hsig=IMLM_Hsig;
188 I_WI.tp=IMLM_Tp;
189 I_WI.dtp=compangle(IMLM_DTp, IMLM.xaxisdir);
190 I_WI.dp=compangle(IMLM_Dp, IMLM.xaxisdir);
191
192
193
194 %for nortek generated spectrum
195
196 %calculate the 0,1,2 moments
197 m0=sum(nortekfreq*freqres);                             
198 m1=sum(nortekfreqs.*nortekfreq*freqres);
199 m2=sum((nortekfreqs.^2).*nortekfreq*freqres);
200 % Calculate the Sig wave height
201 nortek_Hsig=4*sqrt(m0);
202
203 % Calculate the peak period Tp
204 [P,I]=max(nortekfreq);
205 nortek_Tp=1/(nortekfreqs(I));
206
207 %Calculate the Direction of the peak period DTp
208 [P,I]=max(real(nortek.S(I,:)));
209 nortek_DTp=nortekdirs(I);
210
211 %Calculate the Dominant Direction Dp
212 [P,I]=max(nortekdir);
213 nortek_Dp=nortekdirs(I);
214
215 %Display on the screen the SigH,Tp,Dp,DTp
216 disp(['nortek']);
217 disp(['SigH (meters): ' num2str(nortek_Hsig)]);
218 disp(['peak period (seconds): ' num2str(nortek_Tp)]);
219 disp(['Dir of peak period: ' num2str(compangle(nortek_DTp, nortek.xaxisdir))]);
220 disp(['Dominant Direction: ' num2str(compangle(nortek_Dp, nortek.xaxisdir))]);
221 disp(['  ']);
222
223 nortek_WI.hsig=nortek_Hsig;
224 nortek_WI.tp=nortek_Tp;
225 nortek_WI.dtp=compangle(nortek_DTp, nortek.xaxisdir);
226 nortek_WI.dp=compangle(nortek_Dp, nortek.xaxisdir);
227
228
229
230 %function to change from axis angles to compass bearings
231
232 function angle=compangle(angle,xaxisdir)
233 angle=xaxisdir*ones(size(angle))-angle;
234 angle=angle+360*(angle<0);
235 angle=angle-360*(angle>360);
236
237
238
239
240
Note: See TracBrowser for help on using the browser.