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

root/gliderproc/trunk/MATLAB/opnml/basics/tellipse_params.m

Revision 495 (checked in by cbc, 12 years ago)

Initial import of Stark code.

Line 
1 function  [UMAJOR,UMINOR,PHASE,ORIEN]=tellipse_params(u,phi_u,v,phi_v)
2 %TELLIPSE_PARAMS compute ellipse parameters from amp/phase specification
3 %
4 %  TELLIPSE_PARAMS requires the following arguments:
5 %      ua   - east (u) component amplitudes       
6 %      up   - east (u) component phases (degrees)       
7 %      va   - north (v) component amplitudes         
8 %      vp   - north (v) component phases (degrees)
9 %   
10 %  TELLIPSE_PARAMS outputs:
11 %      UMAJOR -
12 %      UMINOR -
13 %      PHASE  -
14 %      ORIEN  -
15 %
16 %  TELLIPSE_PARAMS expects the input phases to be in degrees and
17 %  attemps to determine the units of the phaselag by computing
18 %  the range of the phaselag columns in the input matrix.
19 %  If this range is within [0,2*pi], TELLIPSE_PARAMS reports this as
20 %  a potential problem.  It does NOT abort due to the possibility
21 %  of the phaselags correctly being in degrees and still having
22 %  a range within [0,2*pi].
23 %
24 % Call as: [UMAJOR,UMINOR,PHASE,ORIEN]=tellipse_params(ua,up,va,vp);
25 %
26 % Written by : Brian O. Blanton
27 %
28
29 % DEFINE ERROR STRINGS
30 err3=['Number of input arguments MUST be 4! Type "help tellipse_params"'];
31 err4=['Length of x,y,u,v,phi_u,phi_v must be the same'];
32 err7=['Particle excursion flag (arg 10) must be 0 or 1'];
33 warn1=str2mat([' Phases in input to TELLIPSE span'],...
34               [' less that 2*pi degrees and appear'],...
35               [' to be in radians.  If the resulting '],...
36               [' plot looks wierd, this may be the'],...
37               [' problem.']);
38
39 % Argument check
40 if nargin ~=4
41    error(err3);
42 end
43
44 % check input vector lengths
45 if length(u)~=length(v) | length(u)~=length(phi_u)| length(u)~=length(phi_v)
46    error(err4);
47 end
48
49
50 % convert input phases to radians
51 deg_to_rad=pi/180;
52 phi_u=phi_u*deg_to_rad;
53 phi_v=phi_v*deg_to_rad;
54
55
56 % COMPUTE TIDAL ELLIPSE PARAMETERS FROM AMP-PHASE INFORMATION
57 % NOTATION AS PER : Atlas of Tidal Elevation and Current
58 %                   Observations on the Northeast
59 %                   American Continental Shelf
60 %                   and Slope
61 %
62 %                   By: John A. Moody, Bradford Butman,
63 %                   Robert C. Beardsley, Wendell S. Brown,
64 %                   Peter Daifuku, James D. Irish,
65 %                   Dennis A Mayer, Harold O. Mofjeld,
66 %                   Brian Petrie, Steven Ramp, Peter Smith,
67 %                   and W. R. Wright
68
69 %                   U.S. Geological Survey Bulletin 1611
70 %
71 A1=u.*cos(phi_u);
72 B1=u.*sin(phi_u);
73 A2=v.*cos(phi_v);
74 B2=v.*sin(phi_v);
75 Uplus =0.5*sqrt((A1+B2).*(A1+B2)+(A2-B1).*(A2-B1));
76 Uminus=0.5*sqrt((A1-B2).*(A1-B2)+(A2+B1).*(A2+B1));
77
78 % Compute major and minor axis components
79 UMAJOR=Uplus+Uminus;
80 UMINOR=Uplus-Uminus;
81
82 % Compute phase; not needed at this time
83 numer= 2*(A1.*B1) + 2*(A2.*B2);
84 denom= A1.*A1 - B2.*B2 + A2.*A2 - B1.*B1;
85 PHASE=0.5*atan2(numer,denom);
86
87 % Compute orientation
88 numer= 2*(A1.*A2 + B1.*B2);
89 denom= A1.*A1 + B1.*B1 - (A2.*A2 + B2.*B2);
90 ORIEN=0.5*atan2(numer,denom);
91
92
93
94 %
95 %LabSig  Brian O. Blanton
96 %        Department in Marine Sciences
97 %        12-7 Venable Hall
98 %        CB# 3300
99 %        University of North Carolina
100 %        Chapel Hill, NC
101 %                 27599-3300
102 %
103 %        brian_blanton@unc.edu
104 %
Note: See TracBrowser for help on using the browser.