Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions gsw/_fixed_wrapped_ufuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,59 @@

from ._wrapped_ufuncs import *

attrs = ["__doc__", "types", "nin", "nout"]


def transfer_attrs(new, orig):
for attr in attrs:
setattr(new, attr, getattr(orig, attr))


_p_from_z = p_from_z


def p_from_z(z, lat, geo_strf_dyn_height=0, sea_surface_geopotential=0):
def p_from_z(z, lat, geo_strf_dyn_height=0, sea_surface_geopotential=0, **kwargs):
if numpy.ma.any(numpy.ma.asarray(z) > 5):
raise ValueError(f"z should be generally negative; found max(z) = {numpy.ma.max(z)}")
return _p_from_z(z, lat, geo_strf_dyn_height, sea_surface_geopotential)
return _p_from_z(z, lat, geo_strf_dyn_height, sea_surface_geopotential, **kwargs)


p_from_z.__doc__ = _p_from_z.__doc__
transfer_attrs(p_from_z, _p_from_z)

_z_from_p = z_from_p


def z_from_p(p, lat, geo_strf_dyn_height=0, sea_surface_geopotential=0):
return _z_from_p(p, lat, geo_strf_dyn_height, sea_surface_geopotential)
def z_from_p(p, lat, geo_strf_dyn_height=0, sea_surface_geopotential=0, **kwargs):
return _z_from_p(p, lat, geo_strf_dyn_height, sea_surface_geopotential, **kwargs)


z_from_p.__doc__ = _z_from_p.__doc__
transfer_attrs(z_from_p, _z_from_p)

_gibbs = gibbs


def gibbs(ns, nt, np, SA, t, p):
def gibbs(ns, nt, np, SA, t, p, **kwargs):
params = {"ns": ns, "nt": nt, "np": np}
for k, v in params.items():
u = numpy.unique(v)
if u.min() < 0 or u.max() > 2 or u.dtype.kind != "i":
raise ValueError(f"ns, nt, np must contain integers 0, 1, or 2; found {k}={v}")
return _gibbs(ns, nt, np, SA, t, p)
return _gibbs(ns, nt, np, SA, t, p, **kwargs)


gibbs.__doc__ = _gibbs.__doc__
transfer_attrs(gibbs, _gibbs)


_gibbs_ice = gibbs_ice


def gibbs_ice(nt, np, t, p):
def gibbs_ice(nt, np, t, p, **kwargs):
params = {"nt": nt, "np": np}
for k, v in params.items():
u = numpy.unique(v)
if u.min() < 0 or u.max() > 2 or u.dtype.kind != "i":
raise ValueError(f"nt, np must contain integers 0, 1, or 2; found {k}={v}")
return _gibbs_ice(nt, np, t, p)
return _gibbs_ice(nt, np, t, p, **kwargs)


gibbs_ice.__doc__ = _gibbs_ice.__doc__
transfer_attrs(gibbs_ice, _gibbs_ice)
Loading
Loading