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

root/gliderproc/trunk/MATLAB/seawater/sw_dpth.m

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

Initial import of Stark code.

Line 
1
2 function DEPTHM = sw_dpth(P,LAT)
3
4 % SW_DPTH    Depth from pressure
5 %===========================================================================
6 % SW_DPTH   $Id: sw_dpth.m,v 1.1 2003/12/12 04:23:22 pen078 Exp $
7 %           Copyright (C) CSIRO, Phil Morgan 1992.
8 %
9 % USAGE:  dpth = sw_dpth(P,LAT)
10 %
11 % DESCRIPTION:
12 %    Calculates depth in metres from pressure in dbars.
13 %
14 % INPUT:  (all must have same dimensions)
15 %   P   = Pressure    [db]
16 %   LAT = Latitude in decimal degress north [-90..+90]
17 %         (lat may have dimensions 1x1 or 1xn where P(mxn).
18 %
19 % OUTPUT:
20 %  dpth = depth [metres]
21 %
22 % AUTHOR:  Phil Morgan 92-04-06  (morgan@ml.csiro.au)
23 %
24 % DISCLAIMER:
25 %   This software is provided "as is" without warranty of any kind.
26 %   See the file sw_copy.m for conditions of use and licence.
27 %
28 % REFERENCES:
29 %    Unesco 1983. Algorithms for computation of fundamental properties of
30 %    seawater, 1983. _Unesco Tech. Pap. in Mar. Sci._, No. 44, 53 pp.
31 %=========================================================================
32
33 % Modifications
34 % 99-06-25. Lindsay Pender, Fixed transpose of row vectors.
35
36 % CALLER:  general purpose
37 % CALLEE:  none
38
39 %-------------
40 % CHECK INPUTS
41 %-------------
42 [mP,nP] = size(P);
43 [mL,nL] = size(LAT);
44 if mL==1 & nL==1                    % LAT scalar - fill to size of P
45   LAT = LAT*ones(size(P));
46
47 elseif nP == nL & mL == 1           % LAT is row vector
48   LAT = LAT(ones(1, mP), :);        % Coppy down each column
49
50 elseif mP == mL & nL == 1           % LAT is column vector
51   LAT = LAT(:, ones(1, nP));        % Copy across each row
52
53 elseif mP == mL & nP == nL
54   % Ok
55
56 else
57    error('sw_depth.m:  Inputs arguments have wrong dimensions')
58 end %if
59
60 %-------------
61 % BEGIN
62 %-------------
63 % Eqn 25, p26.  Unesco 1983.
64
65 DEG2RAD = pi/180;
66 c1 = +9.72659;
67 c2 = -2.2512E-5;
68 c3 = +2.279E-10;
69 c4 = -1.82E-15;
70 gam_dash = 2.184e-6;
71
72 LAT = abs(LAT);
73 X   = sin(LAT*DEG2RAD);  % convert to radians
74 X   = X.*X;
75 bot_line = 9.780318*(1.0+(5.2788E-3+2.36E-5*X).*X) + gam_dash*0.5*P;
76 top_line = (((c4*P+c3).*P+c2).*P+c1).*P;
77 DEPTHM   = top_line./bot_line;
78 return
79 %===========================================================================
80 %
81
Note: See TracBrowser for help on using the browser.