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

root/DPWavesProc/trunk/DPWavesProc/nortek/nortek_waveplot.m

Revision 215 (checked in by gdusek, 16 years ago)

--

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 %Compute the coefficient for the upper and lower error bounds for the
58 %frequency
59 %spectrum assuming 95% confidence.  Added on 9/17/08
60 degF=2*EMEP.degF; % 2* since for the Nortek the range beam sampled at 4hz (4096) is decimated or averaged to 2hz (2048)
61 chiUp=chi2inv(.975,degF);
62 chiLow=chi2inv(.025,degF);
63 coeffUp=degF/chiLow;
64 coeffLow=degF/chiUp;
65
66 %calculate the conf limits throughout the frequency spectrum
67 EMEPfreqUP=EMEPfreq*coeffUp;
68 EMEPfreqLOW=EMEPfreq*coeffLow;
69 IMLMfreqUP=IMLMfreq*coeffUp;
70 IMLMfreqLOW=IMLMfreq*coeffLow;
71
72 %Find the maximum for the directional spectrum so we can set up the proper
73 %x-axis
74 [maxvalue,maxindex] = max(EMEPdir);
75 maxdir=dirs(maxindex);
76 % set up the x-axis for all of the spectra depending on the max
77 if ((100 < maxdir) | (maxdir < -100));
78     %for diwasp spectra
79     index1=find(dirs < 0);
80     index2=find(dirs > -1);
81     dirs(index1)=dirs(index1) +360;
82     %for nortek
83     Aindex=find(nortek.dirs < 0);               
84     Bindex=find((-1 < nortek.dirs) & (nortek.dirs < 361));
85     Bindex2=find(nortek.dirs > 360);
86     nortek.dirs(Bindex2)=nortek.dirs(Bindex2)-360;
87     nortek.dirs(Aindex)=nortek.dirs(Aindex)+360;
88
89     %plot the directional energy spectrum
90     fig2=figure('Position',[scrsz]);
91     subplot(1,2,1);
92     h1 = plot(dirs(index2),EMEPdir(index2),'b');
93     hold on
94     h1a= plot(dirs(index1),EMEPdir(index1),'b');
95     h2 = plot(dirs(index2),IMLMdir(index2),'r');
96     h2a= plot(dirs(index1),IMLMdir(index1),'r');
97     %plot the nortek data
98     h3 = plot(nortek.dirs(Bindex2),nortekdir(Bindex2),'k');
99     h3a = plot(nortek.dirs(Bindex),nortekdir(Bindex),'k');
100     h3b= plot(nortek.dirs(Aindex),nortekdir(Aindex),'k');
101 else
102     %for diwasp spectra do nothing
103    
104     %for nortek
105     Aindex=find(nortek.dirs > 180);
106     Bindex=find(nortek.dirs < 181);
107     nortek.dirs(Aindex)=nortek.dirs(Aindex)-360;
108     %plot the directional energy spectrum
109     fig2=figure('Position',[scrsz]);
110     subplot(1,2,1);
111     h1 = plot(dirs,EMEPdir,'b');
112     hold on
113     h2 = plot(dirs,IMLMdir,'r');
114     %plot the nortek data
115     h3a = plot(nortek.dirs(Bindex),nortekdir(Bindex),'k');
116     h3b = plot(nortek.dirs(Aindex),nortekdir(Aindex),'k');
117    
118 end
119
120 legend([h1, h2, h3a],'EMEP','IMLM','nortek quickwave','location','best');
121 title('directional wave spectrum integrated over frequency');
122 xlabel('axis angle (degrees true)');
123 ylabel('m^2 / deg');
124
125 %plot the frequency energy spectrum
126 subplot(1,2,2);
127 h1=plot(freqs,EMEPfreq,'b');
128 hold on
129 h2=plot(freqs,EMEPfreqUP,'b--');
130 plot(freqs,EMEPfreqLOW,'b--');
131 h3=plot(freqs,IMLMfreq,'r');
132 h4=plot(freqs,IMLMfreqUP,'r--');
133 plot(freqs,IMLMfreqLOW,'r--');
134 h5=plot(nortekfreqs,nortekfreq,'k');
135 legend('EMEP','EMEP 95% confidence','IMLM','IMLM 95% confidence','nortek quickwave','location','best');
136 title('directional wave spectrum integrated over direction');
137 xlabel('frequency in Hz');
138 ylabel('m^2 / hz');
139
140 % ______Calculate and display the wave parameters SigH, Tp, Dp,DTp_______
141
142 %For EMEP AST and radial velocities
143
144 %calculate the 0,1,2 moments
145 m0=sum(EMEPfreq*freqres);                             
146 m1=sum(freqs.*EMEPfreq*freqres);
147 m2=sum((freqs.^2).*EMEPfreq*freqres);
148 % Calculate the Sig wave height
149 EMEP_Hsig=4*sqrt(m0);
150 %Use the function HsigConf.m to calculate the sigH confidence limits
151 EMEP_HsConf=nortek_HsigConf(EMEP);
152
153 % Calculate the peak period Tp
154 [P,I]=max(EMEPfreq);
155 EMEP_Tp=1/(freqs(I));
156
157 %Calculate the Direction of the peak period DTp
158 [P,I]=max(real(EMEP.S(I,:)));
159 EMEP_DTp=dirs(I);
160
161 %Calculate the Dominant Direction Dp
162 [P,I]=max(EMEPdir);
163 EMEP_Dp=dirs(I);
164
165 %Display on the screen the SigH,Tp,Dp,DTp
166 disp(['EMEP']);
167 disp(['SigH (meters): ' num2str(EMEP_Hsig)]);
168 disp(['SigH 95% conf. (meters): ' num2str(EMEP_HsConf)]);
169 disp(['peak period (seconds): ' num2str(EMEP_Tp)]);
170 disp(['Dir of peak period: ' num2str(compangle(EMEP_DTp, EMEP.xaxisdir))]);
171 disp(['Dominant Direction: ' num2str(compangle(EMEP_Dp, EMEP.xaxisdir))]);
172 disp(['  ']);
173
174 E_WI.hsig=EMEP_Hsig;
175 E_WI.hconf=EMEP_HsConf;
176 E_WI.tp=EMEP_Tp;
177 E_WI.dtp=compangle(EMEP_DTp, EMEP.xaxisdir);
178 E_WI.dp=compangle(EMEP_Dp, EMEP.xaxisdir);
179
180
181 % For IMLM AST and radial velocities
182
183 %calculate the 0,1,2 moments
184 m0=sum(IMLMfreq*freqres);                             
185 m1=sum(freqs.*IMLMfreq*freqres);
186 m2=sum((freqs.^2).*IMLMfreq*freqres);
187 % Calculate the Sig wave height
188 IMLM_Hsig=4*sqrt(m0);
189 %Use the function HsigConf.m to calculate the sigH confidence limits
190 IMLM_HsConf=nortek_HsigConf(IMLM);
191
192 % Calculate the peak period Tp
193 [P,I]=max(IMLMfreq);
194 IMLM_Tp=1/(freqs(I));
195
196 %Calculate the Direction of the peak period DTp
197 [P,I]=max(real(IMLM.S(I,:)));
198 IMLM_DTp=dirs(I);
199
200 %Calculate the Dominant Direction Dp
201 [P,I]=max(IMLMdir);
202 IMLM_Dp=dirs(I);
203
204 %Display on the screen the SigH,Tp,Dp,DTp
205 disp(['IMLM']);
206 disp(['SigH (meters): ' num2str(IMLM_Hsig)]);
207 disp(['SigH 95% conf. (meters): ' num2str(IMLM_HsConf)]);
208 disp(['peak period (seconds): ' num2str(IMLM_Tp)]);
209 disp(['Dir of peak period: ' num2str(compangle(IMLM_DTp, IMLM.xaxisdir))]);
210 disp(['Dominant Direction: ' num2str(compangle(IMLM_Dp, IMLM.xaxisdir))]);
211 disp(['  ']);
212
213 I_WI.hsig=IMLM_Hsig;
214 I_WI.hconf=IMLM_HsConf;
215 I_WI.tp=IMLM_Tp;
216 I_WI.dtp=compangle(IMLM_DTp, IMLM.xaxisdir);
217 I_WI.dp=compangle(IMLM_Dp, IMLM.xaxisdir);
218
219
220
221 %for nortek generated spectrum
222
223 %calculate the 0,1,2 moments
224 m0=sum(nortekfreq*freqres);                             
225 m1=sum(nortekfreqs.*nortekfreq*freqres);
226 m2=sum((nortekfreqs.^2).*nortekfreq*freqres);
227 % Calculate the Sig wave height
228 nortek_Hsig=4*sqrt(m0);
229
230 % Calculate the peak period Tp
231 [P,I]=max(nortekfreq);
232 nortek_Tp=1/(nortekfreqs(I));
233
234 %Calculate the Direction of the peak period DTp
235 [P,I]=max(real(nortek.S(I,:)));
236 nortek_DTp=nortekdirs(I);
237
238 %Calculate the Dominant Direction Dp
239 [P,I]=max(nortekdir);
240 nortek_Dp=nortekdirs(I);
241
242 %Display on the screen the SigH,Tp,Dp,DTp
243 disp(['nortek']);
244 disp(['SigH (meters): ' num2str(nortek_Hsig)]);
245 disp(['peak period (seconds): ' num2str(nortek_Tp)]);
246 disp(['Dir of peak period: ' num2str(compangle(nortek_DTp, nortek.xaxisdir))]);
247 disp(['Dominant Direction: ' num2str(compangle(nortek_Dp, nortek.xaxisdir))]);
248 disp(['  ']);
249
250 nortek_WI.hsig=nortek_Hsig;
251 nortek_WI.hconf=[NaN NaN];
252 nortek_WI.tp=nortek_Tp;
253 nortek_WI.dtp=compangle(nortek_DTp, nortek.xaxisdir);
254 nortek_WI.dp=compangle(nortek_Dp, nortek.xaxisdir);
255
256
257
258 %function to change from axis angles to compass bearings
259
260 function angle=compangle(angle,xaxisdir)
261 angle=xaxisdir*ones(size(angle))-angle;
262 angle=angle+360*(angle<0);
263 angle=angle-360*(angle>360);
264
265
266
267
268
Note: See TracBrowser for help on using the browser.