1 |
|
---|
2 |
function PT = sw_ptmp(S,T,P,PR) |
---|
3 |
|
---|
4 |
% SW_PTMP Potential temperature |
---|
5 |
%=========================================================================== |
---|
6 |
% SW_PTMP $Id: sw_ptmp.m,v 1.1 2003/12/12 04:23:22 pen078 Exp $ |
---|
7 |
% Copyright (C) CSIRO, Phil Morgan 1992. |
---|
8 |
% |
---|
9 |
% USAGE: ptmp = sw_ptmp(S,T,P,PR) |
---|
10 |
% |
---|
11 |
% DESCRIPTION: |
---|
12 |
% Calculates potential temperature as per UNESCO 1983 report. |
---|
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 |
% PR = Reference pressure [db] |
---|
19 |
% (P & PR may have dims 1x1, mx1, 1xn or mxn for S(mxn) ) |
---|
20 |
% |
---|
21 |
% OUTPUT: |
---|
22 |
% ptmp = Potential temperature relative to PR [degree C (ITS-90)] |
---|
23 |
% |
---|
24 |
% AUTHOR: Phil Morgan 92-04-06, Lindsay Pender (Lindsay.Pender@csiro.au) |
---|
25 |
% |
---|
26 |
% DISCLAIMER: |
---|
27 |
% This software is provided "as is" without warranty of any kind. |
---|
28 |
% See the file sw_copy.m for conditions of use and licence. |
---|
29 |
% |
---|
30 |
% REFERENCES: |
---|
31 |
% Fofonoff, P. and Millard, R.C. Jr |
---|
32 |
% Unesco 1983. Algorithms for computation of fundamental properties of |
---|
33 |
% seawater, 1983. _Unesco Tech. Pap. in Mar. Sci._, No. 44, 53 pp. |
---|
34 |
% Eqn.(31) p.39 |
---|
35 |
% |
---|
36 |
% Bryden, H. 1973. |
---|
37 |
% "New Polynomials for thermal expansion, adiabatic temperature gradient |
---|
38 |
% and potential temperature of sea water." |
---|
39 |
% DEEP-SEA RES., 1973, Vol20,401-408. |
---|
40 |
%========================================================================= |
---|
41 |
|
---|
42 |
% Modifications |
---|
43 |
% 99-06-25. Lindsay Pender, Fixed transpose of row vectors. |
---|
44 |
% 03-12-12. Lindsay Pender, Converted to ITS-90. |
---|
45 |
|
---|
46 |
% CALLER: general purpose |
---|
47 |
% CALLEE: sw_adtg.m |
---|
48 |
|
---|
49 |
%------------- |
---|
50 |
% CHECK INPUTS |
---|
51 |
%------------- |
---|
52 |
if nargin ~= 4 |
---|
53 |
error('sw_ptmp.m: Must pass 4 parameters ') |
---|
54 |
end %if |
---|
55 |
|
---|
56 |
% CHECK S,T,P dimensions and verify consistent |
---|
57 |
[ms,ns] = size(S); |
---|
58 |
[mt,nt] = size(T); |
---|
59 |
[mp,np] = size(P); |
---|
60 |
|
---|
61 |
[mpr,npr] = size(PR); |
---|
62 |
|
---|
63 |
|
---|
64 |
% CHECK THAT S & T HAVE SAME SHAPE |
---|
65 |
if (ms~=mt) | (ns~=nt) |
---|
66 |
error('check_stp: S & T must have same dimensions') |
---|
67 |
end %if |
---|
68 |
|
---|
69 |
% CHECK OPTIONAL SHAPES FOR P |
---|
70 |
if mp==1 & np==1 % P is a scalar. Fill to size of S |
---|
71 |
P = P(1)*ones(ms,ns); |
---|
72 |
elseif np==ns & mp==1 % P is row vector with same cols as S |
---|
73 |
P = P( ones(1,ms), : ); % Copy down each column. |
---|
74 |
elseif mp==ms & np==1 % P is column vector |
---|
75 |
P = P( :, ones(1,ns) ); % Copy across each row |
---|
76 |
elseif mp==ms & np==ns % PR is a matrix size(S) |
---|
77 |
% shape ok |
---|
78 |
else |
---|
79 |
error('check_stp: P has wrong dimensions') |
---|
80 |
end %if |
---|
81 |
[mp,np] = size(P); |
---|
82 |
|
---|
83 |
|
---|
84 |
% CHECK OPTIONAL SHAPES FOR PR |
---|
85 |
if mpr==1 & npr==1 % PR is a scalar. Fill to size of S |
---|
86 |
PR = PR(1)*ones(ms,ns); |
---|
87 |
elseif npr==ns & mpr==1 % PR is row vector with same cols as S |
---|
88 |
PR = PR( ones(1,ms), : ); % Copy down each column. |
---|
89 |
elseif mpr==ms & npr==1 % P is column vector |
---|
90 |
PR = PR( :, ones(1,ns) ); % Copy across each row |
---|
91 |
elseif mpr==ms & npr==ns % PR is a matrix size(S) |
---|
92 |
% shape ok |
---|
93 |
else |
---|
94 |
error('check_stp: PR has wrong dimensions') |
---|
95 |
end %if |
---|
96 |
|
---|
97 |
%***check_stp |
---|
98 |
|
---|
99 |
%------ |
---|
100 |
% BEGIN |
---|
101 |
%------ |
---|
102 |
|
---|
103 |
% theta1 |
---|
104 |
del_P = PR - P; |
---|
105 |
del_th = del_P.*sw_adtg(S,T,P); |
---|
106 |
th = T * 1.00024 + 0.5*del_th; |
---|
107 |
q = del_th; |
---|
108 |
|
---|
109 |
% theta2 |
---|
110 |
del_th = del_P.*sw_adtg(S,th/1.00024,P+0.5*del_P); |
---|
111 |
th = th + (1 - 1/sqrt(2))*(del_th - q); |
---|
112 |
q = (2-sqrt(2))*del_th + (-2+3/sqrt(2))*q; |
---|
113 |
|
---|
114 |
% theta3 |
---|
115 |
del_th = del_P.*sw_adtg(S,th/1.00024,P+0.5*del_P); |
---|
116 |
th = th + (1 + 1/sqrt(2))*(del_th - q); |
---|
117 |
q = (2 + sqrt(2))*del_th + (-2-3/sqrt(2))*q; |
---|
118 |
|
---|
119 |
% theta4 |
---|
120 |
del_th = del_P.*sw_adtg(S,th/1.00024,P+del_P); |
---|
121 |
PT = (th + (del_th - 2*q)/6)/1.00024; |
---|
122 |
return |
---|
123 |
%========================================================================= |
---|
124 |
|
---|