1 |
function [E_UVW_WI,I_UVW_WI,E_range_WI,I_range_WI,wmon_WI,fig1,fig2]=waveplot(EMEP,IMLM,rangeE,rangeI,spec,sysinfo) |
---|
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 |
%first change to m^2/Hz/deg |
---|
13 |
wmon.S=spec/(360*1000*1000); |
---|
14 |
|
---|
15 |
%what is the start angle |
---|
16 |
heading=sysinfo(18,:); |
---|
17 |
heading=heading/100; |
---|
18 |
sangle=heading+magvar; |
---|
19 |
|
---|
20 |
%what is the frequency and dir resolution for those generated in DIWASP |
---|
21 |
freqres=0.01; |
---|
22 |
freqs=[0.01:0.01:.4]; |
---|
23 |
dirres=2; |
---|
24 |
dirs=[-180:2:180]; |
---|
25 |
|
---|
26 |
%set up the directions |
---|
27 |
adj_angle=90-sangle+360+180; |
---|
28 |
wmon.dirs=[adj_angle:-4:-(356-adj_angle)]; |
---|
29 |
wmondirres=4; |
---|
30 |
wmon.xaxisdir=90; |
---|
31 |
wmon.freqs=[0.00781250:0.00781250:1]; |
---|
32 |
wmonfreqres=0.00781250; |
---|
33 |
|
---|
34 |
% plot the spectrum generated through DIWASP |
---|
35 |
|
---|
36 |
scrsz = get(0,'ScreenSize'); |
---|
37 |
fig1=figure('Position',[scrsz]); |
---|
38 |
subplot(2,3,1); |
---|
39 |
subplotspec(EMEP,4); |
---|
40 |
title('EMEP uvw'); |
---|
41 |
|
---|
42 |
subplot(2,3,2); |
---|
43 |
subplotspec(IMLM,4); |
---|
44 |
title('IMLM uvw'); |
---|
45 |
|
---|
46 |
subplot(2,3,3); |
---|
47 |
subplotspec(wmon,4); |
---|
48 |
title('Wavesmon output'); |
---|
49 |
|
---|
50 |
subplot(2,3,4); |
---|
51 |
subplotspec(rangeE,4); |
---|
52 |
title('EMEP Range'); |
---|
53 |
|
---|
54 |
subplot(2,3,5); |
---|
55 |
subplotspec(rangeI,4); |
---|
56 |
title('IMLM Range'); |
---|
57 |
|
---|
58 |
%calculate just the dir energy spectrum on a single graph |
---|
59 |
|
---|
60 |
EMEPdir=sum(EMEP.S)*freqres; |
---|
61 |
IMLMdir=sum(real(IMLM.S))*freqres; |
---|
62 |
EMEPrangedir=sum(rangeE.S)*freqres; |
---|
63 |
IMLMrangedir=sum(real(rangeI.S))*freqres; |
---|
64 |
wmondir=sum(wmon.S)*wmonfreqres; |
---|
65 |
|
---|
66 |
%calculate just the frequency energy spectrum |
---|
67 |
EMEPfreq=sum(EMEP.S')*dirres; |
---|
68 |
IMLMfreq=sum(real(IMLM.S)')*dirres; |
---|
69 |
EMEPrangefreq=sum(rangeE.S')*dirres; |
---|
70 |
IMLMrangefreq=sum(real(rangeI.S)')*dirres; |
---|
71 |
wmonfreq=sum(wmon.S')*wmondirres; |
---|
72 |
|
---|
73 |
%Find the maximum for the directional spectrum so we can set up the proper |
---|
74 |
%x-axis |
---|
75 |
[maxvalue,maxindex] = max(EMEPdir); |
---|
76 |
maxdir=dirs(maxindex); |
---|
77 |
% set up the x-axis for all of the spectra depending on the max |
---|
78 |
if ((100 < maxdir) | (maxdir < -100)); |
---|
79 |
%for diwasp spectra |
---|
80 |
index1=find(dirs < 0); |
---|
81 |
index2=find(dirs > -1); |
---|
82 |
dirs(index1)=dirs(index1) +360; |
---|
83 |
%for wavesmon |
---|
84 |
Aindex=find(wmon.dirs < 0); |
---|
85 |
Bindex=find((-1 < wmon.dirs) & (wmon.dirs < 361)); |
---|
86 |
Bindex2=find(wmon.dirs > 360); |
---|
87 |
wmon.dirs(Bindex2)=wmon.dirs(Bindex2)-360; |
---|
88 |
wmon.dirs(Aindex)=wmon.dirs(Aindex)+360; |
---|
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),EMEPrangedir(index2),'r'); |
---|
96 |
h2a= plot(dirs(index1),EMEPrangedir(index1),'r'); |
---|
97 |
h3 = plot(dirs(index2),IMLMrangedir(index2),'g'); |
---|
98 |
h3a= plot(dirs(index1),IMLMrangedir(index1),'g'); |
---|
99 |
%plot the wavesmon data |
---|
100 |
h4 = plot(wmon.dirs(Bindex2),wmondir(Bindex2),'k'); |
---|
101 |
h4a = plot(wmon.dirs(Bindex),wmondir(Bindex),'k'); |
---|
102 |
h4b= plot(wmon.dirs(Aindex),wmondir(Aindex),'k'); |
---|
103 |
axis(axis); |
---|
104 |
h5 = plot(dirs(index2),IMLMdir(index2),'c'); |
---|
105 |
h5a= plot(dirs(index1),IMLMdir(index1),'c'); |
---|
106 |
|
---|
107 |
else |
---|
108 |
%for diwasp spectra do nothing |
---|
109 |
|
---|
110 |
%for wavesmon |
---|
111 |
Aindex=find(wmon.dirs > 180); |
---|
112 |
Bindex=find(wmon.dirs < 181); |
---|
113 |
wmon.dirs(Aindex)=wmon.dirs(Aindex)-360; |
---|
114 |
%plot the directional energy spectrum |
---|
115 |
fig2=figure('Position',[scrsz]); |
---|
116 |
subplot(1,2,1); |
---|
117 |
h1 = plot(dirs,EMEPdir,'b'); |
---|
118 |
hold on |
---|
119 |
h2 = plot(dirs,EMEPrangedir,'r'); |
---|
120 |
h3 = plot(dirs,IMLMrangedir,'g'); |
---|
121 |
%plot the wavesmon data |
---|
122 |
h4 = plot(wmon.dirs(Aindex),wmondir(Aindex),'k'); |
---|
123 |
h4a = plot(wmon.dirs(Bindex),wmondir(Bindex),'k'); |
---|
124 |
axis(axis); |
---|
125 |
h5 = plot(dirs,IMLMdir,'c'); |
---|
126 |
end |
---|
127 |
|
---|
128 |
legend([h1, h2, h3, h4, h5],'EMEP uvw','EMEP range','IMLM range','wavesmon','IMLM uvw','location','best'); |
---|
129 |
title('directional wave spectrum integrated over frequency'); |
---|
130 |
xlabel('axis angle (degrees true)'); |
---|
131 |
ylabel('m^2 / deg'); |
---|
132 |
|
---|
133 |
%plot the frequency energy spectrum |
---|
134 |
subplot(1,2,2); |
---|
135 |
plot(freqs,EMEPfreq,'b'); |
---|
136 |
hold on |
---|
137 |
plot(freqs,EMEPrangefreq,'r'); |
---|
138 |
plot(freqs,IMLMrangefreq,'g'); |
---|
139 |
plot(wmon.freqs,wmonfreq,'k'); |
---|
140 |
axis(axis); |
---|
141 |
plot(freqs,IMLMfreq,'c'); |
---|
142 |
legend('EMEP uvw','EMEP range','IMLM range','wavesmon','IMLM uvw','location','best'); |
---|
143 |
title('directional wave spectrum integrated over direction'); |
---|
144 |
xlabel('frequency in Hz'); |
---|
145 |
ylabel('m^2 / hz'); |
---|
146 |
|
---|
147 |
% ______Calculate and display the wave parameters SigH, Tp, Dp,DTp_______ |
---|
148 |
|
---|
149 |
%For EMEP uvw |
---|
150 |
|
---|
151 |
%calculate the 0,1,2 moments |
---|
152 |
m0=sum(EMEPfreq*freqres); |
---|
153 |
m1=sum(freqs.*EMEPfreq*freqres); |
---|
154 |
m2=sum((freqs.^2).*EMEPfreq*freqres); |
---|
155 |
% Calculate the Sig wave height |
---|
156 |
EMEP_UVW_Hsig=4*sqrt(m0); |
---|
157 |
|
---|
158 |
% Calculate the peak period Tp |
---|
159 |
[P,I]=max(EMEPfreq); |
---|
160 |
EMEP_UVW_Tp=1/(freqs(I)); |
---|
161 |
|
---|
162 |
%Calculate the Direction of the peak period DTp |
---|
163 |
[P,I]=max(real(EMEP.S(I,:))); |
---|
164 |
EMEP_UVW_DTp=dirs(I); |
---|
165 |
|
---|
166 |
%Calculate the Dominant Direction Dp |
---|
167 |
[P,I]=max(EMEPdir); |
---|
168 |
EMEP_UVW_Dp=dirs(I); |
---|
169 |
|
---|
170 |
%Display on the screen the SigH,Tp,Dp,DTp |
---|
171 |
disp(['EMEP uvw']); |
---|
172 |
disp(['SigH (meters): ' num2str(EMEP_UVW_Hsig)]); |
---|
173 |
disp(['peak period (seconds): ' num2str(EMEP_UVW_Tp)]); |
---|
174 |
disp(['Dir of peak period: ' num2str(compangle(EMEP_UVW_DTp, EMEP.xaxisdir))]); |
---|
175 |
disp(['Dominant Direction: ' num2str(compangle(EMEP_UVW_Dp, EMEP.xaxisdir))]); |
---|
176 |
disp([' ']); |
---|
177 |
|
---|
178 |
E_UVW_WI.hsig=EMEP_UVW_Hsig; |
---|
179 |
E_UVW_WI.tp=EMEP_UVW_Tp; |
---|
180 |
E_UVW_WI.dtp=compangle(EMEP_UVW_DTp, EMEP.xaxisdir); |
---|
181 |
E_UVW_WI.dp=compangle(EMEP_UVW_Dp, EMEP.xaxisdir); |
---|
182 |
|
---|
183 |
|
---|
184 |
% For IMLM uvw |
---|
185 |
|
---|
186 |
%calculate the 0,1,2 moments |
---|
187 |
m0=sum(IMLMfreq*freqres); |
---|
188 |
m1=sum(freqs.*IMLMfreq*freqres); |
---|
189 |
m2=sum((freqs.^2).*IMLMfreq*freqres); |
---|
190 |
% Calculate the Sig wave height |
---|
191 |
IMLM_UVW_Hsig=4*sqrt(m0); |
---|
192 |
|
---|
193 |
% Calculate the peak period Tp |
---|
194 |
[P,I]=max(IMLMfreq); |
---|
195 |
IMLM_UVW_Tp=1/(freqs(I)); |
---|
196 |
|
---|
197 |
%Calculate the Direction of the peak period DTp |
---|
198 |
[P,I]=max(real(IMLM.S(I,:))); |
---|
199 |
IMLM_UVW_DTp=dirs(I); |
---|
200 |
|
---|
201 |
%Calculate the Dominant Direction Dp |
---|
202 |
[P,I]=max(IMLMdir); |
---|
203 |
IMLM_UVW_Dp=dirs(I); |
---|
204 |
|
---|
205 |
%Display on the screen the SigH,Tp,Dp,DTp |
---|
206 |
disp(['IMLM uvw']); |
---|
207 |
disp(['SigH (meters): ' num2str(IMLM_UVW_Hsig)]); |
---|
208 |
disp(['peak period (seconds): ' num2str(IMLM_UVW_Tp)]); |
---|
209 |
disp(['Dir of peak period: ' num2str(compangle(IMLM_UVW_DTp, IMLM.xaxisdir))]); |
---|
210 |
disp(['Dominant Direction: ' num2str(compangle(IMLM_UVW_Dp, IMLM.xaxisdir))]); |
---|
211 |
disp([' ']); |
---|
212 |
|
---|
213 |
I_UVW_WI.hsig=IMLM_UVW_Hsig; |
---|
214 |
I_UVW_WI.tp=IMLM_UVW_Tp; |
---|
215 |
I_UVW_WI.dtp=compangle(IMLM_UVW_DTp, IMLM.xaxisdir); |
---|
216 |
I_UVW_WI.dp=compangle(IMLM_UVW_Dp, IMLM.xaxisdir); |
---|
217 |
|
---|
218 |
% for Range of EMEP |
---|
219 |
|
---|
220 |
%calculate the 0,1,2 moments |
---|
221 |
m0=sum(EMEPrangefreq*freqres); |
---|
222 |
m1=sum(freqs.*EMEPrangefreq*freqres); |
---|
223 |
m2=sum((freqs.^2).*EMEPrangefreq*freqres); |
---|
224 |
% Calculate the Sig wave height |
---|
225 |
EMEP_range_Hsig=4*sqrt(m0); |
---|
226 |
|
---|
227 |
% Calculate the peak period Tp |
---|
228 |
[P,I]=max(EMEPrangefreq); |
---|
229 |
EMEP_range_Tp=1/(freqs(I)); |
---|
230 |
|
---|
231 |
%Calculate the Direction of the peak period DTp |
---|
232 |
[P,I]=max(real(rangeE.S(I,:))); |
---|
233 |
EMEP_range_DTp=dirs(I); |
---|
234 |
|
---|
235 |
%Calculate the Dominant Direction Dp |
---|
236 |
[P,I]=max(EMEPrangedir); |
---|
237 |
EMEP_range_Dp=dirs(I); |
---|
238 |
|
---|
239 |
%Display on the screen the SigH,Tp,Dp,DTp |
---|
240 |
disp(['EMEP range']); |
---|
241 |
disp(['SigH (meters): ' num2str(EMEP_range_Hsig)]); |
---|
242 |
disp(['peak period (seconds): ' num2str(EMEP_range_Tp)]); |
---|
243 |
disp(['Dir of peak period: ' num2str(compangle(EMEP_range_DTp, rangeE.xaxisdir))]); |
---|
244 |
disp(['Dominant Direction: ' num2str(compangle(EMEP_range_Dp, rangeE.xaxisdir))]); |
---|
245 |
disp([' ']); |
---|
246 |
|
---|
247 |
E_range_WI.hsig=EMEP_range_Hsig; |
---|
248 |
E_range_WI.tp=EMEP_range_Tp; |
---|
249 |
E_range_WI.dtp=compangle(EMEP_range_DTp, rangeE.xaxisdir); |
---|
250 |
E_range_WI.dp=compangle(EMEP_range_Dp, rangeE.xaxisdir); |
---|
251 |
|
---|
252 |
|
---|
253 |
%for Range of IMLM |
---|
254 |
|
---|
255 |
%calculate the 0,1,2 moments |
---|
256 |
m0=sum(IMLMrangefreq*freqres); |
---|
257 |
m1=sum(freqs.*IMLMrangefreq*freqres); |
---|
258 |
m2=sum((freqs.^2).*IMLMrangefreq*freqres); |
---|
259 |
% Calculate the Sig wave height |
---|
260 |
IMLM_range_Hsig=4*sqrt(m0); |
---|
261 |
|
---|
262 |
% Calculate the peak period Tp |
---|
263 |
[P,I]=max(IMLMrangefreq); |
---|
264 |
IMLM_range_Tp=1/(freqs(I)); |
---|
265 |
|
---|
266 |
%Calculate the Direction of the peak period DTp |
---|
267 |
[P,I]=max(real(rangeI.S(I,:))); |
---|
268 |
IMLM_range_DTp=dirs(I); |
---|
269 |
|
---|
270 |
%Calculate the Dominant Direction Dp |
---|
271 |
[P,I]=max(IMLMrangedir); |
---|
272 |
IMLM_range_Dp=dirs(I); |
---|
273 |
|
---|
274 |
%Display on the screen the SigH,Tp,Dp,DTp |
---|
275 |
disp(['IMLM range']); |
---|
276 |
disp(['SigH (meters): ' num2str(IMLM_range_Hsig)]); |
---|
277 |
disp(['peak period (seconds): ' num2str(IMLM_range_Tp)]); |
---|
278 |
disp(['Dir of peak period: ' num2str(compangle(IMLM_range_DTp, rangeI.xaxisdir))]); |
---|
279 |
disp(['Dominant Direction: ' num2str(compangle(IMLM_range_Dp, rangeI.xaxisdir))]); |
---|
280 |
disp([' ']); |
---|
281 |
|
---|
282 |
I_range_WI.hsig=IMLM_range_Hsig; |
---|
283 |
I_range_WI.tp=IMLM_range_Tp; |
---|
284 |
I_range_WI.dtp=compangle(IMLM_range_DTp, rangeI.xaxisdir); |
---|
285 |
I_range_WI.dp=compangle(IMLM_range_Dp, rangeI.xaxisdir); |
---|
286 |
|
---|
287 |
% for wavesmon |
---|
288 |
|
---|
289 |
%calculate the 0,1,2 moments |
---|
290 |
m0=sum(wmonfreq*wmonfreqres); |
---|
291 |
m1=sum(wmon.freqs.*wmonfreq*wmonfreqres); |
---|
292 |
m2=sum((wmon.freqs.^2).*wmonfreq*wmonfreqres); |
---|
293 |
% Calculate the Sig wave height |
---|
294 |
wmon_Hsig=4*sqrt(m0); |
---|
295 |
|
---|
296 |
% Calculate the peak period Tp |
---|
297 |
[P,I]=max(wmonfreq); |
---|
298 |
wmon_Tp=1/(wmon.freqs(I)); |
---|
299 |
|
---|
300 |
%Calculate the Direction of the peak period DTp |
---|
301 |
[P,I]=max(real(wmon.S(I,:))); |
---|
302 |
wmon_DTp=wmon.dirs(I); |
---|
303 |
|
---|
304 |
%Calculate the Dominant Direction Dp |
---|
305 |
[P,I]=max(wmondir); |
---|
306 |
wmon_Dp=wmon.dirs(I); |
---|
307 |
|
---|
308 |
%Display on the screen the SigH,Tp,Dp,DTp |
---|
309 |
disp(['Wavesmon output']); |
---|
310 |
disp(['SigH (meters): ' num2str(wmon_Hsig)]); |
---|
311 |
disp(['peak period (seconds): ' num2str(wmon_Tp)]); |
---|
312 |
disp(['Dir of peak period: ' num2str(compangle(wmon_DTp, wmon.xaxisdir))]); |
---|
313 |
disp(['Dominant Direction: ' num2str(compangle(wmon_Dp, wmon.xaxisdir))]); |
---|
314 |
disp([' ']); |
---|
315 |
|
---|
316 |
wmon_WI.hsig=wmon_Hsig; |
---|
317 |
wmon_WI.tp=wmon_Tp; |
---|
318 |
wmon_WI.dtp=compangle(wmon_DTp, wmon.xaxisdir); |
---|
319 |
wmon_WI.dp=compangle(wmon_Dp, wmon.xaxisdir); |
---|
320 |
|
---|
321 |
|
---|
322 |
%function to change from axis angles to compass bearings |
---|
323 |
|
---|
324 |
function angle=compangle(angle,xaxisdir) |
---|
325 |
angle=xaxisdir*ones(size(angle))-angle; |
---|
326 |
angle=angle+360*(angle<0); |
---|
327 |
angle=angle-360*(angle>360); |
---|
328 |
|
---|
329 |
|
---|
330 |
|
---|
331 |
|
---|
332 |
|
---|