Skip to content

Commit

Permalink
Merge pull request #365 from gwmod/364_improve_split_layers
Browse files Browse the repository at this point in the history
implement suggestions by @vincentpost
  • Loading branch information
dbrakenhoff authored Aug 7, 2024
2 parents b8ae8d3 + 13b7612 commit 464a616
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 21 deletions.
18 changes: 0 additions & 18 deletions docs/examples/04_modifying_layermodels.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -263,24 +263,6 @@
"split_reindexer"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The new layers are named according to the REGIS codes, with an added number if the layer was split into multiple sub-layers. For plotting a cross-section we want to use the original color from the REGIS cross-section plot for the new sub-layers."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for j, i in split_reindexer.items():\n",
" if j not in colors:\n",
" colors[j] = colors[i]"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
4 changes: 2 additions & 2 deletions nlmod/dims/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def split_layers_ds(
for lay0 in split_dict:
for i, _ in enumerate(split_dict[lay0]):
index = layers.index(lay0)
layers.insert(index, lay0 + "_" + str(i + 1))
layers.insert(index, lay0 + "_" + str(i))
layers_org.insert(index, lay0)
ds = ds.reindex({"layer": layers})

Expand Down Expand Up @@ -300,7 +300,7 @@ def split_layers_ds(
def _split_var(ds, var, layer, thickness, fctrs, top, bot):
"""Internal method to split a variable of one layer in multiple layers."""
for i in range(len(fctrs)):
name = layer + "_" + str(i + 1)
name = layer + "_" + str(i)
if var == top:
# take orignal top and subtract thickness of higher splitted layers
ds[var].loc[name] = ds[var].loc[layer] - np.sum(fctrs[:i]) * thickness
Expand Down
3 changes: 2 additions & 1 deletion nlmod/plot/dcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ def plot_layers(
if isinstance(colors, pd.DataFrame):
colors = colors["color"]
if isinstance(colors, (dict, pd.Series)):
colors = [colors[layer] for layer in self.layer]
# split on _ in case layers were split and appended with a numbered suffix
colors = [colors[layer.split("_")[0]] for layer in self.layer]

if colors == "none":
colors = ["none"] * len(self.layer)
Expand Down

0 comments on commit 464a616

Please sign in to comment.