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

« back to all changes in this revision

Viewing changes to gsw/gibbs/earth.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 constants import gamma, earth_radius, OMEGA
8
 
from gsw.utilities import match_args_return
9
 
from conversions import z_from_p
 
7
from .constants import gamma, earth_radius, OMEGA
 
8
from ..utilities import match_args_return
 
9
from .conversions import z_from_p
10
10
 
11
11
 
12
12
__all__ = ['f',
13
13
           'grav',
14
14
           'distance']
15
15
 
16
 
RAD = np.pi / 180.0
 
16
DEG2RAD = np.pi / 180
17
17
 
18
18
 
19
19
def f(lat):
49
49
    """
50
50
 
51
51
    lat = np.asanyarray(lat)
52
 
    return 2 * OMEGA * np.sin(lat * RAD)
 
52
    return 2 * OMEGA * np.sin(lat * DEG2RAD)
53
53
 
54
54
 
55
55
@match_args_return
104
104
    2011-03-29. Trevor McDougall & Paul Barker
105
105
    """
106
106
 
107
 
    X = np.sin(lat * RAD)
 
107
    X = np.sin(lat * DEG2RAD)
108
108
    sin2 = X ** 2
109
109
    gs = 9.780327 * (1.0 + (5.2792e-3 + (2.32e-5 * sin2)) * sin2)
110
110
    z = z_from_p(p, lat)
181
181
    2000-11-06. Rich Pawlowicz
182
182
    2011-04-04. Paul Barker and Trevor McDougall
183
183
    """
184
 
    #FIXME? The argument handling seems much too complicated.
 
184
    # FIXME? The argument handling seems much too complicated.
185
185
    # Maybe we can come up with some simple specifications of
186
186
    # what argument combinations are permitted, and handle everything
187
187
    # with broadcasting. - EF
188
188
 
189
 
    #FIXME: Eric what do you think? This assume p(stations, depth)
 
189
    # FIXME: Eric what do you think? This assume p(stations, depth)
190
190
    lon, lat, = np.atleast_2d(lon), np.atleast_2d(lat)
191
191
 
192
192
    if (lon.size == 1) & (lat.size == 1):
196
196
 
197
197
    lon, lat, p = np.broadcast_arrays(lon, lat, p)
198
198
 
199
 
    dlon = np.diff(lon * RAD)
200
 
    dlat = np.diff(lat * RAD)
201
 
 
202
 
    a = ((np.sin(dlat / 2.)) ** 2 + np.cos(lat[:, :-1] * RAD) *
203
 
           np.cos(lat[:, 1:] * RAD) * (np.sin(dlon / 2.)) ** 2)
204
 
 
205
 
    # FIXME: Do we need np.ma here?
206
 
    angles = 2. * np.arctan2(np.ma.sqrt(a), np.ma.sqrt(1 - a))
 
199
    dlon = np.diff(lon * DEG2RAD)
 
200
    dlat = np.diff(lat * DEG2RAD)
 
201
 
 
202
    a = ((np.sin(dlat / 2)) ** 2 + np.cos(lat[:, :-1] * DEG2RAD) *
 
203
           np.cos(lat[:, 1:] * DEG2RAD) * (np.sin(dlon / 2)) ** 2)
 
204
 
 
205
    angles = 2 * np.arctan2(np.sqrt(a), np.sqrt(1 - a))
207
206
 
208
207
    p_mid = 0.5 * (p[:, 0:-1] + p[:, 0:-1])
209
208
    lat_mid = 0.5 * (lat[:, :-1] + lat[:, 1:])