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

root/adcp/trunk/adcp/diwasp_1_1GD/infospec.m

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

Adding diwasp customizations.

Line 
1 function [H,Tp,DTp,Dp]=infospec(SM)
2
3 %DIWASP V1.1 function
4 %infospec: calculates and displays information about a directional spectrum
5 %
6 %[Hsig,Tp,DTp,Dp]=infospec(SM)
7 %
8 %Outputs:
9 %Hsig           Signficant wave height (Hmo)
10 %Tp                     Peak period
11 %DTp            Direction of spectral peak
12 %Dp                     Dominant direction
13 %
14 %Inputs:
15 %SM             A spectral matrix structure containing the file data
16 %
17 %Hsig is the significant wave height. Tp is the peak frequency, the highest point in the one dimensional spectrum.
18 %DTp is the main direction of the peak period (i.e the highest point in the two-dimensional directional spectrum).
19 %Dp is the dominant direction defined as the direction with the highest energy integrated over all frequencies.
20 %
21 %"help data_structures" for information on the DIWASP data structures
22
23 %Copyright (C) 2002 Coastal Oceanography Group, CWR, UWA, Perth
24
25 SM=check_data(SM,2);if isempty(SM) return;end;
26
27 H=HSig(SM);
28
29 S=sum(real(SM.S),2); % S is freq spectrum
30
31 [P,I]=max(S);
32 Tp=1/(SM.freqs(I));
33 [P,I]=max(real(SM.S(I,:)));
34 DTp=SM.dirs(I);
35 [P,I]=max(real(sum(SM.S,1)));
36 Dp=SM.dirs(I);
37
38 disp(['Infospec::']);
39 disp(['Significant wave height (Hmo): ' num2str(H)]);
40 disp(['Peak period: ' num2str(Tp)]);
41 disp(['Direction of peak period: ' num2str(DTp) ' axis angle / ' num2str(compangle(DTp,SM.xaxisdir)) ' compass bearing']);
42 disp(['Dominant direction: ' num2str(Dp) ' axis angle / ' num2str(compangle(Dp,SM.xaxisdir)) ' compass bearing']);
43
44
45 function dirs=compangle(dirs,xaxisdir)
46 dirs=xaxisdir*ones(size(dirs))-dirs;
47 dirs=dirs+360*(dirs<0);
48 dirs=dirs-360*(dirs>360);
Note: See TracBrowser for help on using the browser.