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

Changeset 314

Show
Ignore:
Timestamp:
01/07/10 15:10:02
Author:
gdusek
Message:

changes to mulitple files due to recent merge

Files:

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
     1function [fig1]=confplot(uvw,range,radial
    22 
    3 %set up the wavesmon data in a structure 
    43 
    5 %what is the magnetic variation to nearest degree 
    6 magvar=10; 
    74 
    8 %first change to m^2/Hz/deg 
    9 wmon.S=spec/(360*1000*1000); 
    10  
    11 %what is the start angle 
    12 heading=sysinfo(18,:); 
    13 heading=heading/100; 
    14 sangle=heading+magvar; 
    15  
    16 %what is the frequency and dir resolution for those generated in DIWASP 
    17 freqres=0.01; 
    185freqs=[0.01:0.01:.4]; 
    196dirres=2; 
    20 dirs=[-180:2:180]; 
    217 
    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 
    299 
    3010%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; 
     11uvwfreq=sum(uvw.S')*dirres; 
     12rangefreq=sum(range.S')*dirres; 
     13radialfreq=sum(real(radial.S)')*dirres; 
    3514 
    3615%Compute the coefficient for the upper and lower error bounds for the power 
    3716%spectrum assuming 95% confidence.  Added on 9/17/08 
    38 degF=radialE.degF; 
     17degF=radial.degF; 
    3918chiUp=chi2inv(.975,degF); 
    4019chiLow=chi2inv(.025,degF); 
     
    4524 
    4625%calculate the conf limits throughout the frequency spectrum 
    47 EMEPradialfreqUP=EMEPradialfreq*coeffUp; 
    48 EMEPradialfreqLOW=EMEPradialfreq*coeffLow; 
     26radialfreqUP=radialfreq*coeffUp; 
     27radialfreqLOW=radialfreq*coeffLow; 
    4928 
    5029%same thing for the Puvw and range 
     
    5433coeffUp2=degF2/chiLow2; 
    5534coeffLow2=degF2/chiUp2; 
    56 logCoeffUp2=log10(coeffUp2) 
    57 logCoeffLow2=log10(coeffLow2) 
     35logCoeffUp2=log10(coeffUp2); 
     36logCoeffLow2=log10(coeffLow2); 
    5837 
    5938%calculate the conf limits throughout the frequency spectrum 
    60 EMEPfreqUP=EMEPfreq*coeffUp2; 
    61 EMEPfreqLOW=EMEPfreq*coeffLow2; 
    62 EMEPrangefreqUP=EMEPrangefreq*coeffUp2; 
    63 EMEPrangefreqLOW=EMEPrangefreq*coeffLow2; 
     39uvwfreqUP=uvwfreq*coeffUp2; 
     40uvwfreqLOW=uvwfreq*coeffLow2; 
     41rangefreqUP=rangefreq*coeffUp2; 
     42rangefreqLOW=rangefreq*coeffLow2; 
    6443 
    6544scrsz = get(0,'ScreenSize'); 
     
    6746 
    6847%plot the frequency energy spectrum 
    69 h1=semilogy(freqs,EMEPfreq,'b'); 
     48h1=semilogy(freqs,uvwfreq,'b'); 
    7049hold on 
    7150plot([0.1,0.1],[10^logCoeffLow2,10^logCoeffUp2],'b.-'); 
     
    7352%plot(freqs,EMEPfreqLOW,'b--'); 
    7453 
    75 h2=semilogy(freqs,EMEPrangefreq,'r'); 
     54h2=semilogy(freqs,rangefreq,'r'); 
    7655plot([0.11,0.11],[10^logCoeffLow2,10^logCoeffUp2],'r.-'); 
    7756%plot(freqs,EMEPrangefreqUP,'r--'); 
    7857%plot(freqs,EMEPrangefreqLOW,'r--'); 
    7958 
    80 h3=semilogy(freqs,EMEPradialfreq,'g'); 
     59h3=semilogy(freqs,radialfreq,'g'); 
    8160plot([0.12,0.12],[10^logCoeffLow,10^logCoeffUp],'g.-'); 
    8261%plot(freqs,EMEPradialfreqUP,'g--'); 
     
    8564%set(gca,'ytick',[-4 -3 -2 -1 0 1]); 
    8665axis(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'); 
     66legend([h1,h2,h3],'EMEP uvw','EMEP range','EMEP radial','location','best'); 
     67title('1d Frequency Spectrum'); 
    9068xlabel('frequency in Hz'); 
    9169ylabel('m^2 / hz'); 
  • DPWP/trunk/DPWP/adcp_matlab/radialtouvw.m

    r232 r314  
    2222 
    2323%whats the magnetic variation 
    24 magvar=-10; 
     24magvar=-10;  
    2525 
    2626%set up sysinfo file 
     
    6363for i=1:orbOut 
    6464     
    65     %first take out any points outside of 4 std deviations 
     65    %first take out any points outside of 4 std deviations  
    6666    std_orbit(i)=nanstd(orbit(:,i)); 
    6767    ibad_std=find(abs(orbit(:,i)) > 4*std_orbit(i)); 
     
    133133d = -SH.*CR + CH.*SP.*SR; e = CH.*CP; f = -SH.*SR - CH.*SP.*CR; 
    134134g = -CP.*SR;              h = SP;     j = CP.*CR; 
    135 uno=1; 
     135 
    136136 
    137137%reshape the orbital matrix to 3 dimensions 
     
    186186g = CP.*SR;              h = SP;     j = CP.*CR; 
    187187 
     188 
     189 
    188190%transform the original x,y,z positions to the new positions accounting for 
    189191%heading, pitch and roll... we also add adcpheight back in 
     
    249251ID.fs=2; 
    250252%depth 
    251 ID.depth=(adcpheight+mean(press)); 
     253ID.depth=(0.4+mean(press)); %note changed for work with the FRF ADCP********************** 
    252254%the spectral matrix structure 
    253255SM.freqs=[0.01:0.01:0.4]; 
     
    265267    % the layout 
    266268    ID.layout = [ 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0;  
    267     adcpheight bin2height bin2height bin2height bin3height bin3height bin3height bin4height bin4height bin4height]; 
     269    adcpheight bin3height bin3height bin3height bin4height bin4height bin4height bin5height bin5height bin5height]; 
    268270    % 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)); 
    270272     
    271273elseif data_type == 2 
     
    284286    % the datatypes 
    285287    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)]; 
    290292    % 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)); 
    292294 
    293295    % 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)]; 
    297299    % 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     
    300303end 
    301304 
  • DPWP/trunk/DPWP/adcp_matlab/specmultiplot.m

    r232 r314  
    6060 
    6161    %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     
    6465    % run diwasp to generate this spectrum with EMEP 
    6566    [radialE, EPout]=dirspec(ID,SM,EP,{'PLOTTYPE',0,'MESSAGE',0}); 
     
    107108%this changes the coordinates from axis to compass (and from direction TO, 
    108109%to direction FROM) 
    109 % NEED TO ADJUST THIS TO AUTOMATICALLY ACOUNT FOR USER INPUTTED SM.dirs!!! 
    110110newspec2d=zeros(size(spec2d)); 
    111111for i= 1:size(spec2d,1) 
     
    134134end 
    135135 
    136 Winfo.Spectrum.EMEPradial=newspec2d; 
     136%Winfo.Spectrum.EMEPradial=newspec2d; 
    137137 
    138138%Use this to organize spec IF SM.dirs=[-180:2:178] 
  • DPWP/trunk/DPWP/diwasp_1_1GD/dirspec.m

    r231 r314  
    152152%What are the number of sensors (data series) used to compute the power 
    153153%spectrum?  If we aren't using radial velocities it is just 1. 
     154 
    154155dataUsed=1; 
    155156 
  • DPWP/trunk/DPWP/nortek/nortek_radialtouvw.m

    r217 r314  
    115115%transform the original x,y,z positions to the new positions accounting for 
    116116%heading, pitch and roll... we also add adcpheight back in 
    117 newxyzpos=ones(3,3); 
     117 
    118118new_xyzpos(1,:)=xyzpos(1,:)*a+xyzpos(2,:)*b+xyzpos(3,:)*c; 
    119119new_xyzpos(2,:)=xyzpos(1,:)*d+xyzpos(2,:)*e+xyzpos(3,:)*f; 
     
    174174SM.xaxisdir= 90; 
    175175%the estimation parameter 
    176 EP.method= 'EMEP'; 
    177 EP.iter=100
     176EP.method= 'IMLM'; 
     177EP.iter=3
    178178 
    179179if data_type == 1 
  • DPWP/trunk/DPWP/nortek/nortek_specmultiplot.m

    r217 r314  
    1 function [Winfo]=nortek_specmultiplot(dateinfo1,dateinfo2,timestep);  
     1function [Winfo]=nortek_specmultiplot(dateinfo1,dateinfo2,timestep) 
    22 
    33%NOTE:  This function is for the Nortek AWAC profiler! 
     
    3030    end 
    3131end 
    32              
     32  
     33%Make a directory for the data 
     34mkdir('tempdir'); 
    3335       
    3436%set up time, which is Winfo.time as date str in the yymmddHHMM format 
     
    3638 
    3739%set up data structure for wave info 
    38 Winfo.setup={'IMLM'}'; 
     40Winfo.setup={'EMEP'}'; 
    3941Winfo.hsig=[]; 
    4042Winfo.hconf=[]; 
     
    4547 
    4648%load the wave data from the nortek quick wave software 
    47 wavedata=load('BPWave01.wap'); 
     49%wavedata=load('BPWave01.wap'); 
    4850 
    4951%Load the data and run the script 
     
    5557    orbit=strcat('orbit_',dateinfo,'.txt'); 
    5658    sysinfo=strcat('sysinfo_',dateinfo,'.txt'); 
    57     nortekspec=strcat('nortekspec_',dateinfo,'.txt'); 
     59    %nortekspec=strcat('nortekspec_',dateinfo,'.txt'); 
    5860 
    5961    pressure=load(pressure); 
     
    6163    orbit=load(orbit); 
    6264    sysinfo=load(sysinfo); 
    63     nortekspec=load(nortekspec); 
     65    %nortekspec=load(nortekspec); 
    6466 
    6567    %set up data with standard AST freq at 0.01 and dir at 2 
     
    7476    %Use waveplot to plot the polar, freq and dir plots of the spectra 
    7577 
    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);  
    7780     
    7881    saveas(fig1,['polar1_' dateinfo '.fig']); 
    7982    saveas(fig2,['dirfreq1_' dateinfo '.fig']); 
     83     
     84    movefile(['polar1_' dateinfo '.fig'],'tempdir'); 
     85    movefile(['dirfreq1_' dateinfo '.fig'],'tempdir'); 
    8086     
    8187    close all; 
     
    97103end 
    98104 
     105save(['specdata_' dateinfo],'Winfo'); 
     106movefile(['specdata_' dateinfo '.mat'],'tempdir'); 
     107 
     108movefile('tempdir',strcat('procdata_',dateinfo)); 
     109 
    99110%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); 
    101112 
    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']); 
    106117 
    107118close 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)  
     1function [I_WI,fig1,fig2]=nortek_waveplot(IMLM)  
    22 
    33%make sure to load the EMEP, IMLM and wavesmon samples 
     
    55%rangeE=load('EMEP_range'), rangeI=load('IMLM_range') 
    66 
    7 %set up the wavesmon data in a structure 
     7 
    88 
    99%what is the magnetic variation to nearest degree 
    10 magvar=10; 
     10magvar=-10; 
    1111 
    1212%what is the frequency and dir resolution for those generated in DIWASP 
     
    1616dirs=[-180:2:180]; 
    1717 
    18 %what is the frequency and dir resolution for those created by nortek 
    19 %freqres is the same 
    20 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  
    2818% plot the spectrum generated through DIWASP  
    2919 
    3020scrsz = get(0,'ScreenSize'); 
    3121fig1=figure('Position',[scrsz]); 
    32 subplot(2,2,1); 
    33 subplotspec(EMEP,4); 
    34 title('EMEP AST beam and radial velocities'); 
     22 
    3523 
    3624subplot(2,2,2); 
    3725subplotspec(IMLM,4); 
    38 title('IMLM AST beam and radial velocities'); 
     26title('EMEP AST beam and radial velocities'); 
    3927 
    40 subplot(2,2,3); 
    41 subplotspec(nortek,4); 
    42 title('nortek quick wave spectrum'); 
     28 
    4329 
    4430 
    4531%calculate just the dir energy spectrum on a single graph 
    4632 
    47 EMEPdir=sum(EMEP.S)*freqres; 
     33 
    4834IMLMdir=sum(real(IMLM.S))*freqres; 
    49 nortekdir=sum(nortek.S)*freqres; 
     35 
    5036 
    5137 
    5238%calculate just the frequency energy spectrum 
    53 EMEPfreq=sum(EMEP.S')*dirres; 
    5439IMLMfreq=sum(real(IMLM.S)')*dirres; 
    55 nortekfreq=sum(nortek.S')*nortekdirres; 
     40 
    5641 
    5742%Compute the coefficient for the upper and lower error bounds for the 
    5843%frequency 
    5944%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) 
     45degF=2*IMLM.degF; % 2* since for the Nortek the range beam sampled at 4hz (4096) is decimated or averaged to 2hz (2048) 
    6146chiUp=chi2inv(.975,degF); 
    6247chiLow=chi2inv(.025,degF); 
     
    6550 
    6651%calculate the conf limits throughout the frequency spectrum 
    67 EMEPfreqUP=EMEPfreq*coeffUp; 
    68 EMEPfreqLOW=EMEPfreq*coeffLow; 
     52 
    6953IMLMfreqUP=IMLMfreq*coeffUp; 
    7054IMLMfreqLOW=IMLMfreq*coeffLow; 
     
    7256%Find the maximum for the directional spectrum so we can set up the proper 
    7357%x-axis 
    74 [maxvalue,maxindex] = max(EMEPdir); 
     58[maxvalue,maxindex] = max(IMLMdir); 
    7559maxdir=dirs(maxindex); 
    7660% set up the x-axis for all of the spectra depending on the max 
    77 if ((100 < maxdir) | (maxdir < -100)); 
     61if ((100 < maxdir) || (maxdir < -100)); 
    7862    %for diwasp spectra 
    7963    index1=find(dirs < 0); 
    8064    index2=find(dirs > -1); 
    8165    dirs(index1)=dirs(index1) +360; 
    82     %for nortek 
    83     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; 
    8866 
    8967    %plot the directional energy spectrum 
    9068    fig2=figure('Position',[scrsz]); 
    9169    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     
    10173else 
    102     %for diwasp spectra do nothing 
    10374     
    104     %for nortek 
    105     Aindex=find(nortek.dirs > 180); 
    106     Bindex=find(nortek.dirs < 181); 
    107     nortek.dirs(Aindex)=nortek.dirs(Aindex)-360; 
    10875    %plot the directional energy spectrum 
    10976    fig2=figure('Position',[scrsz]); 
    11077    subplot(1,2,1); 
    111     h1 = plot(dirs,EMEPdir,'b'); 
    11278    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'); 
    11780     
    11881end 
    11982 
    120 legend([h1, h2, h3a],'EMEP','IMLM','nortek quickwave','location','best'); 
     83legend(h2a,'EMEP'); 
    12184title('directional wave spectrum integrated over frequency'); 
    12285xlabel('axis angle (degrees true)'); 
     
    12588%plot the frequency energy spectrum 
    12689subplot(1,2,2); 
    127 h1=plot(freqs,EMEPfreq,'b'); 
     90h3=plot(freqs,IMLMfreq,'r'); 
    12891hold on 
    129 h2=plot(freqs,EMEPfreqUP,'b--'); 
    130 plot(freqs,EMEPfreqLOW,'b--'); 
    131 h3=plot(freqs,IMLMfreq,'r'); 
    13292h4=plot(freqs,IMLMfreqUP,'r--'); 
    13393plot(freqs,IMLMfreqLOW,'r--'); 
    134 h5=plot(nortekfreqs,nortekfreq,'k'); 
    135 legend('EMEP','EMEP 95% confidence','IMLM','IMLM 95% confidence','nortek quickwave','location','best'); 
     94legend('EMEP','EMEP 95% confidence'); 
    13695title('directional wave spectrum integrated over direction'); 
    13796xlabel('frequency in Hz'); 
     
    14099% ______Calculate and display the wave parameters SigH, Tp, Dp,DTp_______ 
    141100 
    142 %For EMEP AST and radial velocities 
    143  
    144 %calculate the 0,1,2 moments 
    145 m0=sum(EMEPfreq*freqres);                               
    146 m1=sum(freqs.*EMEPfreq*freqres); 
    147 m2=sum((freqs.^2).*EMEPfreq*freqres); 
    148 % Calculate the Sig wave height 
    149 EMEP_Hsig=4*sqrt(m0); 
    150 %Use the function HsigConf.m to calculate the sigH confidence limits 
    151 EMEP_HsConf=nortek_HsigConf(EMEP); 
    152  
    153 % Calculate the peak period Tp 
    154 [P,I]=max(EMEPfreq); 
    155 EMEP_Tp=1/(freqs(I)); 
    156  
    157 %Calculate the Direction of the peak period DTp 
    158 [P,I]=max(real(EMEP.S(I,:))); 
    159 EMEP_DTp=dirs(I); 
    160  
    161 %Calculate the Dominant Direction Dp 
    162 [P,I]=max(EMEPdir); 
    163 EMEP_Dp=dirs(I); 
    164  
    165 %Display on the screen the SigH,Tp,Dp,DTp 
    166 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); 
    179101 
    180102 
     
    203125 
    204126%Display on the screen the SigH,Tp,Dp,DTp 
    205 disp(['IMLM']); 
     127disp(['EMEP']); 
    206128disp(['SigH (meters): ' num2str(IMLM_Hsig)]); 
    207129disp(['SigH 95% conf. (meters): ' num2str(IMLM_HsConf)]); 
     
    219141 
    220142 
    221 %for nortek generated spectrum 
    222  
    223 %calculate the 0,1,2 moments 
    224 m0=sum(nortekfreq*freqres);                               
    225 m1=sum(nortekfreqs.*nortekfreq*freqres); 
    226 m2=sum((nortekfreqs.^2).*nortekfreq*freqres); 
    227 % Calculate the Sig wave height 
    228 nortek_Hsig=4*sqrt(m0); 
    229  
    230 % Calculate the peak period Tp 
    231 [P,I]=max(nortekfreq); 
    232 nortek_Tp=1/(nortekfreqs(I)); 
    233  
    234 %Calculate the Direction of the peak period DTp 
    235 [P,I]=max(real(nortek.S(I,:))); 
    236 nortek_DTp=nortekdirs(I); 
    237  
    238 %Calculate the Dominant Direction Dp 
    239 [P,I]=max(nortekdir); 
    240 nortek_Dp=nortekdirs(I); 
    241  
    242 %Display on the screen the SigH,Tp,Dp,DTp 
    243 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  
    257143 
    258144%function to change from axis angles to compass bearings