diff --git a/docs/examples/04_modifying_layermodels.ipynb b/docs/examples/04_modifying_layermodels.ipynb index 9233c982..322c433b 100644 --- a/docs/examples/04_modifying_layermodels.ipynb +++ b/docs/examples/04_modifying_layermodels.ipynb @@ -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": {}, diff --git a/nlmod/dims/layers.py b/nlmod/dims/layers.py index c468582f..d4c0eacf 100644 --- a/nlmod/dims/layers.py +++ b/nlmod/dims/layers.py @@ -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}) @@ -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 diff --git a/nlmod/plot/dcs.py b/nlmod/plot/dcs.py index 0a879445..67a02ded 100644 --- a/nlmod/plot/dcs.py +++ b/nlmod/plot/dcs.py @@ -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)