Skip to content

Commit 92c83f0

Browse files
committed
fix extent again
1 parent f260bde commit 92c83f0

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

uxarray/core/dataarray.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -406,19 +406,12 @@ def to_raster(
406406
else:
407407

408408
def _is_default_extent() -> bool:
409-
# Default extents can be (0, 1) or projection limits while autoscale stays on.
409+
# Default extents are indicated by xlim/ylim being (0, 1)
410+
# when autoscale is still on (no extent has been explicitly set)
410411
if not ax.get_autoscale_on():
411412
return False
412-
try:
413-
import cartopy.crs as ccrs
414-
415-
extent = ax.get_extent(ccrs.PlateCarree())
416-
except Exception:
417-
xlim, ylim = ax.get_xlim(), ax.get_ylim()
418-
return np.allclose(xlim, (0.0, 1.0)) and np.allclose(
419-
ylim, (0.0, 1.0)
420-
)
421-
return np.allclose(extent, (-180.0, 180.0, -90.0, 90.0), atol=1.0)
413+
xlim, ylim = ax.get_xlim(), ax.get_ylim()
414+
return np.allclose(xlim, (0.0, 1.0)) and np.allclose(ylim, (0.0, 1.0))
422415

423416
if _is_default_extent():
424417
try:
@@ -438,8 +431,11 @@ def _is_default_extent() -> bool:
438431
"ax.set_extent(...), or ax.set_xlim(...) + ax.set_ylim(...).",
439432
stacklevel=2,
440433
)
441-
except Exception:
442-
pass
434+
except Exception as e:
435+
warn(
436+
f"Failed to auto-set extent from grid bounds: {e}",
437+
stacklevel=2,
438+
)
443439
input_ax_attrs = _RasterAxAttrs.from_ax(ax, pixel_ratio=pixel_ratio)
444440

445441
raster, pixel_mapping_np = _nearest_neighbor_resample(

0 commit comments

Comments
 (0)