Skip to content

Commit 216c30f

Browse files
committed
remove std nme of sigma
1 parent d303eed commit 216c30f

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

gsw_xarray/_attributes.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -717,19 +717,15 @@
717717
"units": "kg/m^3",
718718
},
719719
"sigma1": {
720-
"standard_name": "sea_water_sigma_theta",
721720
"units": "kg/m^3",
722721
},
723722
"sigma2": {
724-
"standard_name": "sea_water_sigma_theta",
725723
"units": "kg/m^3",
726724
},
727725
"sigma3": {
728-
"standard_name": "sea_water_sigma_theta",
729726
"units": "kg/m^3",
730727
},
731728
"sigma4": {
732-
"standard_name": "sea_water_sigma_theta",
733729
"units": "kg/m^3",
734730
},
735731
"sound_speed": {

gsw_xarray/_check_funcs.py

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
1+
def _rm_std_nme(d):
2+
"""
3+
Return a dict which does not contain the standard name
4+
"""
5+
d = d.copy()
6+
# necessary to use a copy, or it will pop the item from the original dict
7+
try:
8+
d.pop("standard_name")
9+
except KeyError:
10+
pass
11+
return d
12+
113
def check_pot_rho_t_exact(attrs, args, kwargs):
214
"""
3-
From cf convention:
4-
Sea water potential density is the density a parcel of sea water would have if moved adiabatically to a reference pressure, by default assumed to be sea level pressure. To specify the reference pressure to which the quantity applies, provide a scalar coordinate variable with standard name reference_pressure. The density of a substance is its mass per unit volume. For sea water potential density, if 1000 kg m-3 is subtracted, the standard name sea_water_sigma_theta should be chosen instead.
15+
If the reference pressure is not 0, remove standard name.
16+
17+
Reminder of the function call:
18+
gsw.pot_rho_t_exact(SA, t, p, p_ref)
19+
20+
TODO: could provide a scalar coordinate variable with standard name reference_pressure
21+
(see issue 32, https://github.com/DocOtak/gsw-xarray/issues/32)
522
"""
6-
return attrs
23+
# get value of p_ref
24+
try:
25+
p_ref = kwargs["p_ref"]
26+
except KeyError:
27+
p_ref = args[3]
28+
29+
if p_ref == 0:
30+
return attrs
31+
else:
32+
return _rm_std_nme(attrs)
733

834

935
def check_z_from_p(attrs, args, kwargs):
@@ -43,10 +69,9 @@ def check_z_from_p(attrs, args, kwargs):
4369
)
4470

4571
if geo_strf_dyn_height != 0 or sea_surface_geopotential != 0:
46-
attrs = attrs.copy()
47-
# necessary to use a copy, or it will pop the item from the original dict
48-
attrs.pop("standard_name")
49-
return attrs
72+
return _rm_std_nme(attrs)
73+
else:
74+
return attrs
5075

5176

5277
_check_funcs = {

0 commit comments

Comments
 (0)