Skip to content

Commit

Permalink
MNT: Update to_xarray to show nradar info. (#1576)
Browse files Browse the repository at this point in the history
  • Loading branch information
zssherman authored May 10, 2024
1 parent 9589bfd commit b1b1aa9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pyart/core/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions tests/core/test_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit b1b1aa9

Please sign in to comment.