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

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

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

Initial import of Stark code.

Line 
1
2 function pres = sw_pres(DEPTH,LAT)
3
4 % SW_PRES    Pressure from depth
5 %===========================================================================
6 % SW_PRES   $Id: sw_pres.m,v 1.1 2003/12/12 04:23:22 pen078 Exp $
7 %           Copyright (C) CSIRO, Phil Morgan 1993.
8 %
9 % USAGE:  pres = sw_pres(depth,lat)
10 %
11 % DESCRIPTION:
12 %    Calculates pressure in dbars from depth in meters.
13 %
14 % INPUT:  (all must have same dimensions)
15 %   depth = depth [metres]
16 %   lat   = Latitude in decimal degress north [-90..+90]
17 %           (LAT may have dimensions 1x1 or 1xn where depth(mxn) )
18 %
19 % OUTPUT:
20 %  pres   = Pressure    [db]
21 %
22 % AUTHOR:  Phil Morgan 93-06-25  (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 %    Saunders, P.M. 1981
30 %    "Practical conversion of Pressure to Depth"
31 %    Journal of Physical Oceanography, 11, 573-574
32 %
33 % CHECK VALUE:
34 %    P=7500.00 db for LAT=30 deg, depth=7321.45 meters
35 %=========================================================================
36
37 % Modifications
38 % 99-06-25. Lindsay Pender, Fixed transpose of row vectors.
39
40 % CALLER:  general purpose
41 % CALLEE:  none
42
43 %-------------
44 % CHECK INPUTS
45 %-------------
46 [mD,nD] = size(DEPTH);
47 [mL,nL] = size(LAT);
48 if mL==1 & nL==1                    % LAT scalar - fill to size of P
49   LAT = LAT*ones(size(DEPTH));
50
51 elseif nD == nL & mL == 1           % LAT is row vector
52   LAT = LAT(ones(1, mD), :);        % Coppy down each column
53
54 elseif mD == mL & nL == 1           % LAT is column vector
55   LAT = LAT(:, ones(1, nD));        % Copy across each row
56
57 elseif mD == mL & nD == nL
58   % Ok
59
60 else
61    error('sw_pres.m:  Inputs arguments have wrong dimensions')
62 end %if
63
64 %-------------
65 % BEGIN
66 %-------------
67
68 DEG2RAD = pi/180;
69 X       = sin(abs(LAT)*DEG2RAD);  % convert to radians
70 C1      = 5.92E-3+X.^2*5.25E-3;
71 pres    = ((1-C1)-sqrt(((1-C1).^2)-(8.84E-6*DEPTH)))/4.42E-6;
72 return
73 %===========================================================================
74
Note: See TracBrowser for help on using the browser.