|
4 | 4 | Class to generate NEMO v4.0 s-coordinates |
5 | 5 | """ |
6 | 6 |
|
7 | | -from itertools import product |
8 | 7 | from typing import Optional |
9 | 8 |
|
10 | 9 | import numpy as np |
@@ -207,54 +206,10 @@ def _compute_env(self, depth: DataArray) -> DataArray: |
207 | 206 |
|
208 | 207 | # set first land point adjacent to a wet cell to |
209 | 208 | # min_dep as this needs to be included in smoothing |
210 | | - |
211 | | - # ------------------------------------------------------------ |
212 | | - # This is the original NEMO Fortran90 code: translated |
213 | | - # in python it is very inefficient |
214 | | - # ------------------------------------------------------------ |
215 | | - # zenv = depth.copy() |
216 | | - # env = zenv.data |
217 | | - # |
218 | | - # nj = env.shape[0] |
219 | | - # ni = env.shape[1] |
220 | | - # |
221 | | - # for j in range(nj - 1): |
222 | | - # for i in range(ni - 1): |
223 | | - # if not lsm[j, i]: |
224 | | - # ip1 = np.minimum(i + 1, ni) |
225 | | - # jp1 = np.minimum(j + 1, nj) |
226 | | - # im1 = np.maximum(i - 1, 0) |
227 | | - # jm1 = np.maximum(j - 1, 0) |
228 | | - # if ( |
229 | | - # depth[jp1, im1] |
230 | | - # + depth[jp1, i] |
231 | | - # + depth[jp1, ip1] |
232 | | - # + depth[j, im1] |
233 | | - # + depth[j, ip1] |
234 | | - # + depth[jm1, im1] |
235 | | - # + depth[jm1, i] |
236 | | - # + depth[jm1, ip1] |
237 | | - # ) > 0.0: |
238 | | - # env[j, i] = min_dep |
239 | | - # |
240 | | - # zenv.data = env |
241 | | - # ------------------------------------------------------------ |
242 | | - |
243 | | - # ------------------------------------------------------------ |
244 | | - # This is my translation into xarray. I think it does what |
245 | | - # it should, a part on the boundaries: I tested with AMM7, |
246 | | - # and zenv computed with NEMO-like code (above) and this |
247 | | - # one are perfectly identical apart for two single different |
248 | | - # points just on the border ... I don't think it will make |
249 | | - # a huge difference but if there is a better way to manage |
250 | | - # the borders with xarray and obtain exactly the same results |
251 | | - # of the original NEMO-like code, happy to use it. |
252 | | - # ------------------------------------------------------------ |
253 | 209 | cst_lsm = lsm.rolling({dim: 3 for dim in lsm.dims}, min_periods=2).sum() |
254 | 210 | cst_lsm = cst_lsm.shift({dim: -1 for dim in lsm.dims}) |
255 | 211 | cst_lsm = (cst_lsm > 0) & (lsm == 0) |
256 | 212 | zenv = depth.where(cst_lsm == 0, self._min_dep) |
257 | | - # ------------------------------------------------------------ |
258 | 213 |
|
259 | 214 | zenv = _smooth_MB06(zenv, self._rmax) |
260 | 215 | zenv = zenv.where(zenv > self._min_dep, self._min_dep) |
|
0 commit comments