Skip to content

Commit 3119aad

Browse files
oceandiemalmans2
andauthored
Fix little inconsistencies at the boundaries
Co-authored-by: Mattia Almansi <mattia.almansi@noc.ac.uk>
1 parent 9589679 commit 3119aad

1 file changed

Lines changed: 3 additions & 12 deletions

File tree

pydomcfg/domzgr/sco.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -250,19 +250,10 @@ def _compute_env(self, depth: DataArray) -> DataArray:
250250
# the borders with xarray and obtain exactly the same results
251251
# of the original NEMO-like code, happy to use it.
252252
# ------------------------------------------------------------
253-
cst_lsm = lsm * 0.0
254-
ngb_pnt = [-1, 0, 1]
255-
for j, i in product(ngb_pnt, repeat=2):
256-
if not (j == 0 and i == 0):
257-
lsm_sft = lsm.shift({lsm.dims[1]: i, lsm.dims[0]: j})
258-
cst_lsm += lsm_sft
259-
260-
cst_lsm = cst_lsm.where(lsm == 0, 0)
261-
cst_lsm = cst_lsm.where(cst_lsm == 0, 1)
253+
cst_lsm = lsm.rolling({dim: 3 for dim in lsm.dims}, min_periods=2).sum()
254+
cst_lsm = cst_lsm.shift({dim: -1 for dim in lsm.dims})
255+
cst_lsm = (cst_lsm > 0) & (lsm == 0)
262256
zenv = depth.where(cst_lsm == 0, self._min_dep)
263-
for dim in lsm.dims:
264-
for indx in [0, -1]:
265-
zenv[{dim: indx}] = depth[{dim: indx}]
266257
# ------------------------------------------------------------
267258

268259
zenv = _smooth_MB06(zenv, self._rmax)

0 commit comments

Comments
 (0)