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

root/adcp/trunk/adcp/waveplot3.m

Revision 168 (checked in by cbc, 16 years ago)

Adding diwasp customizations.

Line 
1 function waveplot3(EMEP,IMLM,rangeE,rangeI,spec)
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 sangle=281+magvar;
17
18 %what is the frequency and dir resolution for those generated in DIWASP
19 freqres=0.01;
20 freqs=[0.01:0.01:.4];
21 dirres=2;
22 dirs=[-180:2:180];
23
24 %set up the directions
25 adj_angle=90-sangle+360+180;
26 wmon.dirs=[adj_angle:-4:-(356-adj_angle)];
27 wmondirres=4;
28 wmon.xaxisdir=90;
29 wmon.freqs=[0.00781250:0.00781250:1];
30 wmonfreqres=0.00781250;
31
32 % plot the spectrum generated through DIWASP
33
34 subplot(2,3,1);
35 subplotspec(EMEP.SMout,4);
36 title('EMEP Range');
37
38 subplot(2,3,2);
39 subplotspec(IMLM.SMout,4);
40 title('IMLM Range');
41
42 subplot(2,3,3);
43 subplotspec(wmon,4);
44 title('Wavesmon output');
45
46 subplot(2,3,4);
47 subplotspec(rangeE.SMout,4);
48 title('EMEP Range cpsd');
49
50 subplot(2,3,5);
51 subplotspec(rangeI.SMout,4);
52 title('IMLM Range cpsd');
53
54 %calculate just the dir energy spectrum on a single graph
55
56 EMEPdir=sum(EMEP.SMout.S)*freqres;
57 IMLMdir=sum(real(IMLM.SMout.S))*freqres;
58 EMEPrangedir=sum(rangeE.SMout.S)*freqres;
59 IMLMrangedir=sum(real(rangeI.SMout.S))*freqres;
60 wmondir=sum(wmon.S)*wmonfreqres;
61
62 %calculate just the frequency energy spectrum
63 EMEPfreq=sum(EMEP.SMout.S')*dirres;
64 IMLMfreq=sum(real(IMLM.SMout.S)')*dirres;
65 EMEPrangefreq=sum(rangeE.SMout.S')*dirres;
66 IMLMrangefreq=sum(real(rangeI.SMout.S)')*dirres;
67 wmonfreq=sum(wmon.S')*wmondirres;
68
69 %plot the directional energy spectrum
70 figure;
71 subplot(1,2,1);
72 plot(dirs,EMEPdir,'b');
73 hold on
74 plot(dirs,EMEPrangedir,'r');
75 plot(dirs,IMLMrangedir,'g');
76 %need to make sure the wmon plot has the same x-axis as the others
77 Aindex=find(wmon.dirs > 180);
78 Bindex=find(wmon.dirs <181);
79 wmon.dirs(Aindex)=wmon.dirs(Aindex)-360;
80
81 plot(wmon.dirs(Aindex),wmondir(Aindex),'k');
82 plot(wmon.dirs(Bindex),wmondir(Bindex),'k');
83 axis(axis);
84 plot(dirs,IMLMdir,'c');
85 legend('EMEP range','EMEP range cpsd','IMLM range cpsd','wavesmon','','IMLM range');
86 title('directional wave spectrum integrated over frequency');
87 xlabel('axis angle (degrees true)');
88 ylabel('m^2 / deg');
89
90 %plot the frequency energy spectrum
91 subplot(1,2,2);
92 plot(freqs,EMEPfreq,'b');
93 hold on
94 plot(freqs,EMEPrangefreq,'r');
95 plot(freqs,IMLMrangefreq,'g');
96 plot(wmon.freqs,wmonfreq,'k');
97 axis(axis);
98 plot(freqs,IMLMfreq,'c');
99 legend('EMEP range','EMEP range cpsd','IMLM range cpsd','wavesmon','IMLM range');
100 title('directional wave spectrum integrated over direction');
101 xlabel('frequency in Hz');
102 ylabel('m^2 / hz');
103
104 % ______Calculate and display the wave parameters SigH, Tp, Dp,DTp_______
105
106 %For EMEP uvw
107
108 %calculate the 0,1,2 moments
109 m0=sum(EMEPfreq*freqres);                             
110 m1=sum(freqs.*EMEPfreq*freqres);
111 m2=sum((freqs.^2).*EMEPfreq*freqres);
112 % Calculate the Sig wave height
113 Hsig=4*sqrt(m0);
114
115 % Calculate the peak period Tp
116 [P,I]=max(EMEPfreq);
117 Tp=1/(freqs(I));
118
119 %Calculate the Direction of the peak period DTp
120 [P,I]=max(real(EMEP.SMout.S(I,:)));
121 DTp=dirs(I);
122
123 %Calculate the Dominant Direction Dp
124 [P,I]=max(EMEPdir);
125 Dp=dirs(I);
126
127 %Display on the screen the SigH,Tp,Dp,DTp
128 disp(['EMEP range']);
129 disp(['SigH (meters): ' num2str(Hsig)]);
130 disp(['peak period (seconds): ' num2str(Tp)]);
131 disp(['Dir of peak period: ' num2str(compangle(DTp, EMEP.SMout.xaxisdir))]);
132 disp(['Dominant Direction: ' num2str(compangle(Dp, EMEP.SMout.xaxisdir))]);
133 disp(['  ']);
134
135 % For IMLM uvw
136
137 %calculate the 0,1,2 moments
138 m0=sum(IMLMfreq*freqres);                             
139 m1=sum(freqs.*IMLMfreq*freqres);
140 m2=sum((freqs.^2).*IMLMfreq*freqres);
141 % Calculate the Sig wave height
142 Hsig=4*sqrt(m0);
143
144 % Calculate the peak period Tp
145 [P,I]=max(IMLMfreq);
146 Tp=1/(freqs(I));
147
148 %Calculate the Direction of the peak period DTp
149 [P,I]=max(real(IMLM.SMout.S(I,:)));
150 DTp=dirs(I);
151
152 %Calculate the Dominant Direction Dp
153 [P,I]=max(IMLMdir);
154 Dp=dirs(I);
155
156 %Display on the screen the SigH,Tp,Dp,DTp
157 disp(['IMLM range']);
158 disp(['SigH (meters): ' num2str(Hsig)]);
159 disp(['peak period (seconds): ' num2str(Tp)]);
160 disp(['Dir of peak period: ' num2str(compangle(DTp, IMLM.SMout.xaxisdir))]);
161 disp(['Dominant Direction: ' num2str(compangle(Dp, IMLM.SMout.xaxisdir))]);
162 disp(['  ']);
163
164 % for Range of EMEP
165
166 %calculate the 0,1,2 moments
167 m0=sum(EMEPrangefreq*freqres);                             
168 m1=sum(freqs.*EMEPrangefreq*freqres);
169 m2=sum((freqs.^2).*EMEPrangefreq*freqres);
170 % Calculate the Sig wave height
171 Hsig=4*sqrt(m0);
172
173 % Calculate the peak period Tp
174 [P,I]=max(EMEPrangefreq);
175 Tp=1/(freqs(I));
176
177 %Calculate the Direction of the peak period DTp
178 [P,I]=max(real(rangeE.SMout.S(I,:)));
179 DTp=dirs(I);
180
181 %Calculate the Dominant Direction Dp
182 [P,I]=max(EMEPrangedir);
183 Dp=dirs(I);
184
185 %Display on the screen the SigH,Tp,Dp,DTp
186 disp(['EMEP range cpsd']);
187 disp(['SigH (meters): ' num2str(Hsig)]);
188 disp(['peak period (seconds): ' num2str(Tp)]);
189 disp(['Dir of peak period: ' num2str(compangle(DTp, rangeE.SMout.xaxisdir))]);
190 disp(['Dominant Direction: ' num2str(compangle(Dp, rangeE.SMout.xaxisdir))]);
191 disp(['  ']);
192
193 %for Range of IMLM
194
195 %calculate the 0,1,2 moments
196 m0=sum(IMLMrangefreq*freqres);                             
197 m1=sum(freqs.*IMLMrangefreq*freqres);
198 m2=sum((freqs.^2).*IMLMrangefreq*freqres);
199 % Calculate the Sig wave height
200 Hsig=4*sqrt(m0);
201
202 % Calculate the peak period Tp
203 [P,I]=max(IMLMrangefreq);
204 Tp=1/(freqs(I));
205
206 %Calculate the Direction of the peak period DTp
207 [P,I]=max(real(rangeI.SMout.S(I,:)));
208 DTp=dirs(I);
209
210 %Calculate the Dominant Direction Dp
211 [P,I]=max(IMLMrangedir);
212 Dp=dirs(I);
213
214 %Display on the screen the SigH,Tp,Dp,DTp
215 disp(['IMLM range cpsd']);
216 disp(['SigH (meters): ' num2str(Hsig)]);
217 disp(['peak period (seconds): ' num2str(Tp)]);
218 disp(['Dir of peak period: ' num2str(compangle(DTp, rangeI.SMout.xaxisdir))]);
219 disp(['Dominant Direction: ' num2str(compangle(Dp, rangeI.SMout.xaxisdir))]);
220 disp(['  ']);
221
222 % for wavesmon
223
224 %calculate the 0,1,2 moments
225 m0=sum(wmonfreq*wmonfreqres);                             
226 m1=sum(wmon.freqs.*wmonfreq*wmonfreqres);
227 m2=sum((wmon.freqs.^2).*wmonfreq*wmonfreqres);
228 % Calculate the Sig wave height
229 Hsig=4*sqrt(m0);
230
231 % Calculate the peak period Tp
232 [P,I]=max(wmonfreq);
233 Tp=1/(wmon.freqs(I));
234
235 %Calculate the Direction of the peak period DTp
236 [P,I]=max(real(wmon.S(I,:)));
237 DTp=wmon.dirs(I);
238
239 %Calculate the Dominant Direction Dp
240 [P,I]=max(wmondir);
241 Dp=wmon.dirs(I);
242
243 %Display on the screen the SigH,Tp,Dp,DTp
244 disp(['Wavesmon output']);
245 disp(['SigH (meters): ' num2str(Hsig)]);
246 disp(['peak period (seconds): ' num2str(Tp)]);
247 disp(['Dir of peak period: ' num2str(compangle(DTp, wmon.xaxisdir))]);
248 disp(['Dominant Direction: ' num2str(compangle(Dp, wmon.xaxisdir))]);
249 disp(['  ']);
250
251
252 %function to change from axis angles to compass bearings
253
254 function angle=compangle(angle,xaxisdir)
255 angle=xaxisdir*ones(size(angle))-angle;
256 angle=angle+360*(angle<0);
257 angle=angle-360*(angle>360);
258
259
260
261
262
Note: See TracBrowser for help on using the browser.