Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance spherical tracer transport test viz #233

Merged
merged 3 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/developers_guide/framework/visualization.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,13 @@ colormap).

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

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

```cfg
# [optional] colormap set_under and set_over options
under_color = k
over_color = orange
```
### plotting from lat/lon grids

You can use {py:func}`polaris.viz.plot_global_lat_lon_field()` to plot a field
Expand Down
4 changes: 4 additions & 0 deletions docs/developers_guide/ocean/tasks/correlated_tracers_2d.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ each resolution. The colormap is controlled by these options:
# colormap
colormap_name = viridis

# [optional] colormap set_under and set_over options
under_color = k
over_color = orange

# the type of norm used in the colormap
norm_type = linear

Expand Down
4 changes: 4 additions & 0 deletions docs/developers_guide/ocean/tasks/divergent_2d.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ each resolution. The colormap is controlled by these options:
# colormap
colormap_name = viridis

# [optional] colormap set_under and set_over options
under_color = k
over_color = orange

# the type of norm used in the colormap
norm_type = linear

Expand Down
4 changes: 4 additions & 0 deletions docs/developers_guide/ocean/tasks/nondivergent_2d.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ each resolution. The colormap is controlled by these options:
# colormap
colormap_name = viridis

# [optional] colormap set_under and set_over options
under_color = k
over_color = orange

# the type of norm used in the colormap
norm_type = linear

Expand Down
4 changes: 4 additions & 0 deletions docs/developers_guide/ocean/tasks/rotation_2d.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ each resolution. The colormap is controlled by these options:
# colormap
colormap_name = viridis

# [optional] colormap set_under and set_over options
under_color = k
over_color = orange

# the type of norm used in the colormap
norm_type = linear

Expand Down
4 changes: 4 additions & 0 deletions polaris/ocean/tasks/sphere_transport/sphere_transport.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ slotted_cylinders_amplitude = 1.0
# colormap
colormap_name = viridis

# [optional] colormap set_under and set_over options
under_color = k
over_color = orange

# the type of norm used in the colormap
norm_type = linear

Expand Down
10 changes: 9 additions & 1 deletion polaris/viz/spherical.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import matplotlib.colors as cols
import matplotlib.pyplot as plt
import uxarray as ux
from matplotlib import cm
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
from pyremap.descriptor.utility import interp_extrap_corner

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

colormap = config.get(colormap_section, 'colormap_name')
cmap = cm.get_cmap(colormap)
if config.has_option(colormap_section, 'under_color'):
under_color = config.get(colormap_section, 'under_color')
cmap.set_under(under_color)
if config.has_option(colormap_section, 'over_color'):
over_color = config.get(colormap_section, 'over_color')
cmap.set_over(over_color)

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

plot = gdf_data.hvplot.polygons(
c=da.name, cmap=colormap, logz=logz,
c=da.name, cmap=cmap, logz=logz,
clim=tuple(colorbar_limits),
clabel=colorbar_label,
width=1600, height=800, title=title,
Expand Down
Loading