-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgsw_Nsquared_lowerlimit.m
100 lines (88 loc) · 3.18 KB
/
gsw_Nsquared_lowerlimit.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
function Nsquared_lowerlimit = gsw_Nsquared_lowerlimit(p,long,lat)
% gsw_Nsquared_lowerlimit specified profile of minimum buoyancy
% frequency squared
%==========================================================================
%
% USAGE:
% Nsquared_lowerlimit = gsw_Nsquared_lowerlimit(p,long,lat)
%
% DESCRIPTION:
% Calculates the minimum Nsquared such that a cast is stable.
%
% INPUT:
% 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 ]
%
% lat & long may have dimensions 1x1 or Mx1 or 1xN or MxN, where p is MxN.
%
% OUTPUT:
% Nsquared_lowerlimit = Minimum Brunt-Vaisala Frequency squared [ 1/s^2 ]
%
% AUTHOR:
% Paul Barker and Trevor McDougall [ help@teos-10.org ]
%
% VERSION NUMBER: 3.05.5 (3rd June, 2016)
%
% 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
% See Eqn. (2.18.3) of this TEOS-10 manual.
%
% The software is available from http://www.TEOS-10.org
%
%==========================================================================
%--------------------------------------------------------------------------
% Check variables
%--------------------------------------------------------------------------
if ~(nargin == 3)
error('gsw_Nsquared_lowerlimit: Requires three inputs')
end
[mp,np] = size(p);
[mla,nla] = size(lat);
if (mla == 1) & (nla == 1)
lat = lat*ones(mp,np);
elseif (np == nla) & (mla == 1)
lat = lat(ones(1,mp), :);
elseif (mp == mla) & (nla == 1)
lat = lat(:,ones(1,np));
elseif (np == mla) & (nla == 1)
lat = lat.';
lat = lat(ones(1,mp), :);
elseif (mp == nla) & (mla == 1)
lat = lat.';
lat = lat(:,ones(1,np));
elseif (mp == mla) & (np == nla)
% ok
else
error('gsw_Nsquared_lowerlimit: Inputs array dimensions arguments do not agree')
end
[mlo,nlo] = size(long);
long(long < 0) = long(long < 0) + 360;
if (mlo == 1) & (nlo == 1)
long = long*ones(mp,np);
elseif (np == nlo) & (mlo == 1)
long = long(ones(1,mp), :);
elseif (mp == mlo) & (nlo == 1)
long = long(:,ones(1,np));
elseif (np == mlo) & (nlo == 1)
long = long.';
long = long(ones(1,mp), :);
elseif (mp == nlo) & (mlo == 1)
long = long.';
long = long(:,ones(1,np));
elseif (mp == mlo) & (np == nlo)
% ok
else
error('gsw_Nsquared_lowerlimit: Inputs array dimensions arguments do not agree')
end
p(p < -1.5) = NaN;
%--------------------------------------------------------------------------
% Start of the calculation
%--------------------------------------------------------------------------
Nsquared_lowerlimit = (0.25 + 0.75*(exp(-p./1000))) * 1e-7;
end