1 |
|
---|
2 |
function R = sw_cndr(S,T,P) |
---|
3 |
|
---|
4 |
% SW_CNDR Conductivity ratio R = C(S,T,P)/C(35,15(IPTS-68),0) |
---|
5 |
%========================================================================= |
---|
6 |
% SW_CNDR $Id: sw_cndr.m,v 1.1 2003/12/12 04:23:22 pen078 Exp $ |
---|
7 |
% Copyright (C) CSIRO, Phil Morgan 1993. |
---|
8 |
% |
---|
9 |
% USAGE: cndr = sw_cndr(S,T,P) |
---|
10 |
% |
---|
11 |
% DESCRIPTION: |
---|
12 |
% Calculates conductivity ratio from S,T,P. |
---|
13 |
% |
---|
14 |
% INPUT: (all must have same dimensions) |
---|
15 |
% S = salinity [psu (PSS-78) ] |
---|
16 |
% T = temperature [degree C (ITS-90)] |
---|
17 |
% P = pressure [db] |
---|
18 |
% (P may have dims 1x1, mx1, 1xn or mxn for S(mxn) ) |
---|
19 |
% |
---|
20 |
% OUTPUT: |
---|
21 |
% cndr = Conductivity ratio R = C(S,T,P)/C(35,15(IPTS-68),0) [no units] |
---|
22 |
% |
---|
23 |
% AUTHOR: Phil Morgan 93-04-21, Lindsay Pender (Lindsay.Pender@csiro.au) |
---|
24 |
% |
---|
25 |
% DISCLAIMER: |
---|
26 |
% This software is provided "as is" without warranty of any kind. |
---|
27 |
% See the file sw_copy.m for conditions of use and licence. |
---|
28 |
% |
---|
29 |
% REFERENCES: |
---|
30 |
% Fofonoff, P. and Millard, R.C. Jr |
---|
31 |
% Unesco 1983. Algorithms for computation of fundamental properties of |
---|
32 |
% seawater, 1983. _Unesco Tech. Pap. in Mar. Sci._, No. 44, 53 pp. |
---|
33 |
%========================================================================= |
---|
34 |
|
---|
35 |
% Modifications |
---|
36 |
% 99-06-25. Lindsay Pender, Fixed transpose of row vectors. |
---|
37 |
% 03-12-12. Lindsay Pender, Converted to ITS-90. |
---|
38 |
|
---|
39 |
% CALLER: general purpose |
---|
40 |
% CALLEE: sw_salds.m sw_sals.m sw_salrt.m |
---|
41 |
|
---|
42 |
%-------------- |
---|
43 |
% check inputs |
---|
44 |
%------------- |
---|
45 |
if nargin~=3 |
---|
46 |
error('sw_cndr.m: must have 3 input arguments') |
---|
47 |
end %if |
---|
48 |
|
---|
49 |
% CHECK S,T,P dimensions and verify consistent |
---|
50 |
[ms,ns] = size(S); |
---|
51 |
[mt,nt] = size(T); |
---|
52 |
[mp,np] = size(P); |
---|
53 |
|
---|
54 |
|
---|
55 |
% CHECK THAT S & T HAVE SAME SHAPE |
---|
56 |
if (ms~=mt) | (ns~=nt) |
---|
57 |
error('check_stp: S & T must have same dimensions') |
---|
58 |
end %if |
---|
59 |
|
---|
60 |
% CHECK OPTIONAL SHAPES FOR P |
---|
61 |
if mp==1 & np==1 % P is a scalar. Fill to size of S |
---|
62 |
P = P(1)*ones(ms,ns); |
---|
63 |
elseif np==ns & mp==1 % P is row vector with same cols as S |
---|
64 |
P = P( ones(1,ms), : ); % Copy down each column. |
---|
65 |
elseif mp==ms & np==1 % P is column vector |
---|
66 |
P = P( :, ones(1,ns) ); % Copy across each row |
---|
67 |
elseif mp==ms & np==ns % PR is a matrix size(S) |
---|
68 |
% shape ok |
---|
69 |
else |
---|
70 |
error('check_stp: P has wrong dimensions') |
---|
71 |
end %if |
---|
72 |
|
---|
73 |
%***check_stp |
---|
74 |
|
---|
75 |
%------- |
---|
76 |
% BEGIN |
---|
77 |
%------- |
---|
78 |
|
---|
79 |
T68 = T * 1.00024; |
---|
80 |
|
---|
81 |
for i = 1:ms |
---|
82 |
for j = 1:ns |
---|
83 |
%--------------------------------------------------------------------- |
---|
84 |
% DO A NEWTON-RAPHSON ITERATION FOR INVERSE INTERPOLATION OF Rt FROM S. |
---|
85 |
%--------------------------------------------------------------------- |
---|
86 |
S_loop = S(i,j); % S in the loop |
---|
87 |
T_loop = T(i,j); % T in the loop |
---|
88 |
Rx_loop = sqrt(S_loop/35.0); % first guess at Rx = sqrt(Rt) |
---|
89 |
SInc = sw_sals(Rx_loop.*Rx_loop,T_loop); % S INCrement (guess) from Rx |
---|
90 |
iloop = 0; |
---|
91 |
end_loop = 0; |
---|
92 |
while ~end_loop |
---|
93 |
Rx_loop = Rx_loop + (S_loop - SInc)./sw_salds(Rx_loop,T_loop - 15); |
---|
94 |
SInc = sw_sals(Rx_loop.*Rx_loop,T_loop); |
---|
95 |
iloop = iloop + 1; |
---|
96 |
dels = abs(SInc-S_loop); |
---|
97 |
if (dels>1.0e-4 & iloop<10) |
---|
98 |
end_loop = 0; |
---|
99 |
else |
---|
100 |
end_loop = 1; |
---|
101 |
end %if |
---|
102 |
end %while |
---|
103 |
|
---|
104 |
Rx(i,j) = Rx_loop; |
---|
105 |
|
---|
106 |
end %for j |
---|
107 |
end %for i |
---|
108 |
|
---|
109 |
%------------------------------------------------------ |
---|
110 |
% ONCE Rt FOUND, CORRESPONDING TO EACH (S,T) EVALUATE R |
---|
111 |
%------------------------------------------------------ |
---|
112 |
% eqn(4) p.8 Unesco 1983 |
---|
113 |
|
---|
114 |
d1 = 3.426e-2; |
---|
115 |
d2 = 4.464e-4; |
---|
116 |
d3 = 4.215e-1; |
---|
117 |
d4 = -3.107e-3; |
---|
118 |
|
---|
119 |
e1 = 2.070e-5; |
---|
120 |
e2 = -6.370e-10; |
---|
121 |
e3 = 3.989e-15; |
---|
122 |
|
---|
123 |
A = (d3 + d4.*T68); |
---|
124 |
B = 1 + d1.*T68 + d2.*T68.^2; |
---|
125 |
C = P.*(e1 + e2.*P + e3.*P.^2); |
---|
126 |
|
---|
127 |
% eqn(6) p.9 UNESCO 1983. |
---|
128 |
Rt = Rx.*Rx; |
---|
129 |
rt = sw_salrt(T); |
---|
130 |
Rtrt = rt.*Rt; |
---|
131 |
D = B - A.*rt.*Rt; |
---|
132 |
E = rt.*Rt.*A.*(B+C); |
---|
133 |
R = sqrt(abs(D.^2+4*E)) - D; |
---|
134 |
R = 0.5*R./A; |
---|
135 |
|
---|