Skip to content

Commit 41ac0fa

Browse files
authored
Merge branch 'main' into rajeeja/scale-gradient-curl-radius
2 parents 5ec8839 + 5625cc9 commit 41ac0fa

4 files changed

Lines changed: 26 additions & 11 deletions

File tree

docs/user-guide/mpl.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@
384384
"metadata": {},
385385
"source": [
386386
"```{important}\n",
387-
"By default, `periodic_elements` is set to `\"exclude\"`. \n",
387+
"`to_polycollection()` defaults to `periodic_elements=\"exclude\"`; use `\"split\"` to preserve antimeridian faces. \n",
388388
"```\n",
389389
"\n",
390390
"To reduce the number of polygons in the collection, you can [subset](./subset) before converting."

docs/user-guide/plotting.ipynb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@
260260
"* ``periodic_elements='split'``: Periodic polygons are split along the antimeridian\n",
261261
"* ``periodic_elements='ignore'``: Periodic polygons are left uncorrected.\n",
262262
"\n",
263-
"```{warning}\n",
264-
"It is suggested to keep ``periodic_elements='exclude'`` (default value) when working with moderatly large datasets, as there is a significant overhead needed correct the antimeridian faces.\n",
263+
"```{note}\n",
264+
"Shaded polygon plots default to ``periodic_elements='split'`` so seam-crossing faces are preserved. For very large grids, ``periodic_elements='exclude'`` can be faster if dropping antimeridian faces is acceptable.\n",
265265
"```\n"
266266
]
267267
},
@@ -294,10 +294,8 @@
294294
"source": [
295295
"(\n",
296296
" uxds_mpas[\"bottomDepth\"]\n",
297-
" .plot(\n",
298-
" cmap=\"Blues\",\n",
299-
" )\n",
300-
" .opts(width=700, height=350, title=\"Default Plot (Excluding Periodic Elements)\")\n",
297+
" .plot(periodic_elements=\"exclude\", cmap=\"Blues\", width=700, height=350)\n",
298+
" .opts(title=\"Exclude Periodic Elements\")\n",
301299
" + uxds_mpas[\"bottomDepth\"]\n",
302300
" .plot(periodic_elements=\"split\", cmap=\"Blues\", width=700, height=350)\n",
303301
" .opts(title=\"Include Periodic Elements (Split)\")\n",

test/core/test_dataarray.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,23 @@ def test_to_polycollection(gridpath, datasetpath):
7777
assert len(pc_geoflow_grid._paths) == uxds_geoflow.uxgrid.n_face
7878

7979

80+
def test_to_geodataframe_preserves_antimeridian_faces(gridpath, datasetpath):
81+
uxds = ux.open_dataset(
82+
gridpath("scrip", "ne30pg2", "grid.nc"),
83+
datasetpath("scrip", "ne30pg2", "data.nc"),
84+
)
85+
uxda = uxds["RELHUM"]
86+
for dim in uxda.dims[:-1]:
87+
uxda = uxda.isel({dim: 0})
88+
89+
gdf = uxda.to_geodataframe(periodic_elements="split")
90+
polygons = uxda.plot.polygons(rasterize=False)
91+
92+
assert gdf.shape == (uxds.uxgrid.n_face, 2)
93+
assert len(polygons.data) == uxds.uxgrid.n_face
94+
assert len(uxds.uxgrid.antimeridian_face_indices) == 120
95+
96+
8097
def test_geodataframe_caching(gridpath, datasetpath):
8198
uxds = ux.open_dataset(
8299
gridpath("ugrid", "outCSne30", "outCSne30.ug"),

uxarray/plot/accessor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def __getattr__(self, name: str) -> Any:
368368

369369
def polygons(
370370
self,
371-
periodic_elements: str | None = "exclude",
371+
periodic_elements: str | None = "split",
372372
backend: str | None = None,
373373
engine: str | None = "spatialpandas",
374374
rasterize: bool | None = True,
@@ -388,11 +388,11 @@ def polygons(
388388
389389
Parameters
390390
----------
391-
periodic_elements : str, optional, default="exclude"
392-
Specifies whether to include or exclude periodic elements in the grid.
391+
periodic_elements : str, optional, default="split"
392+
Specifies whether to split, ignore, or exclude periodic elements in the grid.
393393
Options are:
394-
- "exclude": Exclude periodic elements,
395394
- "split": Split periodic elements.
395+
- "exclude": Exclude periodic elements,
396396
- "ignore": Include periodic elements without any corrections
397397
backend : str or None, optional
398398
Plotting backend to use. One of ['matplotlib', 'bokeh']. Equivalent to running holoviews.extension(backend)

0 commit comments

Comments
 (0)