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

ENH: xarray grid output #1477

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

syedhamidali
Copy link
Contributor

To streamline the process of extracting a subset from pyart.core.grid or the grid object, I propose to add a few more variables to the xarray dataset that mirrors the grid object. When this xarray dataset is written to a NetCDF file, it becomes equivalent to the original pyart.core.grid object.

How can this be utilized?

import pyart

# Reading a grid from a netcdf file
grid = pyart.io.read_grid("file.nc")

# Converting the grid to an xarray dataset
ds = grid.to_xarray()

# Slicing the dataset based on x and y coordinates
ds = ds.sel(x=slice(5000, 70000), y=slice(5000, 70000), drop=True)

# Saving the sliced dataset to a new netcdf file
ds.to_netcdf("outfile.nc")

Subsequently, it is possible to read the modified dataset using pyart as follows:

# Reading the modified dataset with pyart
grid_small = pyart.io.read_grid("outfile.nc")

This enhances the process of working with grid data, making it more convenient and efficient for users.

pyart/core/grid.py Outdated Show resolved Hide resolved
@syedhamidali
Copy link
Contributor Author

Hey @mgrover1,

Just wanted to check in on the status of #1477. I believe we’ve completed the function that allows us to directly write xarray grids using ds.to_netcdf method. This functionality should enable us to seamlessly read these grids back in using Py-ART’s grid reader. Let me know if you have any updates or if there are any additional steps required.

@mgrover1
Copy link
Collaborator

@syedhamidali - can you please review the previous comment to ensure that is addressed to fix the failing CI?

@syedhamidali
Copy link
Contributor Author

@syedhamidali - can you please review the previous comment to ensure that is addressed to fix the failing CI?

Resolved in this commit

@mgrover1
Copy link
Collaborator

Fantastic! Thanks @syedhamidali 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants