1
# -*- coding: utf-8 -*-
3
from __future__ import division
7
from constants import gamma, earth_radius, OMEGA
8
from gsw.utilities import match_args_return
9
from conversions import z_from_p
20
r"""Calculates the Coriolis parameter (f) defined by:
23
omega = 7.292115e-5 (Groten, 2004) [radians s :sup:`-1`]
28
latitude [degrees north]
33
Coriolis paramter [s :sup:`-1`]
37
.. [1] Groten, E., 2004: Fundamental Parameters and Current (2004) Best
38
Estimates of the Parameters of Common Relevance to Astronomy, Geodesy, and
39
Geodynamics. Journal of Geodesy, 77, pp. 724-797.
41
.. [2] IOC, SCOR and IAPSO, 2010: The international thermodynamic equation
42
of seawater - 2010: Calculation and use of thermodynamic properties.
43
Intergovernmental Oceanographic Commission, Manuals and Guides No. 56,
44
UNESCO (English), 196 pp.
47
1993-04-20. Phil Morgan
48
2010-07-28. Paul Barker
51
lat = np.asanyarray(lat)
52
return 2 * OMEGA * np.sin(lat * RAD)
57
r"""Calculates acceleration due to gravity as a function of latitude and as
58
a function of pressure in the ocean.
63
latitude in decimal degrees north [-90...+90]
64
p : number or array_like. Default p = 0
70
gravity [m s :sup:`2`]
78
In the ocean z is negative.
83
>>> lat = [-90, -60, -30, 0]
86
array([ 9.83218621, 9.81917886, 9.79324926, 9.780327 ])
92
.. [1] IOC, SCOR and IAPSO, 2010: The international thermodynamic equation
93
of seawater - 2010: Calculation and use of thermodynamic properties.
94
Intergovernmental Oceanographic Commission, Manuals and Guides No. 56,
95
UNESCO (English), 196 pp.
97
.. [2] Moritz (2000) Goedetic reference system 1980. J. Geodesy, 74,
100
.. [3] Saunders, P.M., and N.P. Fofonoff (1976) Conversion of pressure to
101
depth in the ocean. Deep-Sea Res.,pp. 109 - 111.
104
2011-03-29. Trevor McDougall & Paul Barker
107
X = np.sin(lat * RAD)
109
gs = 9.780327 * (1.0 + (5.2792e-3 + (2.32e-5 * sin2)) * sin2)
111
# z is the height corresponding to p.
112
grav = gs * (1 - gamma * z)
118
def distance(lon, lat, p=0):
119
r"""Calculates the distance in met res between successive points in the
120
vectors lon and lat, computed using the Haversine formula on a spherical
121
earth of radius 6,371 km, being the radius of a sphere having the same
122
volume as Earth. For a spherical Earth of radius 6,371,000 m, one nautical
123
mile is 1,853.2488 m, thus one degree of latitude is 111,194.93 m.
126
R = earth's radius (mean radius = 6,371 km)
129
a = \sin^2(\delta \text{lat}/2) +
130
\cos(\text{lat}_1) \cos(\text{lat}_2) \sin^2(\delta \text{lon}/2)
132
c = 2 \times \text{atan2}(\sqrt{a}, \sqrt{(1-a)})
139
decimal degrees east [0..+360] or [-180 ... +180]
141
latitude in decimal degrees north [-90..+90]
142
p : number or array_like. Default p = 0
148
distance between points on a spherical Earth at pressure (p) [m]
156
z is height and is negative in the oceanographic.
158
Distances are probably good to better than 1\% of the "true" distance on
159
the ellipsoidal earth.
166
>>> gsw.distance(lon, lat)
167
array([[ 10030974.652916]])
169
>>> gsw.distance(lon, lat, p)
170
array([[ 10030661.63878009]])
171
>>> p = [[200], [1000]]
172
>>> gsw.distance(lon, lat, p)
173
array([[ 10030661.63878009],
174
[ 10029412.58776001]])
178
.. [1] http://www.eos.ubc.ca/~rich/map.html
181
2000-11-06. Rich Pawlowicz
182
2011-04-04. Paul Barker and Trevor McDougall
184
#FIXME? The argument handling seems much too complicated.
185
# Maybe we can come up with some simple specifications of
186
# what argument combinations are permitted, and handle everything
187
# with broadcasting. - EF
189
#FIXME: Eric what do you think? This assume p(stations, depth)
190
lon, lat, = np.atleast_2d(lon), np.atleast_2d(lat)
192
if (lon.size == 1) & (lat.size == 1):
193
raise ValueError('more than one point is needed to compute distance')
194
elif lon.ndim != lat.ndim:
195
raise ValueError('lon, lat must have the same dimension')
197
lon, lat, p = np.broadcast_arrays(lon, lat, p)
199
dlon = np.diff(lon * RAD)
200
dlat = np.diff(lat * RAD)
202
a = ((np.sin(dlat / 2.)) ** 2 + np.cos(lat[:, :-1] * RAD) *
203
np.cos(lat[:, 1:] * RAD) * (np.sin(dlon / 2.)) ** 2)
205
# FIXME: Do we need np.ma here?
206
angles = 2. * np.arctan2(np.ma.sqrt(a), np.ma.sqrt(1 - a))
208
p_mid = 0.5 * (p[:, 0:-1] + p[:, 0:-1])
209
lat_mid = 0.5 * (lat[:, :-1] + lat[:, 1:])
211
z = z_from_p(p_mid, lat_mid)
213
distance = (earth_radius + z) * angles
218
if __name__ == '__main__':