~ubuntu-branches/ubuntu/wily/gsw/wily-proposed

« back to all changes in this revision

Viewing changes to gsw/gibbs/density_enthalpy_48.py

  • Committer: Package Import Robot
  • Author(s): Alastair McKinstry
  • Date: 2013-07-18 07:26:49 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130718072649-s2yct1q8we4z1w37
Tags: 3.0.2-1
* New upstream release. 
* Move to DH 9.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
import numpy as np
6
6
 
7
 
from library import specvol_SSO_0_p
8
 
from constants import P0, db2Pascal, cp0
 
7
from .library import specvol_SSO_0_p
 
8
from .constants import P0, db2Pascal, cp0
9
9
from gsw.utilities import match_args_return
10
10
 
11
11
__all__ = [
1339
1339
 
1340
1340
    SA = 50 * (v_lab - v_0) / (v_50 - v_0)  # Initial estimate of SA.
1341
1341
 
1342
 
    Ior = (SA < 0) | (SA > 50)
1343
 
    SA[Ior] = np.NaN
 
1342
    SA[np.logical_or(SA < 0, SA > 50)] = np.NaN
1344
1343
 
1345
1344
    v_SA = (v_50 - v_0) / 50.  # Initial v_SA estimate (SA derivative of v).
1346
1345
 
1348
1347
    for Number_of_iterations in range(0, 3):
1349
1348
        SA_old = SA
1350
1349
        delta_v = specvol(SA_old, CT, p) - v_lab
 
1350
        # Half way the mod. N-R method (McDougall and Wotherspoon, 2012)
1351
1351
        SA = SA_old - delta_v / v_SA  # Half way through the mod. N-R method.
1352
1352
        SA_mean = 0.5 * (SA + SA_old)
1353
1353
        rho, alpha, beta = rho_alpha_beta(SA_mean, CT, p)
1354
1354
        v_SA = -beta / rho
1355
1355
        SA = SA_old - delta_v / v_SA
1356
 
        Ior = (SA < 0) | (SA > 50)
1357
 
        SA[Ior] = np.NaN
 
1356
        SA[np.logical_or(SA < 0, SA > 50)] = np.NaN
1358
1357
 
1359
1358
    # After two iterations of this modified Newton-Raphson iteration,
1360
1359
    # the error in SA is no larger than 8x10^-13 g kg^-1, which