File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44Class to generate NEMO v4.0 s-coordinates
55"""
66
7- from typing import Optional # , Tuple
7+ from itertools import product
8+ from typing import Optional
89
910import numpy as np
1011import xarray as xr
1112from xarray import DataArray , Dataset
1213
13- from pydomcfg .utils import _smooth_MB06 # , _calc_rmax
14+ from pydomcfg .utils import _smooth_MB06
1415
1516from .zgr import Zgr
1617
@@ -193,7 +194,7 @@ def _compute_env(self, depth: DataArray) -> DataArray:
193194 ----------
194195 depth: DataArray
195196 xarray DataArray of the 2D bottom topography
196- it MUST have only two dimensions named "x" and "y"
197+ it MUST have only two dimensions
197198 Returns
198199 -------
199200 DataArray
@@ -251,11 +252,10 @@ def _compute_env(self, depth: DataArray) -> DataArray:
251252 # ------------------------------------------------------------
252253 cst_lsm = lsm * 0.0
253254 ngb_pnt = [- 1 , 0 , 1 ]
254- for j in ngb_pnt :
255- for i in ngb_pnt :
256- if j != 0 or i != 0 :
257- lsm_sft = lsm .shift ({lsm .dims [1 ]: i , lsm .dims [0 ]: j })
258- cst_lsm += lsm_sft
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
259259
260260 cst_lsm = cst_lsm .where (lsm == 0 , 0 )
261261 cst_lsm = cst_lsm .where (cst_lsm == 0 , 1 )
You can’t perform that action at this time.
0 commit comments