-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved computation efficiency. Minor bug fixes.
- Loading branch information
1 parent
d276f56
commit 259e142
Showing
192 changed files
with
2,106 additions
and
1,704 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
% AUTHOR: | ||
% Trevor McDougall and Paul Barker [ [email protected] ] | ||
% | ||
% VERSION NUMBER: 3.01 (29th March, 2011) | ||
% VERSION NUMBER: 3.02 (13th November, 2012) | ||
% | ||
% REFERENCES: | ||
% IOC, SCOR and IAPSO, 2010: The international thermodynamic equation of | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
% AUTHOR: | ||
% Trevor McDougall and Paul Barker [ [email protected] ] | ||
% | ||
% VERSION NUMBER: 3.01 (29th March, 2011) | ||
% VERSION NUMBER: 3.02 (13th November, 2012) | ||
% | ||
% REFERENCES: | ||
% Culkin and Smith, 1980: Determination of the Concentration of Potassium | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ | |
% AUTHOR: | ||
% Trevor McDougall and Paul Barker [ [email protected] ] | ||
% | ||
% VERSION NUMBER: 3.01 (11th April 2011) | ||
% VERSION NUMBER: 3.02 (15th November, 2012) | ||
% | ||
% REFERENCES: | ||
% IOC, SCOR and IAPSO, 2010: The international thermodynamic equation of | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ | |
% AUTHOR: | ||
% Trevor McDougall, Paul Barker and Rainer Feistal [ [email protected] ] | ||
% | ||
% VERSION NUMBER: 3.01 (4th November, 2011) | ||
% VERSION NUMBER: 3.02 (13th November, 2012) | ||
% | ||
% REFERENCES: | ||
% IOC, SCOR and IAPSO, 2010: The international thermodynamic equation of | ||
|
@@ -108,8 +108,7 @@ | |
%-------------------------------------------------------------------------- | ||
|
||
% These few lines ensure that SA is non-negative. | ||
[I_neg_SA] = find(SA < 0); | ||
if ~isempty(I_neg_SA) | ||
if any(SA < 0) | ||
error(' gsw_CT_freezing: SA must be non-negative!') | ||
end | ||
|
||
|
@@ -164,11 +163,9 @@ | |
CT_freezing = CT_freezing ... | ||
- saturation_fraction.*(1e-3).*(2.4 - a.*SA).*(1 + b.*(1 - SA./35.16504)); | ||
|
||
[Iout_of_range] = find(p > 10000 | SA > 120 | ... | ||
p + SA.*71.428571428571402 > 13571.42857142857); | ||
if ~isempty(Iout_of_range) | ||
CT_freezing(Iout_of_range) = NaN; | ||
end | ||
% set any values that are out of range to be NaN. | ||
CT_freezing(p > 10000 | SA > 120 | ... | ||
p + SA.*71.428571428571402 > 13571.42857142857) = NaN; | ||
|
||
if transposed | ||
CT_freezing = CT_freezing.'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
% AUTHOR: | ||
% Trevor McDougall and Paul Barker. [ [email protected] ] | ||
% | ||
% VERSION NUMBER: 3.01 (3rd March, 2011) | ||
% VERSION NUMBER: 3.02 (13th November, 2012) | ||
% | ||
% REFERENCES: | ||
% IOC, SCOR and IAPSO, 2010: The international thermodynamic equation of | ||
|
@@ -62,11 +62,8 @@ | |
% Start of the calculation | ||
%-------------------------------------------------------------------------- | ||
|
||
% These few lines ensure that SA is non-negative. | ||
[I_neg_SA] = find(SA < 0); | ||
if ~isempty(I_neg_SA) | ||
SA(I_neg_SA) = 0; | ||
end | ||
% This line ensures that SA is non-negative. | ||
SA(SA < 0) = 0; | ||
|
||
pt = gsw_pt_from_entropy(SA,entropy); | ||
CT = gsw_CT_from_pt(SA,pt); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,8 +22,7 @@ | |
% AUTHOR: | ||
% David Jackett, Trevor McDougall and Paul Barker [ [email protected] ] | ||
% | ||
% VERSION NUMBER: 3.01 (29th March, 2011) | ||
% This function is unchanged from version 2.0 (24th September, 2010). | ||
% VERSION NUMBER: 3.02 (13th November, 2012) | ||
% | ||
% REFERENCES: | ||
% IOC, SCOR and IAPSO, 2010: The international thermodynamic equation of | ||
|
@@ -63,11 +62,8 @@ | |
% Start of the calculation | ||
%-------------------------------------------------------------------------- | ||
|
||
% These few lines ensure that SA is non-negative. | ||
[I_neg_SA] = find(SA < 0); | ||
if ~isempty(I_neg_SA) | ||
SA(I_neg_SA) = 0; | ||
end | ||
% This line ensures that SA is non-negative. | ||
SA(SA < 0) = 0; | ||
|
||
cp0 = 3991.86795711963; % defined in Eqn. (3.3.3) of IOC et al. (2010). | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,18 +43,18 @@ | |
% AUTHOR: | ||
% Trevor McDougall & Paul Barker [ [email protected] ] | ||
% | ||
% VERSION NUMBER: 3.01 (21th April, 2011) | ||
% VERSION NUMBER: 3.02 (15th November, 2012) | ||
% | ||
% 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 | ||
% | ||
% McDougall T.J., P.M. Barker, R. Feistel and D.R. Jackett, 2011: A | ||
% McDougall T.J., P.M. Barker, R. Feistel and D.R. Jackett, 2013: A | ||
% computationally efficient 48-term expression for the density of | ||
% seawater in terms of Conservative Temperature, and related properties | ||
% of seawater. To be submitted to Ocean Science Discussions. | ||
% of seawater. To be submitted to J. Atm. Ocean. Technol., xx, yyy-zzz. | ||
% | ||
% The software is available from http://www.TEOS-10.org | ||
% | ||
|
@@ -115,40 +115,35 @@ | |
rec_half_rho_TT = -110.0; | ||
|
||
CT = nan(size(SA)); | ||
CT_multiple = nan(size(SA)); | ||
CT_multiple = CT; | ||
|
||
[I_SA_p] = find(SA<0 | SA>42 | p <-1.5 | p>12000); | ||
if ~isempty(I_SA_p) | ||
SA(I_SA_p) = NaN; | ||
end | ||
% SA out of range, set to NaN. | ||
SA(SA<0 | SA>42 | p <-1.5 | p>12000) = NaN; | ||
|
||
rho_40 = gsw_rho_CT(SA,40*ones(size(SA)),p); | ||
[I_rho_light] = find((rho - rho_40) < 0); | ||
if ~isempty(I_rho_light) | ||
SA(I_rho_light) = NaN; | ||
end | ||
% rho too light, set to NaN. | ||
SA((rho - rho_40) < 0) = NaN; | ||
|
||
CT_max_rho = gsw_CT_maxdensity(SA,p); | ||
rho_max = gsw_rho(SA,CT_max_rho,p); | ||
rho_extreme = rho_max; | ||
CT_freezing = gsw_CT_freezing(SA,p); % this assumes that the seawater is always saturated with air | ||
rho_freezing = gsw_rho(SA,CT_freezing,p); | ||
[I_fr_gr_max] = find((CT_freezing - CT_max_rho) > 0); | ||
rho_extreme(I_fr_gr_max) = rho_freezing(I_fr_gr_max); | ||
[I_rho_dense] = find(rho > rho_extreme); | ||
if ~isempty(I_rho_dense) | ||
SA(I_rho_dense) = NaN; | ||
end | ||
% reset the extreme values | ||
rho_extreme((CT_freezing - CT_max_rho) > 0) = rho_freezing((CT_freezing - CT_max_rho) > 0); | ||
|
||
[I_bad] = find(isnan(SA.*p.*rho)); | ||
if ~isempty (I_bad) | ||
% set SA values to NaN for the rho's that are too dense. | ||
SA(rho > rho_extreme) = NaN; | ||
|
||
if any(isnan(SA + p + rho)) | ||
[I_bad] = find(isnan(SA + p + rho)); | ||
SA(I_bad) = NaN; | ||
end | ||
|
||
alpha_freezing = gsw_alpha(SA,CT_freezing,p); | ||
[I_salty] = find(alpha_freezing > alpha_limit); | ||
|
||
if ~isempty(I_salty) | ||
if any(alpha_freezing > alpha_limit) | ||
[I_salty] = find(alpha_freezing > alpha_limit); | ||
CT_diff = 40*ones(size(I_salty)) - CT_freezing(I_salty); | ||
|
||
top = rho_40(I_salty) - rho_freezing(I_salty) ... | ||
|
@@ -162,20 +157,21 @@ | |
CT(I_salty) = CT_freezing(I_salty) + 0.5*(-b - sqrt_disc)./a; | ||
end | ||
|
||
[I_fresh] = find(alpha_freezing <= alpha_limit); | ||
if ~isempty(I_fresh) | ||
if any(alpha_freezing <= alpha_limit) | ||
[I_fresh] = find(alpha_freezing <= alpha_limit); | ||
|
||
CT_diff = 40*ones(size(I_fresh)) - CT_max_rho(I_fresh); | ||
factor = (rho_max(I_fresh) - rho(I_fresh))./ ... | ||
(rho_max(I_fresh) - rho_40(I_fresh)); | ||
delta_CT = CT_diff.*sqrt(factor); | ||
|
||
[I_fresh_NR] = find(delta_CT > 5); | ||
if ~isempty(I_fresh_NR) | ||
if any(delta_CT > 5) | ||
[I_fresh_NR] = find(delta_CT > 5); | ||
CT(I_fresh(I_fresh_NR)) = CT_max_rho(I_fresh(I_fresh_NR)) + delta_CT(I_fresh_NR); | ||
end | ||
|
||
[I_quad] = find(delta_CT <= 5); | ||
if ~isempty(I_quad) | ||
if any(delta_CT <= 5) | ||
[I_quad] = find(delta_CT <= 5); | ||
CT_a = nan(size(SA)); | ||
% set the initial value of the quadratic solution routes. | ||
CT_a(I_fresh(I_quad)) = CT_max_rho(I_fresh(I_quad)) + ... | ||
|
@@ -186,10 +182,8 @@ | |
factorqa = (rho_max - rho)./(rho_max - rho_old); | ||
CT_a = CT_max_rho + (CT_old - CT_max_rho).*sqrt(factorqa); | ||
end | ||
[Ifrozen] = find(CT_freezing - CT_a < 0); | ||
if ~isempty(Ifrozen) | ||
CT_a(Ifrozen) = NaN; | ||
end | ||
|
||
CT_a(CT_freezing - CT_a < 0) = NaN; | ||
|
||
CT_b = nan(size(SA)); | ||
% set the initial value of the quadratic solution roots. | ||
|
@@ -203,10 +197,7 @@ | |
end | ||
% After seven iterations of this quadratic iterative procedure, | ||
% the error in rho is no larger than 4.6x10^-13 kg/m^3. | ||
[Ifrozen] = find(CT_freezing - CT_b < 0); | ||
if ~isempty(Ifrozen) | ||
CT_b(Ifrozen) = NaN; | ||
end | ||
CT_b(CT_freezing - CT_b < 0) = NaN; | ||
end | ||
end | ||
|
||
|
@@ -226,16 +217,10 @@ | |
end | ||
|
||
if exist('t_a','var') | ||
[I_quad] = find(~isnan(CT_a)); | ||
if ~isempty(I_quad) | ||
CT(I_quad) = CT_a(I_quad); | ||
end | ||
CT(~isnan(CT_a)) = CT_a(~isnan(CT_a)); | ||
end | ||
if exist('t_b','var') | ||
[I_quad] = find(~isnan(CT_b)); | ||
if ~isempty(I_quad) | ||
CT_multiple(I_quad) = CT_b(I_quad); | ||
end | ||
CT_multiple(~isnan(CT_b)) = CT_b(~isnan(CT_b)); | ||
end | ||
% After three iterations of this modified Newton-Raphson iteration, | ||
% the error in rho is no larger than 1.6x10^-12 kg/m^3. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
function [CT,CT_multiple] = gsw_CT_from_rho_exact(rho,SA,p) | ||
|
||
% gsw_t_from_rho_exact in situ temperature from density | ||
% gsw_t_from_rho_exact in-situ temperature from density | ||
% ========================================================================= | ||
% | ||
% USAGE: | ||
|
@@ -34,7 +34,7 @@ | |
% AUTHOR: | ||
% Trevor McDougall & Paul Barker [ [email protected] ] | ||
% | ||
% VERSION NUMBER: 3.01 (21th April, 2011) | ||
% VERSION NUMBER: 3.02 (13th November, 2012) | ||
% | ||
% REFERENCES: | ||
% IOC, SCOR and IAPSO, 2010: The international thermodynamic equation of | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,8 +25,7 @@ | |
% AUTHOR: | ||
% David Jackett, Trevor McDougall and Paul Barker [ [email protected] ] | ||
% | ||
% VERSION NUMBER: 3.01 (27th March, 2011) | ||
% This function is unchanged from version 2.0 (24th September, 2010). | ||
% VERSION NUMBER: 3.02 (13th November, 2012) | ||
% | ||
% REFERENCES: | ||
% IOC, SCOR and IAPSO, 2010: The international thermodynamic equation of | ||
|
@@ -70,14 +69,9 @@ | |
error('gsw_CT_from_t: Inputs array dimensions arguments do not agree') | ||
end %if | ||
|
||
[Iout_of_range] = find(p < 100 & (t > 80 | t < -12)); | ||
if (~isempty(Iout_of_range)) | ||
t(Iout_of_range) = NaN; | ||
end | ||
[Iout_of_range] = find(p >= 100 & (t > 40 | t < -12)); | ||
if (~isempty(Iout_of_range)) | ||
t(Iout_of_range) = NaN; | ||
end | ||
%Find values that are out of range, set them to NaN. | ||
t(p < 100 & (t > 80 | t < -12)) = NaN; | ||
t(p >= 100 & (t > 40 | t < -12)) = NaN; | ||
|
||
if ms == 1 | ||
SA = SA.'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ | |
% AUTHOR: | ||
% Trevor McDougall & Paul Barker [ [email protected] ] | ||
% | ||
% VERSION NUMBER: 3.01 (3rd April, 2011) | ||
% VERSION NUMBER: 3.02 (15th November, 2012) | ||
% | ||
% REFERENCES: | ||
% IOC, SCOR and IAPSO, 2010: The international thermodynamic equation of | ||
|
Oops, something went wrong.