From a18445d122973c077a2763dc51b9d4b53dd291b7 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Mon, 22 Jun 2026 07:16:12 -0500 Subject: [PATCH] New plotting routine. --- pydda/vis/barb_plot.py | 52 +++++++++++++----------------------- pydda/vis/quiver_plot.py | 27 ++++++------------- pydda/vis/streamline_plot.py | 28 +++++++------------ 3 files changed, 35 insertions(+), 72 deletions(-) diff --git a/pydda/vis/barb_plot.py b/pydda/vis/barb_plot.py index dc3127fd..e5b8cfef 100644 --- a/pydda/vis/barb_plot.py +++ b/pydda/vis/barb_plot.py @@ -195,8 +195,7 @@ def plot_horiz_xsection_barbs( linewidths=2, ) cs.set_clim([np.min(u_vel_contours), np.max(u_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar(cs, ax=ax, label="U [m/s]") @@ -211,8 +210,7 @@ def plot_horiz_xsection_barbs( linewidths=2, ) cs.set_clim([np.min(v_vel_contours), np.max(v_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar(cs, ax=ax, label="V [m/s]") @@ -227,8 +225,7 @@ def plot_horiz_xsection_barbs( linewidths=2, ) cs.set_clim([np.min(w_vel_contours), np.max(w_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar(cs, ax=ax, label="W [m/s]") @@ -244,8 +241,7 @@ def plot_horiz_xsection_barbs( linewidths=2, ) cs.set_clim([np.min(wind_vel_contours), np.max(wind_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar(cs, ax=ax, label="|V| [m/s]") @@ -261,7 +257,7 @@ def plot_horiz_xsection_barbs( grid_y[level, :, :], bca, levels=[bca_min, bca_max], - color="k", + colors="k", ) if axes_labels_flag is True: @@ -469,8 +465,7 @@ def plot_horiz_xsection_barbs_map( extend="both", ) cs.set_clim([np.min(u_vel_contours), np.max(u_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar( @@ -500,8 +495,7 @@ def plot_horiz_xsection_barbs_map( extend="both", ) cs.set_clim([np.min(v_vel_contours), np.max(v_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar( @@ -531,8 +525,7 @@ def plot_horiz_xsection_barbs_map( extend="both", ) cs.set_clim([np.min(w_vel_contours), np.max(w_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar( @@ -563,8 +556,7 @@ def plot_horiz_xsection_barbs_map( levels=wind_vel_contours, linewidths=2, ) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: @@ -596,7 +588,7 @@ def plot_horiz_xsection_barbs_map( grid_lat[::, ::], bca, levels=[bca_min, bca_max], - color="k", + colors="k", zorder=1, ) @@ -790,8 +782,7 @@ def plot_xz_xsection_barbs( linewidths=2, ) cs.set_clim([np.min(u_vel_contours), np.max(u_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar(cs, ax=ax, label="U [m/s]", extend="min") @@ -806,8 +797,7 @@ def plot_xz_xsection_barbs( linewidths=2, ) cs.set_clim([np.min(v_vel_contours), np.max(v_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar(cs, ax=ax, label="V [m/s]", extend="min") @@ -822,8 +812,7 @@ def plot_xz_xsection_barbs( linewidths=2, ) cs.set_clim([np.min(w_vel_contours), np.max(w_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar(cs, ax=ax, label="W [m/s]", extend="min") @@ -839,8 +828,7 @@ def plot_xz_xsection_barbs( linewidths=2, ) cs.set_clim([np.min(wind_vel_contours), np.max(wind_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar(cs, ax=ax, label="|V| [m/s]") @@ -1035,8 +1023,7 @@ def plot_yz_xsection_barbs( linewidths=2, ) cs.set_clim([np.min(u_vel_contours), np.max(u_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") plt.clabel(cs) if colorbar_contour_flag is True: plt.colorbar(cs, ax=ax, label="U [m/s]", extend="min") @@ -1051,8 +1038,7 @@ def plot_yz_xsection_barbs( linewidths=2, ) cs.set_clim([np.min(v_vel_contours), np.max(v_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") plt.clabel(cs) if colorbar_contour_flag is True: plt.colorbar(cs, ax=ax, label="V [m/s]", extend="min") @@ -1067,8 +1053,7 @@ def plot_yz_xsection_barbs( linewidths=2, ) cs.set_clim([np.min(w_vel_contours), np.max(w_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") plt.clabel(cs) if colorbar_contour_flag is True: plt.colorbar(cs, ax=ax, label="W [m/s]", extend="min") @@ -1084,8 +1069,7 @@ def plot_yz_xsection_barbs( linewidths=2, ) cs.set_clim([np.min(wind_vel_contours), np.max(wind_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar(cs, ax=ax, label="|V| [m/s]") diff --git a/pydda/vis/quiver_plot.py b/pydda/vis/quiver_plot.py index 07cf51d3..12ae632a 100644 --- a/pydda/vis/quiver_plot.py +++ b/pydda/vis/quiver_plot.py @@ -296,8 +296,7 @@ def plot_horiz_xsection_quiver( linewidths=2, ) cs.set_clim([np.min(wind_vel_contours), np.max(wind_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar(cs, ax=ax, label="|V| [m/s]") @@ -598,9 +597,7 @@ def plot_horiz_xsection_quiver_map( extend="both", ) cs.set_clim([np.min(u_vel_contours), np.max(u_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_over(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", over="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar( @@ -630,9 +627,7 @@ def plot_horiz_xsection_quiver_map( extend="both", ) cs.set_clim([np.min(v_vel_contours), np.max(v_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_over(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", over="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar( @@ -662,9 +657,7 @@ def plot_horiz_xsection_quiver_map( extend="both", ) cs.set_clim([np.min(w_vel_contours), np.max(w_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_over(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", over="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar( @@ -695,9 +688,7 @@ def plot_horiz_xsection_quiver_map( levels=wind_vel_contours, linewidths=2, ) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) - + cs.cmap.with_extremes(under="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar( @@ -728,7 +719,7 @@ def plot_horiz_xsection_quiver_map( grid_lat[:, :], bca, levels=[bca_min, bca_max], - color="k", + colors="k", zorder=1, ) @@ -1021,8 +1012,7 @@ def plot_xz_xsection_quiver( linewidths=2, ) cs.set_clim([np.min(wind_vel_contours), np.max(wind_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar(cs, ax=ax, label="|V| [m/s]") @@ -1316,8 +1306,7 @@ def plot_yz_xsection_quiver( linewidths=2, ) cs.set_clim([np.min(wind_vel_contours), np.max(wind_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar(cs, ax=ax, label="|V| [m/s]") diff --git a/pydda/vis/streamline_plot.py b/pydda/vis/streamline_plot.py index 339aff96..00604911 100644 --- a/pydda/vis/streamline_plot.py +++ b/pydda/vis/streamline_plot.py @@ -233,8 +233,7 @@ def plot_horiz_xsection_streamlines( linewidths=2, ) cs.set_clim([np.min(wind_vel_contours), np.max(wind_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar(cs, ax=ax, label="|V| [m/s]") @@ -253,7 +252,7 @@ def plot_horiz_xsection_streamlines( grid_y[level, :, :], bca, levels=[bca_min, bca_max], - color="k", + colors="k", ) if axes_labels_flag is True: @@ -477,9 +476,7 @@ def plot_horiz_xsection_streamlines_map( extend="both", ) cs.set_clim([np.min(u_vel_contours), np.max(u_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_over(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white", over="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar( @@ -509,9 +506,7 @@ def plot_horiz_xsection_streamlines_map( extend="both", ) cs.set_clim([np.min(v_vel_contours), np.max(v_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_over(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white", over="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar( @@ -541,9 +536,7 @@ def plot_horiz_xsection_streamlines_map( extend="both", ) cs.set_clim([np.min(w_vel_contours), np.max(w_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_over(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white", over="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar( @@ -574,8 +567,7 @@ def plot_horiz_xsection_streamlines_map( levels=wind_vel_contours, linewidths=2, ) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: @@ -607,7 +599,7 @@ def plot_horiz_xsection_streamlines_map( grid_lat[:, :], bca, levels=[bca_min, bca_max], - color="k", + colors="k", zorder=1, ) @@ -844,8 +836,7 @@ def plot_xz_xsection_streamlines( linewidths=2, ) cs.set_clim([np.min(wind_vel_contours), np.max(wind_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar(cs, ax=ax, label="|V| [m/s]") @@ -1082,8 +1073,7 @@ def plot_yz_xsection_streamlines( alpha=contour_alpha, ) cs.set_clim([np.min(wind_vel_contours), np.max(wind_vel_contours)]) - cs.cmap.set_under(color="white", alpha=0) - cs.cmap.set_bad(color="white", alpha=0) + cs.cmap.with_extremes(under="white", bad="white") ax.clabel(cs) if colorbar_contour_flag is True: plt.colorbar(cs, ax=ax, label="|V| [m/s]")