Skip to content

Commit

Permalink
Merge pull request #829 from MetOffice/transect_titleinfo
Browse files Browse the repository at this point in the history
Improve transect title
  • Loading branch information
jwarner8 authored Nov 4, 2024
2 parents e03deb3 + 2c29cbc commit df53dd7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/CSET/operators/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,18 @@ def _plot_and_save_spatial_plot(
):
axes.set_yscale("log")

# Add title.
axes.set_title(title, fontsize=16)
axes.set_title(
f'{title}\n'
f'Start Lat: {cube.attributes["transect_coords"].split("_")[0]}'
f' Start Lon: {cube.attributes["transect_coords"].split("_")[1]}'
f' End Lat: {cube.attributes["transect_coords"].split("_")[2]}'
f' End Lon: {cube.attributes["transect_coords"].split("_")[3]}',
fontsize=16,
)

else:
# Add title.
axes.set_title(title, fontsize=16)

# Add watermark with min/max/mean. Currently not user toggable.
# In the bbox dictionary, fc and ec are hex colour codes for grey shade.
Expand Down
4 changes: 4 additions & 0 deletions src/CSET/operators/transect.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ def calc_transect(cube: iris.cube.Cube, startcoords: tuple, endcoords: tuple):
# Concatenate into single cube.
interpolated_cubes = interpolated_cubes.concatenate()

# Add metadata to interpolated cubes showing coordinates.
interpolated_cubes[0].attributes["transect_coords"] = (
f"{startcoords[0]}_{startcoords[1]}_{endcoords[1]}_{endcoords[1]}"
)
# If concatenation successful, should be CubeList with one cube left.
assert len(interpolated_cubes) == 1
return interpolated_cubes[0]
Binary file modified tests/test_data/transect_out_umml.nc
Binary file not shown.
Binary file modified tests/test_data/transect_out_umpl.nc
Binary file not shown.

0 comments on commit df53dd7

Please sign in to comment.