-
Notifications
You must be signed in to change notification settings - Fork 0
/
gsw_N2sol.m
executable file
·161 lines (141 loc) · 5.86 KB
/
gsw_N2sol.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
function N2sol = gsw_N2sol(SA,CT,p,long,lat)
% gsw_N2sol solubility of N2 in seawater
%==========================================================================
%
% USAGE:
% N2sol = gsw_N2sol(SA,CT,p,long,lat)
%
% DESCRIPTION:
% Calculates the nitrogen, N2, concentration expected at equilibrium with
% air at an Absolute Pressure of 101325 Pa (sea pressure of 0 dbar)
% including saturated water vapor. This function uses the solubility
% coefficients as listed in Hamme and Emerson (2004).
%
% Note that this algorithm has not been approved by IOC and is not work
% from SCOR/IAPSO Working Group 127. It is included in the GSW
% Oceanographic Toolbox as it seems to be oceanographic best practice.
%
% INPUT:
% SA = Absolute Salinity [ g/kg ]
% CT = Conservative Temperature (ITS-90) [ deg C ]
% p = sea pressure [ dbar ]
% ( i.e. absolute pressure - 10.1325 dbar )
% long = longitude in decimal degrees [ 0 ... +360 ]
% or [ -180 ... +180 ]
% lat = latitude in decimal degrees north [ -90 ... +90 ]
%
% SA & CT need to have the same dimensions. p, lat and long may have
% dimensions 1x1 or Mx1 or 1xN or MxN, where SA and CT are MxN.
%
% OUTPUT:
% N2sol = solubility of nitrogen in micro-moles per kg [ umol/kg ]
%
% AUTHOR: Roberta Hamme, Paul Barker and Trevor McDougall
% [ [email protected] ]
%
% VERSION NUMBER: 3.05 (27th January 2015)
%
% REFERENCES:
% IOC, SCOR and IAPSO, 2010: The international thermodynamic equation of
% seawater - 2010: Calculation and use of thermodynamic properties.
% Intergovernmental Oceanographic Commission, Manuals and Guides No. 56,
% UNESCO (English), 196 pp. Available from http://www.TEOS-10.org
%
% Hamme, R., and S. Emerson, 2004: The solubility of neon, nitrogen and
% argon in distilled water and seawater. Deep-Sea Research, 51,
% 1517-1528.
%
% The software is available from http://www.TEOS-10.org
%
%==========================================================================
%--------------------------------------------------------------------------
% Check variables and resize if necessary
%--------------------------------------------------------------------------
if nargin ~= 5
error('gsw_N2sol: Requires five inputs')
end %if
[ms,ns] = size(SA);
[mt,nt] = size(CT);
[mp,np] = size(p);
if (mt ~= ms | nt ~= ns)
error('gsw_N2sol: SA and pt must have same dimensions')
end
if (mp == 1) & (np == 1) % p scalar - fill to size of SA
p = p*ones(ms,ns);
elseif (ns == np) & (mp == 1) % p is row vector,
p = p(ones(1,ms), :); % copy down each column.
elseif (ms == mp) & (np == 1) % p is column vector,
p = p(:,ones(1,ns)); % copy across each row.
elseif (ns == mp) & (np == 1) % p is a transposed row vector,
p = p.'; % transpose, then
p = p(ones(1,ms), :); % copy down each column.
elseif (ms == mp) & (ns == np)
% ok
else
error('gsw_N2sol: Inputs array dimensions arguments do not agree')
end %if
[mla,nla] = size(lat);
if (mla == 1) & (nla == 1) % lat is a scalar - fill to size of SA
lat = lat*ones(ms,ns);
elseif (ns == nla) & (mla == 1) % lat is a row vector,
lat = lat(ones(1,ms), :); % copy down each column.
elseif (ms == mla) & (nla == 1) % lat is a column vector,
lat = lat(:,ones(1,ns)); % copy across each row.
elseif (ns == mla) & (nla == 1) % lat is a transposed row vector,
lat = lat.'; % transpose, then
lat = lat(ones(1,ms), :); % copy down each column.
elseif (ms == mla) & (ns == nla)
% ok
else
error('gsw_N2sol: Inputs array dimensions arguments do not agree')
end %if
[mlo,nlo] = size(long);
long(long < 0) = long(long < 0) + 360;
if (mlo == 1) & (nlo == 1) % long is a scalar - fill to size of SA
long = long*ones(ms,ns);
elseif (ns == nlo) & (mlo == 1) % long is a row vector,
long = long(ones(1,ms), :); % copy down each column.
elseif (ms == mlo) & (nlo == 1) % long is a column vector,
long = long(:,ones(1,ns)); % copy across each row.
elseif (ns == mlo) & (nlo == 1) % long is a transposed row vector,
long = long.'; % transpose, then
long = long(ones(1,ms), :); % copy down each column.
elseif (ms == mlo) & (ns == nlo)
% ok
else
error('gsw_N2sol: Inputs array dimensions arguments do not agree')
end %if
if ms == 1
SA = SA.';
CT = CT.';
p = p.';
lat = lat.';
long = long.';
transposed = 1;
else
transposed = 0;
end
%--------------------------------------------------------------------------
% Start of the calculation
%--------------------------------------------------------------------------
SP = gsw_SP_from_SA(SA,p,long,lat);
x = SP; % Note that salinity argument is Practical Salinity, this is
% beacuse the major ionic components of seawater related to Cl
% are what affect the solubility of non-electrolytes in seawater.
pt = gsw_pt_from_CT(SA,CT); % pt is potential temperature referenced to
% the sea surface.
y = log((298.15 - pt)./(gsw_T0 + pt)); % pt is the temperature in degress C
% on the 1990 International Temperature Scale ITS-90.
% The coefficents below are from Table 4 of Hamme and Emerson (2004)
a0 = 6.42931;
a1 = 2.92704;
a2 = 4.32531;
a3 = 4.69149;
b0 = -7.44129e-3;
b1 = -8.02566e-3;
b2 = -1.46775e-2;
N2sol = exp(a0 + y.*(a1 + y.*(a2 + a3*y)) + x.*(b0 + y.*(b1 + b2*y)));
if transposed
N2sol = N2sol.';
end
end