diff --git a/pyart/core/grid.py b/pyart/core/grid.py index 7d36dbc622..5821c73f7a 100644 --- a/pyart/core/grid.py +++ b/pyart/core/grid.py @@ -366,6 +366,14 @@ def to_xarray(self): ds.z.encoding["_FillValue"] = None ds.lat.encoding["_FillValue"] = None ds.lon.encoding["_FillValue"] = None + + # Grab original radar(s) name and number of radars used to make grid + ds.attrs["nradar"] = self.nradar + ds.attrs["radar_name"] = self.radar_name + + # Grab all metadata + ds.attrs.update(self.metadata) + ds.close() return ds diff --git a/tests/core/test_grid.py b/tests/core/test_grid.py index 90121cb57b..09e9c2be87 100644 --- a/tests/core/test_grid.py +++ b/tests/core/test_grid.py @@ -101,6 +101,9 @@ def test_grid_to_xarray(): assert_equal(ds.lat.data, lat) assert_equal(ds.time.data, time) + assert ds.attrs["nradar"] == 1 + assert ds.attrs["radar_name"]["data"][0] == "ExampleRadar" + def _check_dicts_similar(dic1, dic2): for k, v in dic1.items():