1 |
function [E_radial_WI,fig1,fig2]=waveplot(radialE,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 |
|
---|
8 |
%what is the frequency and dir resolution for those generated in DIWASP |
---|
9 |
freqres=0.01; |
---|
10 |
freqs=[0.01:0.01:.4]; |
---|
11 |
dirres=2; |
---|
12 |
dirs=[0:2:360]; |
---|
13 |
|
---|
14 |
|
---|
15 |
% plot the spectrum generated through DIWASP |
---|
16 |
|
---|
17 |
scrsz = get(0,'ScreenSize'); |
---|
18 |
fig1=figure('Position',[scrsz]); |
---|
19 |
subplot(1,1,1); |
---|
20 |
subplotspec(radialE,4); |
---|
21 |
title('radial velocity data'); |
---|
22 |
|
---|
23 |
|
---|
24 |
%calculate just the dir energy spectrum on a single graph |
---|
25 |
|
---|
26 |
|
---|
27 |
EMEPradialdir=sum(radialE.S)*freqres; |
---|
28 |
|
---|
29 |
%calculate just the frequency energy spectrum |
---|
30 |
EMEPradialfreq=sum(radialE.S')*dirres; |
---|
31 |
|
---|
32 |
%__________________________________________________________________________ |
---|
33 |
%Use this if you want to calculate confidence bounds for the frequency spec |
---|
34 |
|
---|
35 |
%Compute the coefficient for the upper and lower error bounds for the power |
---|
36 |
%spectrum assuming 95% confidence. Added on 9/17/08 |
---|
37 |
degF=radialE.degF; |
---|
38 |
chiUp=chi2inv(.975,degF); |
---|
39 |
chiLow=chi2inv(.025,degF); |
---|
40 |
coeffUp=degF/chiLow; |
---|
41 |
coeffLow=degF/chiUp; |
---|
42 |
|
---|
43 |
|
---|
44 |
%calculate the conf limits throughout the frequency spectrum |
---|
45 |
EMEPradialfreqUP=EMEPradialfreq*coeffUp; |
---|
46 |
EMEPradialfreqLOW=EMEPradialfreq*coeffLow; |
---|
47 |
|
---|
48 |
%__________________________________________________________________________ |
---|
49 |
|
---|
50 |
%Find the maximum for the directional spectrum so we can set up the proper |
---|
51 |
%x-axis |
---|
52 |
[maxvalue,maxindex] = max(EMEPradialdir); |
---|
53 |
maxdir=dirs(maxindex); |
---|
54 |
% set up the x-axis for all of the spectra depending on the max |
---|
55 |
if ((100 < maxdir) || (maxdir < -100)); |
---|
56 |
%for diwasp spectra |
---|
57 |
index1=find(dirs < 0); |
---|
58 |
index2=find(dirs > -1); |
---|
59 |
dirs(index1)=dirs(index1) +360; |
---|
60 |
%plot the directional energy spectrum |
---|
61 |
fig2=figure('Position',[scrsz]); |
---|
62 |
subplot(1,2,1); |
---|
63 |
h1 = plot(dirs(index2),EMEPradialdir(index2),'b'); |
---|
64 |
hold on |
---|
65 |
h1a= plot(dirs(index1),EMEPradialdir(index1),'b'); |
---|
66 |
else |
---|
67 |
%plot the directional energy spectrum |
---|
68 |
fig2=figure('Position',[scrsz]); |
---|
69 |
subplot(1,2,1); |
---|
70 |
h1 = plot(dirs,EMEPradialdir,'b'); |
---|
71 |
end |
---|
72 |
|
---|
73 |
legend([h1],'EMEP radial','location','best'); |
---|
74 |
title('directional wave spectrum integrated over frequency'); |
---|
75 |
xlabel('axis angle (degrees true)'); |
---|
76 |
ylabel('m^2 / deg'); |
---|
77 |
|
---|
78 |
%plot the frequency energy spectrum |
---|
79 |
subplot(1,2,2); |
---|
80 |
h1=plot(freqs,EMEPradialfreq,'b'); |
---|
81 |
hold on |
---|
82 |
h2=plot(freqs,EMEPradialfreqUP,'b--'); |
---|
83 |
h2a=plot(freqs,EMEPradialfreqLOW,'b--'); |
---|
84 |
legend([h1,h2],'EMEP radial','95% confidence limits','location','best'); |
---|
85 |
title('directional wave spectrum integrated over direction'); |
---|
86 |
xlabel('frequency in Hz'); |
---|
87 |
ylabel('m^2 / hz'); |
---|
88 |
|
---|
89 |
% ______Calculate and display the wave parameters SigH, Tp, Dp,DTp_______ |
---|
90 |
|
---|
91 |
|
---|
92 |
% for Radial of EMEP |
---|
93 |
|
---|
94 |
% Calculate the Sig wave height |
---|
95 |
EMEP_radial_Hsig=Hsig(radialE); |
---|
96 |
%Use the function HsigConf.m to calculate the sigH confidence limits |
---|
97 |
EMEP_radial_HsConf=HsigConf(radialE); |
---|
98 |
|
---|
99 |
% Calculate the peak period Tp |
---|
100 |
[P,I]=max(EMEPradialfreq); |
---|
101 |
EMEP_radial_Tp=1/(freqs(I)); |
---|
102 |
|
---|
103 |
%Calculate the Direction of the peak period DTp |
---|
104 |
[P,I]=max(real(radialE.S(I,:))); |
---|
105 |
EMEP_radial_DTp=dirs(I); |
---|
106 |
|
---|
107 |
%Calculate the Dominant Direction Dp |
---|
108 |
[P,I]=max(EMEPradialdir); |
---|
109 |
EMEP_radial_Dp=dirs(I); |
---|
110 |
|
---|
111 |
%Display on the screen the SigH,Tp,Dp,DTp |
---|
112 |
disp(['EMEP radial']); |
---|
113 |
disp(['SigH (meters): ' num2str(EMEP_radial_Hsig)]); |
---|
114 |
disp(['SigH 95% confidence limits: ' num2str(EMEP_radial_HsConf)]); |
---|
115 |
disp(['peak period (seconds): ' num2str(EMEP_radial_Tp)]); |
---|
116 |
disp(['Dir of peak period: ' num2str(compangle(EMEP_radial_DTp, radialE.xaxisdir))]); |
---|
117 |
disp(['Dominant Direction: ' num2str(compangle(EMEP_radial_Dp, radialE.xaxisdir))]); |
---|
118 |
disp([' ']); |
---|
119 |
|
---|
120 |
E_radial_WI.hsig=EMEP_radial_Hsig; |
---|
121 |
E_radial_WI.hconf=EMEP_radial_HsConf; |
---|
122 |
E_radial_WI.tp=EMEP_radial_Tp; |
---|
123 |
E_radial_WI.dtp=compangle(EMEP_radial_DTp, radialE.xaxisdir); |
---|
124 |
E_radial_WI.dp=compangle(EMEP_radial_Dp, radialE.xaxisdir); |
---|
125 |
|
---|
126 |
|
---|
127 |
|
---|
128 |
%function to change from axis angles to compass bearings |
---|
129 |
|
---|
130 |
function angle=compangle(angle,xaxisdir) |
---|
131 |
angle=xaxisdir*ones(size(angle))-angle; |
---|
132 |
angle=angle+360*(angle<0); |
---|
133 |
angle=angle-360*(angle>360); |
---|
134 |
|
---|
135 |
|
---|
136 |
|
---|
137 |
|
---|
138 |
|
---|