Skip to content

Commit

Permalink
add equality check with bottom layer
Browse files Browse the repository at this point in the history
  • Loading branch information
veenstrajelmer committed Sep 3, 2024
1 parent 00bea02 commit 9f3d3b9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dfm_tools/hydrolib_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,11 @@ def forcinglike_to_Dataset(forcingobj, convertnan=False):
if convertnan: #convert ffilled/bfilled values back to nan
deepestlayeridx = data_xr_var[varn_depth].to_numpy().argmin()
if deepestlayeridx==0: #sorted from deep to shallow layers
bool_nandepths = (data_xr_var==data_xr_var.shift({varn_depth:-1})).all(dim='time')
bool_eq_above = data_xr_var==data_xr_var.shift({varn_depth:-1})
else: #sorted from shallow to deep layers
bool_nandepths = (data_xr_var==data_xr_var.shift({varn_depth:1})).all(dim='time')
bool_eq_above = data_xr_var==data_xr_var.shift({varn_depth:1})
bool_eq_bottom = data_xr_var==data_xr_var.isel({varn_depth:deepestlayeridx})
bool_nandepths = (bool_eq_above & bool_eq_bottom).all(dim='time')
data_xr_var = data_xr_var.where(~bool_nandepths)
if 'time' in dims:
time_unit = forcingobj.quantityunitpair[0].unit.lower()
Expand Down

0 comments on commit 9f3d3b9

Please sign in to comment.