1 |
function [I_WI,fig1,fig2]=nortek_waveplot(IMLM) |
---|
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 |
|
---|
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=[0:2:360]; |
---|
17 |
|
---|
18 |
% plot the spectrum generated through DIWASP |
---|
19 |
|
---|
20 |
scrsz = get(0,'ScreenSize'); |
---|
21 |
fig1=figure('Position',[scrsz]); |
---|
22 |
|
---|
23 |
|
---|
24 |
subplot(2,2,2); |
---|
25 |
subplotspec(IMLM,4); |
---|
26 |
title('EMEP AST beam and radial velocities'); |
---|
27 |
|
---|
28 |
|
---|
29 |
|
---|
30 |
|
---|
31 |
%calculate just the dir energy spectrum on a single graph |
---|
32 |
|
---|
33 |
|
---|
34 |
IMLMdir=sum(real(IMLM.S))*freqres; |
---|
35 |
|
---|
36 |
|
---|
37 |
|
---|
38 |
%calculate just the frequency energy spectrum |
---|
39 |
IMLMfreq=sum(real(IMLM.S)')*dirres; |
---|
40 |
|
---|
41 |
|
---|
42 |
%Compute the coefficient for the upper and lower error bounds for the |
---|
43 |
%frequency |
---|
44 |
%spectrum assuming 95% confidence. Added on 9/17/08 |
---|
45 |
degF=2*IMLM.degF; % 2* since for the Nortek the range beam sampled at 4hz (4096) is decimated or averaged to 2hz (2048) |
---|
46 |
chiUp=chi2inv(.975,degF); |
---|
47 |
chiLow=chi2inv(.025,degF); |
---|
48 |
coeffUp=degF/chiLow; |
---|
49 |
coeffLow=degF/chiUp; |
---|
50 |
|
---|
51 |
%calculate the conf limits throughout the frequency spectrum |
---|
52 |
|
---|
53 |
IMLMfreqUP=IMLMfreq*coeffUp; |
---|
54 |
IMLMfreqLOW=IMLMfreq*coeffLow; |
---|
55 |
|
---|
56 |
%Find the maximum for the directional spectrum so we can set up the proper |
---|
57 |
%x-axis |
---|
58 |
[maxvalue,maxindex] = max(IMLMdir); |
---|
59 |
maxdir=dirs(maxindex); |
---|
60 |
% set up the x-axis for all of the spectra depending on the max |
---|
61 |
if ((100 < maxdir) || (maxdir < -100)); |
---|
62 |
%for diwasp spectra |
---|
63 |
index1=find(dirs < 0); |
---|
64 |
index2=find(dirs > -1); |
---|
65 |
dirs(index1)=dirs(index1) +360; |
---|
66 |
|
---|
67 |
%plot the directional energy spectrum |
---|
68 |
fig2=figure('Position',[scrsz]); |
---|
69 |
subplot(1,2,1); |
---|
70 |
h2 = plot(dirs(index2),IMLMdir(index2),'b'); |
---|
71 |
h2a= plot(dirs(index1),IMLMdir(index1),'b'); |
---|
72 |
|
---|
73 |
else |
---|
74 |
|
---|
75 |
%plot the directional energy spectrum |
---|
76 |
fig2=figure('Position',[scrsz]); |
---|
77 |
subplot(1,2,1); |
---|
78 |
hold on |
---|
79 |
h2a = plot(dirs,IMLMdir,'b'); |
---|
80 |
|
---|
81 |
end |
---|
82 |
|
---|
83 |
legend(h2a,'EMEP'); |
---|
84 |
title('directional wave spectrum integrated over frequency'); |
---|
85 |
xlabel('axis angle (degrees true)'); |
---|
86 |
ylabel('m^2 / deg'); |
---|
87 |
|
---|
88 |
%plot the frequency energy spectrum |
---|
89 |
subplot(1,2,2); |
---|
90 |
h3=plot(freqs,IMLMfreq,'r'); |
---|
91 |
hold on |
---|
92 |
h4=plot(freqs,IMLMfreqUP,'r--'); |
---|
93 |
plot(freqs,IMLMfreqLOW,'r--'); |
---|
94 |
legend('EMEP','EMEP 95% confidence'); |
---|
95 |
title('directional wave spectrum integrated over direction'); |
---|
96 |
xlabel('frequency in Hz'); |
---|
97 |
ylabel('m^2 / hz'); |
---|
98 |
|
---|
99 |
% ______Calculate and display the wave parameters SigH, Tp, Dp,DTp_______ |
---|
100 |
|
---|
101 |
|
---|
102 |
|
---|
103 |
% For IMLM AST and radial velocities |
---|
104 |
|
---|
105 |
%calculate the 0,1,2 moments |
---|
106 |
m0=sum(IMLMfreq*freqres); |
---|
107 |
m1=sum(freqs.*IMLMfreq*freqres); |
---|
108 |
m2=sum((freqs.^2).*IMLMfreq*freqres); |
---|
109 |
% Calculate the Sig wave height |
---|
110 |
IMLM_Hsig=4*sqrt(m0); |
---|
111 |
%Use the function HsigConf.m to calculate the sigH confidence limits |
---|
112 |
IMLM_HsConf=nortek_HsigConf(IMLM); |
---|
113 |
|
---|
114 |
% Calculate the peak period Tp |
---|
115 |
[P,I]=max(IMLMfreq); |
---|
116 |
IMLM_Tp=1/(freqs(I)); |
---|
117 |
|
---|
118 |
%Calculate the Direction of the peak period DTp |
---|
119 |
[P,I]=max(real(IMLM.S(I,:))); |
---|
120 |
IMLM_DTp=dirs(I); |
---|
121 |
|
---|
122 |
%Calculate the Dominant Direction Dp |
---|
123 |
[P,I]=max(IMLMdir); |
---|
124 |
IMLM_Dp=dirs(I); |
---|
125 |
|
---|
126 |
%Display on the screen the SigH,Tp,Dp,DTp |
---|
127 |
disp(['EMEP']); |
---|
128 |
disp(['SigH (meters): ' num2str(IMLM_Hsig)]); |
---|
129 |
disp(['SigH 95% conf. (meters): ' num2str(IMLM_HsConf)]); |
---|
130 |
disp(['peak period (seconds): ' num2str(IMLM_Tp)]); |
---|
131 |
disp(['Dir of peak period: ' num2str(compangle(IMLM_DTp, IMLM.xaxisdir))]); |
---|
132 |
disp(['Dominant Direction: ' num2str(compangle(IMLM_Dp, IMLM.xaxisdir))]); |
---|
133 |
disp([' ']); |
---|
134 |
|
---|
135 |
I_WI.hsig=IMLM_Hsig; |
---|
136 |
I_WI.hconf=IMLM_HsConf; |
---|
137 |
I_WI.tp=IMLM_Tp; |
---|
138 |
I_WI.dtp=compangle(IMLM_DTp, IMLM.xaxisdir); |
---|
139 |
I_WI.dp=compangle(IMLM_Dp, IMLM.xaxisdir); |
---|
140 |
|
---|
141 |
|
---|
142 |
|
---|
143 |
|
---|
144 |
%function to change from axis angles to compass bearings |
---|
145 |
|
---|
146 |
function angle=compangle(angle,xaxisdir) |
---|
147 |
angle=xaxisdir*ones(size(angle))-angle; |
---|
148 |
angle=angle+360*(angle<0); |
---|
149 |
angle=angle-360*(angle>360); |
---|
150 |
|
---|
151 |
|
---|
152 |
|
---|
153 |
|
---|
154 |
|
---|