Skip to content

Commit

Permalink
Merge pull request #29 from ocefpaf/soundspeed
Browse files Browse the repository at this point in the history
Soundspeed
  • Loading branch information
ocefpaf committed May 5, 2015
2 parents 7532cc0 + c81051e commit 86edaed
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 29 deletions.
7 changes: 6 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
Changelog
---------

Version 0.2.4, 05-May-2015.

* Added `woa_profile`.
* Re-write of `woa_subset` to use iris instead of Pandas.
* Deprecate 'state' option in soundspeed.

Version 0.2.3, 23-Jan-2015.

* Unpinned version in setup.py.
* Several small bugs and typos fixes.

Version 0.2.2, 18-Aug-2014.
Expand Down
2 changes: 1 addition & 1 deletion oceans/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

__version__ = '0.2.3'
__version__ = '0.2.4'

__all__ = ['RPSstuff',
'datasets',
Expand Down
8 changes: 3 additions & 5 deletions oceans/datasets/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# e-mail: ocefpaf@gmail
# web: http://ocefpaf.tiddlyspot.com/
# created: 09-Sep-2011
# modified: Mon 04 May 2015 02:30:43 PM BRT
# modified: Mon 04 May 2015 05:44:40 PM BRT
#
# obs: some Functions were based on:
# http://www.trondkristiansen.com/?page_id=1071
Expand Down Expand Up @@ -92,8 +92,6 @@ def woa_subset(bbox=[2.5, 357.5, -87.5, 87.5], variable='temperature',
... gl.yformatter = LATITUDE_FORMATTER
... return fig, ax
>>> # Extract a 2D surface -- Annual temperature climatology:
>>> import numpy as np
>>> import numpy.ma as ma
>>> import matplotlib.pyplot as plt
>>> from oceans.ff_tools import wrap_lon180
>>> from oceans.colormaps import cm, get_color
Expand Down Expand Up @@ -154,7 +152,7 @@ def woa_subset(bbox=[2.5, 357.5, -87.5, 87.5], variable='temperature',
cubes = iris.load_raw(url)
cubes = [cube.intersection(longitude=(bbox[0], bbox[1]),
latitude=(bbox[2], bbox[3])) for cube in cubes]

cubes = iris.cube.CubeList(cubes)
if full:
return cubes
else:
Expand Down Expand Up @@ -225,7 +223,7 @@ def woa_profile(lon, lat, variable='temperature', clim_type='00',
cubes = [extract_nearest_neighbour(cube, [('longitude', lon),
('latitude', lat)])
for cube in cubes]

cubes = iris.cube.CubeList(cubes)
if full:
return cubes
else:
Expand Down
22 changes: 0 additions & 22 deletions oceans/sw_extras/sw_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,14 +620,6 @@ def psu2ppt(psu):
psu ** 2 + a[6] * psu ** 2.5)


def swstate():
pass


def adiabattempgrad():
pass


def soundspeed(S, T, D, equation='mackenzie'):
"""Various sound-speed equations.
1) soundspeed(s, t, d) returns the sound speed (m/sec) given vectors
Expand Down Expand Up @@ -721,20 +713,6 @@ def soundspeed(S, T, D, equation='mackenzie'):
C = ((C3 * P + C2) * P + C1) * P + C0
# SOUND SPEED RETURN.
ssp = C + (A + B * SR + D * S) * S
elif equation == 'state':
raise TypeError("Not implemented!")
P = D
# Copied somewhat from program EOSSPEED.F
svan, sigma = swstate(S, T, P)
VOL = (1.) / (1000. + sigma)
# DV/DP|ADIA = (DV/DP) AT CONSTANT T + ADIA.LAPSE RATE *
# (DV/DT) AT CONSTANT P
# Note: factor of 10 is convert pressure from dB to Bars.
dVdP = swstate(S, T, P, 'dP')
dVdT = swstate(S, T, P, 'dT')
dVdPad = (dVdP + adiabattempgrad(S, T, P) * dVdT) * 10
# C = V * SQRT ( 1/DV/DP| ADIA)
ssp = VOL * np.sqrt(np.abs((1.e5) / dVdPad))
else:
raise TypeError('Unrecognizable equation specified: %s' % equation)
return ssp
Expand Down

0 comments on commit 86edaed

Please sign in to comment.