From ba3c8519ba88f88a3672e5d76696e10063da5898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ruben=20Calj=C3=A9?= Date: Tue, 21 Nov 2023 12:58:23 +0100 Subject: [PATCH] Process comments from @dbrakenhoff --- nlmod/dims/layers.py | 24 ++++++++++++++++++++++-- tests/test_009_layers.py | 4 +++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/nlmod/dims/layers.py b/nlmod/dims/layers.py index 7bf3ff1e..4df04b70 100644 --- a/nlmod/dims/layers.py +++ b/nlmod/dims/layers.py @@ -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 @@ -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 diff --git a/tests/test_009_layers.py b/tests/test_009_layers.py index 8f85ed12..ba6d359d 100644 --- a/tests/test_009_layers.py +++ b/tests/test_009_layers.py @@ -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):