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

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

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

Initial import of Stark code.

Line 
1
2 function [AONB]= aonb(S, T, P, keyword)
3
4 % SW_AONB    Calculate alpha/beta (a on b)
5 %================================================================
6 % SW_AONB   $Revision: 1.1 $   $Date: 2003/12/12 04:23:22 $
7 %           Copyright (C) CSIRO, Nathan Bindoff 1993
8 %
9 % USAGE: [AONB] = aonb(S, T, P, {keyword} )
10 %
11 %        [AONB] = aonb(S, T,    P, 'temp' )      %default
12 %        [AONB] = aonb(S, PTMP, P, 'ptmp' )
13 %
14 % DESCRIPTION
15 %    Calculate alpha/beta.  See sw_alpha.m and sw_beta.m
16 %
17 % INPUT:  (all must have same dimensions)
18 %   S       = salinity              [psu      (PSS-78) ]
19 % * PTMP    = potential temperature [degree C (ITS-90)]
20 % * T       = temperature           [degree C (ITS-90)]
21 %   P       = pressure              [db]
22 %             (P may have dims 1x1, mx1, 1xn or mxn for S(mxn) )
23 %
24 %   keyword = optional string to identify if temp or ptmp passed.
25 %           = No argument defaults to 'temp'
26 %           = 'temp' assumes (S,T,P) passed.    Will execute slower
27 %                    as ptmp will be calculated internally.
28 %           = 'ptmp' assumes (S,PTMP,P) passed. Will execute faster.
29 %
30 % OUTPUT
31 %   AONB  = alpha/beta [psu/degree_C]
32 %
33 % AUTHOR:   N.L. Bindoff  1993, Lindsay Pender (Lindsay.Pender@csiro.au)
34 %
35 % DISCLAIMER:
36 %   This software is provided "as is" without warranty of any kind.
37 %   See the file sw_copy.m for conditions of use and licence.
38 %
39 % REFERENCE:
40 %    McDougall, T.J. 1987. "Neutral Surfaces"
41 %    Journal of Physical Oceanography vol 17 pages 1950-1964,
42 %
43 % CHECK VALUE:
44 %    aonb=0.34763 psu C^-1 at S=40.0 psu, ptmp=10.0 C, p=4000 db
45 %================================================================
46
47 % Modifications
48 % 93-04-22. Phil Morgan,  Help display modified to suit library
49 % 93-04-23. Phil Morgan,  Input argument checking
50 % 94-10-15. Phil Morgan,  Pass S,T,P and keyword for 'ptmp'
51 % 99-06-25. Lindsay Pender, Fixed transpose of row vectors.
52 % 03-12-12. Lindsay Pender, Converted to ITS-90.
53
54 % CHECK INPUT ARGUMENTS
55 if ~(nargin==3 | nargin==4)
56   error('sw_aonb.m: requires 3 input arguments')
57 end %if
58 if nargin == 3
59   keyword = 'temp';
60 end %if
61
62 % CHECK S,T,P dimensions and verify consistent
63 [ms,ns] = size(S);
64 [mt,nt] = size(T);
65 [mp,np] = size(P);
66
67
68 % CHECK THAT S & T HAVE SAME SHAPE
69 if (ms~=mt) | (ns~=nt)
70    error('check_stp: S & T must have same dimensions')
71 end %if
72
73 % CHECK OPTIONAL SHAPES FOR P
74 if     mp==1  & np==1      % P is a scalar.  Fill to size of S
75    P = P(1)*ones(ms,ns);
76 elseif np==ns & mp==1      % P is row vector with same cols as S
77    P = P( ones(1,ms), : ); %   Copy down each column.
78 elseif mp==ms & np==1      % P is column vector
79    P = P( :, ones(1,ns) ); %   Copy across each row
80 elseif mp==ms & np==ns     % PR is a matrix size(S)
81    % shape ok
82 else
83    error('check_stp: P has wrong dimensions')
84 end %if
85
86 %***check_stp
87
88 % ENSURE WE USE PTMP IN CALCULATIONS
89 if ~strcmp(lower(keyword),'ptmp')
90   T = sw_ptmp(S,T,P,0); % now have ptmp
91 end %if
92
93 T = T * 1.00024;
94
95 % BEGIN
96      c1=fliplr([ 0.665157e-1, 0.170907e-1, ...
97         -0.203814e-3, 0.298357e-5, ...
98             -0.255019e-7]);
99          c2=fliplr([ 0.378110e-2, ...
100             -0.846960e-4]);
101          c2a=fliplr([0.0 -0.164759e-6, ...
102             -0.251520e-11]);
103          c3=[-0.678662e-5];
104          c4=fliplr([+0.380374e-4, -0.933746e-6, ...
105             +0.791325e-8]);
106          c5=[0.512857e-12];
107          c6=[-0.302285e-13];
108 %
109 % Now calaculate the thermal expansion saline contraction ratio adb
110 %
111         [m,n] = size(S);
112         sm35  = S-35.0*ones(m,n);
113         AONB  = polyval(c1,T) + sm35.*(polyval(c2,T)...
114                + polyval(c2a,P)) ...
115                + sm35.^2*c3 + P.*polyval(c4,T) ...
116                + c5*(P.^2).*(T.^2) + c6*P.^3;
117
118 return
119 %----------------------------------------------------------------------
120
121
Note: See TracBrowser for help on using the browser.