diff --git a/pyart/core/grid.py b/pyart/core/grid.py index 081595afcb..8ac24dec81 100644 --- a/pyart/core/grid.py +++ b/pyart/core/grid.py @@ -315,6 +315,12 @@ def to_xarray(self): in a one dimensional array. """ + + if not _XARRAY_AVAILABLE: + raise MissingOptionalDependency( + "Xarray is required to use Grid.to_xarray but is not " + "installed!" + ) + lon, lat = self.get_point_longitude_latitude() z = self.z["data"] y = self.y["data"]