Skip to content

Commit 5dcbcf3

Browse files
authored
Remove non-finite fill values for pf.ice_ext() calculation
With the fill value change from 0 to nan in fesom2.7 the pf.ice_ext() did return incorrect values.
1 parent 2a0cca1 commit 5dcbcf3

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

pyfesom2/diagnostics.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,21 @@ def ice_ext(data, mesh, hemisphere="N", threshhold=0.15, attrs={}):
7676
data = data.where(data < threshhold, 1)
7777
data = data.where(data > threshhold)
7878

79-
ext = (data[:, hemis_mask] * mesh.lump2[hemis_mask]).sum(axis=1)
79+
finite_mask = data.squeeze().values
80+
81+
ext = (data[:, hemis_mask & finite_mask] * mesh.lump2[hemis_mask & finite_mask]).sum(axis=1)
8082
da = xr.DataArray(
8183
ext, dims=["time"], coords={"time": data.time}, name=varname, attrs=attrs
8284
)
8385
return da
8486

8587
else:
8688
logger.debug(data)
89+
finite_mask = data.squeeze()
8790
i, j = np.where(data < 0.15)
8891
data[:] = 1
8992
data[i, j] = 0
90-
ext = (data[:, hemis_mask] * mesh.lump2[hemis_mask]).sum(axis=1)
93+
ext = (data[:, hemis_mask & finite_mask] * mesh.lump2[hemis_mask & finite_mask]).sum(axis=1)
9194
return ext
9295

9396

0 commit comments

Comments
 (0)