@@ -139,8 +139,15 @@ def _convert_vertical_coords(
139139 )
140140 coords_and_dims .append ((coord , dim ))
141141
142+ # Common calc for Depth
143+ try :
144+ svd_lev_eq = brsvd1 == brlev
145+ except ValueError :
146+ # In case of broadcasting errors.
147+ svd_lev_eq = False
148+
142149 # Depth - unbound.
143- if (len (lbcode ) != 5 ) and (lbvc == 2 ) and np .all (brsvd1 == brlev ):
150+ if (len (lbcode ) != 5 ) and (lbvc == 2 ) and np .all (svd_lev_eq ):
144151 coord = _dim_or_aux (
145152 blev ,
146153 standard_name = "depth" ,
@@ -150,7 +157,7 @@ def _convert_vertical_coords(
150157 coords_and_dims .append ((coord , dim ))
151158
152159 # Depth - bound.
153- if (len (lbcode ) != 5 ) and (lbvc == 2 ) and np .all (brsvd1 != brlev ):
160+ if (len (lbcode ) != 5 ) and (lbvc == 2 ) and np .all (~ svd_lev_eq ):
154161 coord = _dim_or_aux (
155162 blev ,
156163 standard_name = "depth" ,
@@ -164,10 +171,10 @@ def _convert_vertical_coords(
164171 if (
165172 (len (lbcode ) != 5 )
166173 and (lbvc == 2 )
167- and (np .any (brsvd1 == brlev ) and np .any (brsvd1 != brlev ))
174+ and (np .any (svd_lev_eq ) and np .any (~ svd_lev_eq ))
168175 ):
169- lower = np .where (brsvd1 == brlev , blev , brsvd1 )
170- upper = np .where (brsvd1 == brlev , blev , brlev )
176+ lower = np .where (svd_lev_eq , blev , brsvd1 )
177+ upper = np .where (svd_lev_eq , blev , brlev )
171178 coord = _dim_or_aux (
172179 blev ,
173180 standard_name = "depth" ,
@@ -189,7 +196,7 @@ def _convert_vertical_coords(
189196 units = "1" ,
190197 )
191198 coords_and_dims .append ((coord , dim ))
192- elif np .any (brsvd1 != brlev ):
199+ elif np .any (~ svd_lev_eq ):
193200 # UM populates metadata CORRECTLY,
194201 # so treat it as the expected (bounded) soil depth.
195202 coord = _dim_or_aux (
0 commit comments