From bc59efc1b3b79491a78fe0f5b04e3892b2ee96f9 Mon Sep 17 00:00:00 2001 From: refszkentla <133355176+refszkentla@users.noreply.github.com> Date: Fri, 27 Mar 2026 11:01:16 +0100 Subject: [PATCH 1/4] add borderlines add borderlines along coastlines and update comment where this is applied --- src/CSET/operators/plot.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/CSET/operators/plot.py b/src/CSET/operators/plot.py index 72b49ff1d..18ed11614 100644 --- a/src/CSET/operators/plot.py +++ b/src/CSET/operators/plot.py @@ -25,6 +25,7 @@ from typing import Literal import cartopy.crs as ccrs +import cartopy.feature as cfeature import iris import iris.coords import iris.cube @@ -354,7 +355,7 @@ def _setup_spatial_map( grid_size: int | None = None, subplot: int | None = None, ): - """Define map projections, extent and add coastlines for spatial plots. + """Define map projections, extent and add coastlines and borderlines for spatial plots. For spatial map plots, a relevant map projection for rotated or non-rotated inputs is specified, and map extent defined based on the input data. @@ -435,13 +436,14 @@ def _setup_spatial_map( else: axes = figure.add_subplot(projection=projection) - # Add coastlines if cube contains x and y map coordinates. + # Add coastlines and borderlines if cube contains x and y map coordinates. if cmap.name in ["viridis", "Greys"]: coastcol = "magenta" else: coastcol = "black" - logging.debug("Plotting coastlines in colour %s.", coastcol) + logging.debug("Plotting coastlines and borderlines in colour %s.", coastcol) axes.coastlines(resolution="10m", color=coastcol) + axes.add_feature(cfeature.BORDERS, edgecolor=coastcol) # If is lat/lon spatial map, fix extent to keep plot tight. # Specifying crs within set_extent helps ensure only data region is shown. @@ -577,7 +579,7 @@ def _plot_and_save_spatial_plot( if contour_cube: cntr_cmap, cntr_levels, cntr_norm = _colorbar_map_levels(contour_cube) - # Setup plot map projection, extent and coastlines. + # Setup plot map projection, extent and coastlines and borderlines. axes = _setup_spatial_map(cube, fig, cmap) # Plot the field. @@ -753,7 +755,7 @@ def _plot_and_save_postage_stamp_spatial_plot( for member, subplot in zip( cube.slices_over(stamp_coordinate), range(1, grid_size**2 + 1), strict=False ): - # Setup subplot map projection, extent and coastlines. + # Setup subplot map projection, extent and coastlines and borderlines. axes = _setup_spatial_map( member, fig, cmap, grid_size=grid_size, subplot=subplot ) @@ -1186,7 +1188,7 @@ def _plot_and_save_vector_plot( # Specify the color bar cmap, levels, norm = _colorbar_map_levels(cube_vec_mag) - # Setup plot map projection, extent and coastlines. + # Setup plot map projection, extent and coastlines and borderlines. axes = _setup_spatial_map(cube_vec_mag, fig, cmap) if method == "contourf": @@ -1517,9 +1519,10 @@ def _plot_and_save_scattermap_plot( edgecolors="k", ) - # Add coastlines. + # Add coastlines and borderlines. try: axes.coastlines(resolution="10m") + axes.add_feature(cfeature.BORDERS) except AttributeError: pass From f7c9f9afe1416e12fceb02fae5791c4f8c6bcc25 Mon Sep 17 00:00:00 2001 From: refszkentla <133355176+refszkentla@users.noreply.github.com> Date: Fri, 27 Mar 2026 11:09:18 +0100 Subject: [PATCH 2/4] Update test for pcolormesh coastline messages the message was extended with borderlines --- tests/operators/test_plot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/operators/test_plot.py b/tests/operators/test_plot.py index dc6d46a81..135f52b25 100644 --- a/tests/operators/test_plot.py +++ b/tests/operators/test_plot.py @@ -701,14 +701,14 @@ def test_pcolormesh_coastline(cube, caplog, tmp_working_dir): def test_pcolormesh_coastline_m(cube, caplog, tmp_working_dir): - """Check coastlines plotted in magenta for viridis colormap.""" + """Check coastlines nd borderlines plotted in magenta for viridis colormap.""" with caplog.at_level(logging.DEBUG): # Set cube name to unknown to trigger viridis default cmap cube.rename("unknown_var_name") plot.spatial_pcolormesh_plot(cube) message_match = False for _, _, message in caplog.record_tuples: - if message == "Plotting coastlines in colour magenta.": + if message == "Plotting coastlines and borderlines in colour magenta.": message_match = True assert message_match From 3000b7dd9644a70770d7b83567c965c8f0cf6a07 Mon Sep 17 00:00:00 2001 From: refszkentla <133355176+refszkentla@users.noreply.github.com> Date: Fri, 27 Mar 2026 11:12:09 +0100 Subject: [PATCH 3/4] Fix typo in test docstring for pcolormesh --- tests/operators/test_plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/operators/test_plot.py b/tests/operators/test_plot.py index 135f52b25..40d4e45e8 100644 --- a/tests/operators/test_plot.py +++ b/tests/operators/test_plot.py @@ -701,7 +701,7 @@ def test_pcolormesh_coastline(cube, caplog, tmp_working_dir): def test_pcolormesh_coastline_m(cube, caplog, tmp_working_dir): - """Check coastlines nd borderlines plotted in magenta for viridis colormap.""" + """Check coastlines and borderlines plotted in magenta for viridis colormap.""" with caplog.at_level(logging.DEBUG): # Set cube name to unknown to trigger viridis default cmap cube.rename("unknown_var_name") From 7933b71d484e2bbdfccc73fae2993adb72f8dbef Mon Sep 17 00:00:00 2001 From: refszkentla <133355176+refszkentla@users.noreply.github.com> Date: Fri, 27 Mar 2026 11:14:51 +0100 Subject: [PATCH 4/4] Update test message for coastline plotting --- tests/operators/test_plot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/operators/test_plot.py b/tests/operators/test_plot.py index 40d4e45e8..5fe828f9c 100644 --- a/tests/operators/test_plot.py +++ b/tests/operators/test_plot.py @@ -690,12 +690,12 @@ def test_postage_stamp_pcolormesh_plot_sequence_coord_check(cube, tmp_working_di def test_pcolormesh_coastline(cube, caplog, tmp_working_dir): - """Check coastlines plotted in black for air_temperature colormap.""" + """Check coastlines and borderlines plotted in black for air_temperature colormap.""" with caplog.at_level(logging.DEBUG): plot.spatial_pcolormesh_plot(cube) message_match = False for _, _, message in caplog.record_tuples: - if message == "Plotting coastlines in colour black.": + if message == "Plotting coastlines and borderlines in colour black.": message_match = True assert message_match