Skip to content

Commit dcbe0af

Browse files
authored
Merge pull request #326 from xylar/reuse-spherical-mosaic-descriptor
Allow reuse of mosaic descriptor in spherical plots
2 parents 5d10ec8 + b5cd402 commit dcbe0af

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

polaris/viz/spherical.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def plot_global_mpas_field(
2525
figsize=(8, 4.5),
2626
dpi=200,
2727
patch_edge_color=None,
28+
descriptor=None,
2829
):
2930
"""
3031
Plots a data set as a longitude-latitude map
@@ -72,6 +73,15 @@ def plot_global_mpas_field(
7273
7374
patch_edge_color : str, optional
7475
The color of patch edges (if not the same as the face)
76+
77+
descriptor : mosaic.Descriptor, optional
78+
Descriptor from a previous call to ``plot_global_mpas_field()``
79+
80+
Returns
81+
-------
82+
descriptor : mosaic.Descriptor
83+
For reuse with future plots. Patches are cached, so the Descriptor only
84+
needs to be created once per mesh file.
7585
"""
7686

7787
use_mplstyle()
@@ -80,9 +90,13 @@ def plot_global_mpas_field(
8090
projection = cartopy.crs.PlateCarree(central_longitude=central_longitude)
8191

8292
mesh_ds = xr.open_dataset(mesh_filename)
83-
descriptor = mosaic.Descriptor(
84-
mesh_ds, projection=projection, transform=transform, use_latlon=True
85-
)
93+
if descriptor is None:
94+
descriptor = mosaic.Descriptor(
95+
mesh_ds,
96+
projection=projection,
97+
transform=transform,
98+
use_latlon=True,
99+
)
86100

87101
fig, ax = plt.subplots(
88102
figsize=figsize,

0 commit comments

Comments
 (0)