Skip to content

Commit

Permalink
Process comments from @dbrakenhoff
Browse files Browse the repository at this point in the history
  • Loading branch information
rubencalje committed Nov 21, 2023
1 parent 6c4376c commit ba3c851
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
24 changes: 22 additions & 2 deletions nlmod/dims/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ def remove_layer_dim_from_top(
)
ds["top"] = ds["top"][0]
if set_non_existing_layers_to_nan:
ds = set_nan_top_and_botm(ds)
ds = set_nan_top_and_botm(ds, copy=False)
return ds


Expand Down Expand Up @@ -1193,10 +1193,30 @@ def add_layer_dim_to_top(ds, set_non_existing_layers_to_nan=True, copy=True):
ds = ds.copy(deep=True)
ds["top"] = ds["botm"] + calculate_thickness(ds)
if set_non_existing_layers_to_nan:
set_nan_top_and_botm(ds)
ds = set_nan_top_and_botm(ds, copy=False)
return ds


def convert_to_modflow_top_bot(ds, **kwargs):
"""
Removes the layer dimension from top and fills nans in top and botm.
Alias to remove_layer_dim_from_top
"""
ds = remove_layer_dim_from_top(ds, **kwargs)


def convert_to_regis_top_bot(ds, **kwargs):
"""
Adds a layer dimension to top and sets non-existing cells to nan in top and botm.
Alias to add_layer_dim_to_top
"""
ds = add_layer_dim_to_top(ds, **kwargs)


def remove_inactive_layers(ds):
"""
Remove layers which only contain inactive cells
Expand Down
4 changes: 3 additions & 1 deletion tests/test_009_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ def test_split_layers(plot=False):

def test_add_layer_dim_to_top():
regis = get_regis_horstermeer()
nlmod.layers.add_layer_dim_to_top(regis)
ds = nlmod.layers.add_layer_dim_to_top(regis)
assert "layer" in ds["top"].dims
assert ds["botm"].isnull().any()


def test_combine_layers(plot=False):
Expand Down

0 comments on commit ba3c851

Please sign in to comment.