Changeset 314
- Timestamp:
- 01/07/10 15:10:02
- Files:
-
- DPWP/trunk/DPWP/adcp_matlab/confplot.m (modified) (6 diffs)
- DPWP/trunk/DPWP/adcp_matlab/radialtouvw.m (modified) (7 diffs)
- DPWP/trunk/DPWP/adcp_matlab/specmultiplot.m (modified) (3 diffs)
- DPWP/trunk/DPWP/diwasp_1_1GD/dirspec.m (modified) (1 diff)
- DPWP/trunk/DPWP/nortek/nortek_radialtouvw.m (modified) (2 diffs)
- DPWP/trunk/DPWP/nortek/nortek_specmultiplot.m (modified) (8 diffs)
- DPWP/trunk/DPWP/nortek/nortek_waveplot.m (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
DPWP/trunk/DPWP/adcp_matlab/confplot.m
r216 r314 1 function [fig1]=confplot( EMEP,rangeE,radialE,spec,sysinfo)1 function [fig1]=confplot(uvw,range,radial) 2 2 3 %set up the wavesmon data in a structure4 3 5 %what is the magnetic variation to nearest degree6 magvar=10;7 4 8 %first change to m^2/Hz/deg9 wmon.S=spec/(360*1000*1000);10 11 %what is the start angle12 heading=sysinfo(18,:);13 heading=heading/100;14 sangle=heading+magvar;15 16 %what is the frequency and dir resolution for those generated in DIWASP17 freqres=0.01;18 5 freqs=[0.01:0.01:.4]; 19 6 dirres=2; 20 dirs=[-180:2:180];21 7 22 %set up the directions 23 adj_angle=90-sangle+360+180; 24 wmon.dirs=[adj_angle:-4:-(356-adj_angle)]; 25 wmondirres=4; 26 wmon.xaxisdir=90; 27 wmon.freqs=[0.00781250:0.00781250:1]; 28 wmonfreqres=0.00781250; 8 29 9 30 10 %calculate just the frequency energy spectrum 31 EMEPfreq=sum(EMEP.S')*dirres; 32 EMEPrangefreq=sum(rangeE.S')*dirres; 33 EMEPradialfreq=sum(real(radialE.S)')*dirres; 34 wmonfreq=sum(wmon.S')*wmondirres; 11 uvwfreq=sum(uvw.S')*dirres; 12 rangefreq=sum(range.S')*dirres; 13 radialfreq=sum(real(radial.S)')*dirres; 35 14 36 15 %Compute the coefficient for the upper and lower error bounds for the power 37 16 %spectrum assuming 95% confidence. Added on 9/17/08 38 degF=radial E.degF;17 degF=radial.degF; 39 18 chiUp=chi2inv(.975,degF); 40 19 chiLow=chi2inv(.025,degF); … … 45 24 46 25 %calculate the conf limits throughout the frequency spectrum 47 EMEPradialfreqUP=EMEPradialfreq*coeffUp;48 EMEPradialfreqLOW=EMEPradialfreq*coeffLow;26 radialfreqUP=radialfreq*coeffUp; 27 radialfreqLOW=radialfreq*coeffLow; 49 28 50 29 %same thing for the Puvw and range … … 54 33 coeffUp2=degF2/chiLow2; 55 34 coeffLow2=degF2/chiUp2; 56 logCoeffUp2=log10(coeffUp2) 57 logCoeffLow2=log10(coeffLow2) 35 logCoeffUp2=log10(coeffUp2); 36 logCoeffLow2=log10(coeffLow2); 58 37 59 38 %calculate the conf limits throughout the frequency spectrum 60 EMEPfreqUP=EMEPfreq*coeffUp2;61 EMEPfreqLOW=EMEPfreq*coeffLow2;62 EMEPrangefreqUP=EMEPrangefreq*coeffUp2;63 EMEPrangefreqLOW=EMEPrangefreq*coeffLow2;39 uvwfreqUP=uvwfreq*coeffUp2; 40 uvwfreqLOW=uvwfreq*coeffLow2; 41 rangefreqUP=rangefreq*coeffUp2; 42 rangefreqLOW=rangefreq*coeffLow2; 64 43 65 44 scrsz = get(0,'ScreenSize'); … … 67 46 68 47 %plot the frequency energy spectrum 69 h1=semilogy(freqs, EMEPfreq,'b');48 h1=semilogy(freqs,uvwfreq,'b'); 70 49 hold on 71 50 plot([0.1,0.1],[10^logCoeffLow2,10^logCoeffUp2],'b.-'); … … 73 52 %plot(freqs,EMEPfreqLOW,'b--'); 74 53 75 h2=semilogy(freqs, EMEPrangefreq,'r');54 h2=semilogy(freqs,rangefreq,'r'); 76 55 plot([0.11,0.11],[10^logCoeffLow2,10^logCoeffUp2],'r.-'); 77 56 %plot(freqs,EMEPrangefreqUP,'r--'); 78 57 %plot(freqs,EMEPrangefreqLOW,'r--'); 79 58 80 h3=semilogy(freqs, EMEPradialfreq,'g');59 h3=semilogy(freqs,radialfreq,'g'); 81 60 plot([0.12,0.12],[10^logCoeffLow,10^logCoeffUp],'g.-'); 82 61 %plot(freqs,EMEPradialfreqUP,'g--'); … … 85 64 %set(gca,'ytick',[-4 -3 -2 -1 0 1]); 86 65 axis(axis); 87 h4=semilogy(wmon.freqs,wmonfreq,'k'); 88 legend([h1,h2,h3,h4],'EMEP uvw','EMEP range','EMEP radial','wavesmon','location','best'); 89 title('directional wave spectrum integrated over direction'); 66 legend([h1,h2,h3],'EMEP uvw','EMEP range','EMEP radial','location','best'); 67 title('1d Frequency Spectrum'); 90 68 xlabel('frequency in Hz'); 91 69 ylabel('m^2 / hz'); DPWP/trunk/DPWP/adcp_matlab/radialtouvw.m
r232 r314 22 22 23 23 %whats the magnetic variation 24 magvar=-10; 24 magvar=-10; 25 25 26 26 %set up sysinfo file … … 63 63 for i=1:orbOut 64 64 65 %first take out any points outside of 4 std deviations 65 %first take out any points outside of 4 std deviations 66 66 std_orbit(i)=nanstd(orbit(:,i)); 67 67 ibad_std=find(abs(orbit(:,i)) > 4*std_orbit(i)); … … 133 133 d = -SH.*CR + CH.*SP.*SR; e = CH.*CP; f = -SH.*SR - CH.*SP.*CR; 134 134 g = -CP.*SR; h = SP; j = CP.*CR; 135 uno=1; 135 136 136 137 137 %reshape the orbital matrix to 3 dimensions … … 186 186 g = CP.*SR; h = SP; j = CP.*CR; 187 187 188 189 188 190 %transform the original x,y,z positions to the new positions accounting for 189 191 %heading, pitch and roll... we also add adcpheight back in … … 249 251 ID.fs=2; 250 252 %depth 251 ID.depth=( adcpheight+mean(press));253 ID.depth=(0.4+mean(press)); %note changed for work with the FRF ADCP********************** 252 254 %the spectral matrix structure 253 255 SM.freqs=[0.01:0.01:0.4]; … … 265 267 % the layout 266 268 ID.layout = [ 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0; 267 adcpheight bin 2height bin2height bin2height bin3height bin3height bin3height bin4height bin4height bin4height];269 adcpheight bin3height bin3height bin3height bin4height bin4height bin4height bin5height bin5height bin5height]; 268 270 % the data 269 ID.data = horzcat(press, u_all(:, 2), v_all(:,2), w_all(:,2), u_all(:,3), v_all(:,3), w_all(:,3), u_all(:,4), v_all(:,4), w_all(:,4));271 ID.data = horzcat(press, u_all(:,3), v_all(:,3), w_all(:,3), u_all(:,4), v_all(:,4), w_all(:,4), u_all(:,5), v_all(:,5), w_all(:,5)); 270 272 271 273 elseif data_type == 2 … … 284 286 % the datatypes 285 287 ID.datatypes={'radial' 'radial' 'radial' 'radial' 'radial' 'radial' 'radial' 'radial' 'radial' 'radial' 'radial' 'radial'}; 286 % the layout 287 ID.layout = [xyzpositions(1,1,2) xyzpositions(1,2,2) xyzpositions(1,3,2) xyzpositions(1,4,2) xyzpositions(1,1,3) xyzpositions(1,2,3) xyzpositions(1,3,3) xyzpositions(1,4,3) xyzpositions(1,1,4) xyzpositions(1,2,4) xyzpositions(1,3,4) xyzpositions(1,4,4);288 xyzpositions(2,1,2) xyzpositions(2,2,2) xyzpositions(2,3,2) xyzpositions(2,4,2) xyzpositions(2,1,3) xyzpositions(2,2,3) xyzpositions(2,3,3) xyzpositions(2,4,3) xyzpositions(2,1,4) xyzpositions(2,2,4) xyzpositions(2,3,4) xyzpositions(2,4,4);289 xyzpositions(3,1,2) xyzpositions(3,2,2) xyzpositions(3,3,2) xyzpositions(3,4,2) xyzpositions(3,1,3) xyzpositions(3,2,3) xyzpositions(3,3,3) xyzpositions(3,4,3) xyzpositions(3,1,4) xyzpositions(3,2,4) xyzpositions(3,3,4) xyzpositions(3,4,4)];288 % the layout using bins 2,3,4 289 %ID.layout = [xyzpositions(1,1,2) xyzpositions(1,2,2) xyzpositions(1,3,2) xyzpositions(1,4,2) xyzpositions(1,1,3) xyzpositions(1,2,3) xyzpositions(1,3,3) xyzpositions(1,4,3) xyzpositions(1,1,4) xyzpositions(1,2,4) xyzpositions(1,3,4) xyzpositions(1,4,4); 290 %xyzpositions(2,1,2) xyzpositions(2,2,2) xyzpositions(2,3,2) xyzpositions(2,4,2) xyzpositions(2,1,3) xyzpositions(2,2,3) xyzpositions(2,3,3) xyzpositions(2,4,3) xyzpositions(2,1,4) xyzpositions(2,2,4) xyzpositions(2,3,4) xyzpositions(2,4,4); 291 %xyzpositions(3,1,2) xyzpositions(3,2,2) xyzpositions(3,3,2) xyzpositions(3,4,2) xyzpositions(3,1,3) xyzpositions(3,2,3) xyzpositions(3,3,3) xyzpositions(3,4,3) xyzpositions(3,1,4) xyzpositions(3,2,4) xyzpositions(3,3,4) xyzpositions(3,4,4)]; 290 292 % the data 291 ID.data = horzcat(orbitnew(:,5),orbitnew(:,6),orbitnew(:,7),orbitnew(:,8),orbitnew(:,9),orbitnew(:,10),orbitnew(:,11),orbitnew(:,12),orbitnew(:,13),orbitnew(:,14),orbitnew(:,15),orbitnew(:,16));293 %ID.data = horzcat(orbitnew(:,5),orbitnew(:,6),orbitnew(:,7),orbitnew(:,8),orbitnew(:,9),orbitnew(:,10),orbitnew(:,11),orbitnew(:,12),orbitnew(:,13),orbitnew(:,14),orbitnew(:,15),orbitnew(:,16)); 292 294 293 295 % the layout using bins 3,4,5 294 %ID.layout = [xyzpositions(1,1,5) xyzpositions(1,2,5) xyzpositions(1,3,5) xyzpositions(1,4,5) xyzpositions(1,1,4) xyzpositions(1,2,4) xyzpositions(1,3,4) xyzpositions(1,4,4) xyzpositions(1,1,3) xyzpositions(1,2,3) xyzpositions(1,3,3) xyzpositions(1,4,3);295 %xyzpositions(2,1,5) xyzpositions(2,2,5) xyzpositions(2,3,5) xyzpositions(2,4,5) xyzpositions(2,1,4) xyzpositions(2,2,4) xyzpositions(2,3,4) xyzpositions(2,4,4) xyzpositions(2,1,3) xyzpositions(2,2,3) xyzpositions(2,3,3) xyzpositions(2,4,3);296 %xyzpositions(3,1,5) xyzpositions(3,2,5) xyzpositions(3,3,5) xyzpositions(3,4,5) xyzpositions(3,1,4) xyzpositions(3,2,4) xyzpositions(3,3,4) xyzpositions(3,4,4) xyzpositions(3,1,3) xyzpositions(3,2,3) xyzpositions(3,3,3) xyzpositions(3,4,3)];296 ID.layout = [xyzpositions(1,1,5) xyzpositions(1,2,5) xyzpositions(1,3,5) xyzpositions(1,4,5) xyzpositions(1,1,4) xyzpositions(1,2,4) xyzpositions(1,3,4) xyzpositions(1,4,4) xyzpositions(1,1,3) xyzpositions(1,2,3) xyzpositions(1,3,3) xyzpositions(1,4,3); 297 xyzpositions(2,1,5) xyzpositions(2,2,5) xyzpositions(2,3,5) xyzpositions(2,4,5) xyzpositions(2,1,4) xyzpositions(2,2,4) xyzpositions(2,3,4) xyzpositions(2,4,4) xyzpositions(2,1,3) xyzpositions(2,2,3) xyzpositions(2,3,3) xyzpositions(2,4,3); 298 xyzpositions(3,1,5) xyzpositions(3,2,5) xyzpositions(3,3,5) xyzpositions(3,4,5) xyzpositions(3,1,4) xyzpositions(3,2,4) xyzpositions(3,3,4) xyzpositions(3,4,4) xyzpositions(3,1,3) xyzpositions(3,2,3) xyzpositions(3,3,3) xyzpositions(3,4,3)]; 297 299 % the data 298 % ID.data = horzcat(orbitnew(:,17),orbitnew(:,18),orbitnew(:,19),orbitnew(:,20),orbitnew(:,13),orbitnew(:,14),orbitnew(:,15),orbitnew(:,16),orbitnew(:,9),orbitnew(:,10),orbitnew(:,11),orbitnew(:,12)); 299 300 ID.data = horzcat(orbitnew(:,17),orbitnew(:,18),orbitnew(:,19),orbitnew(:,20),orbitnew(:,13),orbitnew(:,14),orbitnew(:,15),orbitnew(:,16),orbitnew(:,9),orbitnew(:,10),orbitnew(:,11),orbitnew(:,12)); 301 302 300 303 end 301 304 DPWP/trunk/DPWP/adcp_matlab/specmultiplot.m
r232 r314 60 60 61 61 %set up data with radial velocities, freq and dir at default 62 [ID,SM,EP]=radialtouvw(pressure,range,orbit,sysinfo,3); 63 62 [ID,SM,EP]=radialtouvw(pressure,range,orbit,sysinfo,3); %last input argument represents the data types, 1=p-u-v-w,2=range,3=radials 63 64 64 65 % run diwasp to generate this spectrum with EMEP 65 66 [radialE, EPout]=dirspec(ID,SM,EP,{'PLOTTYPE',0,'MESSAGE',0}); … … 107 108 %this changes the coordinates from axis to compass (and from direction TO, 108 109 %to direction FROM) 109 % NEED TO ADJUST THIS TO AUTOMATICALLY ACOUNT FOR USER INPUTTED SM.dirs!!!110 110 newspec2d=zeros(size(spec2d)); 111 111 for i= 1:size(spec2d,1) … … 134 134 end 135 135 136 Winfo.Spectrum.EMEPradial=newspec2d;136 %Winfo.Spectrum.EMEPradial=newspec2d; 137 137 138 138 %Use this to organize spec IF SM.dirs=[-180:2:178] DPWP/trunk/DPWP/diwasp_1_1GD/dirspec.m
r231 r314 152 152 %What are the number of sensors (data series) used to compute the power 153 153 %spectrum? If we aren't using radial velocities it is just 1. 154 154 155 dataUsed=1; 155 156 DPWP/trunk/DPWP/nortek/nortek_radialtouvw.m
r217 r314 115 115 %transform the original x,y,z positions to the new positions accounting for 116 116 %heading, pitch and roll... we also add adcpheight back in 117 newxyzpos=ones(3,3); 117 118 118 new_xyzpos(1,:)=xyzpos(1,:)*a+xyzpos(2,:)*b+xyzpos(3,:)*c; 119 119 new_xyzpos(2,:)=xyzpos(1,:)*d+xyzpos(2,:)*e+xyzpos(3,:)*f; … … 174 174 SM.xaxisdir= 90; 175 175 %the estimation parameter 176 EP.method= ' EMEP';177 EP.iter= 100;176 EP.method= 'IMLM'; 177 EP.iter=3; 178 178 179 179 if data_type == 1 DPWP/trunk/DPWP/nortek/nortek_specmultiplot.m
r217 r314 1 function [Winfo]=nortek_specmultiplot(dateinfo1,dateinfo2,timestep) ;1 function [Winfo]=nortek_specmultiplot(dateinfo1,dateinfo2,timestep) 2 2 3 3 %NOTE: This function is for the Nortek AWAC profiler! … … 30 30 end 31 31 end 32 32 33 %Make a directory for the data 34 mkdir('tempdir'); 33 35 34 36 %set up time, which is Winfo.time as date str in the yymmddHHMM format … … 36 38 37 39 %set up data structure for wave info 38 Winfo.setup={' IMLM'}';40 Winfo.setup={'EMEP'}'; 39 41 Winfo.hsig=[]; 40 42 Winfo.hconf=[]; … … 45 47 46 48 %load the wave data from the nortek quick wave software 47 wavedata=load('BPWave01.wap');49 %wavedata=load('BPWave01.wap'); 48 50 49 51 %Load the data and run the script … … 55 57 orbit=strcat('orbit_',dateinfo,'.txt'); 56 58 sysinfo=strcat('sysinfo_',dateinfo,'.txt'); 57 nortekspec=strcat('nortekspec_',dateinfo,'.txt');59 %nortekspec=strcat('nortekspec_',dateinfo,'.txt'); 58 60 59 61 pressure=load(pressure); … … 61 63 orbit=load(orbit); 62 64 sysinfo=load(sysinfo); 63 nortekspec=load(nortekspec);65 %nortekspec=load(nortekspec); 64 66 65 67 %set up data with standard AST freq at 0.01 and dir at 2 … … 74 76 %Use waveplot to plot the polar, freq and dir plots of the spectra 75 77 76 [E_WI,I_WI,nortek_WI,fig1,fig2]=nortek_waveplot(E_F01_D2,I_F01_D2,sysinfo,nortekspec); 78 %[E_WI,I_WI,nortek_WI,fig1,fig2]=nortek_waveplot(E_F01_D2,I_F01_D2,sysinfo,nortekspec); 79 [I_WI,fig1,fig2]=nortek_waveplot1(I_F01_D2); 77 80 78 81 saveas(fig1,['polar1_' dateinfo '.fig']); 79 82 saveas(fig2,['dirfreq1_' dateinfo '.fig']); 83 84 movefile(['polar1_' dateinfo '.fig'],'tempdir'); 85 movefile(['dirfreq1_' dateinfo '.fig'],'tempdir'); 80 86 81 87 close all; … … 97 103 end 98 104 105 save(['specdata_' dateinfo],'Winfo'); 106 movefile(['specdata_' dateinfo '.mat'],'tempdir'); 107 108 movefile('tempdir',strcat('procdata_',dateinfo)); 109 99 110 %now create the time series plots of the wave info 100 [fig_sigh,fig_pp,fig_dp,fig_dd]=nortek_Winfo_plot(Winfo);111 %[fig_sigh,fig_pp,fig_dp,fig_dd]=nortek_Winfo_plot(Winfo); 101 112 102 saveas(fig_sigh,['sigh_' dateinfo '.fig']);103 saveas(fig_pp,['peakp_' dateinfo '.fig']);104 saveas(fig_dp,['dirpeak_' dateinfo '.fig']);105 saveas(fig_dd,['domdir_' dateinfo '.fig']);113 %saveas(fig_sigh,['sigh_' dateinfo '.fig']); 114 %saveas(fig_pp,['peakp_' dateinfo '.fig']); 115 %saveas(fig_dp,['dirpeak_' dateinfo '.fig']); 116 %saveas(fig_dd,['domdir_' dateinfo '.fig']); 106 117 107 118 close all; DPWP/trunk/DPWP/nortek/nortek_waveplot.m
r215 r314 1 function [ E_WI,I_WI,nortek_WI,fig1,fig2]=nortek_waveplot(EMEP,IMLM,sysinfo,nortekspec)1 function [I_WI,fig1,fig2]=nortek_waveplot(IMLM) 2 2 3 3 %make sure to load the EMEP, IMLM and wavesmon samples … … 5 5 %rangeE=load('EMEP_range'), rangeI=load('IMLM_range') 6 6 7 %set up the wavesmon data in a structure 7 8 8 9 9 %what is the magnetic variation to nearest degree 10 magvar= 10;10 magvar=-10; 11 11 12 12 %what is the frequency and dir resolution for those generated in DIWASP … … 16 16 dirs=[-180:2:180]; 17 17 18 %what is the frequency and dir resolution for those created by nortek19 %freqres is the same20 nortekfreqs=[0.01:0.01:.4];21 nortekdirres=4;22 nortekdirs=[270:-4:-86];23 nortek.S=nortekspec;24 nortek.dirs=nortekdirs;25 nortek.freqs=nortekfreqs;26 nortek.xaxisdir=90;27 28 18 % plot the spectrum generated through DIWASP 29 19 30 20 scrsz = get(0,'ScreenSize'); 31 21 fig1=figure('Position',[scrsz]); 32 subplot(2,2,1); 33 subplotspec(EMEP,4); 34 title('EMEP AST beam and radial velocities'); 22 35 23 36 24 subplot(2,2,2); 37 25 subplotspec(IMLM,4); 38 title(' IMLMAST beam and radial velocities');26 title('EMEP AST beam and radial velocities'); 39 27 40 subplot(2,2,3); 41 subplotspec(nortek,4); 42 title('nortek quick wave spectrum'); 28 43 29 44 30 45 31 %calculate just the dir energy spectrum on a single graph 46 32 47 EMEPdir=sum(EMEP.S)*freqres; 33 48 34 IMLMdir=sum(real(IMLM.S))*freqres; 49 nortekdir=sum(nortek.S)*freqres; 35 50 36 51 37 52 38 %calculate just the frequency energy spectrum 53 EMEPfreq=sum(EMEP.S')*dirres;54 39 IMLMfreq=sum(real(IMLM.S)')*dirres; 55 nortekfreq=sum(nortek.S')*nortekdirres; 40 56 41 57 42 %Compute the coefficient for the upper and lower error bounds for the 58 43 %frequency 59 44 %spectrum assuming 95% confidence. Added on 9/17/08 60 degF=2* EMEP.degF; % 2* since for the Nortek the range beam sampled at 4hz (4096) is decimated or averaged to 2hz (2048)45 degF=2*IMLM.degF; % 2* since for the Nortek the range beam sampled at 4hz (4096) is decimated or averaged to 2hz (2048) 61 46 chiUp=chi2inv(.975,degF); 62 47 chiLow=chi2inv(.025,degF); … … 65 50 66 51 %calculate the conf limits throughout the frequency spectrum 67 EMEPfreqUP=EMEPfreq*coeffUp; 68 EMEPfreqLOW=EMEPfreq*coeffLow; 52 69 53 IMLMfreqUP=IMLMfreq*coeffUp; 70 54 IMLMfreqLOW=IMLMfreq*coeffLow; … … 72 56 %Find the maximum for the directional spectrum so we can set up the proper 73 57 %x-axis 74 [maxvalue,maxindex] = max( EMEPdir);58 [maxvalue,maxindex] = max(IMLMdir); 75 59 maxdir=dirs(maxindex); 76 60 % set up the x-axis for all of the spectra depending on the max 77 if ((100 < maxdir) | (maxdir < -100));61 if ((100 < maxdir) || (maxdir < -100)); 78 62 %for diwasp spectra 79 63 index1=find(dirs < 0); 80 64 index2=find(dirs > -1); 81 65 dirs(index1)=dirs(index1) +360; 82 %for nortek83 Aindex=find(nortek.dirs < 0);84 Bindex=find((-1 < nortek.dirs) & (nortek.dirs < 361));85 Bindex2=find(nortek.dirs > 360);86 nortek.dirs(Bindex2)=nortek.dirs(Bindex2)-360;87 nortek.dirs(Aindex)=nortek.dirs(Aindex)+360;88 66 89 67 %plot the directional energy spectrum 90 68 fig2=figure('Position',[scrsz]); 91 69 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),IMLMdir(index2),'r'); 96 h2a= plot(dirs(index1),IMLMdir(index1),'r'); 97 %plot the nortek data 98 h3 = plot(nortek.dirs(Bindex2),nortekdir(Bindex2),'k'); 99 h3a = plot(nortek.dirs(Bindex),nortekdir(Bindex),'k'); 100 h3b= plot(nortek.dirs(Aindex),nortekdir(Aindex),'k'); 70 h2 = plot(dirs(index2),IMLMdir(index2),'b'); 71 h2a= plot(dirs(index1),IMLMdir(index1),'b'); 72 101 73 else 102 %for diwasp spectra do nothing103 74 104 %for nortek105 Aindex=find(nortek.dirs > 180);106 Bindex=find(nortek.dirs < 181);107 nortek.dirs(Aindex)=nortek.dirs(Aindex)-360;108 75 %plot the directional energy spectrum 109 76 fig2=figure('Position',[scrsz]); 110 77 subplot(1,2,1); 111 h1 = plot(dirs,EMEPdir,'b');112 78 hold on 113 h2 = plot(dirs,IMLMdir,'r'); 114 %plot the nortek data 115 h3a = plot(nortek.dirs(Bindex),nortekdir(Bindex),'k'); 116 h3b = plot(nortek.dirs(Aindex),nortekdir(Aindex),'k'); 79 h2a = plot(dirs,IMLMdir,'b'); 117 80 118 81 end 119 82 120 legend( [h1, h2, h3a],'EMEP','IMLM','nortek quickwave','location','best');83 legend(h2a,'EMEP'); 121 84 title('directional wave spectrum integrated over frequency'); 122 85 xlabel('axis angle (degrees true)'); … … 125 88 %plot the frequency energy spectrum 126 89 subplot(1,2,2); 127 h 1=plot(freqs,EMEPfreq,'b');90 h3=plot(freqs,IMLMfreq,'r'); 128 91 hold on 129 h2=plot(freqs,EMEPfreqUP,'b--');130 plot(freqs,EMEPfreqLOW,'b--');131 h3=plot(freqs,IMLMfreq,'r');132 92 h4=plot(freqs,IMLMfreqUP,'r--'); 133 93 plot(freqs,IMLMfreqLOW,'r--'); 134 h5=plot(nortekfreqs,nortekfreq,'k'); 135 legend('EMEP','EMEP 95% confidence','IMLM','IMLM 95% confidence','nortek quickwave','location','best'); 94 legend('EMEP','EMEP 95% confidence'); 136 95 title('directional wave spectrum integrated over direction'); 137 96 xlabel('frequency in Hz'); … … 140 99 % ______Calculate and display the wave parameters SigH, Tp, Dp,DTp_______ 141 100 142 %For EMEP AST and radial velocities143 144 %calculate the 0,1,2 moments145 m0=sum(EMEPfreq*freqres);146 m1=sum(freqs.*EMEPfreq*freqres);147 m2=sum((freqs.^2).*EMEPfreq*freqres);148 % Calculate the Sig wave height149 EMEP_Hsig=4*sqrt(m0);150 %Use the function HsigConf.m to calculate the sigH confidence limits151 EMEP_HsConf=nortek_HsigConf(EMEP);152 153 % Calculate the peak period Tp154 [P,I]=max(EMEPfreq);155 EMEP_Tp=1/(freqs(I));156 157 %Calculate the Direction of the peak period DTp158 [P,I]=max(real(EMEP.S(I,:)));159 EMEP_DTp=dirs(I);160 161 %Calculate the Dominant Direction Dp162 [P,I]=max(EMEPdir);163 EMEP_Dp=dirs(I);164 165 %Display on the screen the SigH,Tp,Dp,DTp166 disp(['EMEP']);167 disp(['SigH (meters): ' num2str(EMEP_Hsig)]);168 disp(['SigH 95% conf. (meters): ' num2str(EMEP_HsConf)]);169 disp(['peak period (seconds): ' num2str(EMEP_Tp)]);170 disp(['Dir of peak period: ' num2str(compangle(EMEP_DTp, EMEP.xaxisdir))]);171 disp(['Dominant Direction: ' num2str(compangle(EMEP_Dp, EMEP.xaxisdir))]);172 disp([' ']);173 174 E_WI.hsig=EMEP_Hsig;175 E_WI.hconf=EMEP_HsConf;176 E_WI.tp=EMEP_Tp;177 E_WI.dtp=compangle(EMEP_DTp, EMEP.xaxisdir);178 E_WI.dp=compangle(EMEP_Dp, EMEP.xaxisdir);179 101 180 102 … … 203 125 204 126 %Display on the screen the SigH,Tp,Dp,DTp 205 disp([' IMLM']);127 disp(['EMEP']); 206 128 disp(['SigH (meters): ' num2str(IMLM_Hsig)]); 207 129 disp(['SigH 95% conf. (meters): ' num2str(IMLM_HsConf)]); … … 219 141 220 142 221 %for nortek generated spectrum222 223 %calculate the 0,1,2 moments224 m0=sum(nortekfreq*freqres);225 m1=sum(nortekfreqs.*nortekfreq*freqres);226 m2=sum((nortekfreqs.^2).*nortekfreq*freqres);227 % Calculate the Sig wave height228 nortek_Hsig=4*sqrt(m0);229 230 % Calculate the peak period Tp231 [P,I]=max(nortekfreq);232 nortek_Tp=1/(nortekfreqs(I));233 234 %Calculate the Direction of the peak period DTp235 [P,I]=max(real(nortek.S(I,:)));236 nortek_DTp=nortekdirs(I);237 238 %Calculate the Dominant Direction Dp239 [P,I]=max(nortekdir);240 nortek_Dp=nortekdirs(I);241 242 %Display on the screen the SigH,Tp,Dp,DTp243 disp(['nortek']);244 disp(['SigH (meters): ' num2str(nortek_Hsig)]);245 disp(['peak period (seconds): ' num2str(nortek_Tp)]);246 disp(['Dir of peak period: ' num2str(compangle(nortek_DTp, nortek.xaxisdir))]);247 disp(['Dominant Direction: ' num2str(compangle(nortek_Dp, nortek.xaxisdir))]);248 disp([' ']);249 250 nortek_WI.hsig=nortek_Hsig;251 nortek_WI.hconf=[NaN NaN];252 nortek_WI.tp=nortek_Tp;253 nortek_WI.dtp=compangle(nortek_DTp, nortek.xaxisdir);254 nortek_WI.dp=compangle(nortek_Dp, nortek.xaxisdir);255 256 257 143 258 144 %function to change from axis angles to compass bearings