Skip to content

Commit 002293c

Browse files
authored
Merge pull request #233 from cbegeman/enhance-tracer-test-viz
Enhance spherical tracer transport test viz Add options for over/under colors for the colormap used in spherical mpas visualization. These were added to be able to more conveniently visualize over and undershoots in the tracer advection scheme tested in the sphere_transport tests.
2 parents 563b1f8 + accf5df commit 002293c

File tree

7 files changed

+35
-1
lines changed

7 files changed

+35
-1
lines changed

docs/developers_guide/framework/visualization.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,13 @@ colormap).
154154

155155
The `colorbar_limits` are the lower and upper bound of the colorbar range.
156156

157+
There are also two optional config options used to set the colors on either end of the colormap:
157158

159+
```cfg
160+
# [optional] colormap set_under and set_over options
161+
under_color = k
162+
over_color = orange
163+
```
158164
### plotting from lat/lon grids
159165

160166
You can use {py:func}`polaris.viz.plot_global_lat_lon_field()` to plot a field

docs/developers_guide/ocean/tasks/correlated_tracers_2d.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ each resolution. The colormap is controlled by these options:
7777
# colormap
7878
colormap_name = viridis
7979
80+
# [optional] colormap set_under and set_over options
81+
under_color = k
82+
over_color = orange
83+
8084
# the type of norm used in the colormap
8185
norm_type = linear
8286

docs/developers_guide/ocean/tasks/divergent_2d.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ each resolution. The colormap is controlled by these options:
7171
# colormap
7272
colormap_name = viridis
7373
74+
# [optional] colormap set_under and set_over options
75+
under_color = k
76+
over_color = orange
77+
7478
# the type of norm used in the colormap
7579
norm_type = linear
7680

docs/developers_guide/ocean/tasks/nondivergent_2d.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ each resolution. The colormap is controlled by these options:
7777
# colormap
7878
colormap_name = viridis
7979
80+
# [optional] colormap set_under and set_over options
81+
under_color = k
82+
over_color = orange
83+
8084
# the type of norm used in the colormap
8185
norm_type = linear
8286

docs/developers_guide/ocean/tasks/rotation_2d.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ each resolution. The colormap is controlled by these options:
7171
# colormap
7272
colormap_name = viridis
7373
74+
# [optional] colormap set_under and set_over options
75+
under_color = k
76+
over_color = orange
77+
7478
# the type of norm used in the colormap
7579
norm_type = linear
7680

polaris/ocean/tasks/sphere_transport/sphere_transport.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ slotted_cylinders_amplitude = 1.0
8484
# colormap
8585
colormap_name = viridis
8686

87+
# [optional] colormap set_under and set_over options
88+
under_color = k
89+
over_color = orange
90+
8791
# the type of norm used in the colormap
8892
norm_type = linear
8993

polaris/viz/spherical.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import matplotlib.colors as cols
1010
import matplotlib.pyplot as plt
1111
import uxarray as ux
12+
from matplotlib import cm
1213
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
1314
from pyremap.descriptor.utility import interp_extrap_corner
1415

@@ -81,6 +82,13 @@ def plot_global_mpas_field(mesh_filename, da, out_filename, config,
8182
projection = cartopy.crs.PlateCarree(central_longitude=central_longitude)
8283

8384
colormap = config.get(colormap_section, 'colormap_name')
85+
cmap = cm.get_cmap(colormap)
86+
if config.has_option(colormap_section, 'under_color'):
87+
under_color = config.get(colormap_section, 'under_color')
88+
cmap.set_under(under_color)
89+
if config.has_option(colormap_section, 'over_color'):
90+
over_color = config.get(colormap_section, 'over_color')
91+
cmap.set_over(over_color)
8492

8593
norm_type = config.get(colormap_section, 'norm_type')
8694
if norm_type == 'linear':
@@ -94,7 +102,7 @@ def plot_global_mpas_field(mesh_filename, da, out_filename, config,
94102
dtype=float)
95103

96104
plot = gdf_data.hvplot.polygons(
97-
c=da.name, cmap=colormap, logz=logz,
105+
c=da.name, cmap=cmap, logz=logz,
98106
clim=tuple(colorbar_limits),
99107
clabel=colorbar_label,
100108
width=1600, height=800, title=title,

0 commit comments

Comments
 (0)