From 03053b979e1dde73b866045a1ca889a7719939c5 Mon Sep 17 00:00:00 2001 From: Joost Delsman Date: Thu, 9 Feb 2023 18:08:47 +0100 Subject: [PATCH 1/3] fix for quasi 3d layering --- imod/visualize/cross_sections.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/imod/visualize/cross_sections.py b/imod/visualize/cross_sections.py index f3f9d0328..c6de8ea06 100644 --- a/imod/visualize/cross_sections.py +++ b/imod/visualize/cross_sections.py @@ -80,9 +80,9 @@ def _meshcoords(da, continuous=True): C = np.full((nrow - 1, ncol - 1), np.nan) C[:, 0::2] = data else: - _, ncol = Y.shape - C = np.full((nrow, ncol - 1), np.nan) - C[:, 0::2] = data + nrow, ncol = Y.shape + C = np.full((nrow - 1, ncol - 1), np.nan) + C[0::2, 0::2] = data return X, Y, C, nodata @@ -106,7 +106,7 @@ def _plot_aquitards(aquitards, ax, kwargs_aquitards): C_aq = C_aq.astype(np.float64) for j, i in enumerate(range(0, X_aq.shape[0] - 1, 2)): Y_i = Y_aq[i : i + 2] - C_i = C_aq[j] + C_i = C_aq[i] C_i[C_i == 0.0] = np.nan nodata = np.repeat(np.isnan(C_i[0::2]), 2) Y_i[:, nodata] = np.nan @@ -243,7 +243,10 @@ def cross_section( fig, ax = plt.subplots() # Plot raster - X, Y, C, nodata = _meshcoords(da, continuous=True) + continuous = not ( + da["top"].shape == da["bottom"].shape + ) # allow quasi-3d schematisations + X, Y, C, nodata = _meshcoords(da, continuous=continuous) ax1 = ax.pcolormesh(X, Y, C, **settings_pcmesh) # Plot aquitards if applicable if aquitards is not None: @@ -262,9 +265,9 @@ def cross_section( ax1.cmap.set_under("#FFFFFF") # Add colorbar - divider = make_axes_locatable(ax) - cbar_ax = divider.append_axes("right", size="5%", pad="5%") - fig.colorbar(ax1, cax=cbar_ax, **settings_cbar) + # divider = make_axes_locatable(ax) + # cbar_ax = divider.append_axes("right", size="5%", pad="5%") + # fig.colorbar(ax1, cax=cbar_ax, **settings_cbar) if not return_cmap_norm: return fig, ax From 107c94254092325289acc7ac0b06ec18bf2410b1 Mon Sep 17 00:00:00 2001 From: Joost Delsman Date: Thu, 9 Feb 2023 18:16:15 +0100 Subject: [PATCH 2/3] reverted inclusion of colorbar --- imod/visualize/cross_sections.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/imod/visualize/cross_sections.py b/imod/visualize/cross_sections.py index c6de8ea06..97a32c829 100644 --- a/imod/visualize/cross_sections.py +++ b/imod/visualize/cross_sections.py @@ -265,9 +265,9 @@ def cross_section( ax1.cmap.set_under("#FFFFFF") # Add colorbar - # divider = make_axes_locatable(ax) - # cbar_ax = divider.append_axes("right", size="5%", pad="5%") - # fig.colorbar(ax1, cax=cbar_ax, **settings_cbar) + divider = make_axes_locatable(ax) + cbar_ax = divider.append_axes("right", size="5%", pad="5%") + fig.colorbar(ax1, cax=cbar_ax, **settings_cbar) if not return_cmap_norm: return fig, ax From ec2440c6cb67b386ce99a64d5dd2d276e3067c93 Mon Sep 17 00:00:00 2001 From: Joost Delsman Date: Thu, 9 Feb 2023 18:08:47 +0100 Subject: [PATCH 3/3] fix for quasi 3d layering --- imod/visualize/cross_sections.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/imod/visualize/cross_sections.py b/imod/visualize/cross_sections.py index 032fd0035..920643795 100644 --- a/imod/visualize/cross_sections.py +++ b/imod/visualize/cross_sections.py @@ -80,9 +80,9 @@ def _meshcoords(da, continuous=True): C = np.full((nrow - 1, ncol - 1), np.nan) C[:, 0::2] = data else: - _, ncol = Y.shape - C = np.full((nrow, ncol - 1), np.nan) - C[:, 0::2] = data + nrow, ncol = Y.shape + C = np.full((nrow - 1, ncol - 1), np.nan) + C[0::2, 0::2] = data return X, Y, C, nodata @@ -106,7 +106,7 @@ def _plot_aquitards(aquitards, ax, kwargs_aquitards): C_aq = C_aq.astype(np.float64) for j, i in enumerate(range(0, X_aq.shape[0] - 1, 2)): Y_i = Y_aq[i : i + 2] - C_i = C_aq[j] + C_i = C_aq[i] C_i[C_i == 0.0] = np.nan nodata = np.repeat(np.isnan(C_i[0::2]), 2) Y_i[:, nodata] = np.nan @@ -246,7 +246,10 @@ def cross_section( fig, ax = plt.subplots() # Plot raster - X, Y, C, nodata = _meshcoords(da, continuous=True) + continuous = not ( + da["top"].shape == da["bottom"].shape + ) # allow quasi-3d schematisations + X, Y, C, nodata = _meshcoords(da, continuous=continuous) ax1 = ax.pcolormesh(X, Y, C, **settings_pcmesh) # Plot aquitards if applicable if aquitards is not None: