|
8 | 8 | from ._wrapped_ufuncs import * |
9 | 9 |
|
10 | 10 | _p_from_z = p_from_z |
| 11 | + |
| 12 | + |
11 | 13 | def p_from_z(z, lat, geo_strf_dyn_height=0, sea_surface_geopotential=0): |
| 14 | + if numpy.ma.any(numpy.ma.asarray(z) > 5): |
| 15 | + raise ValueError(f"z should be generally negative; found max(z) = {numpy.ma.max(z)}") |
12 | 16 | return _p_from_z(z, lat, geo_strf_dyn_height, sea_surface_geopotential) |
| 17 | + |
| 18 | + |
13 | 19 | p_from_z.__doc__ = _p_from_z.__doc__ |
14 | 20 |
|
15 | 21 | _z_from_p = z_from_p |
| 22 | + |
| 23 | + |
16 | 24 | def z_from_p(p, lat, geo_strf_dyn_height=0, sea_surface_geopotential=0): |
17 | 25 | return _z_from_p(p, lat, geo_strf_dyn_height, sea_surface_geopotential) |
| 26 | + |
| 27 | + |
18 | 28 | z_from_p.__doc__ = _z_from_p.__doc__ |
19 | 29 |
|
20 | 30 | _gibbs = gibbs |
| 31 | + |
| 32 | + |
21 | 33 | def gibbs(ns, nt, np, SA, t, p): |
22 | 34 | params = {"ns": ns, "nt": nt, "np": np} |
23 | 35 | for k, v in params.items(): |
24 | 36 | u = numpy.unique(v) |
25 | 37 | if u.min() < 0 or u.max() > 2 or u.dtype.kind != "i": |
26 | | - raise ValueError("ns, nt, np must contain integers 0, 1, or 2;" |
27 | | - f" found {k}={v}") |
| 38 | + raise ValueError(f"ns, nt, np must contain integers 0, 1, or 2; found {k}={v}") |
28 | 39 | return _gibbs(ns, nt, np, SA, t, p) |
| 40 | + |
| 41 | + |
29 | 42 | gibbs.__doc__ = _gibbs.__doc__ |
30 | 43 |
|
31 | 44 |
|
32 | 45 | _gibbs_ice = gibbs_ice |
| 46 | + |
| 47 | + |
33 | 48 | def gibbs_ice(nt, np, t, p): |
34 | 49 | params = {"nt": nt, "np": np} |
35 | 50 | for k, v in params.items(): |
36 | 51 | u = numpy.unique(v) |
37 | 52 | if u.min() < 0 or u.max() > 2 or u.dtype.kind != "i": |
38 | | - raise ValueError("nt, np must contain integers 0, 1, or 2;" |
39 | | - f" found {k}={v}") |
| 53 | + raise ValueError(f"nt, np must contain integers 0, 1, or 2; found {k}={v}") |
40 | 54 | return _gibbs_ice(nt, np, t, p) |
| 55 | + |
| 56 | + |
41 | 57 | gibbs_ice.__doc__ = _gibbs_ice.__doc__ |
0 commit comments