1 |
|
---|
2 |
function [BETA] = sw_beta(S, T, P, keyword) |
---|
3 |
|
---|
4 |
% SW_BETA Saline contraction coefficient (beta) |
---|
5 |
%======================================================================== |
---|
6 |
% SW_BETA $Id: sw_beta.m,v 1.1 2003/12/12 04:23:22 pen078 Exp $ |
---|
7 |
% % Copyright (C) CSIRO, Nathan Bindoff 1993. |
---|
8 |
% |
---|
9 |
% USAGE: [BETA] = sw_beta(S, T, P, {keyword} ) |
---|
10 |
% |
---|
11 |
% [BETA] = sw_beta(S, T, P, 'temp') %default |
---|
12 |
% [BETA] = sw_beta(S, PTMP, P, 'ptmp') |
---|
13 |
% |
---|
14 |
% DESCRIPTION |
---|
15 |
% The saline contraction coefficient as defined by T.J. McDougall. |
---|
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 |
% BETA = Saline Contraction Coefficient [psu.^-1] |
---|
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 |
% beta=0.72088e-3 psu.^-1 at S=40.0 psu, ptmp = 10.0 C (ITS-68), 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_beta.m: requires 3 or 4 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 |
|
---|
97 |
c1=fliplr([ 0.785567e-3, -0.301985e-5 ... |
---|
98 |
0.555579e-7, -0.415613e-9]); |
---|
99 |
c2=fliplr([ -0.356603e-6, 0.788212e-8]); |
---|
100 |
c3=fliplr([0.0 0.408195e-10, -0.602281e-15]); |
---|
101 |
c4=[0.515032e-8]; |
---|
102 |
c5=fliplr([-0.121555e-7, 0.192867e-9, -0.213127e-11]); |
---|
103 |
c6=fliplr([0.176621e-12 -0.175379e-14]); |
---|
104 |
c7=[0.121551e-17]; |
---|
105 |
% |
---|
106 |
% Now calaculate the thermal expansion saline contraction ratio adb |
---|
107 |
% |
---|
108 |
[m,n] = size(S); |
---|
109 |
sm35 = S-35*ones(m,n); |
---|
110 |
BETA = polyval(c1,T) + sm35.*(polyval(c2,T) + ... |
---|
111 |
polyval(c3,P)) + c4*(sm35.^2) + ... |
---|
112 |
P.*polyval(c5,T) + (P.^2).*polyval(c6,T) ... |
---|
113 |
+c7*( P.^3); |
---|
114 |
|
---|
115 |
return |
---|
116 |
%------------------------------------------------------------------------ |
---|
117 |
|
---|