Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT: Update to_xarray to show nradar info. #1576

Merged
merged 2 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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