1 |
function [E_radial_WI,I_radial_WI,fig5,fig6]=radialwaveplot(radialE,radialI,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 |
scrsz = get(0,'ScreenSize'); |
---|
36 |
fig5=figure('Position',[scrsz]); |
---|
37 |
subplot(2,3,1); |
---|
38 |
subplotspec(radialE,4); |
---|
39 |
title('EMEP radial vel'); |
---|
40 |
|
---|
41 |
subplot(2,3,2); |
---|
42 |
subplotspec(radialI,4); |
---|
43 |
title('IMLM radial vel'); |
---|
44 |
|
---|
45 |
subplot(2,3,3); |
---|
46 |
subplotspec(wmon,4); |
---|
47 |
title('Wavesmon output'); |
---|
48 |
|
---|
49 |
|
---|
50 |
%calculate just the dir energy spectrum on a single graph |
---|
51 |
|
---|
52 |
EMEPdir=sum(radialE.S)*freqres; |
---|
53 |
IMLMdir=sum(real(radialI.S))*freqres; |
---|
54 |
wmondir=sum(wmon.S)*wmonfreqres; |
---|
55 |
|
---|
56 |
%calculate just the frequency energy spectrum |
---|
57 |
EMEPfreq=sum(radialE.S')*dirres; |
---|
58 |
IMLMfreq=sum(real(radialI.S)')*dirres; |
---|
59 |
wmonfreq=sum(wmon.S')*wmondirres; |
---|
60 |
|
---|
61 |
%Find the maximum for the directional spectrum so we can set up the proper |
---|
62 |
%x-axis |
---|
63 |
[maxvalue,maxindex] = max(EMEPdir); |
---|
64 |
maxdir=dirs(maxindex); |
---|
65 |
% set up the x-axis for all of the spectra depending on the max |
---|
66 |
if ((100 < maxdir) | (maxdir < -100)); |
---|
67 |
%for diwasp spectra |
---|
68 |
index1=find(dirs < 0); |
---|
69 |
index2=find(dirs > -1); |
---|
70 |
dirs(index1)=dirs(index1) +360; |
---|
71 |
%for wavesmon |
---|
72 |
Aindex=find(wmon.dirs < 0); |
---|
73 |
Bindex=find((-1 < wmon.dirs) & (wmon.dirs < 361)); |
---|
74 |
Bindex2=find(wmon.dirs > 360); |
---|
75 |
wmon.dirs(Bindex2)=wmon.dirs(Bindex2)-360; |
---|
76 |
wmon.dirs(Aindex)=wmon.dirs(Aindex)+360; |
---|
77 |
%plot the directional energy spectrum |
---|
78 |
fig6=figure('Position',[scrsz]); |
---|
79 |
subplot(1,2,1); |
---|
80 |
h1 = plot(dirs(index2),EMEPdir(index2),'b'); |
---|
81 |
hold on |
---|
82 |
h1a= plot(dirs(index1),EMEPdir(index1),'b'); |
---|
83 |
%plot the wavesmon data |
---|
84 |
h2 = plot(wmon.dirs(Bindex2),wmondir(Bindex2),'k'); |
---|
85 |
h2a = plot(wmon.dirs(Bindex),wmondir(Bindex),'k'); |
---|
86 |
h2b= plot(wmon.dirs(Aindex),wmondir(Aindex),'k'); |
---|
87 |
axis(axis); |
---|
88 |
%h5 = plot(dirs(index2),IMLMdir(index2),'c'); |
---|
89 |
%h5a= plot(dirs(index1),IMLMdir(index1),'c'); |
---|
90 |
|
---|
91 |
else |
---|
92 |
%for diwasp spectra do nothing |
---|
93 |
|
---|
94 |
%for wavesmon |
---|
95 |
Aindex=find(wmon.dirs > 180); |
---|
96 |
Bindex=find(wmon.dirs < 181); |
---|
97 |
wmon.dirs(Aindex)=wmon.dirs(Aindex)-360; |
---|
98 |
%plot the directional energy spectrum |
---|
99 |
fig6=figure('Position',[scrsz]); |
---|
100 |
subplot(1,2,1); |
---|
101 |
h1 = plot(dirs,EMEPdir,'b'); |
---|
102 |
hold on |
---|
103 |
%plot the wavesmon data |
---|
104 |
h2 = plot(wmon.dirs(Aindex),wmondir(Aindex),'k'); |
---|
105 |
h2a = plot(wmon.dirs(Bindex),wmondir(Bindex),'k'); |
---|
106 |
axis(axis); |
---|
107 |
%h5 = plot(dirs,IMLMdir,'c'); |
---|
108 |
end |
---|
109 |
|
---|
110 |
legend([h1, h2], 'EMEP radial vel','wavesmon','location','best'); |
---|
111 |
title('directional wave spectrum integrated over frequency'); |
---|
112 |
xlabel('axis angle (degrees true)'); |
---|
113 |
ylabel('m^2 / deg'); |
---|
114 |
|
---|
115 |
%plot the frequency energy spectrum |
---|
116 |
subplot(1,2,2); |
---|
117 |
plot(freqs,EMEPfreq,'b'); |
---|
118 |
hold on |
---|
119 |
plot(wmon.freqs,wmonfreq,'k'); |
---|
120 |
axis(axis); |
---|
121 |
plot(freqs,IMLMfreq,'c'); |
---|
122 |
legend('EMEP radial vel','wavesmon','IMLM radial vel','location','best'); |
---|
123 |
title('directional wave spectrum integrated over direction'); |
---|
124 |
xlabel('frequency in Hz'); |
---|
125 |
ylabel('m^2 / Hz'); |
---|
126 |
|
---|
127 |
% ______Calculate and display the wave parameters SigH, Tp, Dp,DTp_______ |
---|
128 |
|
---|
129 |
%For EMEP radial |
---|
130 |
|
---|
131 |
%calculate the 0,1,2 moments |
---|
132 |
m0=sum(EMEPfreq*freqres); |
---|
133 |
m1=sum(freqs.*EMEPfreq*freqres); |
---|
134 |
m2=sum((freqs.^2).*EMEPfreq*freqres); |
---|
135 |
% Calculate the Sig wave height |
---|
136 |
EMEP_radial_Hsig=4*sqrt(m0); |
---|
137 |
|
---|
138 |
% Calculate the peak period Tp |
---|
139 |
[P,I]=max(EMEPfreq); |
---|
140 |
EMEP_radial_Tp=1/(freqs(I)); |
---|
141 |
|
---|
142 |
%Calculate the Direction of the peak period DTp |
---|
143 |
[P,I]=max(real(radialE.S(I,:))); |
---|
144 |
EMEP_radial_DTp=dirs(I); |
---|
145 |
|
---|
146 |
%Calculate the Dominant Direction Dp |
---|
147 |
[P,I]=max(EMEPdir); |
---|
148 |
EMEP_radial_Dp=dirs(I); |
---|
149 |
|
---|
150 |
%Display on the screen the SigH,Tp,Dp,DTp |
---|
151 |
disp(['EMEP radial vel']); |
---|
152 |
disp(['SigH (meters): ' num2str(EMEP_radial_Hsig)]); |
---|
153 |
disp(['peak period (seconds): ' num2str(EMEP_radial_Tp)]); |
---|
154 |
disp(['Dir of peak period: ' num2str(compangle(EMEP_radial_DTp, radialE.xaxisdir))]); |
---|
155 |
disp(['Dominant Direction: ' num2str(compangle(EMEP_radial_Dp, radialE.xaxisdir))]); |
---|
156 |
disp([' ']); |
---|
157 |
|
---|
158 |
E_radial_WI.hsig=EMEP_radial_Hsig; |
---|
159 |
E_radial_WI.tp=EMEP_radial_Tp; |
---|
160 |
E_radial_WI.dtp=compangle(EMEP_radial_DTp, radialE.xaxisdir); |
---|
161 |
E_radial_WI.dp=compangle(EMEP_radial_Dp, radialE.xaxisdir); |
---|
162 |
|
---|
163 |
% For IMLM r |
---|
164 |
|
---|
165 |
%calculate the 0,1,2 moments |
---|
166 |
m0=sum(IMLMfreq*freqres); |
---|
167 |
m1=sum(freqs.*IMLMfreq*freqres); |
---|
168 |
m2=sum((freqs.^2).*IMLMfreq*freqres); |
---|
169 |
% Calculate the Sig wave height |
---|
170 |
IMLM_radial_Hsig=4*sqrt(m0); |
---|
171 |
|
---|
172 |
% Calculate the peak period Tp |
---|
173 |
[P,I]=max(IMLMfreq); |
---|
174 |
IMLM_radial_Tp=1/(freqs(I)); |
---|
175 |
|
---|
176 |
%Calculate the Direction of the peak period DTp |
---|
177 |
[P,I]=max(real(radialI.S(I,:))); |
---|
178 |
IMLM_radial_DTp=dirs(I); |
---|
179 |
|
---|
180 |
%Calculate the Dominant Direction Dp |
---|
181 |
[P,I]=max(IMLMdir); |
---|
182 |
IMLM_radial_Dp=dirs(I); |
---|
183 |
|
---|
184 |
%Display on the screen the SigH,Tp,Dp,DTp |
---|
185 |
disp(['IMLM radial vel']); |
---|
186 |
disp(['SigH (meters): ' num2str(IMLM_radial_Hsig)]); |
---|
187 |
disp(['peak period (seconds): ' num2str(IMLM_radial_Tp)]); |
---|
188 |
disp(['Dir of peak period: ' num2str(compangle(IMLM_radial_DTp, radialI.xaxisdir))]); |
---|
189 |
disp(['Dominant Direction: ' num2str(compangle(IMLM_radial_Dp, radialI.xaxisdir))]); |
---|
190 |
disp([' ']); |
---|
191 |
|
---|
192 |
I_radial_WI.hsig=IMLM_radial_Hsig; |
---|
193 |
I_radial_WI.tp=IMLM_radial_Tp; |
---|
194 |
I_radial_WI.dtp=compangle(IMLM_radial_DTp, radialI.xaxisdir); |
---|
195 |
I_radial_WI.dp=compangle(IMLM_radial_Dp, radialI.xaxisdir); |
---|
196 |
|
---|
197 |
% for wavesmon |
---|
198 |
|
---|
199 |
%calculate the 0,1,2 moments |
---|
200 |
m0=sum(wmonfreq*wmonfreqres); |
---|
201 |
m1=sum(wmon.freqs.*wmonfreq*wmonfreqres); |
---|
202 |
m2=sum((wmon.freqs.^2).*wmonfreq*wmonfreqres); |
---|
203 |
% Calculate the Sig wave height |
---|
204 |
Hsig=4*sqrt(m0); |
---|
205 |
|
---|
206 |
% Calculate the peak period Tp |
---|
207 |
[P,I]=max(wmonfreq); |
---|
208 |
Tp=1/(wmon.freqs(I)); |
---|
209 |
|
---|
210 |
%Calculate the Direction of the peak period DTp |
---|
211 |
[P,I]=max(real(wmon.S(I,:))); |
---|
212 |
DTp=wmon.dirs(I); |
---|
213 |
|
---|
214 |
%Calculate the Dominant Direction Dp |
---|
215 |
[P,I]=max(wmondir); |
---|
216 |
Dp=wmon.dirs(I); |
---|
217 |
|
---|
218 |
%Display on the screen the SigH,Tp,Dp,DTp |
---|
219 |
disp(['Wavesmon output']); |
---|
220 |
disp(['SigH (meters): ' num2str(Hsig)]); |
---|
221 |
disp(['peak period (seconds): ' num2str(Tp)]); |
---|
222 |
disp(['Dir of peak period: ' num2str(compangle(DTp, wmon.xaxisdir))]); |
---|
223 |
disp(['Dominant Direction: ' num2str(compangle(Dp, wmon.xaxisdir))]); |
---|
224 |
disp([' ']); |
---|
225 |
|
---|
226 |
|
---|
227 |
%function to change from axis angles to compass bearings |
---|
228 |
|
---|
229 |
function angle=compangle(angle,xaxisdir) |
---|
230 |
angle=xaxisdir*ones(size(angle))-angle; |
---|
231 |
angle=angle+360*(angle<0); |
---|
232 |
angle=angle-360*(angle>360); |
---|
233 |
|
---|
234 |
|
---|
235 |
|
---|
236 |
|
---|
237 |
|
---|