From 1dc5a8b55e7f5903ca199916f60ceec77e3ee615 Mon Sep 17 00:00:00 2001 From: zmoon Date: Mon, 18 Nov 2024 17:23:19 -0600 Subject: [PATCH] Fix dataset-to-monet for da --- monet/monet_accessor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/monet/monet_accessor.py b/monet/monet_accessor.py index 9bbab26..4b1ab9e 100644 --- a/monet/monet_accessor.py +++ b/monet/monet_accessor.py @@ -119,7 +119,9 @@ def _dataset_to_monet( # Rename lat/lon coordinates to 'latitude'/'longitude' dset = _rename_to_monet_latlon(dset) # common cases - if not {"latitude", "longitude"} <= set(dset.variables): + if (isinstance(dset, xr.Dataset) and not {"latitude", "longitude"} <= set(dset.variables)) or ( + isinstance(dset, xr.DataArray) and not {"latitude", "longitude"} <= set(dset.coords) + ): dset = dset.rename({lat_name: "latitude", lon_name: "longitude"}) # Maybe wrap longitudes